From d511a89a8a5061c9e3ffecd7a3ebe92fbc83d553 Mon Sep 17 00:00:00 2001 From: Alexandre Deckner Date: Fri, 20 Jun 2008 02:39:33 +0000 Subject: [PATCH] - Since r21336, BView::ScrollBy was checking the values against the ScrollBar ranges but ScrollBy is often called before updating the scroll range (ie: in ContainerWindow.cpp). IMO, the programatic ScrollBy method shouldn't depend on the ScrollBars ranges or state. The original fix in r21336 was apparently hiding other BScrollBar or BView bugs that have been fixed in the mean time. The content was offseted when going back to list mode after moving icons on the left/up in icon mode. This fixes Tracker bug #2312. - Revert and fix changes to ContainerWindow.cpp in r18481 (cvs 1.37). The condition was broken, but it wouldn't ScrollBy() anyway due to the previous problem. Fixing BView made the content autoscroll even if the lefttop corner of the extent was already visible. - Probably unrelated, fix changes to ContainerWindow.cpp in r18993 (cvs 1.38). PoseView()->Bounds().left/top < 0 is expected, if for example in icon mode you move an icon close or crossing the left side of the window and then scroll left to adjust. This fix ResizeToFit that wouldn't scroll the view correctly in some cases. So we had a Tracker Bug uncovering a BView fix that was hiding another Tracker bug, everything is fixed hopefully, phew :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26043 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 20 ---------------- src/kits/tracker/ContainerWindow.cpp | 35 +++++++++++++++------------- 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index a92c466885..b1627b817f 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -1507,26 +1507,6 @@ BView::ScrollTo(BPoint where) if (where.x == fBounds.left && where.y == fBounds.top) return; - // make sure scrolling is within valid bounds - if (fHorScroller) { - float min, max; - fHorScroller->GetRange(&min, &max); - - if (where.x < min) - where.x = min; - else if (where.x > max) - where.x = max; - } - if (fVerScroller) { - float min, max; - fVerScroller->GetRange(&min, &max); - - if (where.y < min) - where.y = min; - else if (where.y > max) - where.y = max; - } - _CheckLockAndSwitchCurrent(); // if we're attached to a window tell app_server about this change diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index e550d97a5d..a4d3aee979 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -1077,17 +1077,20 @@ void BContainerWindow::FrameResized(float, float) { if (PoseView() && dynamic_cast(this) == NULL) { - BRect extent = PoseView()->Extent(); - if (extent.bottom < PoseView()->Bounds().bottom - && fPreviousBounds.Height() < Bounds().Height()) { - PoseView()->ScrollBy(0, max_c(extent.bottom - PoseView()->Bounds().bottom, - fPreviousBounds.Height() - Bounds().Height())); - } - if (extent.right < PoseView()->Bounds().right - && fPreviousBounds.Width() < Bounds().Width()) { - PoseView()->ScrollBy(max_c(extent.right - PoseView()->Bounds().right, - fPreviousBounds.Width() - Bounds().Width()), 0); - } + BRect extent = PoseView()->Extent(); + float offsetX = extent.left - PoseView()->Bounds().left; + float offsetY = extent.top - PoseView()->Bounds().top; + + // scroll when the size augmented, there is a negative offset + // and we have resized over the bottom right corner of the extent + if (offsetX < 0 && PoseView()->Bounds().right > extent.right + && Bounds().Width() > fPreviousBounds.Width()) + PoseView()->ScrollBy(max_c(fPreviousBounds.Width() - Bounds().Width(), offsetX), 0); + + if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom + && Bounds().Height() > fPreviousBounds.Height()) + PoseView()->ScrollBy(0, max_c(fPreviousBounds.Height() - Bounds().Height(), offsetY)); + PoseView()->UpdateScrollRange(); PoseView()->ResetPosePlacementHint(); } @@ -1336,11 +1339,11 @@ BContainerWindow::ResizeToFit() MoveTo(frame.LeftTop()); PoseView()->DisableScrollBars(); - if (PoseView()->Bounds().bottom > extent.bottom && PoseView()->Bounds().top < 0) - PoseView()->ScrollBy(0, extent.bottom - PoseView()->Bounds().bottom); - if (PoseView()->Bounds().right > extent.right && PoseView()->Bounds().left < 0) - PoseView()->ScrollBy(extent.right - PoseView()->Bounds().right, 0); - + // scroll if there is an offset + PoseView()->ScrollBy( + extent.left - PoseView()->Bounds().left, + extent.top - PoseView()->Bounds().top); + PoseView()->UpdateScrollRange(); PoseView()->EnableScrollBars(); }