vfs: check userland buffers before reading them.
[haiku.git] / src / libs / alm / RowColumnManager.h
blob39bc57dbfb32da5a9dad71e2b46c6d9e9cc2859f
1 /*
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.
5 */
6 #ifndef ROW_COLUMN_MANAGER_H
7 #define ROW_COLUMN_MANAGER_H
10 #include "Area.h"
11 #include "Column.h"
12 #include "LinearSpec.h"
13 #include "Row.h"
14 #include "Tab.h"
17 namespace BPrivate {
18 class SharedSolver;
22 namespace BALM {
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 {
39 public:
40 RowColumnManager(LinearSpec* spec);
41 ~RowColumnManager();
43 void AddArea(Area* area);
44 void RemoveArea(Area* area);
46 void UpdateConstraints();
47 void TabsChanged(Area* area);
48 private:
49 friend class BPrivate::SharedSolver;
50 Row* _FindRowFor(Area* area);
51 Column* _FindColumnFor(Area* area);
53 double _PreferredHeight(Row* row,
54 double& weight);
55 double _PreferredWidth(Column* column,
56 double& weight);
58 void _UpdateConstraints(Row* row);
59 void _UpdateConstraints(Column* column);
61 BObjectList<Row> fRows;
62 BObjectList<Column> fColumns;
64 LinearSpec* fLinearSpec;
68 } // namespace BALM
71 #endif // ROW_COLUMN_MANAGER_H