From 1c38517e256ac29d81f2b36e896200faefb8043e Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Sun, 15 Sep 2013 23:39:44 +0200 Subject: [PATCH] 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. --- src/kits/interface/ListView.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index 5c1b4baa3f..d19cd75b6b 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -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); }