From f10474fc0b77e23e362e4e6670dfcbbbba4210ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 21 Sep 2007 08:40:00 +0000 Subject: [PATCH] * the main window is now using the min/max size from the layout system * added Min/MaxSize() implementations to PropertyListView and ScrollView, which fixes the instable layout (upper list views shrinking towards the top whenever views are added/removed in the property list) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22267 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/icon-o-matic/MainWindow.cpp | 5 ++ .../generic/gui/scrollview/ScrollView.cpp | 75 ++++++++++++++++--- .../generic/gui/scrollview/ScrollView.h | 8 ++ .../property/view/PropertyListView.cpp | 33 +++++++- .../generic/property/view/PropertyListView.h | 8 +- .../icon-o-matic/gui/IconObjectListView.cpp | 2 +- .../icon-o-matic/gui/IconObjectListView.h | 5 +- 7 files changed, 122 insertions(+), 14 deletions(-) diff --git a/src/apps/icon-o-matic/MainWindow.cpp b/src/apps/icon-o-matic/MainWindow.cpp index 7e51c39218..0b57b7f880 100644 --- a/src/apps/icon-o-matic/MainWindow.cpp +++ b/src/apps/icon-o-matic/MainWindow.cpp @@ -83,7 +83,12 @@ enum { MainWindow::MainWindow(IconEditorApp* app, Document* document, const BMessage* settings) : BWindow(BRect(50, 50, 900, 750), "Icon-O-Matic", +#ifdef __HAIKU__ + B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), +#else B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS), +#endif fApp(app), fDocument(document), fIcon(NULL) diff --git a/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp b/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp index 80ae49d93f..442fac887f 100644 --- a/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp +++ b/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp @@ -1,10 +1,10 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Stephan Aßmus * Ingo Weinhold + * Stephan Aßmus */ #include "ScrollView.h" @@ -14,6 +14,9 @@ #include #include +#ifdef __HAIKU__ +# include +#endif #include #include #include @@ -22,7 +25,7 @@ #include "ScrollCornerBitmaps.h" -// InternalScrollBar +// #pragma mark - InternalScrollBar class InternalScrollBar : public BScrollBar { public: @@ -60,9 +63,7 @@ InternalScrollBar::ValueChanged(float value) fScrollView->_ScrollValueChanged(this, value); } - - -// ScrollCorner +// #pragma mark -ScrollCorner class ScrollCorner : public BView { public: @@ -255,9 +256,7 @@ ScrollCorner::SetDragging(bool dragging) } } - - -// ScrollView +// #pragma mark - ScrollView // constructor ScrollView::ScrollView(BView* child, uint32 scrollingFlags, BRect frame, @@ -390,6 +389,49 @@ void ScrollView::WindowActivated(bool activated) Invalidate(); } +#ifdef __HAIKU__ + +// MinSize +BSize +ScrollView::MinSize() +{ + BSize size = (fChild ? fChild->MinSize() : BSize(-1, -1)); + + if (fVVisible) + size.width += B_V_SCROLL_BAR_WIDTH; + if (fHVisible) + size.height += B_H_SCROLL_BAR_HEIGHT; + + float borderSize = BorderSize(); + size.width += 2 * borderSize; + size.height += 2 * borderSize; + + return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); +} + +// PreferredSize +BSize +ScrollView::PreferredSize() +{ +// TODO: This is not yet correct. + BSize size = (fChild ? fChild->PreferredSize() : BSize(-1, -1)); + + if (fVVisible) + size.width += B_V_SCROLL_BAR_WIDTH; + if (fHVisible) + size.height += B_H_SCROLL_BAR_HEIGHT; + + float borderSize = BorderSize(); + size.width += 2 * borderSize; + size.height += 2 * borderSize; + + return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); +} + +#endif // __HAIKU__ + +// #pragma mark - + // ScrollingFlags uint32 ScrollView::ScrollingFlags() const @@ -459,6 +501,17 @@ ScrollView::HVScrollCorner() const return fScrollCorner; } +// BorderSize +float +ScrollView::BorderSize() const +{ + if (fScrollingFlags & SCROLL_NO_FRAME) + return 0.0; + return 2.0; +} + +// #pragma mark - + // SetHSmallStep void ScrollView::SetHSmallStep(float hStep) @@ -506,6 +559,8 @@ ScrollView::VSmallStep() const return fVSmallStep; } +// #pragma mark - + // DataRectChanged void ScrollView::DataRectChanged(BRect /*oldDataRect*/, BRect /*newDataRect*/) @@ -586,6 +641,8 @@ ScrollView::_ScrollCornerValueChanged(BPoint offset) SetScrollOffset(offset); } +// #pragma mark - + // _Layout // // Relayouts all children (fChild, scroll bars). diff --git a/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h b/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h index ae7d25d7c9..dcd45c1982 100644 --- a/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h +++ b/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h @@ -41,6 +41,12 @@ class ScrollView : public BView, public Scroller { virtual void FrameResized(float width, float height); virtual void WindowActivated(bool activated); +#ifdef __HAIKU__ + virtual BSize MinSize(); + virtual BSize PreferredSize(); +#endif + + uint32 ScrollingFlags() const; void SetVisibleRectIsChildBounds(bool flag); bool VisibleRectIsChildBounds() const; @@ -60,6 +66,8 @@ class ScrollView : public BView, public Scroller { float HSmallStep() const; float VSmallStep() const; + float BorderSize() const; + protected: virtual void DataRectChanged(BRect oldDataRect, BRect newDataRect); diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp index 4fb7701d68..22d64a3ac4 100644 --- a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp +++ b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -13,6 +13,9 @@ #include #include +#ifdef __HAIKU__ +# include +#endif #include #include #include @@ -250,6 +253,34 @@ PropertyListView::MessageReceived(BMessage* message) } } +#ifdef __HAIKU__ + +BSize +PropertyListView::MinSize() +{ + // We need a stable min size: the BView implementation uses + // GetPreferredSize(), which by default just returns the current size. + return BLayoutUtils::ComposeSize(ExplicitMinSize(), BSize(10, 10)); +} + + +BSize +PropertyListView::MaxSize() +{ + return BView::MaxSize(); +} + + +BSize +PropertyListView::PreferredSize() +{ + // We need a stable preferred size: the BView implementation uses + // GetPreferredSize(), which by default just returns the current size. + return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), BSize(100, 50)); +} + +#endif // __HAIKU__ + // #pragma mark - // TabFocus diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyListView.h b/src/apps/icon-o-matic/generic/property/view/PropertyListView.h index ada24b2c8c..4af428db0d 100644 --- a/src/apps/icon-o-matic/generic/property/view/PropertyListView.h +++ b/src/apps/icon-o-matic/generic/property/view/PropertyListView.h @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -42,6 +42,12 @@ class PropertyListView : public BView, virtual void MouseDown(BPoint where); virtual void MessageReceived(BMessage* message); +#ifdef __HAIKU__ + virtual BSize MinSize(); + virtual BSize MaxSize(); + virtual BSize PreferredSize(); +#endif + // Scrollable interface virtual void ScrollOffsetChanged(BPoint oldOffset, BPoint newOffset); diff --git a/src/apps/icon-o-matic/gui/IconObjectListView.cpp b/src/apps/icon-o-matic/gui/IconObjectListView.cpp index 31dfc4a195..f60ea2e41f 100644 --- a/src/apps/icon-o-matic/gui/IconObjectListView.cpp +++ b/src/apps/icon-o-matic/gui/IconObjectListView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: diff --git a/src/apps/icon-o-matic/gui/IconObjectListView.h b/src/apps/icon-o-matic/gui/IconObjectListView.h index 269bc670bb..0618f04bb0 100644 --- a/src/apps/icon-o-matic/gui/IconObjectListView.h +++ b/src/apps/icon-o-matic/gui/IconObjectListView.h @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -22,9 +22,10 @@ class IconObjectListView : public PropertyListView, IconObjectListView(); virtual ~IconObjectListView(); - // PropertyListView interface + // BView interface virtual void Draw(BRect updateRect); + // PropertyListView interface virtual void PropertyChanged(const Property* previous, const Property* current); virtual void PasteProperties(const PropertyObject* object);