Opened 22 months ago

Closed 5 weeks ago

#13757 closed bug (no change required)

BListView Selection Boxes not Updated

Reported by: AGMS Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Interface Kit Version: R1/Development
Keywords: BListView, BListItem Cc: agmsmith@…, PulkoMandy
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

If you change a BListView's items (custom BListItems) to have different sizes (in this case it was changing a font size, making the items taller or shorter), and call Update() on all of the items to set the new width and height (the custom Update does a SetWidth() and a SetHeight()), the items get drawn with the new size but the selection rectangles for each item don't get updated (so the selection highlights are all for the previous size, and the mouse clicks are similarly off).

In BeOS it works if you call the BListView's Invalidate() function.

I got it to work in all Haiku versions by adding a dummy list item at the top of the list and then deleting it (a do-nothing FrameResized() call worked only in more recent Haiku).

So, I suggest calling the private function that updates the selection rectangles (_UpdateItems() or _RecalcItemTops()?) in the general Invalidate() call. Or maybe make it a separate function. Or should the BListItem Update() be a virtual function that does some housekeeping?

Attachments (2)

0001-Recalculate-BListView-cached-selection-boxes-in-Inva.patch (3.8 KB) - added by AGMS 22 months ago.
Patch to BListView::Invalidate() to also update the list items' cached selection boxes.
0001-Update-BListItem-SetHeight-docs-with-selection-box-w.patch (1.4 KB) - added by AGMS 22 months ago.
Documentation change describing work-arounds for BListItem::SetHeight() not updating the selection boxes in the BListView.

Download all attachments as: .zip

Change History (14)

Changed 22 months ago by AGMS

Patch to BListView::Invalidate() to also update the list items' cached selection boxes.

comment:1 Changed 22 months ago by AGMS

Has a Patch: set

comment:2 Changed 22 months ago by AGMS

That patch to BListView::Invalidate() is a bit of a hack since Invalidate() isn't a virtual function. Anyone got a better suggestion for wedging something into Invalidate()?

Changed 22 months ago by AGMS

Documentation change describing work-arounds for BListItem::SetHeight() not updating the selection boxes in the BListView.

comment:3 Changed 22 months ago by AGMS

Rather than changing the code to fix the selection box caching problem, here's a second patch that just updates the documentation with a warning and work-around.

comment:4 Changed 22 months ago by waddlesplash

Cc: PulkoMandy added

I wonder: Instead of either of the solutions proposed here, perhaps we could have the BListItem call _RecalcItemTops(0) when the size changes and remove the need to call Invalidate? Because that seems much cleaner than the solutions proposed thus far.

comment:5 Changed 22 months ago by AGMS

Unfortunately the BListItem doesn't know which BListView it is inside of. So it can't call _RecalcItemTops. Also can't override SetHeight(), it's not virtual. Pity.

comment:6 Changed 21 months ago by AGMS

I think the documentation update would be enough.

comment:7 Changed 19 months ago by pulkomandy

Patch migrated to Gerrit: https://review.haiku-os.org/45

comment:8 Changed 19 months ago by pulkomandy

Has a Patch: unset

comment:9 Changed 18 months ago by AGMS

Documentation fix is in hrev51796.

comment:10 Changed 4 months ago by cocobean

Last edited 4 months ago by cocobean (previous) (diff)

comment:11 Changed 4 months ago by AGMS

Still a problem as of April 2019, but you could say it was resolved by documentation.

comment:12 Changed 5 weeks ago by waddlesplash

Resolution: no change required
Status: newclosed
Note: See TracTickets for help on using tickets.