ListView: More safe ScrollToSelection implementation

The Problem was observed in the Time Preferences Zone view - the
selection was set inside of TimeZoneView::DoLayout() call on
the OutlineListView control that had zero-sized Bounds. After
the control was resized the selection stay mainly hidden "under"
the upper edge. The Problem looks like generic so should be fixed
in the interface kit code. Proposed fix introduces additional check
for the scroll position to not cross the top edge of control.
This commit is contained in:
Siarzhuk Zharski 2013-09-15 23:39:44 +02:00 committed by Rene Gollent
parent 92dbf1869f
commit 1c38517e25

View File

@ -1037,10 +1037,13 @@ BListView::ScrollToSelection()
if (Bounds().Contains(itemFrame))
return;
if (itemFrame.top < Bounds().top)
ScrollTo(itemFrame.left, itemFrame.top);
else
ScrollTo(itemFrame.left, itemFrame.bottom - Bounds().Height());
float scrollPos = itemFrame.top < Bounds().top ?
itemFrame.top : itemFrame.bottom - Bounds().Height();
if (itemFrame.top - scrollPos < Bounds().top)
scrollPos = itemFrame.top;
ScrollTo(itemFrame.left, scrollPos);
}