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

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 3 May 2020 15:39:01 -0400 (EDT)

hrev54130 adds 1 changeset to branch 'master'
old head: 325ca7f19c77daf0841f27b77aad6b7e6a7c6fab
new head: b7c0f682e4cf4020face128cf5694df65fac9652
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b7c0f682e4cf+%5E325ca7f19c77

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

b7c0f682e4cf: BListView: fix ScrollToSelection
  
  When selection moves down, BListView was sometimes scroll to upper item,
  not lower.
  
  Change-Id: I8f3cf87d43e93c3d2cabfd7ca76f44f1575525e0
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2311
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
  Reviewed-by: John Scipione <jscipione@xxxxxxxxx>
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                              [ X512 <danger_mail@xxxxxxx> ]

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

Revision:    hrev54130
Commit:      b7c0f682e4cf4020face128cf5694df65fac9652
URL:         https://git.haiku-os.org/haiku/commit/?id=b7c0f682e4cf
Author:      X512 <danger_mail@xxxxxxx>
Date:        Thu Mar  5 14:01:19 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun May  3 19:38:57 2020 UTC

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

1 file changed, 5 insertions(+), 10 deletions(-)
src/kits/interface/ListView.cpp | 15 +++++----------

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

diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp
index fce55539b9..bd65e7e120 100644
--- a/src/kits/interface/ListView.cpp
+++ b/src/kits/interface/ListView.cpp
@@ -1113,16 +1113,11 @@ BListView::ScrollToSelection()
 {
        BRect itemFrame = ItemFrame(CurrentSelection(0));
 
-       if (Bounds().Contains(itemFrame))
-               return;
-
-       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);
+       if (itemFrame.top < Bounds().top
+               || itemFrame.Height() > Bounds().Height())
+               ScrollBy(0, itemFrame.top - Bounds().top);
+       else if (itemFrame.bottom > Bounds().bottom)
+               ScrollBy(0, itemFrame.bottom - Bounds().bottom);
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev54130 - src/kits/interface - waddlesplash