[haiku-commits] haiku: hrev46066 - src/kits/interface

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Sep 2013 00:07:22 +0200 (CEST)

hrev46066 adds 1 changeset to branch 'master'
old head: 83f9d3c431b1e0b236690acc62d1eb9e875342a5
new head: 81cdbc6ae63980490bb3d3f3717631553a68b75b
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=81cdbc6+%5E83f9d3c

----------------------------------------------------------------------------

81cdbc6: 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.

                                        [ Siarzhuk Zharski <zharik@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46066
Commit:      81cdbc6ae63980490bb3d3f3717631553a68b75b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=81cdbc6
Author:      Siarzhuk Zharski <zharik@xxxxxx>
Date:        Sun Sep 15 21:39:44 2013 UTC

----------------------------------------------------------------------------

1 file changed, 7 insertions(+), 4 deletions(-)
src/kits/interface/ListView.cpp | 11 +++++++----

----------------------------------------------------------------------------

diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp
index 5c1b4ba..d19cd75 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);
 }
 
 


Other related posts: