- 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:
@@ -5,6 +5,7 @@
|
||||
#ifndef ALM_LAYOUT_H
|
||||
#define ALM_LAYOUT_H
|
||||
|
||||
|
||||
#include <AbstractLayout.h>
|
||||
#include <File.h>
|
||||
#include <List.h>
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef AREA_H
|
||||
#define AREA_H
|
||||
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <List.h>
|
||||
#include <Size.h>
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef COLUMN_H
|
||||
#define COLUMN_H
|
||||
|
||||
|
||||
#include <List.h>
|
||||
|
||||
#include "Constraint.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef ROW_H
|
||||
#define ROW_H
|
||||
|
||||
|
||||
#include <List.h>
|
||||
|
||||
#include "Constraint.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef X_TAB_H
|
||||
#define X_TAB_H
|
||||
|
||||
|
||||
#include "LinearSpec.h"
|
||||
#include "Variable.h"
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef Y_TAB_H
|
||||
#define Y_TAB_H
|
||||
|
||||
|
||||
#include "LinearSpec.h"
|
||||
#include "Variable.h"
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "ALMLayout.h"
|
||||
|
||||
#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.
|
||||
*
|
||||
@@ -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;
|
||||
|
||||
+13
-12
@@ -4,6 +4,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Area.h"
|
||||
|
||||
#include <algorithm> // 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;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Column.h"
|
||||
|
||||
#include "ALMLayout.h"
|
||||
#include "OperatorType.h"
|
||||
#include "XTab.h"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Row.h"
|
||||
|
||||
#include "ALMLayout.h"
|
||||
#include "OperatorType.h"
|
||||
#include "YTab.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "XTab.h"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user