@@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26
26
using namespace ruis ;
27
27
28
- namespace {
28
+ namespace ruis ::internal {
29
29
class provider : public list_provider
30
30
{
31
31
public:
@@ -48,7 +48,7 @@ class provider : public list_provider
48
48
{
49
49
auto cells = this ->table_list_provider .get ().get_row_widgets (index);
50
50
51
- // TODO: size cells
51
+ this -> owner . arrange_list_item_cells ( cells);
52
52
53
53
// clang-format off
54
54
return make::container (this ->context ,
@@ -65,7 +65,7 @@ class provider : public list_provider
65
65
// clang-format on
66
66
}
67
67
};
68
- } // namespace
68
+ } // namespace ruis::internal
69
69
70
70
namespace {
71
71
utki::shared_ref<ruis::tiling_area> make_headers_widget (
@@ -89,9 +89,41 @@ utki::shared_ref<ruis::tiling_area> make_headers_widget(
89
89
table_list::table_list (
90
90
utki::shared_ref<ruis::context> context, //
91
91
all_parameters params
92
+ ) :
93
+ table_list(
94
+ make_headers_widget (
95
+ context, //
96
+ std::move (params.table_list_params.column_headers)
97
+ ),
98
+ // clang-format off
99
+ ruis::make::list(context,
100
+ {
101
+ .layout_params {
102
+ .dims = {ruis::dim::fill, ruis::dim::fill},
103
+ .weight = 1
104
+ },
105
+ .list_providable_params {
106
+ .provider = [&]() -> utki::shared_ref<list_provider> {
107
+ return utki::make_shared<internal::provider>(
108
+ *this ,
109
+ std::move (params.table_list_params .provider )
110
+ );
111
+ }()
112
+ }
113
+ }
114
+ ),
115
+ // clang-format on
116
+ params
117
+ )
118
+ {}
119
+
120
+ table_list::table_list (
121
+ utki::shared_ref<tiling_area> headers, //
122
+ utki::shared_ref<list> rows_list,
123
+ all_parameters& params
92
124
) :
93
125
ruis::widget(
94
- std::move (context) , //
126
+ headers.get().context , //
95
127
std::move(params.layout_params),
96
128
std::move(params.widget_params)
97
129
),
@@ -104,29 +136,39 @@ table_list::table_list(
104
136
}
105
137
},
106
138
{
107
- make_headers_widget (this ->context ,
108
- std::move (params.table_list_params .column_headers )
109
- ),
110
- ruis::make::list (this ->context ,
111
- {
112
- .layout_params {
113
- .dims = {ruis::dim::fill, ruis::dim::fill},
114
- .weight = 1
115
- },
116
- .list_providable_params {
117
- .provider = [&]() -> utki::shared_ref<list_provider> {
118
- return utki::make_shared<::provider>(
119
- *this ,
120
- std::move (params.table_list_params .provider )
121
- );
122
- }()
123
- }
124
- }
125
- )
139
+ headers,
140
+ rows_list
126
141
}
127
- )
128
- // clang-format on
129
- {}
142
+ ),
143
+ // clang-format on
144
+ headers_tiling_area(std::move(headers)),
145
+ table_rows_list(std::move(rows_list))
146
+ {
147
+ this ->headers_tiling_area .get ().tiles_resized_handler = [this ](auto & ta) {
148
+ for (auto & child : this ->table_rows_list .get ().children ()) {
149
+ auto * c = dynamic_cast <ruis::container*>(&child.get ());
150
+ ASSERT (c)
151
+ this ->arrange_list_item_cells (c->children ());
152
+ }
153
+ };
154
+ }
155
+
156
+ void table_list::arrange_list_item_cells (ruis::semiconst_widget_list& cells)
157
+ {
158
+ real pos = 0 ;
159
+ for (auto [c, h] : utki::views::zip (cells, this ->headers_tiling_area .get ().content ().children ())) {
160
+ auto md = c.get ().measure ({
161
+ h.get ().rect ().d .x (),
162
+ -1 //
163
+ });
164
+ c.get ().resize (md);
165
+ c.get ().move_to ({
166
+ pos,
167
+ 0 //
168
+ });
169
+ pos += md.x ();
170
+ }
171
+ }
130
172
131
173
utki::shared_ref<ruis::table_list> make::table_list (
132
174
utki::shared_ref<ruis::context> context, //
0 commit comments