From 9503cf19be94b5a8297ecd73ab50e7acd92a98f6 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Wed, 22 Sep 2010 21:53:32 +0000 Subject: [PATCH] - Don't pass a min size in the Area _Init function. The min size is updated before solving the layout so we don't have to set it in the beginning. This also simplifies the BALMLayout api. - Header include style fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38788 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/libs/alm/ALMLayout.h | 13 ++++----- headers/libs/alm/Area.h | 6 ++-- headers/libs/alm/Column.h | 1 + headers/libs/alm/Row.h | 1 + headers/libs/alm/XTab.h | 1 + headers/libs/alm/YTab.h | 1 + src/libs/alm/ALMLayout.cpp | 55 ++---------------------------------- src/libs/alm/Area.cpp | 25 ++++++++-------- src/libs/alm/Column.cpp | 2 ++ src/libs/alm/Row.cpp | 2 ++ src/libs/alm/XTab.cpp | 1 + 11 files changed, 33 insertions(+), 75 deletions(-) diff --git a/headers/libs/alm/ALMLayout.h b/headers/libs/alm/ALMLayout.h index f1a863eff0..118ecb4db5 100644 --- a/headers/libs/alm/ALMLayout.h +++ b/headers/libs/alm/ALMLayout.h @@ -5,6 +5,7 @@ #ifndef ALM_LAYOUT_H #define ALM_LAYOUT_H + #include #include #include @@ -22,8 +23,8 @@ namespace BALM { -/** - * A GUI layout engine using the ALM. +/*! + * A GUI layout engine using the Auckland Layout Model (ALM). */ class BALMLayout : public BAbstractLayout { public: @@ -36,11 +37,7 @@ public: Row* AddRow(YTab* top, YTab* bottom); Column* AddColumn(); Column* AddColumn(XTab* left, XTab* right); - - Area* AddArea(XTab* left, YTab* top, XTab* right, - YTab* bottom, BView* content, BSize minContentSize); - Area* AddArea(Row* row, Column* column, - BView* content, BSize minContentSize); + Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom, BView* content); Area* AddArea(Row* row, Column* column, @@ -62,7 +59,7 @@ public: virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); virtual void DerivedLayoutItems(); - + char* PerformancePath() const; void SetPerformancePath(char* path); diff --git a/headers/libs/alm/Area.h b/headers/libs/alm/Area.h index fc0245fff5..0d305d0c3b 100644 --- a/headers/libs/alm/Area.h +++ b/headers/libs/alm/Area.h @@ -5,6 +5,7 @@ #ifndef AREA_H #define AREA_H + #include #include #include @@ -81,10 +82,9 @@ private: Area(BLayoutItem* item); void _Init(LinearSpec* ls, XTab* left, YTab* top, - XTab* right, YTab* bottom, BView* content, - BSize minContentSize); + XTab* right, YTab* bottom, BView* content); void _Init(LinearSpec* ls, Row* row, Column* column, - BView* content, BSize minContentSize); + BView* content); void _DoLayout(); diff --git a/headers/libs/alm/Column.h b/headers/libs/alm/Column.h index 73f37e52aa..c561eb54fd 100644 --- a/headers/libs/alm/Column.h +++ b/headers/libs/alm/Column.h @@ -5,6 +5,7 @@ #ifndef COLUMN_H #define COLUMN_H + #include #include "Constraint.h" diff --git a/headers/libs/alm/Row.h b/headers/libs/alm/Row.h index 0fd332fa80..9195743043 100644 --- a/headers/libs/alm/Row.h +++ b/headers/libs/alm/Row.h @@ -5,6 +5,7 @@ #ifndef ROW_H #define ROW_H + #include #include "Constraint.h" diff --git a/headers/libs/alm/XTab.h b/headers/libs/alm/XTab.h index c1c5a5354a..7dd708c790 100644 --- a/headers/libs/alm/XTab.h +++ b/headers/libs/alm/XTab.h @@ -5,6 +5,7 @@ #ifndef X_TAB_H #define X_TAB_H + #include "LinearSpec.h" #include "Variable.h" diff --git a/headers/libs/alm/YTab.h b/headers/libs/alm/YTab.h index ddd77cdb21..25f76f02c0 100644 --- a/headers/libs/alm/YTab.h +++ b/headers/libs/alm/YTab.h @@ -5,6 +5,7 @@ #ifndef Y_TAB_H #define Y_TAB_H + #include "LinearSpec.h" #include "Variable.h" diff --git a/src/libs/alm/ALMLayout.cpp b/src/libs/alm/ALMLayout.cpp index 955c8111c0..5539e50b36 100644 --- a/src/libs/alm/ALMLayout.cpp +++ b/src/libs/alm/ALMLayout.cpp @@ -5,6 +5,7 @@ * Distributed under the terms of the MIT License. */ + #include "ALMLayout.h" #include // for floor @@ -142,55 +143,6 @@ BALMLayout::AddColumn(XTab* left, XTab* right) } -/** - * Adds a new area to the specification, setting only the necessary minimum size constraints. - * - * @param left left border - * @param top top border - * @param right right border - * @param bottom bottom border - * @param content the control which is the area content - * @param minContentSize minimum content size - * @return the new area - */ -Area* -BALMLayout::AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom, - BView* content, BSize minContentSize) -{ - BLayoutItem* item = AddView(content); - Area* area = _AreaForItem(item); - if (!area) - return NULL; - - area->_Init(&fSolver, left, top, right, bottom, content, - minContentSize); - return area; -} - - -/** - * Adds a new area to the specification, setting only the necessary minimum size constraints. - * - * @param row the row that defines the top and bottom border - * @param column the column that defines the left and right border - * @param content the control which is the area content - * @param minContentSize minimum content size - * @return the new area - */ -Area* -BALMLayout::AddArea(Row* row, Column* column, BView* content, - BSize minContentSize) -{ - BLayoutItem* item = AddView(content); - Area* area = _AreaForItem(item); - if (!area) - return NULL; - - area->_Init(&fSolver, row, column, content, minContentSize); - return area; -} - - /** * Adds a new area to the specification, automatically setting preferred size constraints. * @@ -210,8 +162,7 @@ BALMLayout::AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom, if (!area) return NULL; - area->_Init(&fSolver, left, top, right, bottom, content, - BSize(0, 0)); + area->_Init(&fSolver, left, top, right, bottom, content); area->SetDefaultBehavior(); area->SetAutoPreferredContentSize(false); return area; @@ -234,7 +185,7 @@ BALMLayout::AddArea(Row* row, Column* column, BView* content) if (!area) return NULL; - area->_Init(&fSolver, row, column, content, BSize(0, 0)); + area->_Init(&fSolver, row, column, content); area->SetDefaultBehavior(); area->SetAutoPreferredContentSize(false); return area; diff --git a/src/libs/alm/Area.cpp b/src/libs/alm/Area.cpp index 75facdc40c..bc0de761f4 100644 --- a/src/libs/alm/Area.cpp +++ b/src/libs/alm/Area.cpp @@ -4,6 +4,7 @@ * Distributed under the terms of the MIT License. */ + #include "Area.h" #include // for max @@ -517,8 +518,8 @@ Area::Area(BLayoutItem* item) * Initialize variables. */ void -Area::_Init(LinearSpec* ls, XTab* left, YTab* top, - XTab* right, YTab* bottom, BView* content, BSize minContentSize) +Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom, + BView* content) { fMaxContentWidth = NULL; fMaxContentHeight = NULL; @@ -544,24 +545,24 @@ Area::_Init(LinearSpec* ls, XTab* left, YTab* top, fTop = top; fBottom = bottom; - // adds the two essential constraints of the area that make sure that the left x-tab is - // really to the left of the right x-tab, and the top y-tab really above the bottom y-tab - fMinContentWidth = ls->AddConstraint(-1.0, left, 1.0, right, OperatorType(GE), - minContentSize.Width()); - fConstraints.AddItem(fMinContentWidth); + // adds the two essential constraints of the area that make sure that the + // left x-tab is really to the left of the right x-tab, and the top y-tab + // really above the bottom y-tab + fMinContentWidth = ls->AddConstraint(-1.0, left, 1.0, right, + OperatorType(GE), 0); + fMinContentHeight = ls->AddConstraint(-1.0, top, 1.0, bottom, + OperatorType(GE), 0); - fMinContentHeight = ls->AddConstraint(-1.0, top, 1.0, bottom, OperatorType(GE), - minContentSize.Height()); + fConstraints.AddItem(fMinContentWidth); fConstraints.AddItem(fMinContentHeight); } void -Area::_Init(LinearSpec* ls, Row* row, Column* column, BView* content, - BSize minContentSize) +Area::_Init(LinearSpec* ls, Row* row, Column* column, BView* content) { _Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(), - content, minContentSize); + content); fRow = row; fColumn = column; } diff --git a/src/libs/alm/Column.cpp b/src/libs/alm/Column.cpp index 3ec80c25c5..d9485c4e6c 100644 --- a/src/libs/alm/Column.cpp +++ b/src/libs/alm/Column.cpp @@ -4,7 +4,9 @@ * Distributed under the terms of the MIT License. */ + #include "Column.h" + #include "ALMLayout.h" #include "OperatorType.h" #include "XTab.h" diff --git a/src/libs/alm/Row.cpp b/src/libs/alm/Row.cpp index e605dabcc9..107832d450 100644 --- a/src/libs/alm/Row.cpp +++ b/src/libs/alm/Row.cpp @@ -4,7 +4,9 @@ * Distributed under the terms of the MIT License. */ + #include "Row.h" + #include "ALMLayout.h" #include "OperatorType.h" #include "YTab.h" diff --git a/src/libs/alm/XTab.cpp b/src/libs/alm/XTab.cpp index d059bd68bd..c2e55cfc4e 100644 --- a/src/libs/alm/XTab.cpp +++ b/src/libs/alm/XTab.cpp @@ -4,6 +4,7 @@ * Distributed under the terms of the MIT License. */ + #include "XTab.h"