File: table-layout.hpp

package info (click to toggle)
ares 126-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 32,600 kB
  • sloc: cpp: 356,508; ansic: 20,394; makefile: 16; sh: 2
file content (128 lines) | stat: -rw-r--r-- 3,631 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#if defined(Hiro_TableLayout)

struct TableLayout;
struct TableLayoutColumn;
struct TableLayoutRow;
struct TableLayoutCell;

struct mTableLayout;
struct mTableLayoutColumn;
struct mTableLayoutRow;
struct mTableLayoutCell;

using sTableLayout = shared_pointer<mTableLayout>;
using sTableLayoutColumn = shared_pointer<mTableLayoutColumn>;
using sTableLayoutRow = shared_pointer<mTableLayoutRow>;
using sTableLayoutCell = shared_pointer<mTableLayoutCell>;

struct mTableLayout : mSizable {
  using type = mTableLayout;
  using mSizable::remove;

  auto alignment() const -> Alignment;
  auto append(sSizable sizable, Size size) -> type&;
  auto cell(u32 position) const -> TableLayoutCell;
  auto cell(u32 x, u32 y) const -> TableLayoutCell;
  auto cell(sSizable sizable) const -> TableLayoutCell;
  auto cells() const -> vector<TableLayoutCell>;
  auto cellCount() const -> u32;
  auto column(u32 position) const -> TableLayoutColumn;
  auto columns() const -> vector<TableLayoutColumn>;
  auto columnCount() const -> u32;
  auto minimumSize() const -> Size override;
  auto padding() const -> Geometry;
  auto remove(sSizable sizable) -> type&;
  auto remove(sTableLayoutCell cell) -> type&;
  auto reset() -> type& override;
  auto resize() -> type&;
  auto row(u32 position) const -> TableLayoutRow;
  auto rows() const -> vector<TableLayoutRow>;
  auto rowCount() const -> u32;
  auto setAlignment(Alignment alignment) -> type&;
  auto setEnabled(bool enabled) -> type& override;
  auto setFont(const Font& font) -> type& override;
  auto setGeometry(Geometry geometry) -> type& override;
  auto setPadding(Geometry padding) -> type&;
  auto setParent(mObject* parent = nullptr, s32 offset = -1) -> type& override;
  auto setSize(Size size) -> type&;
  auto setVisible(bool visible) -> type& override;
  auto size() const -> Size;
  auto synchronize() -> type&;

private:
  auto destruct() -> void override;

  struct State {
    Alignment alignment;
    vector<TableLayoutCell> cells;
    vector<TableLayoutColumn> columns;
    Geometry padding;
    vector<TableLayoutRow> rows;
    Size size;
  } state;
};

struct mTableLayoutColumn : mObject {
  using type = mTableLayoutColumn;

  auto alignment() const -> Alignment;
  auto setAlignment(Alignment alignment) -> type&;
  auto setSpacing(f32 spacing) -> type&;
  auto spacing() const -> f32;
  auto synchronize() -> type&;

private:
  struct State {
    Alignment alignment;
    f32 spacing = 5_sx;
  } state;

  friend class mTableLayout;
};

struct mTableLayoutRow : mObject {
  using type = mTableLayoutRow;

  auto alignment() const -> Alignment;
  auto setAlignment(Alignment alignment) -> type&;
  auto setSpacing(f32 spacing) -> type&;
  auto spacing() const -> f32;
  auto synchronize() -> type&;

private:
  struct State {
    Alignment alignment;
    f32 spacing = 5_sy;
  } state;

  friend class mTableLayout;
};

struct mTableLayoutCell : mObject {
  using type = mTableLayoutCell;

  auto alignment() const -> Alignment;
  auto setAlignment(Alignment alignment) -> type&;
  auto setEnabled(bool enabled) -> type& override;
  auto setFont(const Font& font) -> type& override;
  auto setParent(mObject* parent = nullptr, s32 offset = -1) -> type& override;
  auto setSizable(sSizable sizable) -> type&;
  auto setSize(Size size) -> type&;
  auto setVisible(bool visible) -> type& override;
  auto sizable() const -> Sizable;
  auto size() const -> Size;
  auto synchronize() -> type&;

private:
  auto destruct() -> void override;

  struct State {
    Alignment alignment;
    sSizable sizable;
    Size size;
  } state;

  friend class mTableLayout;
};

#endif