- Areas with same tabs are put in a column/row automtically. Move preferred size constraint from Area to the column/row. This avoids a "spring" effect of the
quadratic solver if multiple Areas are in the same column/row. - Replace GetString by ToString. - some clean up git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40941 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
|
||||
namespace BALM {
|
||||
|
||||
|
||||
class RowColumnManager;
|
||||
|
||||
|
||||
/*!
|
||||
* A GUI layout engine using the Auckland Layout Model (ALM).
|
||||
*/
|
||||
@@ -33,9 +37,12 @@ public:
|
||||
|
||||
XTab* AddXTab();
|
||||
YTab* AddYTab();
|
||||
Row* AddRow();
|
||||
int32 CountXTabs() const;
|
||||
int32 CountYTabs() const;
|
||||
XTab* XTabAt(int32 index) const;
|
||||
YTab* YTabAt(int32 index) const;
|
||||
|
||||
Row* AddRow(YTab* top, YTab* bottom);
|
||||
Column* AddColumn();
|
||||
Column* AddColumn(XTab* left, XTab* right);
|
||||
|
||||
XTab* Left() const;
|
||||
@@ -56,10 +63,11 @@ public:
|
||||
|
||||
Area* AreaFor(const BView* view) const;
|
||||
Area* AreaFor(const BLayoutItem* item) const;
|
||||
Area* AreaAt(int32 index) const;
|
||||
Area* CurrentArea() const;
|
||||
void SetCurrentArea(const Area* area);
|
||||
void SetCurrentArea(const BView* view);
|
||||
void SetCurrentArea(const BLayoutItem* item);
|
||||
bool SetCurrentArea(const Area* area);
|
||||
bool SetCurrentArea(const BView* view);
|
||||
bool SetCurrentArea(const BLayoutItem* item);
|
||||
|
||||
XTab* LeftOf(const BView* view) const;
|
||||
XTab* LeftOf(const BLayoutItem* item) const;
|
||||
@@ -150,10 +158,10 @@ private:
|
||||
|
||||
Area* fCurrentArea;
|
||||
|
||||
#if USE_SCALE_VARIABLE
|
||||
Variable* fScaleWidth;
|
||||
Variable* fScaleHeight;
|
||||
#endif
|
||||
XTabList fXTabList;
|
||||
YTabList fYTabList;
|
||||
|
||||
RowColumnManager* fRowColumnManager;
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
+14
-31
@@ -20,9 +20,6 @@
|
||||
#include "Tab.h"
|
||||
|
||||
|
||||
#define USE_SCALE_VARIABLE 0
|
||||
|
||||
|
||||
class Constraint;
|
||||
|
||||
|
||||
@@ -58,6 +55,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class RowColumnManager;
|
||||
|
||||
|
||||
/**
|
||||
* Rectangular area in the GUI, defined by a tab on each side.
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ class Area {
|
||||
public:
|
||||
~Area();
|
||||
|
||||
BView* View();
|
||||
BLayoutItem* Item();
|
||||
|
||||
XTab* Left() const;
|
||||
XTab* Right() const;
|
||||
@@ -78,8 +78,6 @@ public:
|
||||
|
||||
Row* GetRow() const;
|
||||
Column* GetColumn() const;
|
||||
void SetRow(Row* row);
|
||||
void SetColumn(Column* column);
|
||||
|
||||
double ContentAspectRatio() const;
|
||||
void SetContentAspectRatio(double ratio);
|
||||
@@ -98,40 +96,29 @@ public:
|
||||
void SetRightInset(float right);
|
||||
void SetBottomInset(float bottom);
|
||||
|
||||
operator BString() const;
|
||||
void GetString(BString& string) const;
|
||||
BString ToString() const;
|
||||
|
||||
Constraint* SetWidthAs(Area* area, float factor = 1.0f);
|
||||
Constraint* SetHeightAs(Area* area, float factor = 1.0f);
|
||||
|
||||
void InvalidateSizeConstraints();
|
||||
|
||||
BRect Frame();
|
||||
BRect ItemFrame();
|
||||
|
||||
private:
|
||||
Area(BLayoutItem* item);
|
||||
|
||||
#if USE_SCALE_VARIABLE
|
||||
void _Init(LinearSpec* ls, XTab* left, YTab* top,
|
||||
XTab* right, YTab* bottom,
|
||||
Variable* scaleWidth,
|
||||
Variable* scaleHeight);
|
||||
RowColumnManager* manager);
|
||||
void _Init(LinearSpec* ls, Row* row, Column* column,
|
||||
Variable* scaleWidth,
|
||||
Variable* scaleHeight);
|
||||
#else
|
||||
void _Init(LinearSpec* ls, XTab* left, YTab* top,
|
||||
XTab* right, YTab* bottom);
|
||||
void _Init(LinearSpec* ls, Row* row, Column* column);
|
||||
#endif
|
||||
RowColumnManager* manager);
|
||||
|
||||
void _DoLayout();
|
||||
|
||||
void _UpdateMinSizeConstraint(BSize min);
|
||||
void _UpdateMaxSizeConstraint(BSize max);
|
||||
void _UpdatePreferredWidthConstraint(
|
||||
BSize& preferred);
|
||||
void _UpdatePreferredHeightConstraint(
|
||||
BSize& preferred);
|
||||
void _SetupPreferredConstraints();
|
||||
private:
|
||||
BLayoutItem* fLayoutItem;
|
||||
|
||||
@@ -151,22 +138,18 @@ private:
|
||||
BSize fTopLeftInset;
|
||||
BSize fRightBottomInset;
|
||||
|
||||
BList fConstraints;
|
||||
BObjectList<Constraint> fConstraints;
|
||||
Constraint* fMinContentWidth;
|
||||
Constraint* fMaxContentWidth;
|
||||
Constraint* fMinContentHeight;
|
||||
Constraint* fMaxContentHeight;
|
||||
Constraint* fPreferredContentWidth;
|
||||
Constraint* fPreferredContentHeight;
|
||||
double fContentAspectRatio;
|
||||
Constraint* fContentAspectRatioC;
|
||||
|
||||
#if USE_SCALE_VARIABLE
|
||||
Variable* fScaleWidth;
|
||||
Variable* fScaleHeight;
|
||||
#endif
|
||||
RowColumnManager* fRowColumnManager;
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
friend class BALMLayout;
|
||||
friend class RowColumnManager;
|
||||
|
||||
};
|
||||
|
||||
|
||||
+11
-20
@@ -13,7 +13,11 @@
|
||||
|
||||
namespace BALM {
|
||||
|
||||
|
||||
class Area;
|
||||
class BALMLayout;
|
||||
class RowColumnManager;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a column defined by two x-tabs.
|
||||
@@ -24,34 +28,21 @@ public:
|
||||
|
||||
XTab* Left() const;
|
||||
XTab* Right() const;
|
||||
Column* Previous() const;
|
||||
void SetPrevious(Column* value);
|
||||
Column* Next() const;
|
||||
void SetNext(Column* value);
|
||||
|
||||
void InsertBefore(Column* column);
|
||||
void InsertAfter(Column* column);
|
||||
Constraint* HasSameWidthAs(Column* column);
|
||||
private:
|
||||
Column(LinearSpec* ls, XTab* left, XTab* right);
|
||||
|
||||
ConstraintList* Constraints() const;
|
||||
|
||||
protected:
|
||||
Column(BALMLayout* layout);
|
||||
|
||||
protected:
|
||||
LinearSpec* fLS;
|
||||
XTab* fLeft;
|
||||
XTab* fRight;
|
||||
|
||||
private:
|
||||
Column* fPrevious;
|
||||
Column* fNext;
|
||||
Constraint* fPreviousGlue;
|
||||
Constraint* fNextGlue;
|
||||
ConstraintList fConstraints;
|
||||
//! managed by RowColumnManager
|
||||
Constraint* fPrefSizeConstraint;
|
||||
BObjectList<Area> fAreas;
|
||||
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
friend class BALMLayout;
|
||||
friend class BALM::RowColumnManager;
|
||||
|
||||
};
|
||||
|
||||
|
||||
+11
-18
@@ -13,7 +13,11 @@
|
||||
|
||||
namespace BALM {
|
||||
|
||||
|
||||
class Area;
|
||||
class BALMLayout;
|
||||
class RowColumnManager;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a row defined by two y-tabs.
|
||||
@@ -24,32 +28,21 @@ public:
|
||||
|
||||
YTab* Top() const;
|
||||
YTab* Bottom() const;
|
||||
Row* Previous() const;
|
||||
void SetPrevious(Row* value);
|
||||
Row* Next() const;
|
||||
void SetNext(Row* value);
|
||||
void InsertBefore(Row* row);
|
||||
void InsertAfter(Row* row);
|
||||
Constraint* HasSameHeightAs(Row* row);
|
||||
ConstraintList* Constraints() const;
|
||||
|
||||
protected:
|
||||
Row(BALMLayout* layout);
|
||||
private:
|
||||
Row(LinearSpec* ls, YTab* top, YTab* bottom);
|
||||
|
||||
protected:
|
||||
LinearSpec* fLS;
|
||||
YTab* fTop;
|
||||
YTab* fBottom;
|
||||
|
||||
private:
|
||||
Row* fPrevious;
|
||||
Row* fNext;
|
||||
Constraint* fPreviousGlue;
|
||||
Constraint* fNextGlue;
|
||||
ConstraintList fConstraints;
|
||||
//! managed by RowColumnManager
|
||||
Constraint* fPrefSizeConstraint;
|
||||
BObjectList<Area> fAreas;
|
||||
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
friend class BALMLayout;
|
||||
friend class BALM::RowColumnManager;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,12 @@ public:
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
|
||||
using BALM::XTab;
|
||||
using BALM::YTab;
|
||||
|
||||
typedef BObjectList<XTab> XTabList;
|
||||
typedef BObjectList<YTab> YTabList;
|
||||
|
||||
|
||||
#endif // X_TAB_H
|
||||
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
bool IsValid();
|
||||
void Invalidate();
|
||||
|
||||
operator BString() const;
|
||||
void GetString(BString& string) const;
|
||||
BString ToString() const;
|
||||
void PrintToStream();
|
||||
|
||||
~Constraint();
|
||||
|
||||
@@ -129,8 +129,7 @@ public:
|
||||
ResultType Result() const;
|
||||
bigtime_t SolvingTime() const;
|
||||
|
||||
operator BString() const;
|
||||
void GetString(BString& string) const;
|
||||
BString ToString() const;
|
||||
|
||||
const ConstraintList& Constraints() const;
|
||||
const VariableList& UsedVariables() const;
|
||||
|
||||
@@ -35,8 +35,7 @@ public:
|
||||
const char* Label();
|
||||
void SetLabel(const char* label);
|
||||
|
||||
operator BString() const;
|
||||
void GetString(BString& string) const;
|
||||
BString ToString() const;
|
||||
|
||||
Constraint* IsEqual(Variable* var);
|
||||
Constraint* IsSmallerOrEqual(Variable* var);
|
||||
@@ -54,7 +53,7 @@ public:
|
||||
//! delete it yourself!
|
||||
void Invalidate();
|
||||
|
||||
~Variable();
|
||||
virtual ~Variable();
|
||||
|
||||
protected:
|
||||
Variable(LinearSpec* ls);
|
||||
|
||||
Reference in New Issue
Block a user