Added libalm.so and its dependency liblinprog.so. libalm.so provides a
BLayout implementation (BALMLayout) using the Auckland Layout Model (ALM). The original ALM was implemented by Christof Lutteroth, the Haiku/C++ version by James Kim. The code needs some review, but the test programs seem to work fine. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23889 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
#ifndef AREA_H
|
||||
#define AREA_H
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "SoftConstraint.h"
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <List.h>
|
||||
#include <Size.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
namespace BALM {
|
||||
|
||||
class Column;
|
||||
class BALMLayout;
|
||||
class Row;
|
||||
class XTab;
|
||||
class YTab;
|
||||
|
||||
/**
|
||||
* Rectangular area in the GUI, defined by a tab on each side.
|
||||
*/
|
||||
class Area {
|
||||
|
||||
public:
|
||||
bool AutoPrefContentSize() const;
|
||||
void SetAutoPrefContentSize(bool value);
|
||||
XTab* Left() const;
|
||||
void SetLeft(XTab* left);
|
||||
XTab* Right() const;
|
||||
void SetRight(XTab* right);
|
||||
YTab* Top() const;
|
||||
void SetTop(YTab* top);
|
||||
YTab* Bottom() const;
|
||||
void SetBottom(YTab* bottom);
|
||||
Row* GetRow() const;
|
||||
void SetRow(Row* row);
|
||||
Column* GetColumn() const;
|
||||
void SetColumn(Column* column);
|
||||
BView* Content() const;
|
||||
void SetContent(BView* content);
|
||||
XTab* ContentLeft() const;
|
||||
YTab* ContentTop() const;
|
||||
XTab* ContentRight() const;
|
||||
YTab* ContentBottom() const;
|
||||
BSize MinContentSize() const;
|
||||
void SetMinContentSize(BSize min);
|
||||
BSize MaxContentSize() const;
|
||||
void SetMaxContentSize(BSize max);
|
||||
BSize PrefContentSize() const;
|
||||
void SetPrefContentSize(BSize pref);
|
||||
BSize ShrinkRigidity() const;
|
||||
void SetShrinkRigidity(BSize shrink);
|
||||
BSize ExpandRigidity() const;
|
||||
void SetExpandRigidity(BSize expand);
|
||||
double ContentAspectRatio() const;
|
||||
void SetContentAspectRatio(double ratio);
|
||||
BAlignment Alignment() const;
|
||||
void SetAlignment(BAlignment alignment);
|
||||
void SetHAlignment(alignment horizontal);
|
||||
void SetVAlignment(vertical_alignment vertical);
|
||||
int32 LeftInset() const;
|
||||
void SetLeftInset(int32 left);
|
||||
int32 TopInset() const;
|
||||
void SetTopInset(int32 top);
|
||||
int32 RightInset() const;
|
||||
void SetRightInset(int32 right);
|
||||
int32 BottomInset() const;
|
||||
void SetBottomInset(int32 bottom);
|
||||
void SetDefaultPrefContentSize();
|
||||
//~ string ToString();
|
||||
Constraint* HasSameWidthAs(Area* area);
|
||||
Constraint* HasSameHeightAs(Area* area);
|
||||
BList* HasSameSizetAs(Area* area);
|
||||
~Area();
|
||||
|
||||
protected:
|
||||
Area(BALMLayout* ls, XTab* left, YTab* top,
|
||||
XTab* right, YTab* bottom,
|
||||
BView* content,
|
||||
BSize minContentSize);
|
||||
Area(BALMLayout* ls, Row* row, Column* column,
|
||||
BView* content,
|
||||
BSize minContentSize);
|
||||
void DoLayout();
|
||||
|
||||
private:
|
||||
void InitChildArea();
|
||||
void UpdateHorizontal();
|
||||
void UpdateVertical();
|
||||
void Init(BALMLayout* ls, XTab* left, YTab* top,
|
||||
XTab* right, YTab* bottom,
|
||||
BView* content,
|
||||
BSize minContentSize);
|
||||
|
||||
public:
|
||||
static BSize kMaxSize;
|
||||
static BSize kMinSize;
|
||||
static BSize kUndefinedSize;
|
||||
|
||||
protected:
|
||||
BView* fContent;
|
||||
BList* fConstraints;
|
||||
|
||||
private:
|
||||
BALMLayout* fLS;
|
||||
XTab* fLeft;
|
||||
XTab* fRight;
|
||||
YTab* fTop;
|
||||
YTab* fBottom;
|
||||
Row* fRow;
|
||||
Column* fColumn;
|
||||
BSize fMinContentSize;
|
||||
BSize fMaxContentSize;
|
||||
Constraint* fMinContentWidth;
|
||||
Constraint* fMaxContentWidth;
|
||||
Constraint* fMinContentHeight;
|
||||
Constraint* fMaxContentHeight;
|
||||
BSize fPrefContentSize;
|
||||
BSize fShrinkRigidity;
|
||||
BSize fExpandRigidity;
|
||||
double fContentAspectRatio;
|
||||
Constraint* fContentAspectRatioC;
|
||||
bool fAutoPrefContentSize;
|
||||
SoftConstraint* fPrefContentWidth;
|
||||
SoftConstraint* fPrefContentHeight;
|
||||
Area* fChildArea;
|
||||
BAlignment fAlignment;
|
||||
int32 fLeftInset;
|
||||
int32 fTopInset;
|
||||
int32 fRightInset;
|
||||
int32 fBottomInset;
|
||||
Constraint* fLeftConstraint;
|
||||
Constraint* fTopConstraint;
|
||||
Constraint* fRightConstraint;
|
||||
Constraint* fBottomConstraint;
|
||||
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::Area;
|
||||
|
||||
#endif // AREA_H
|
||||
@@ -0,0 +1,106 @@
|
||||
#ifndef BALM_LAYOUT_H
|
||||
#define BALM_LAYOUT_H
|
||||
|
||||
#include <File.h>
|
||||
#include <Layout.h>
|
||||
#include <List.h>
|
||||
#include <Size.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "LayoutStyleType.h"
|
||||
#include "LinearSpec.h"
|
||||
|
||||
|
||||
namespace BALM {
|
||||
|
||||
class Area;
|
||||
class Column;
|
||||
class Row;
|
||||
class XTab;
|
||||
class YTab;
|
||||
|
||||
/**
|
||||
* A GUI layout engine using the ALM.
|
||||
*/
|
||||
class BALMLayout : public BLayout, public LinearSpec {
|
||||
|
||||
public:
|
||||
BALMLayout();
|
||||
void SolveLayout();
|
||||
|
||||
XTab* AddXTab();
|
||||
YTab* AddYTab();
|
||||
Row* AddRow();
|
||||
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, BView* content);
|
||||
Area* AreaOf(BView* control);
|
||||
BList* Areas() const;
|
||||
void SetAreas(BList* areas);
|
||||
XTab* Left() const;
|
||||
void SetLeft(XTab* left);
|
||||
XTab* Right() const;
|
||||
void SetRight(XTab* right);
|
||||
YTab* Top() const;
|
||||
void SetTop(YTab* top);
|
||||
YTab* Bottom() const;
|
||||
void SetBottom(YTab* bottom);
|
||||
|
||||
void RecoverLayout(BView* parent);
|
||||
LayoutStyleType LayoutStyle() const;
|
||||
void SetLayoutStyle(LayoutStyleType style);
|
||||
|
||||
BLayoutItem* AddView(BView* child);
|
||||
BLayoutItem* AddView(int32 index, BView* child);
|
||||
bool AddItem(BLayoutItem* item);
|
||||
bool AddItem(int32 index, BLayoutItem* item);
|
||||
bool RemoveView(BView* child);
|
||||
bool RemoveItem(BLayoutItem* item);
|
||||
BLayoutItem* RemoveItem(int32 index);
|
||||
|
||||
BSize MinSize();
|
||||
BSize MaxSize();
|
||||
BSize PreferredSize();
|
||||
BAlignment Alignment();
|
||||
bool HasHeightForWidth();
|
||||
void GetHeightForWidth(float width, float* min,
|
||||
float* max, float* preferred);
|
||||
void InvalidateLayout();
|
||||
void LayoutView();
|
||||
|
||||
char* PerformancePath() const;
|
||||
void SetPerformancePath(char* path);
|
||||
|
||||
private:
|
||||
BSize CalculateMinSize();
|
||||
BSize CalculateMaxSize();
|
||||
BSize CalculatePreferredSize();
|
||||
|
||||
private:
|
||||
LayoutStyleType fLayoutStyle;
|
||||
bool fActivated;
|
||||
|
||||
BList* fAreas;
|
||||
XTab* fLeft;
|
||||
XTab* fRight;
|
||||
YTab* fTop;
|
||||
YTab* fBottom;
|
||||
BSize fMinSize;
|
||||
BSize fMaxSize;
|
||||
BSize fPreferredSize;
|
||||
char* fPerformancePath;
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::BALMLayout;
|
||||
|
||||
#endif // BALM_LAYOUT_H
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef COLUMN_H
|
||||
#define COLUMN_H
|
||||
|
||||
#include "Constraint.h"
|
||||
|
||||
#include <List.h>
|
||||
|
||||
|
||||
namespace BALM {
|
||||
|
||||
class BALMLayout;
|
||||
class XTab;
|
||||
|
||||
/**
|
||||
* Represents a column defined by two x-tabs.
|
||||
*/
|
||||
class Column {
|
||||
|
||||
public:
|
||||
XTab* Left() const;
|
||||
XTab* Right() const;
|
||||
Column* Previous() const;
|
||||
void SetPrevious(Column* value);
|
||||
Column* Next() const;
|
||||
void SetNext(Column* value);
|
||||
//~ string ToString();
|
||||
void InsertBefore(Column* column);
|
||||
void InsertAfter(Column* column);
|
||||
Constraint* HasSameWidthAs(Column* column);
|
||||
BList* Constraints() const;
|
||||
void SetConstraints(BList* constraints);
|
||||
~Column();
|
||||
|
||||
protected:
|
||||
Column(BALMLayout* ls);
|
||||
|
||||
protected:
|
||||
BALMLayout* fLS;
|
||||
XTab* fLeft;
|
||||
XTab* fRight;
|
||||
|
||||
private:
|
||||
Column* fPrevious;
|
||||
Column* fNext;
|
||||
Constraint* fPreviousGlue;
|
||||
Constraint* fNextGlue;
|
||||
BList* fConstraints;
|
||||
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::Column;
|
||||
|
||||
#endif // COLUMN_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef LAYOUT_STYLE_TYPE_H
|
||||
#define LAYOUT_STYLE_TYPE_H
|
||||
|
||||
|
||||
namespace BALM {
|
||||
|
||||
/**
|
||||
* The possibilities for adjusting a GUI's layout.
|
||||
* Either change the child controls so that they fit into their parent control, or adjust
|
||||
* the size of the parent control so that the children have as much space as they want.
|
||||
*/
|
||||
enum LayoutStyleType {
|
||||
FIT_TO_SIZE, ADJUST_SIZE
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::LayoutStyleType;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef ROW_H
|
||||
#define ROW_H
|
||||
|
||||
#include "Constraint.h"
|
||||
|
||||
#include <List.h>
|
||||
|
||||
|
||||
namespace BALM {
|
||||
|
||||
class BALMLayout;
|
||||
class YTab;
|
||||
|
||||
/**
|
||||
* Represents a row defined by two y-tabs.
|
||||
*/
|
||||
class Row {
|
||||
|
||||
public:
|
||||
YTab* Top() const;
|
||||
YTab* Bottom() const;
|
||||
Row* Previous() const;
|
||||
void SetPrevious(Row* value);
|
||||
Row* Next() const;
|
||||
void SetNext(Row* value);
|
||||
//~ string ToString();
|
||||
void InsertBefore(Row* row);
|
||||
void InsertAfter(Row* row);
|
||||
Constraint* HasSameHeightAs(Row* row);
|
||||
BList* Constraints() const;
|
||||
void SetConstraints(BList* constraints);
|
||||
~Row();
|
||||
|
||||
protected:
|
||||
Row(BALMLayout* ls);
|
||||
|
||||
protected:
|
||||
BALMLayout* fLS;
|
||||
YTab* fTop;
|
||||
YTab* fBottom;
|
||||
|
||||
private:
|
||||
Row* fPrevious;
|
||||
Row* fNext;
|
||||
Constraint* fPreviousGlue;
|
||||
Constraint* fNextGlue;
|
||||
BList* fConstraints;
|
||||
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::Row;
|
||||
|
||||
#endif // ROW_H
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef X_TAB_H
|
||||
#define X_TAB_H
|
||||
|
||||
#include "Variable.h"
|
||||
|
||||
|
||||
namespace BALM {
|
||||
|
||||
class BALMLayout;
|
||||
|
||||
/**
|
||||
* Vertical grid line (x-tab).
|
||||
*/
|
||||
class XTab : public Variable {
|
||||
|
||||
protected:
|
||||
XTab(BALMLayout* ls);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Property signifying if there is a constraint which relates
|
||||
* this tab to a different tab that is further to the left.
|
||||
* Only used for reverse engineering.
|
||||
*/
|
||||
bool fLeftLink;
|
||||
|
||||
public:
|
||||
friend class Area;
|
||||
friend class Column;
|
||||
friend class BALMLayout;
|
||||
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::XTab;
|
||||
|
||||
#endif // X_TAB_H
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef Y_TAB_H
|
||||
#define Y_TAB_H
|
||||
|
||||
#include "Variable.h"
|
||||
|
||||
namespace BALM {
|
||||
|
||||
class BALMLayout;
|
||||
|
||||
/**
|
||||
* Horizontal grid line (y-tab).
|
||||
*/
|
||||
class YTab : public Variable {
|
||||
|
||||
protected:
|
||||
YTab(BALMLayout* ls);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Property signifying if there is a constraint which relates
|
||||
* this tab to a different tab that is further to the top.
|
||||
* Only used for reverse engineering.
|
||||
*/
|
||||
bool fTopLink;
|
||||
|
||||
public:
|
||||
friend class Area;
|
||||
friend class Row;
|
||||
friend class BALMLayout;
|
||||
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
using BALM::YTab;
|
||||
|
||||
#endif // Y_TAB_H
|
||||
Reference in New Issue
Block a user