- 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
This commit is contained in:
Clemens Zeidler
2010-09-22 21:53:32 +00:00
parent 30c47afa79
commit 9503cf19be
11 changed files with 33 additions and 75 deletions
+5 -8
View File
@@ -5,6 +5,7 @@
#ifndef ALM_LAYOUT_H #ifndef ALM_LAYOUT_H
#define ALM_LAYOUT_H #define ALM_LAYOUT_H
#include <AbstractLayout.h> #include <AbstractLayout.h>
#include <File.h> #include <File.h>
#include <List.h> #include <List.h>
@@ -22,8 +23,8 @@
namespace BALM { namespace BALM {
/** /*!
* A GUI layout engine using the ALM. * A GUI layout engine using the Auckland Layout Model (ALM).
*/ */
class BALMLayout : public BAbstractLayout { class BALMLayout : public BAbstractLayout {
public: public:
@@ -36,11 +37,7 @@ public:
Row* AddRow(YTab* top, YTab* bottom); Row* AddRow(YTab* top, YTab* bottom);
Column* AddColumn(); Column* AddColumn();
Column* AddColumn(XTab* left, XTab* right); 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, Area* AddArea(XTab* left, YTab* top, XTab* right,
YTab* bottom, BView* content); YTab* bottom, BView* content);
Area* AddArea(Row* row, Column* column, Area* AddArea(Row* row, Column* column,
@@ -62,7 +59,7 @@ public:
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
virtual void DerivedLayoutItems(); virtual void DerivedLayoutItems();
char* PerformancePath() const; char* PerformancePath() const;
void SetPerformancePath(char* path); void SetPerformancePath(char* path);
+3 -3
View File
@@ -5,6 +5,7 @@
#ifndef AREA_H #ifndef AREA_H
#define AREA_H #define AREA_H
#include <Alignment.h> #include <Alignment.h>
#include <List.h> #include <List.h>
#include <Size.h> #include <Size.h>
@@ -81,10 +82,9 @@ private:
Area(BLayoutItem* item); Area(BLayoutItem* item);
void _Init(LinearSpec* ls, XTab* left, YTab* top, void _Init(LinearSpec* ls, XTab* left, YTab* top,
XTab* right, YTab* bottom, BView* content, XTab* right, YTab* bottom, BView* content);
BSize minContentSize);
void _Init(LinearSpec* ls, Row* row, Column* column, void _Init(LinearSpec* ls, Row* row, Column* column,
BView* content, BSize minContentSize); BView* content);
void _DoLayout(); void _DoLayout();
+1
View File
@@ -5,6 +5,7 @@
#ifndef COLUMN_H #ifndef COLUMN_H
#define COLUMN_H #define COLUMN_H
#include <List.h> #include <List.h>
#include "Constraint.h" #include "Constraint.h"
+1
View File
@@ -5,6 +5,7 @@
#ifndef ROW_H #ifndef ROW_H
#define ROW_H #define ROW_H
#include <List.h> #include <List.h>
#include "Constraint.h" #include "Constraint.h"
+1
View File
@@ -5,6 +5,7 @@
#ifndef X_TAB_H #ifndef X_TAB_H
#define X_TAB_H #define X_TAB_H
#include "LinearSpec.h" #include "LinearSpec.h"
#include "Variable.h" #include "Variable.h"
+1
View File
@@ -5,6 +5,7 @@
#ifndef Y_TAB_H #ifndef Y_TAB_H
#define Y_TAB_H #define Y_TAB_H
#include "LinearSpec.h" #include "LinearSpec.h"
#include "Variable.h" #include "Variable.h"
+3 -52
View File
@@ -5,6 +5,7 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "ALMLayout.h" #include "ALMLayout.h"
#include <math.h> // for floor #include <math.h> // 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. * 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) if (!area)
return NULL; return NULL;
area->_Init(&fSolver, left, top, right, bottom, content, area->_Init(&fSolver, left, top, right, bottom, content);
BSize(0, 0));
area->SetDefaultBehavior(); area->SetDefaultBehavior();
area->SetAutoPreferredContentSize(false); area->SetAutoPreferredContentSize(false);
return area; return area;
@@ -234,7 +185,7 @@ BALMLayout::AddArea(Row* row, Column* column, BView* content)
if (!area) if (!area)
return NULL; return NULL;
area->_Init(&fSolver, row, column, content, BSize(0, 0)); area->_Init(&fSolver, row, column, content);
area->SetDefaultBehavior(); area->SetDefaultBehavior();
area->SetAutoPreferredContentSize(false); area->SetAutoPreferredContentSize(false);
return area; return area;
+13 -12
View File
@@ -4,6 +4,7 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "Area.h" #include "Area.h"
#include <algorithm> // for max #include <algorithm> // for max
@@ -517,8 +518,8 @@ Area::Area(BLayoutItem* item)
* Initialize variables. * Initialize variables.
*/ */
void void
Area::_Init(LinearSpec* ls, XTab* left, YTab* top, Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom,
XTab* right, YTab* bottom, BView* content, BSize minContentSize) BView* content)
{ {
fMaxContentWidth = NULL; fMaxContentWidth = NULL;
fMaxContentHeight = NULL; fMaxContentHeight = NULL;
@@ -544,24 +545,24 @@ Area::_Init(LinearSpec* ls, XTab* left, YTab* top,
fTop = top; fTop = top;
fBottom = bottom; fBottom = bottom;
// adds the two essential constraints of the area that make sure that the left x-tab is // adds the two essential constraints of the area that make sure that the
// really to the left of the right x-tab, and the top y-tab really above the bottom y-tab // left x-tab is really to the left of the right x-tab, and the top y-tab
fMinContentWidth = ls->AddConstraint(-1.0, left, 1.0, right, OperatorType(GE), // really above the bottom y-tab
minContentSize.Width()); fMinContentWidth = ls->AddConstraint(-1.0, left, 1.0, right,
fConstraints.AddItem(fMinContentWidth); 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), fConstraints.AddItem(fMinContentWidth);
minContentSize.Height());
fConstraints.AddItem(fMinContentHeight); fConstraints.AddItem(fMinContentHeight);
} }
void void
Area::_Init(LinearSpec* ls, Row* row, Column* column, BView* content, Area::_Init(LinearSpec* ls, Row* row, Column* column, BView* content)
BSize minContentSize)
{ {
_Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(), _Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(),
content, minContentSize); content);
fRow = row; fRow = row;
fColumn = column; fColumn = column;
} }
+2
View File
@@ -4,7 +4,9 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "Column.h" #include "Column.h"
#include "ALMLayout.h" #include "ALMLayout.h"
#include "OperatorType.h" #include "OperatorType.h"
#include "XTab.h" #include "XTab.h"
+2
View File
@@ -4,7 +4,9 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "Row.h" #include "Row.h"
#include "ALMLayout.h" #include "ALMLayout.h"
#include "OperatorType.h" #include "OperatorType.h"
#include "YTab.h" #include "YTab.h"
+1
View File
@@ -4,6 +4,7 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "XTab.h" #include "XTab.h"