2 * Copyright 2011, Haiku, Inc. All rights reserved.
3 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
4 * Distributed under the terms of the MIT License.
6 #ifndef ROW_COLUMN_MANAGER_H
7 #define ROW_COLUMN_MANAGER_H
12 #include "LinearSpec.h"
25 /*! The RowColumnManager groups areas with same vertical or horizontal tabs
26 into column and rows. For each row and column, a preferred size is
27 calculated from the areas in the row or column. This preferred size is used
28 to create a preferred size soft-constraint.
29 Having only one constraint for each row and column avoids the so called
30 spring effect. That is each area with a preferred size constraint is pulling
31 or pressing torwards its preferred size. For example, a row with three areas
32 pushes stronger than a row with two areas. Assuming that all areas have the
33 same preferred size, the three-area row gets a different size than the
34 two-area row. However, one would expect that both rows have the same height.
35 The row and column approach of the RowColumnManager solves this problem.
38 class RowColumnManager
{
40 RowColumnManager(LinearSpec
* spec
);
43 void AddArea(Area
* area
);
44 void RemoveArea(Area
* area
);
46 void UpdateConstraints();
47 void TabsChanged(Area
* area
);
49 friend class BPrivate::SharedSolver
;
50 Row
* _FindRowFor(Area
* area
);
51 Column
* _FindColumnFor(Area
* area
);
53 double _PreferredHeight(Row
* row
,
55 double _PreferredWidth(Column
* column
,
58 void _UpdateConstraints(Row
* row
);
59 void _UpdateConstraints(Column
* column
);
61 BObjectList
<Row
> fRows
;
62 BObjectList
<Column
> fColumns
;
64 LinearSpec
* fLinearSpec
;
71 #endif // ROW_COLUMN_MANAGER_H