Opened 2 years ago

Closed 5 months 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 2 years 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 2 years 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)

by AGMS, 2 years ago

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

comment:1 by AGMS, 2 years ago

Has a Patch: set

comment:2 by AGMS, 2 years ago

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()?

by AGMS, 2 years ago

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

comment:3 by AGMS, 2 years ago

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 by waddlesplash, 2 years ago

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 by AGMS, 2 years ago

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 by AGMS, 2 years ago

I think the documentation update would be enough.

comment:7 by pulkomandy, 2 years ago

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

comment:8 by pulkomandy, 2 years ago

Has a Patch: unset

comment:9 by AGMS, 22 months ago

Documentation fix is in hrev51796.

comment:10 by cocobean, 8 months ago

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

comment:11 by AGMS, 8 months ago

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

comment:12 by waddlesplash, 5 months ago

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