2008-02-25 04:54:05 +03:00
|
|
|
/*
|
2010-09-22 03:31:50 +04:00
|
|
|
* Copyright 2006 - 2010, Haiku, Inc. All rights reserved.
|
2008-02-25 04:54:05 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2010-09-22 03:31:50 +04:00
|
|
|
#ifndef ALM_LAYOUT_H
|
|
|
|
#define ALM_LAYOUT_H
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2010-09-23 01:53:32 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
#include <AbstractLayout.h>
|
2008-02-06 13:51:44 +03:00
|
|
|
#include <File.h>
|
|
|
|
#include <List.h>
|
|
|
|
#include <Size.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <View.h>
|
|
|
|
|
2009-10-28 12:00:14 +03:00
|
|
|
#include "Area.h"
|
|
|
|
#include "Column.h"
|
2008-02-06 13:51:44 +03:00
|
|
|
#include "LinearSpec.h"
|
2010-09-20 10:26:32 +04:00
|
|
|
#include "Row.h"
|
2010-09-30 05:32:48 +04:00
|
|
|
#include "Tab.h"
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
namespace BALM {
|
2010-09-23 04:04:08 +04:00
|
|
|
|
2010-09-23 01:53:32 +04:00
|
|
|
/*!
|
|
|
|
* A GUI layout engine using the Auckland Layout Model (ALM).
|
2008-02-06 13:51:44 +03:00
|
|
|
*/
|
2010-09-21 02:47:13 +04:00
|
|
|
class BALMLayout : public BAbstractLayout {
|
2008-02-06 13:51:44 +03:00
|
|
|
public:
|
2010-10-21 15:19:18 +04:00
|
|
|
BALMLayout(float spacing = 0.0f,
|
|
|
|
BALMLayout* friendLayout = NULL);
|
2010-09-21 11:04:40 +04:00
|
|
|
virtual ~BALMLayout();
|
|
|
|
|
2010-09-20 10:26:32 +04:00
|
|
|
XTab* AddXTab();
|
|
|
|
YTab* AddYTab();
|
|
|
|
Row* AddRow();
|
|
|
|
Row* AddRow(YTab* top, YTab* bottom);
|
|
|
|
Column* AddColumn();
|
|
|
|
Column* AddColumn(XTab* left, XTab* right);
|
2010-09-23 01:53:32 +04:00
|
|
|
|
2010-09-20 10:26:32 +04:00
|
|
|
XTab* Left() const;
|
|
|
|
XTab* Right() const;
|
|
|
|
YTab* Top() const;
|
|
|
|
YTab* Bottom() const;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2010-09-20 10:26:32 +04:00
|
|
|
char* PerformancePath() const;
|
|
|
|
void SetPerformancePath(char* path);
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2010-09-29 07:30:47 +04:00
|
|
|
LinearSpec* Solver() const;
|
2010-09-21 02:47:13 +04:00
|
|
|
|
2010-09-23 04:53:33 +04:00
|
|
|
void SetInset(float inset);
|
2010-09-29 07:30:47 +04:00
|
|
|
float Inset() const;
|
2010-09-23 04:53:33 +04:00
|
|
|
|
|
|
|
void SetSpacing(float spacing);
|
2010-09-29 07:30:47 +04:00
|
|
|
float Spacing() const;
|
|
|
|
|
2010-09-30 05:32:48 +04:00
|
|
|
Area* AreaFor(const BView* view) const;
|
2010-09-29 07:30:47 +04:00
|
|
|
Area* AreaFor(const BLayoutItem* item) const;
|
|
|
|
Area* CurrentArea() const;
|
|
|
|
void SetCurrentArea(const Area* area);
|
2010-09-30 05:32:48 +04:00
|
|
|
void SetCurrentArea(const BView* view);
|
2010-09-29 07:30:47 +04:00
|
|
|
void SetCurrentArea(const BLayoutItem* item);
|
|
|
|
|
2010-09-30 05:32:48 +04:00
|
|
|
XTab* LeftOf(const BView* view) const;
|
|
|
|
XTab* LeftOf(const BLayoutItem* item) const;
|
|
|
|
XTab* RightOf(const BView* view) const;
|
|
|
|
XTab* RightOf(const BLayoutItem* item) const;
|
|
|
|
YTab* TopOf(const BView* view) const;
|
|
|
|
YTab* TopOf(const BLayoutItem* item) const;
|
|
|
|
YTab* BottomOf(const BView* view) const;
|
|
|
|
YTab* BottomOf(const BLayoutItem* item) const;
|
|
|
|
|
2010-10-04 00:05:52 +04:00
|
|
|
void BuildLayout(GroupItem& item, XTab* left = NULL,
|
|
|
|
YTab* top = NULL, XTab* right = NULL,
|
|
|
|
YTab* bottom = NULL);
|
|
|
|
|
2010-09-23 11:16:49 +04:00
|
|
|
virtual BLayoutItem* AddView(BView* child);
|
|
|
|
virtual BLayoutItem* AddView(int32 index, BView* child);
|
|
|
|
virtual Area* AddView(BView* view, XTab* left, YTab* top,
|
2010-09-30 05:32:48 +04:00
|
|
|
XTab* right = NULL, YTab* bottom = NULL);
|
2010-09-23 11:16:49 +04:00
|
|
|
virtual Area* AddView(BView* view, Row* row, Column* column);
|
2010-09-29 07:30:47 +04:00
|
|
|
virtual Area* AddViewToRight(BView* view, XTab* right = NULL,
|
|
|
|
YTab* top = NULL, YTab* bottom = NULL);
|
|
|
|
virtual Area* AddViewToLeft(BView* view, XTab* left = NULL,
|
|
|
|
YTab* top = NULL, YTab* bottom = NULL);
|
|
|
|
virtual Area* AddViewToTop(BView* view, YTab* top = NULL,
|
|
|
|
XTab* left = NULL, XTab* right = NULL);
|
|
|
|
virtual Area* AddViewToBottom(BView* view,
|
2010-09-23 11:16:49 +04:00
|
|
|
YTab* bottom = NULL, XTab* left = NULL,
|
|
|
|
XTab* right = NULL);
|
|
|
|
|
|
|
|
virtual bool AddItem(BLayoutItem* item);
|
|
|
|
virtual bool AddItem(int32 index, BLayoutItem* item);
|
|
|
|
virtual Area* AddItem(BLayoutItem* item, XTab* left,
|
2010-09-30 05:32:48 +04:00
|
|
|
YTab* top, XTab* right = NULL,
|
|
|
|
YTab* bottom = NULL);
|
2010-09-23 11:16:49 +04:00
|
|
|
virtual Area* AddItem(BLayoutItem* item, Row* row,
|
|
|
|
Column* column);
|
|
|
|
virtual Area* AddItemToRight(BLayoutItem* item,
|
2010-09-29 07:30:47 +04:00
|
|
|
XTab* right = NULL, YTab* top = NULL,
|
|
|
|
YTab* bottom = NULL);
|
2010-09-23 11:16:49 +04:00
|
|
|
virtual Area* AddItemToLeft(BLayoutItem* item,
|
2010-09-29 07:30:47 +04:00
|
|
|
XTab* left = NULL, YTab* top = NULL,
|
|
|
|
YTab* bottom = NULL);
|
2010-09-23 11:16:49 +04:00
|
|
|
virtual Area* AddItemToTop(BLayoutItem* item,
|
2010-09-29 07:30:47 +04:00
|
|
|
YTab* top = NULL, XTab* left = NULL,
|
|
|
|
XTab* right = NULL);
|
2010-09-23 11:16:49 +04:00
|
|
|
virtual Area* AddItemToBottom(BLayoutItem* item,
|
2010-09-29 07:30:47 +04:00
|
|
|
YTab* bottom = NULL, XTab* left = NULL,
|
|
|
|
XTab* right = NULL);
|
2010-09-23 11:16:49 +04:00
|
|
|
|
|
|
|
virtual BSize BaseMinSize();
|
|
|
|
virtual BSize BaseMaxSize();
|
|
|
|
virtual BSize BasePreferredSize();
|
|
|
|
virtual BAlignment BaseAlignment();
|
|
|
|
|
|
|
|
virtual void InvalidateLayout(bool children = false);
|
|
|
|
|
|
|
|
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
|
|
|
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
|
|
|
virtual void DerivedLayoutItems();
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
private:
|
2010-09-23 11:16:49 +04:00
|
|
|
/*! Add a view without initialize the Area. */
|
|
|
|
BLayoutItem* _CreateLayoutItem(BView* view);
|
|
|
|
|
2010-09-22 09:29:50 +04:00
|
|
|
void _SolveLayout();
|
|
|
|
|
2010-09-22 03:18:43 +04:00
|
|
|
void _UpdateAreaConstraints();
|
2010-09-21 11:04:40 +04:00
|
|
|
|
2010-09-22 09:29:50 +04:00
|
|
|
BSize _CalculateMinSize();
|
|
|
|
BSize _CalculateMaxSize();
|
|
|
|
BSize _CalculatePreferredSize();
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2010-10-04 00:05:52 +04:00
|
|
|
void _ParseGroupItem(GroupItem& item, XTab* left,
|
|
|
|
YTab* top, XTab* right, YTab* bottom);
|
2008-02-06 13:51:44 +03:00
|
|
|
|
2010-10-21 15:19:18 +04:00
|
|
|
LinearSpec* fSolver;
|
|
|
|
LinearSpec fOwnSolver;
|
2010-09-21 02:47:13 +04:00
|
|
|
|
2010-09-20 10:26:32 +04:00
|
|
|
XTab* fLeft;
|
|
|
|
XTab* fRight;
|
|
|
|
YTab* fTop;
|
|
|
|
YTab* fBottom;
|
|
|
|
BSize fMinSize;
|
|
|
|
BSize fMaxSize;
|
|
|
|
BSize fPreferredSize;
|
|
|
|
char* fPerformancePath;
|
2010-09-23 04:53:33 +04:00
|
|
|
|
|
|
|
float fInset;
|
|
|
|
float fSpacing;
|
2010-09-29 07:30:47 +04:00
|
|
|
|
|
|
|
Area* fCurrentArea;
|
2008-02-06 13:51:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace BALM
|
|
|
|
|
|
|
|
using BALM::BALMLayout;
|
|
|
|
|
2010-09-22 03:31:50 +04:00
|
|
|
#endif // ALM_LAYOUT_H
|