- Rework the ALM layout api. The AddItemTo* function are now related to the current Area. On default the current Area is the last added Area.
- Add some more const where appreciated. - Fix some style issues and a leak in Row and Column. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38842 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e65a6eb2e0
commit
5b6fca0639
@ -46,29 +46,33 @@ public:
|
|||||||
char* PerformancePath() const;
|
char* PerformancePath() const;
|
||||||
void SetPerformancePath(char* path);
|
void SetPerformancePath(char* path);
|
||||||
|
|
||||||
LinearSpec* Solver();
|
LinearSpec* Solver() const;
|
||||||
|
|
||||||
void SetInset(float inset);
|
void SetInset(float inset);
|
||||||
float Inset();
|
float Inset() const;
|
||||||
|
|
||||||
void SetSpacing(float spacing);
|
void SetSpacing(float spacing);
|
||||||
float Spacing();
|
float Spacing() const;
|
||||||
|
|
||||||
|
Area* AreaFor(const BView* control) const;
|
||||||
|
Area* AreaFor(const BLayoutItem* item) const;
|
||||||
|
Area* CurrentArea() const;
|
||||||
|
void SetCurrentArea(const Area* area);
|
||||||
|
void SetCurrentArea(const BView* control);
|
||||||
|
void SetCurrentArea(const BLayoutItem* item);
|
||||||
|
|
||||||
virtual BLayoutItem* AddView(BView* child);
|
virtual BLayoutItem* AddView(BView* child);
|
||||||
virtual BLayoutItem* AddView(int32 index, BView* child);
|
virtual BLayoutItem* AddView(int32 index, BView* child);
|
||||||
virtual Area* AddView(BView* view, XTab* left, YTab* top,
|
virtual Area* AddView(BView* view, XTab* left, YTab* top,
|
||||||
XTab* right, YTab* bottom);
|
XTab* right, YTab* bottom);
|
||||||
virtual Area* AddView(BView* view, Row* row, Column* column);
|
virtual Area* AddView(BView* view, Row* row, Column* column);
|
||||||
virtual Area* AddViewToRight(BView* view, Area* leftArea,
|
virtual Area* AddViewToRight(BView* view, XTab* right = NULL,
|
||||||
XTab* right = NULL, YTab* top = NULL,
|
YTab* top = NULL, YTab* bottom = NULL);
|
||||||
YTab* bottom = NULL);
|
virtual Area* AddViewToLeft(BView* view, XTab* left = NULL,
|
||||||
virtual Area* AddViewToLeft(BView* view, Area* rightArea,
|
YTab* top = NULL, YTab* bottom = NULL);
|
||||||
XTab* left = NULL, YTab* top = NULL,
|
virtual Area* AddViewToTop(BView* view, YTab* top = NULL,
|
||||||
YTab* bottom = NULL);
|
XTab* left = NULL, XTab* right = NULL);
|
||||||
virtual Area* AddViewToTop(BView* view, Area* bottomArea,
|
virtual Area* AddViewToBottom(BView* view,
|
||||||
YTab* top = NULL, XTab* left = NULL,
|
|
||||||
XTab* right = NULL);
|
|
||||||
virtual Area* AddViewToBottom(BView* view, Area* topArea,
|
|
||||||
YTab* bottom = NULL, XTab* left = NULL,
|
YTab* bottom = NULL, XTab* left = NULL,
|
||||||
XTab* right = NULL);
|
XTab* right = NULL);
|
||||||
|
|
||||||
@ -79,19 +83,17 @@ public:
|
|||||||
virtual Area* AddItem(BLayoutItem* item, Row* row,
|
virtual Area* AddItem(BLayoutItem* item, Row* row,
|
||||||
Column* column);
|
Column* column);
|
||||||
virtual Area* AddItemToRight(BLayoutItem* item,
|
virtual Area* AddItemToRight(BLayoutItem* item,
|
||||||
Area* leftArea, XTab* right = NULL,
|
XTab* right = NULL, YTab* top = NULL,
|
||||||
YTab* top = NULL, YTab* bottom = NULL);
|
YTab* bottom = NULL);
|
||||||
virtual Area* AddItemToLeft(BLayoutItem* item,
|
virtual Area* AddItemToLeft(BLayoutItem* item,
|
||||||
Area* rightArea, XTab* left = NULL,
|
XTab* left = NULL, YTab* top = NULL,
|
||||||
YTab* top = NULL, YTab* bottom = NULL);
|
YTab* bottom = NULL);
|
||||||
virtual Area* AddItemToTop(BLayoutItem* item,
|
virtual Area* AddItemToTop(BLayoutItem* item,
|
||||||
Area* bottomArea, YTab* top = NULL,
|
YTab* top = NULL, XTab* left = NULL,
|
||||||
XTab* left = NULL, XTab* right = NULL);
|
XTab* right = NULL);
|
||||||
virtual Area* AddItemToBottom(BLayoutItem* item,
|
virtual Area* AddItemToBottom(BLayoutItem* item,
|
||||||
Area* topArea, YTab* bottom = NULL,
|
YTab* bottom = NULL, XTab* left = NULL,
|
||||||
XTab* left = NULL, XTab* right = NULL);
|
XTab* right = NULL);
|
||||||
|
|
||||||
virtual Area* AreaOf(BView* control);
|
|
||||||
|
|
||||||
virtual BSize BaseMinSize();
|
virtual BSize BaseMinSize();
|
||||||
virtual BSize BaseMaxSize();
|
virtual BSize BaseMaxSize();
|
||||||
@ -110,7 +112,6 @@ private:
|
|||||||
|
|
||||||
void _SolveLayout();
|
void _SolveLayout();
|
||||||
|
|
||||||
Area* _AreaForItem(BLayoutItem* item) const;
|
|
||||||
void _UpdateAreaConstraints();
|
void _UpdateAreaConstraints();
|
||||||
|
|
||||||
BSize _CalculateMinSize();
|
BSize _CalculateMinSize();
|
||||||
@ -131,6 +132,8 @@ private:
|
|||||||
|
|
||||||
float fInset;
|
float fInset;
|
||||||
float fSpacing;
|
float fSpacing;
|
||||||
|
|
||||||
|
Area* fCurrentArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BALM
|
} // namespace BALM
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#define COLUMN_H
|
#define COLUMN_H
|
||||||
|
|
||||||
|
|
||||||
#include <List.h>
|
|
||||||
|
|
||||||
#include "Constraint.h"
|
#include "Constraint.h"
|
||||||
#include "LinearSpec.h"
|
#include "LinearSpec.h"
|
||||||
|
|
||||||
@ -22,19 +20,20 @@ class XTab;
|
|||||||
*/
|
*/
|
||||||
class Column {
|
class Column {
|
||||||
public:
|
public:
|
||||||
|
~Column();
|
||||||
|
|
||||||
XTab* Left() const;
|
XTab* Left() const;
|
||||||
XTab* Right() const;
|
XTab* Right() const;
|
||||||
Column* Previous() const;
|
Column* Previous() const;
|
||||||
void SetPrevious(Column* value);
|
void SetPrevious(Column* value);
|
||||||
Column* Next() const;
|
Column* Next() const;
|
||||||
void SetNext(Column* value);
|
void SetNext(Column* value);
|
||||||
//~ string ToString();
|
|
||||||
void InsertBefore(Column* column);
|
void InsertBefore(Column* column);
|
||||||
void InsertAfter(Column* column);
|
void InsertAfter(Column* column);
|
||||||
Constraint* HasSameWidthAs(Column* column);
|
Constraint* HasSameWidthAs(Column* column);
|
||||||
BList* Constraints() const;
|
|
||||||
void SetConstraints(BList* constraints);
|
ConstraintList* Constraints() const;
|
||||||
~Column();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Column(LinearSpec* ls);
|
Column(LinearSpec* ls);
|
||||||
@ -49,7 +48,7 @@ private:
|
|||||||
Column* fNext;
|
Column* fNext;
|
||||||
Constraint* fPreviousGlue;
|
Constraint* fPreviousGlue;
|
||||||
Constraint* fNextGlue;
|
Constraint* fNextGlue;
|
||||||
BList* fConstraints;
|
ConstraintList fConstraints;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class BALMLayout;
|
friend class BALMLayout;
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#define ROW_H
|
#define ROW_H
|
||||||
|
|
||||||
|
|
||||||
#include <List.h>
|
|
||||||
|
|
||||||
#include "Constraint.h"
|
#include "Constraint.h"
|
||||||
#include "LinearSpec.h"
|
#include "LinearSpec.h"
|
||||||
|
|
||||||
@ -22,19 +20,18 @@ class YTab;
|
|||||||
*/
|
*/
|
||||||
class Row {
|
class Row {
|
||||||
public:
|
public:
|
||||||
|
~Row();
|
||||||
|
|
||||||
YTab* Top() const;
|
YTab* Top() const;
|
||||||
YTab* Bottom() const;
|
YTab* Bottom() const;
|
||||||
Row* Previous() const;
|
Row* Previous() const;
|
||||||
void SetPrevious(Row* value);
|
void SetPrevious(Row* value);
|
||||||
Row* Next() const;
|
Row* Next() const;
|
||||||
void SetNext(Row* value);
|
void SetNext(Row* value);
|
||||||
//~ string ToString();
|
|
||||||
void InsertBefore(Row* row);
|
void InsertBefore(Row* row);
|
||||||
void InsertAfter(Row* row);
|
void InsertAfter(Row* row);
|
||||||
Constraint* HasSameHeightAs(Row* row);
|
Constraint* HasSameHeightAs(Row* row);
|
||||||
BList* Constraints() const;
|
ConstraintList* Constraints() const;
|
||||||
void SetConstraints(BList* constraints);
|
|
||||||
~Row();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Row(LinearSpec* ls);
|
Row(LinearSpec* ls);
|
||||||
@ -49,7 +46,7 @@ private:
|
|||||||
Row* fNext;
|
Row* fNext;
|
||||||
Constraint* fPreviousGlue;
|
Constraint* fPreviousGlue;
|
||||||
Constraint* fNextGlue;
|
Constraint* fNextGlue;
|
||||||
BList* fConstraints;
|
ConstraintList fConstraints;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class BALMLayout;
|
friend class BALMLayout;
|
||||||
|
@ -33,7 +33,8 @@ const BSize kMaxSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
|
|||||||
BALMLayout::BALMLayout(float spacing)
|
BALMLayout::BALMLayout(float spacing)
|
||||||
:
|
:
|
||||||
fInset(0.0f),
|
fInset(0.0f),
|
||||||
fSpacing(spacing)
|
fSpacing(spacing),
|
||||||
|
fCurrentArea(NULL)
|
||||||
{
|
{
|
||||||
fLeft = new XTab(&fSolver);
|
fLeft = new XTab(&fSolver);
|
||||||
fRight = new XTab(&fSolver);
|
fRight = new XTab(&fSolver);
|
||||||
@ -146,6 +147,56 @@ BALMLayout::AddColumn(XTab* left, XTab* right)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the area that contains the given control.
|
||||||
|
*
|
||||||
|
* @param control the control to look for
|
||||||
|
* @return the area that contains the control
|
||||||
|
*/
|
||||||
|
Area*
|
||||||
|
BALMLayout::AreaFor(const BView* control) const
|
||||||
|
{
|
||||||
|
return AreaFor(ItemAt(IndexOfView(const_cast<BView*>(control))));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Area*
|
||||||
|
BALMLayout::AreaFor(const BLayoutItem* item) const
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
return NULL;
|
||||||
|
return static_cast<Area*>(item->LayoutData());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Area*
|
||||||
|
BALMLayout::CurrentArea() const
|
||||||
|
{
|
||||||
|
return fCurrentArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BALMLayout::SetCurrentArea(const Area* area)
|
||||||
|
{
|
||||||
|
fCurrentArea = const_cast<Area*>(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BALMLayout::SetCurrentArea(const BView* view)
|
||||||
|
{
|
||||||
|
fCurrentArea = AreaFor(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BALMLayout::SetCurrentArea(const BLayoutItem* item)
|
||||||
|
{
|
||||||
|
fCurrentArea = AreaFor(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BLayoutItem*
|
BLayoutItem*
|
||||||
BALMLayout::AddView(BView* child)
|
BALMLayout::AddView(BView* child)
|
||||||
{
|
{
|
||||||
@ -206,11 +257,10 @@ BALMLayout::AddView(BView* view, Row* row, Column* column)
|
|||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddViewToRight(BView* view, Area* leftArea, XTab* right, YTab* top,
|
BALMLayout::AddViewToRight(BView* view, XTab* right, YTab* top, YTab* bottom)
|
||||||
YTab* bottom)
|
|
||||||
{
|
{
|
||||||
BLayoutItem* item = _CreateLayoutItem(view);
|
BLayoutItem* item = _CreateLayoutItem(view);
|
||||||
Area* area = AddItemToRight(item, leftArea, right, top, bottom);
|
Area* area = AddItemToRight(item, right, top, bottom);
|
||||||
if (!area) {
|
if (!area) {
|
||||||
delete item;
|
delete item;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -220,11 +270,10 @@ BALMLayout::AddViewToRight(BView* view, Area* leftArea, XTab* right, YTab* top,
|
|||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddViewToLeft(BView* view, Area* rightArea, XTab* left, YTab* top,
|
BALMLayout::AddViewToLeft(BView* view, XTab* left, YTab* top, YTab* bottom)
|
||||||
YTab* bottom)
|
|
||||||
{
|
{
|
||||||
BLayoutItem* item = _CreateLayoutItem(view);
|
BLayoutItem* item = _CreateLayoutItem(view);
|
||||||
Area* area = AddItemToLeft(item, rightArea, left, top, bottom);
|
Area* area = AddItemToLeft(item, left, top, bottom);
|
||||||
if (!area) {
|
if (!area) {
|
||||||
delete item;
|
delete item;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -234,11 +283,10 @@ BALMLayout::AddViewToLeft(BView* view, Area* rightArea, XTab* left, YTab* top,
|
|||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddViewToTop(BView* view, Area* bottomArea, YTab* top, XTab* left,
|
BALMLayout::AddViewToTop(BView* view, YTab* top, XTab* left, XTab* right)
|
||||||
XTab* right)
|
|
||||||
{
|
{
|
||||||
BLayoutItem* item = _CreateLayoutItem(view);
|
BLayoutItem* item = _CreateLayoutItem(view);
|
||||||
Area* area = AddItemToTop(item, bottomArea, top, left, right);
|
Area* area = AddItemToTop(item, top, left, right);
|
||||||
if (!area) {
|
if (!area) {
|
||||||
delete item;
|
delete item;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -248,11 +296,10 @@ BALMLayout::AddViewToTop(BView* view, Area* bottomArea, YTab* top, XTab* left,
|
|||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddViewToBottom(BView* view, Area* topArea, YTab* bottom,
|
BALMLayout::AddViewToBottom(BView* view, YTab* bottom, XTab* left, XTab* right)
|
||||||
XTab* left, XTab* right)
|
|
||||||
{
|
{
|
||||||
BLayoutItem* item = _CreateLayoutItem(view);
|
BLayoutItem* item = _CreateLayoutItem(view);
|
||||||
Area* area = AddItemToBottom(item, topArea, bottom, left, right);
|
Area* area = AddItemToBottom(item, bottom, left, right);
|
||||||
if (!area) {
|
if (!area) {
|
||||||
delete item;
|
delete item;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -288,7 +335,7 @@ BALMLayout::AddItem(int32 index, BLayoutItem* item)
|
|||||||
// for index = 0 we already have set the right tabs
|
// for index = 0 we already have set the right tabs
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
BLayoutItem* prevItem = ItemAt(index - 1);
|
BLayoutItem* prevItem = ItemAt(index - 1);
|
||||||
Area* area = _AreaForItem(prevItem);
|
Area* area = AreaFor(prevItem);
|
||||||
if (area) {
|
if (area) {
|
||||||
left = area->Right();
|
left = area->Right();
|
||||||
top = area->Top();
|
top = area->Top();
|
||||||
@ -305,9 +352,10 @@ BALMLayout::AddItem(BLayoutItem* item, XTab* left, YTab* top, XTab* right,
|
|||||||
{
|
{
|
||||||
if (!BAbstractLayout::AddItem(-1, item))
|
if (!BAbstractLayout::AddItem(-1, item))
|
||||||
return NULL;
|
return NULL;
|
||||||
Area* area = _AreaForItem(item);
|
Area* area = AreaFor(item);
|
||||||
if (!area)
|
if (!area)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
fCurrentArea = area;
|
||||||
|
|
||||||
area->_Init(&fSolver, left, top, right, bottom);
|
area->_Init(&fSolver, left, top, right, bottom);
|
||||||
return area;
|
return area;
|
||||||
@ -319,9 +367,10 @@ BALMLayout::AddItem(BLayoutItem* item, Row* row, Column* column)
|
|||||||
{
|
{
|
||||||
if (!BAbstractLayout::AddItem(-1, item))
|
if (!BAbstractLayout::AddItem(-1, item))
|
||||||
return NULL;
|
return NULL;
|
||||||
Area* area = _AreaForItem(item);
|
Area* area = AreaFor(item);
|
||||||
if (!area)
|
if (!area)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
fCurrentArea = area;
|
||||||
|
|
||||||
area->_Init(&fSolver, row, column);
|
area->_Init(&fSolver, row, column);
|
||||||
return area;
|
return area;
|
||||||
@ -329,62 +378,61 @@ BALMLayout::AddItem(BLayoutItem* item, Row* row, Column* column)
|
|||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddItemToRight(BLayoutItem* item, Area* leftArea, XTab* right,
|
BALMLayout::AddItemToRight(BLayoutItem* item, XTab* right, YTab* top,
|
||||||
YTab* top, YTab* bottom)
|
YTab* bottom)
|
||||||
{
|
{
|
||||||
XTab* left = leftArea->Right();
|
XTab* left = fCurrentArea->Right();
|
||||||
if (!right)
|
if (!right)
|
||||||
right = AddXTab();
|
right = AddXTab();
|
||||||
if (!top)
|
if (!top)
|
||||||
top = leftArea->Top();
|
top = fCurrentArea->Top();
|
||||||
if (!bottom)
|
if (!bottom)
|
||||||
bottom = leftArea->Bottom();
|
bottom = fCurrentArea->Bottom();
|
||||||
|
|
||||||
return AddItem(item, left, top, right, bottom);
|
return AddItem(item, left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddItemToLeft(BLayoutItem* item, Area* rightArea, XTab* left,
|
BALMLayout::AddItemToLeft(BLayoutItem* item, XTab* left, YTab* top,
|
||||||
YTab* top, YTab* bottom)
|
YTab* bottom)
|
||||||
{
|
{
|
||||||
if (!left)
|
if (!left)
|
||||||
left = AddXTab();
|
left = AddXTab();
|
||||||
XTab* right = rightArea->Left();
|
XTab* right = fCurrentArea->Left();
|
||||||
if (!top)
|
if (!top)
|
||||||
top = rightArea->Top();
|
top = fCurrentArea->Top();
|
||||||
if (!bottom)
|
if (!bottom)
|
||||||
bottom = rightArea->Bottom();
|
bottom = fCurrentArea->Bottom();
|
||||||
|
|
||||||
return AddItem(item, left, top, right, bottom);
|
return AddItem(item, left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddItemToTop(BLayoutItem* item, Area* bottomArea, YTab* top,
|
BALMLayout::AddItemToTop(BLayoutItem* item, YTab* top, XTab* left, XTab* right)
|
||||||
XTab* left, XTab* right)
|
|
||||||
{
|
{
|
||||||
if (!left)
|
if (!left)
|
||||||
left = bottomArea->Left();
|
left = fCurrentArea->Left();
|
||||||
if (!right)
|
if (!right)
|
||||||
right = bottomArea->Right();
|
right = fCurrentArea->Right();
|
||||||
if (!top)
|
if (!top)
|
||||||
top = AddYTab();
|
top = AddYTab();
|
||||||
YTab* bottom = bottomArea->Top();
|
YTab* bottom = fCurrentArea->Top();
|
||||||
|
|
||||||
return AddItem(item, left, top, right, bottom);
|
return AddItem(item, left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Area*
|
Area*
|
||||||
BALMLayout::AddItemToBottom(BLayoutItem* item, Area* topArea, YTab* bottom,
|
BALMLayout::AddItemToBottom(BLayoutItem* item, YTab* bottom, XTab* left,
|
||||||
XTab* left, XTab* right)
|
XTab* right)
|
||||||
{
|
{
|
||||||
if (!left)
|
if (!left)
|
||||||
left = topArea->Left();
|
left = fCurrentArea->Left();
|
||||||
if (!right)
|
if (!right)
|
||||||
right = topArea->Right();
|
right = fCurrentArea->Right();
|
||||||
YTab* top = topArea->Bottom();
|
YTab* top = fCurrentArea->Bottom();
|
||||||
if (!bottom)
|
if (!bottom)
|
||||||
bottom = AddYTab();
|
bottom = AddYTab();
|
||||||
|
|
||||||
@ -392,19 +440,6 @@ BALMLayout::AddItemToBottom(BLayoutItem* item, Area* topArea, YTab* bottom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the area that contains the given control.
|
|
||||||
*
|
|
||||||
* @param control the control to look for
|
|
||||||
* @return the area that contains the control
|
|
||||||
*/
|
|
||||||
Area*
|
|
||||||
BALMLayout::AreaOf(BView* control)
|
|
||||||
{
|
|
||||||
return _AreaForItem(ItemAt(IndexOfView(control)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the left variable.
|
* Gets the left variable.
|
||||||
*/
|
*/
|
||||||
@ -518,7 +553,7 @@ BALMLayout::ItemAdded(BLayoutItem* item, int32 atIndex)
|
|||||||
void
|
void
|
||||||
BALMLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
|
BALMLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
|
||||||
{
|
{
|
||||||
if (Area* area = _AreaForItem(item)) {
|
if (Area* area = AreaFor(item)) {
|
||||||
item->SetLayoutData(NULL);
|
item->SetLayoutData(NULL);
|
||||||
delete area;
|
delete area;
|
||||||
}
|
}
|
||||||
@ -554,7 +589,7 @@ BALMLayout::DerivedLayoutItems()
|
|||||||
|
|
||||||
// set the calculated positions and sizes for every area
|
// set the calculated positions and sizes for every area
|
||||||
for (int32 i = 0; i < CountItems(); i++)
|
for (int32 i = 0; i < CountItems(); i++)
|
||||||
_AreaForItem(ItemAt(i))->_DoLayout();
|
AreaFor(ItemAt(i))->_DoLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -583,9 +618,9 @@ BALMLayout::SetPerformancePath(char* path)
|
|||||||
|
|
||||||
|
|
||||||
LinearSpec*
|
LinearSpec*
|
||||||
BALMLayout::Solver()
|
BALMLayout::Solver() const
|
||||||
{
|
{
|
||||||
return &fSolver;
|
return const_cast<LinearSpec*>(&fSolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -597,7 +632,7 @@ BALMLayout::SetInset(float inset)
|
|||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
BALMLayout::Inset()
|
BALMLayout::Inset() const
|
||||||
{
|
{
|
||||||
return fInset;
|
return fInset;
|
||||||
}
|
}
|
||||||
@ -611,7 +646,7 @@ BALMLayout::SetSpacing(float spacing)
|
|||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
BALMLayout::Spacing()
|
BALMLayout::Spacing() const
|
||||||
{
|
{
|
||||||
return fSpacing;
|
return fSpacing;
|
||||||
}
|
}
|
||||||
@ -740,18 +775,9 @@ BALMLayout::_CalculatePreferredSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Area*
|
|
||||||
BALMLayout::_AreaForItem(BLayoutItem* item) const
|
|
||||||
{
|
|
||||||
if (!item)
|
|
||||||
return NULL;
|
|
||||||
return static_cast<Area*>(item->LayoutData());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BALMLayout::_UpdateAreaConstraints()
|
BALMLayout::_UpdateAreaConstraints()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CountItems(); i++)
|
for (int i = 0; i < CountItems(); i++)
|
||||||
_AreaForItem(ItemAt(i))->InvalidateSizeConstraints();
|
AreaFor(ItemAt(i))->InvalidateSizeConstraints();
|
||||||
}
|
}
|
||||||
|
@ -623,8 +623,8 @@ Area::_UpdateMaxSizeConstraint(BSize max)
|
|||||||
void
|
void
|
||||||
Area::_UpdatePreferredConstraint(BSize preferred)
|
Area::_UpdatePreferredConstraint(BSize preferred)
|
||||||
{
|
{
|
||||||
float width = 64000;
|
float width = 32000;
|
||||||
float height = 64000;
|
float height = 32000;
|
||||||
if (preferred.width > 0)
|
if (preferred.width > 0)
|
||||||
width = preferred.Width() + LeftInset() + RightInset();
|
width = preferred.Width() + LeftInset() + RightInset();
|
||||||
if (preferred.height > 0)
|
if (preferred.height > 0)
|
||||||
|
@ -120,11 +120,6 @@ Column::SetNext(Column* value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//~ string Column::ToString() {
|
|
||||||
//~ return "Column(" + fLeft.ToString() + ", " + fRight.ToString() + ")";
|
|
||||||
//~ }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts the given column directly to the left of this column.
|
* Inserts the given column directly to the left of this column.
|
||||||
*
|
*
|
||||||
@ -163,28 +158,15 @@ Column::HasSameWidthAs(Column* column)
|
|||||||
Constraint* constraint = fLS->AddConstraint(
|
Constraint* constraint = fLS->AddConstraint(
|
||||||
-1.0, fLeft, 1.0, fRight, 1.0, column->fLeft, -1.0, column->fRight,
|
-1.0, fLeft, 1.0, fRight, 1.0, column->fLeft, -1.0, column->fRight,
|
||||||
OperatorType(EQ), 0.0);
|
OperatorType(EQ), 0.0);
|
||||||
fConstraints->AddItem(constraint);
|
fConstraints.AddItem(constraint);
|
||||||
return constraint;
|
return constraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
ConstraintList*
|
||||||
* Gets the constraints.
|
|
||||||
*/
|
|
||||||
BList*
|
|
||||||
Column::Constraints() const
|
Column::Constraints() const
|
||||||
{
|
{
|
||||||
return fConstraints;
|
return const_cast<ConstraintList*>(&fConstraints);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the constraints.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Column::SetConstraints(BList* constraints)
|
|
||||||
{
|
|
||||||
fConstraints = constraints;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -196,8 +178,8 @@ Column::~Column()
|
|||||||
{
|
{
|
||||||
if (fPrevious != NULL)
|
if (fPrevious != NULL)
|
||||||
fPrevious->SetNext(fNext);
|
fPrevious->SetNext(fNext);
|
||||||
for (int32 i = 0; i < fConstraints->CountItems(); i++)
|
for (int32 i = 0; i < fConstraints.CountItems(); i++)
|
||||||
delete (Constraint*)fConstraints->ItemAt(i);
|
delete fConstraints.ItemAt(i);
|
||||||
delete fLeft;
|
delete fLeft;
|
||||||
delete fRight;
|
delete fRight;
|
||||||
}
|
}
|
||||||
@ -211,6 +193,5 @@ Column::Column(LinearSpec* ls)
|
|||||||
fLS = ls;
|
fLS = ls;
|
||||||
fLeft = new XTab(ls);
|
fLeft = new XTab(ls);
|
||||||
fRight = new XTab(ls);
|
fRight = new XTab(ls);
|
||||||
fConstraints = new BList(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +122,6 @@ Row::SetNext(Row* value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//~ string Row::ToString() {
|
|
||||||
//~ return "Row(" + fTop.ToString() + ", " + fBottom.ToString() + ")";
|
|
||||||
//~ }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts the given row directly above this row.
|
* Inserts the given row directly above this row.
|
||||||
*
|
*
|
||||||
@ -165,7 +160,7 @@ Row::HasSameHeightAs(Row* row)
|
|||||||
Constraint* constraint = fLS->AddConstraint(
|
Constraint* constraint = fLS->AddConstraint(
|
||||||
-1.0, fTop, 1.0, fBottom, 1.0, row->fTop, -1.0, row->fBottom,
|
-1.0, fTop, 1.0, fBottom, 1.0, row->fTop, -1.0, row->fBottom,
|
||||||
OperatorType(EQ), 0.0);
|
OperatorType(EQ), 0.0);
|
||||||
fConstraints->AddItem(constraint);
|
fConstraints.AddItem(constraint);
|
||||||
return constraint;
|
return constraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,20 +168,10 @@ Row::HasSameHeightAs(Row* row)
|
|||||||
/**
|
/**
|
||||||
* Gets the constraints.
|
* Gets the constraints.
|
||||||
*/
|
*/
|
||||||
BList*
|
ConstraintList*
|
||||||
Row::Constraints() const
|
Row::Constraints() const
|
||||||
{
|
{
|
||||||
return fConstraints;
|
return const_cast<ConstraintList*>(&fConstraints);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the constraints.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Row::SetConstraints(BList* constraints)
|
|
||||||
{
|
|
||||||
fConstraints = constraints;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,8 +183,8 @@ Row::~Row()
|
|||||||
{
|
{
|
||||||
if (fPrevious != NULL)
|
if (fPrevious != NULL)
|
||||||
fPrevious->SetNext(fNext);
|
fPrevious->SetNext(fNext);
|
||||||
for (int32 i = 0; i < fConstraints->CountItems(); i++)
|
for (int32 i = 0; i < fConstraints.CountItems(); i++)
|
||||||
delete (Constraint*)fConstraints->ItemAt(i);
|
delete (Constraint*)fConstraints.ItemAt(i);
|
||||||
delete fTop;
|
delete fTop;
|
||||||
delete fBottom;
|
delete fBottom;
|
||||||
}
|
}
|
||||||
@ -213,6 +198,5 @@ Row::Row(LinearSpec* ls)
|
|||||||
fLS = ls;
|
fLS = ls;
|
||||||
fTop = new YTab(ls);
|
fTop = new YTab(ls);
|
||||||
fBottom = new YTab(ls);
|
fBottom = new YTab(ls);
|
||||||
fConstraints = new BList(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user