- 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
This commit is contained in:
Alexandre Deckner 2008-06-20 02:39:33 +00:00
parent 04390361b5
commit d511a89a8a
2 changed files with 19 additions and 36 deletions

View File

@ -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

View File

@ -1077,17 +1077,20 @@ void
BContainerWindow::FrameResized(float, float)
{
if (PoseView() && dynamic_cast<BDeskWindow *>(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();
}