From ecae314976edcc69a2048668092251c97678d67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 20 Feb 2004 20:31:42 +0000 Subject: [PATCH] We are now updating our drawings properly on resize. ModifyFlags() now sets B_FRAME_EVENTS if B_FULL_UPDATE_ON_RESIZE was not set. Fixed a small bug in SetBorder(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6665 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ScrollView.cpp | 52 ++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/ScrollView.cpp b/src/kits/interface/ScrollView.cpp index 9fae331ac0..c7ac933d8a 100644 --- a/src/kits/interface/ScrollView.cpp +++ b/src/kits/interface/ScrollView.cpp @@ -226,10 +226,11 @@ BScrollView::SetBorder(border_style border) if (fVerticalScrollBar != NULL) horizontalGap = border != B_NO_BORDER ? 1 : -1; - change = border != B_NO_BORDER ? -2 : 1; + change = border != B_NO_BORDER ? -1 : 1; + if (fHorizontalScrollBar == NULL || fVerticalScrollBar == NULL) + change *= 2; } - fBorder = border; int32 savedResizingMode = 0; @@ -376,9 +377,44 @@ BScrollView::FrameResized(float width, float height) { BView::FrameResized(width, height); - // ToDo: what are fPreviousWidth/fPreviousHeight used for? - // I would guess there could be some problems with resizing, - // but I haven't investigated it yet. + if (fBorder == B_NO_BORDER) + return; + + // changes in width + + BRect bounds = Bounds(); + float border = BorderSize(fBorder) - 1; + + if (bounds.Width() > fPreviousWidth) { + // invalidate the region between the old and the new right border + BRect rect = bounds; + rect.left += fPreviousWidth - border; + rect.right--; + Invalidate(rect); + } else if (bounds.Width() < fPreviousWidth) { + // invalidate the region of the new right border + BRect rect = bounds; + rect.left = rect.right - border; + Invalidate(rect); + } + + // changes in height + + if (bounds.Height() > fPreviousHeight) { + // invalidate the region between the old and the new bottom border + BRect rect = bounds; + rect.top += fPreviousHeight - border; + rect.bottom--; + Invalidate(rect); + } else if (bounds.Height() < fPreviousHeight) { + // invalidate the region of the new bottom border + BRect rect = bounds; + rect.top = rect.bottom - border; + Invalidate(rect); + } + + fPreviousWidth = uint16(bounds.Width()); + fPreviousHeight = uint16(bounds.Height()); } @@ -463,10 +499,12 @@ BScrollView::BorderSize(border_style border) int32 BScrollView::ModifyFlags(int32 flags, border_style border) { + // We either need B_FULL_UPDATE_ON_RESIZE or + // B_FRAME_EVENTS if we have to draw a border if (border != B_NO_BORDER) - return flags | B_WILL_DRAW; + return flags | B_WILL_DRAW | (flags & B_FULL_UPDATE_ON_RESIZE ? 0 : B_FRAME_EVENTS); - return flags & ~B_WILL_DRAW; + return flags & ~(B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE); }