From 61eb1f1d19eed26b6138b0701612e8eb31bb1d86 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 22 Oct 2011 15:01:47 -0600 Subject: [PATCH] Replace remaining InvalidateLayout()'s with LayoutInvalidated(). Also do a bit of cleanup/move methods around. --- headers/os/interface/Menu.h | 4 +- headers/os/interface/MenuField.h | 3 +- headers/os/interface/ScrollView.h | 6 +- headers/os/interface/Slider.h | 5 +- headers/os/interface/TextControl.h | 3 +- headers/os/interface/TextView.h | 3 +- headers/private/interface/ColumnListView.h | 2 +- src/kits/interface/ColumnListView.cpp | 3 +- src/kits/interface/Menu.cpp | 25 +++----- src/kits/interface/MenuField.cpp | 20 +++---- src/kits/interface/ScrollView.cpp | 67 +++++++++++----------- src/kits/interface/Slider.cpp | 18 +++--- src/kits/interface/TextControl.cpp | 20 +++---- src/kits/interface/TextView.cpp | 4 +- 14 files changed, 83 insertions(+), 100 deletions(-) diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index 9a5298b963..e5cb58f962 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -77,8 +77,6 @@ public: virtual void DoLayout(); virtual void FrameMoved(BPoint newPosition); virtual void FrameResized(float newWidth, float newHeight); - void InvalidateLayout(); - virtual void InvalidateLayout(bool descendants); virtual void MakeFocus(bool focus = true); @@ -139,6 +137,8 @@ protected: uint32 resizeMask, uint32 flags, menu_layout layout, bool resizeToFit); + virtual void LayoutInvalidated(bool descendants); + virtual BPoint ScreenLocation(); void SetItemMargins(float left, float top, diff --git a/headers/os/interface/MenuField.h b/headers/os/interface/MenuField.h index bb2e0db959..545dc8798b 100644 --- a/headers/os/interface/MenuField.h +++ b/headers/os/interface/MenuField.h @@ -83,14 +83,13 @@ public: virtual BSize MaxSize(); virtual BSize PreferredSize(); - virtual void InvalidateLayout(bool descendants = false); - BLayoutItem* CreateLabelLayoutItem(); BLayoutItem* CreateMenuBarLayoutItem(); virtual status_t Perform(perform_code d, void* arg); protected: + virtual void LayoutInvalidated(bool descendants); virtual void DoLayout(); private: diff --git a/headers/os/interface/ScrollView.h b/headers/os/interface/ScrollView.h index f927d540ca..8a0214e62b 100644 --- a/headers/os/interface/ScrollView.h +++ b/headers/os/interface/ScrollView.h @@ -48,8 +48,6 @@ public: virtual BSize PreferredSize(); virtual void ResizeToPreferred(); - virtual void InvalidateLayout(bool descendants = false); - virtual void DoLayout(); virtual void FrameMoved(BPoint position); virtual void FrameResized(float width, float height); @@ -80,6 +78,10 @@ public: virtual status_t Perform(perform_code d, void* arg); +protected: + virtual void LayoutInvalidated(bool descendants = false); + virtual void DoLayout(); + private: // FBC padding and forbidden methods virtual void _ReservedScrollView1(); diff --git a/headers/os/interface/Slider.h b/headers/os/interface/Slider.h index d96029dd0c..7244407278 100644 --- a/headers/os/interface/Slider.h +++ b/headers/os/interface/Slider.h @@ -156,12 +156,13 @@ public: virtual float MaxUpdateTextWidth(); - virtual void InvalidateLayout(bool descendants = false); - virtual BSize MinSize(); virtual BSize MaxSize(); virtual BSize PreferredSize(); +protected: + virtual void LayoutInvalidated(bool descendants); + private: void _DrawBlockThumb(); void _DrawTriangleThumb(); diff --git a/headers/os/interface/TextControl.h b/headers/os/interface/TextControl.h index db1375fb0e..a3b8da6064 100644 --- a/headers/os/interface/TextControl.h +++ b/headers/os/interface/TextControl.h @@ -88,12 +88,11 @@ public: virtual BSize MaxSize(); virtual BSize PreferredSize(); - virtual void InvalidateLayout(bool descendants = false); - BLayoutItem* CreateLabelLayoutItem(); BLayoutItem* CreateTextViewLayoutItem(); protected: + virtual void LayoutInvalidated(bool descendants); virtual void DoLayout(); private: diff --git a/headers/os/interface/TextView.h b/headers/os/interface/TextView.h index e43c116c18..a4e78a79c6 100644 --- a/headers/os/interface/TextView.h +++ b/headers/os/interface/TextView.h @@ -220,9 +220,8 @@ public: virtual void GetHeightForWidth(float width, float* min, float* max, float* preferred); - virtual void InvalidateLayout(bool descendants = false); - protected: + virtual void LayoutInvalidated(bool descendants); virtual void DoLayout(); public: diff --git a/headers/private/interface/ColumnListView.h b/headers/private/interface/ColumnListView.h index 6b9a80054f..33773acd8e 100644 --- a/headers/private/interface/ColumnListView.h +++ b/headers/private/interface/ColumnListView.h @@ -373,7 +373,6 @@ public: virtual BSize PreferredSize(); virtual BSize MaxSize(); - virtual void InvalidateLayout(bool descendants = false); protected: virtual void MessageReceived(BMessage* message); @@ -382,6 +381,7 @@ protected: virtual void WindowActivated(bool active); virtual void Draw(BRect updateRect); + virtual void LayoutInvalidated(bool descendants = false); virtual void DoLayout(); private: diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 0b034f1a74..baa05a2822 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -1886,9 +1886,8 @@ BColumnListView::MaxSize() void -BColumnListView::InvalidateLayout(bool descendants) +BColumnListView::LayoutInvalidated(bool descendants) { - BView::InvalidateLayout(descendants); } diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 05e9994b39..a4e79dd40c 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -667,23 +667,6 @@ BMenu::FrameResized(float new_width, float new_height) } -void -BMenu::InvalidateLayout() -{ - InvalidateLayout(false); -} - - -void -BMenu::InvalidateLayout(bool descendants) -{ - fUseCachedMenuLayout = false; - fLayoutData->preferred.Set(B_SIZE_UNSET, B_SIZE_UNSET); - - BView::InvalidateLayout(descendants); -} - - // #pragma mark - @@ -2271,6 +2254,14 @@ BMenu::_ComputeMatrixLayout(BRect &frame) } +void +BMenu::LayoutInvalidated(bool descendants) +{ + fUseCachedMenuLayout = false; + fLayoutData->preferred.Set(B_SIZE_UNSET, B_SIZE_UNSET); +} + + // Assumes the SuperMenu to be locked (due to calling ConvertToScreen()) BPoint BMenu::ScreenLocation() diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 6edb1d9c30..af012849a0 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -801,17 +801,6 @@ BMenuField::PreferredSize() } -void -BMenuField::InvalidateLayout(bool descendants) -{ - CALLED(); - - fLayoutData->valid = false; - - BView::InvalidateLayout(descendants); -} - - BLayoutItem* BMenuField::CreateLabelLayoutItem() { @@ -906,6 +895,15 @@ BMenuField::Perform(perform_code code, void* _data) } +void +BMenuField::LayoutInvalidated(bool descendants) +{ + CALLED(); + + fLayoutData->valid = false; +} + + void BMenuField::DoLayout() { diff --git a/src/kits/interface/ScrollView.cpp b/src/kits/interface/ScrollView.cpp index 878de81cc5..6152946161 100644 --- a/src/kits/interface/ScrollView.cpp +++ b/src/kits/interface/ScrollView.cpp @@ -300,39 +300,6 @@ BScrollView::ResizeToPreferred() } -void -BScrollView::InvalidateLayout(bool descendants) -{ - BView::InvalidateLayout(descendants); -} - - -void -BScrollView::DoLayout() -{ - if (!(Flags() & B_SUPPORTS_LAYOUT)) - return; - - // If the user set a layout, we let the base class version call its hook. - if (GetLayout()) { - BView::DoLayout(); - return; - } - - BRect innerFrame = _InnerFrame(); - - if (fTarget != NULL) { - fTarget->MoveTo(innerFrame.left, innerFrame.top); - fTarget->ResizeTo(innerFrame.Width(), innerFrame.Height()); - - //BLayoutUtils::AlignInFrame(fTarget, fTarget->Bounds()); - } - - _AlignScrollBars(fHorizontalScrollBar != NULL, fVerticalScrollBar != NULL, - innerFrame); -} - - void BScrollView::FrameMoved(BPoint position) { @@ -668,6 +635,40 @@ BScrollView::Perform(perform_code code, void* _data) } +void +BScrollView::LayoutInvalidated(bool descendants) +{ +} + + +void +BScrollView::DoLayout() +{ + if (!(Flags() & B_SUPPORTS_LAYOUT)) + return; + + // If the user set a layout, we let the base class version call its hook. + if (GetLayout()) { + BView::DoLayout(); + return; + } + + BRect innerFrame = _InnerFrame(); + + if (fTarget != NULL) { + fTarget->MoveTo(innerFrame.left, innerFrame.top); + fTarget->ResizeTo(innerFrame.Width(), innerFrame.Height()); + + //BLayoutUtils::AlignInFrame(fTarget, fTarget->Bounds()); + } + + _AlignScrollBars(fHorizontalScrollBar != NULL, fVerticalScrollBar != NULL, + innerFrame); +} + + + + // #pragma mark - diff --git a/src/kits/interface/Slider.cpp b/src/kits/interface/Slider.cpp index 94b99edf79..3a8628e3bd 100644 --- a/src/kits/interface/Slider.cpp +++ b/src/kits/interface/Slider.cpp @@ -1736,16 +1736,6 @@ BSlider::MaxUpdateTextWidth() // #pragma mark - layout related -void -BSlider::InvalidateLayout(bool descendants) -{ - // invalidate cached preferred size - fMinSize.Set(-1, -1); - - BControl::InvalidateLayout(descendants); -} - - BSize BSlider::MinSize() { @@ -1778,6 +1768,14 @@ BSlider::PreferredSize() } +void +BSlider::LayoutInvalidated(bool descendants) +{ + // invalidate cached preferred size + fMinSize.Set(-1, -1); +} + + // #pragma mark - private void diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 9258f6e0bf..42c6c7b36a 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -841,17 +841,6 @@ BTextControl::PreferredSize() } -void -BTextControl::InvalidateLayout(bool descendants) -{ - CALLED(); - - fLayoutData->valid = false; - - BView::InvalidateLayout(descendants); -} - - BLayoutItem* BTextControl::CreateLabelLayoutItem() { @@ -870,6 +859,15 @@ BTextControl::CreateTextViewLayoutItem() } +void +BTextControl::LayoutInvalidated(bool descendants) +{ + CALLED(); + + fLayoutData->valid = false; +} + + void BTextControl::DoLayout() { diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 6a9eb8df76..2f524eb10a 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -2782,13 +2782,11 @@ BTextView::GetHeightForWidth(float width, float* min, float* max, void -BTextView::InvalidateLayout(bool descendants) +BTextView::LayoutInvalidated(bool descendants) { CALLED(); fLayoutData->valid = false; - - BView::InvalidateLayout(descendants); }