ui/winui/container.cpp

changeset 0
2483f517c562
equal deleted inserted replaced
-1:000000000000 0:2483f517c562
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "pch.h"
30
31 #include "container.h"
32
33 #include "../common/context.h"
34 #include "../common/object.h"
35
36 #include "util.h"
37
38
39 void ui_container_begin_close(UiObject* obj) {
40 UiContainer* ct = uic_get_current_container(obj);
41 ct->close = 1;
42 }
43
44 int ui_container_finish(UiObject* obj) {
45 UiContainer* ct = uic_get_current_container(obj);
46 if (ct->close) {
47 ui_end(obj);
48 return 0;
49 }
50 return 1;
51 }
52
53
54 // --------------------- UiBoxContainer ---------------------
55
56 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs args, UiBoxContainerType type) {
57 UiObject* current = uic_current_obj(obj);
58 UI_APPLY_LAYOUT1(current, args);
59
60 Grid grid = Grid();
61 current->container->Add(grid, true);
62
63 UIElement elm = grid;
64 UiWidget* widget = new UiWidget(elm);
65 ui_context_add_widget_destructor(current->ctx, widget);
66
67 UiObject* newobj = uic_object_new(obj, widget);
68 newobj->container = new UiBoxContainer(grid, type, args.margin, args.spacing);
69 ui_context_add_container_destructor(current->ctx, newobj->container);
70 uic_obj_add(obj, newobj);
71
72 return widget;
73 }
74
75 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) {
76 return ui_box(obj, args, UI_BOX_CONTAINER_VBOX);
77 }
78
79 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) {
80 return ui_box(obj, args, UI_BOX_CONTAINER_HBOX);
81 }
82
83 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) {
84 this->grid = grid;
85 this->type = type;
86
87 Thickness t = { (double)margin, (double)margin, (double)margin, (double)margin };
88 grid.Margin(t);
89 grid.ColumnSpacing((double)spacing);
90 grid.RowSpacing((double)spacing);
91
92 GridLength gl;
93 gl.Value = 1;
94 gl.GridUnitType = GridUnitType::Star;
95
96 // hbox needs one row def, vbox needs one col def
97 // all other col/row defs are created when elements are added
98 if (type == UI_BOX_CONTAINER_HBOX) {
99 boxRowDef = RowDefinition();
100 boxRowDef.Height(gl);
101 grid.RowDefinitions().Append(boxRowDef);
102 } else {
103 boxColDef = ColumnDefinition();
104 boxColDef.Width(gl);
105 grid.ColumnDefinitions().Append(boxColDef);
106 }
107
108 ui_reset_layout(layout);
109 }
110
111 void UiBoxContainer::Add(FrameworkElement control, UiBool fill) {
112 if (this->layout.fill != UI_LAYOUT_UNDEFINED) {
113 fill = ui_lb2bool(this->layout.fill);
114 }
115
116 GridLength gl;
117 if (fill) {
118 gl.Value = 1;
119 gl.GridUnitType = GridUnitType::Star;
120 }
121 else {
122 gl.Value = 0;
123 gl.GridUnitType = GridUnitType::Auto;
124 }
125
126 control.HorizontalAlignment(HorizontalAlignment::Stretch);
127 control.VerticalAlignment(VerticalAlignment::Stretch);
128
129 if (type == UI_CONTAINER_HBOX) {
130 ColumnDefinition coldef = ColumnDefinition();
131 coldef.Width(gl);
132 grid.ColumnDefinitions().Append(coldef);
133 grid.SetColumn(control, grid.Children().Size());
134 grid.SetRow(control, 0);
135 } else {
136 RowDefinition rowdef = RowDefinition();
137 rowdef.Height(gl);
138 grid.RowDefinitions().Append(rowdef);
139 grid.SetRow(control, grid.Children().Size());
140 grid.SetColumn(control, 0);
141 }
142
143 grid.Children().Append(control);
144
145 ui_reset_layout(layout);
146 }
147
148
149 // --------------------- UiGridContainer ---------------------
150
151 UIWIDGET ui_grid_create(UiObject* obj, UiContainerArgs args) {
152 UiObject* current = uic_current_obj(obj);
153 UI_APPLY_LAYOUT1(current, args);
154
155 Grid grid = Grid();
156 current->container->Add(grid, true);
157
158 UIElement elm = grid;
159 UiWidget* widget = new UiWidget(elm);
160 ui_context_add_widget_destructor(current->ctx, widget);
161
162 UiObject* newobj = uic_object_new(obj, widget);
163 newobj->container = new UiGridContainer(grid, args.margin, args.columnspacing, args.rowspacing);
164 ui_context_add_container_destructor(current->ctx, newobj->container);
165 uic_obj_add(obj, newobj);
166
167 return widget;
168 }
169
170 UiGridContainer::UiGridContainer(Grid grid, int margin, int columnspacing, int rowspacing) {
171 this->grid = grid;
172 Thickness t = { (double)margin, (double)margin, (double)margin, (double)margin };
173 grid.Margin(t);
174 grid.ColumnSpacing((double)columnspacing);
175 grid.RowSpacing((double)rowspacing);
176 ui_reset_layout(layout);
177 }
178
179 void UiGridContainer::Add(FrameworkElement control, UiBool fill) {
180 GridLength gl;
181
182 int hexpand = FALSE;
183 int vexpand = FALSE;
184 if (layout.hexpand != UI_LAYOUT_UNDEFINED) {
185 hexpand = layout.hexpand;
186 }
187 if (layout.vexpand != UI_LAYOUT_UNDEFINED) {
188 vexpand = layout.vexpand;
189 }
190
191 // create new RowDefinition for the new line
192 if (layout.newline || y == -1) {
193 x = 0;
194 y++;
195 RowDefinition rowdef = RowDefinition();
196 if (vexpand) {
197 gl.GridUnitType = GridUnitType::Star;
198 gl.Value = 1;
199 }
200 else {
201 gl.GridUnitType = GridUnitType::Auto;
202 gl.Value = 0;
203 }
204 rowdef.Height(gl);
205 grid.RowDefinitions().Append(rowdef);
206 }
207
208 // create new columndefinition, if a new column is added
209 if (x == cols) {
210 if (hexpand) {
211 gl.GridUnitType = GridUnitType::Star;
212 gl.Value = 1;
213 }
214 else {
215 gl.GridUnitType = GridUnitType::Auto;
216 gl.Value = 0;
217 }
218 ColumnDefinition coldef = ColumnDefinition();
219 coldef.Width(gl);
220 grid.ColumnDefinitions().Append(coldef);
221 cols++;
222 }
223
224 // add control
225 control.HorizontalAlignment(HorizontalAlignment::Stretch);
226 control.VerticalAlignment(VerticalAlignment::Stretch);
227
228 if (layout.colspan > 0) {
229 grid.SetColumnSpan(control, layout.colspan);
230 }
231 if (layout.rowspan > 0) {
232 grid.SetRowSpan(control, layout.rowspan);
233 }
234
235 grid.SetRow(control, y);
236 grid.SetColumn(control, x);
237 grid.Children().Append(control);
238
239 x++;
240
241 ui_reset_layout(layout);
242 }
243
244 // --------------------- UI Frame ---------------------
245
246 UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs args) {
247 // create a grid for the frame, that contains the label and a sub-frame
248 Grid frame = Grid();
249
250 GridLength gl;
251 gl.GridUnitType = GridUnitType::Star;
252 gl.Value = 1;
253
254 ColumnDefinition coldef = ColumnDefinition();
255 coldef.Width(gl);
256 frame.ColumnDefinitions().Append(coldef);
257
258 RowDefinition rowdefFrame = RowDefinition();
259 rowdefFrame.Height(gl);
260
261 // label
262 int row = 0;
263 if (args.label) {
264 RowDefinition rowdefLabel = RowDefinition();
265 gl.GridUnitType = GridUnitType::Auto;
266 gl.Value = 0;
267 rowdefLabel.Height(gl);
268 frame.RowDefinitions().Append(rowdefLabel);
269
270 TextBlock label = TextBlock();
271 wchar_t* wlabel = str2wstr(args.label, nullptr);
272 winrt::hstring hstr(wlabel);
273 label.Text(hstr);
274 free(wlabel);
275
276 frame.SetRow(label, row++);
277 frame.SetColumn(label, 0);
278 frame.Children().Append(label);
279 }
280
281 // workarea frame
282 frame.RowDefinitions().Append(rowdefFrame);
283
284 Grid workarea = Grid();
285 frame.SetRow(workarea, row);
286 frame.SetColumn(workarea, 0);
287 frame.Children().Append(workarea);
288
289 // some styling for the workarea
290 winrt::Microsoft::UI::Xaml::Media::SolidColorBrush brush{ winrt::Microsoft::UI::ColorHelper::FromArgb(150, 150, 150, 150) };
291 workarea.BorderBrush(brush);
292 CornerRadius radius{ 8, 8, 8, 8 };
293 Thickness t = { 1, 1, 1, 1 };
294 workarea.CornerRadius(radius);
295 workarea.BorderThickness(t);
296
297 Thickness padding = { 10, 10, 10, 10 };
298 workarea.Padding(padding);
299
300 // add frame to the parent container
301 UiObject* current = uic_current_obj(obj);
302 UI_APPLY_LAYOUT1(current, args);
303 current->container->Add(frame, true);
304
305 UIElement elm = frame;
306 UiWidget* widget = new UiWidget(elm);
307 ui_context_add_widget_destructor(current->ctx, widget);
308
309 // sub container
310 UiContainer* ctn = nullptr;
311 switch (args.subcontainer) {
312 default:
313 case UI_CONTAINER_VBOX: {
314 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
315 break;
316 }
317 case UI_CONTAINER_HBOX: {
318 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
319 break;
320 }
321 case UI_CONTAINER_GRID: {
322 ctn = new UiGridContainer(workarea, args.margin, args.columnspacing, args.rowspacing);
323 break;
324 }
325 }
326 ui_context_add_container_destructor(current->ctx, ctn);
327
328 UiObject* newobj = uic_object_new(obj, widget);
329 newobj->container = ctn;
330 uic_obj_add(obj, newobj);
331
332 return widget;
333 }
334
335 // --------------------- UI Expander ---------------------
336
337 UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args) {
338 Expander expander = Expander();
339 if (args.label) {
340 wchar_t* wlabel = str2wstr(args.label, nullptr);
341 expander.Header(box_value(wlabel));
342 free(wlabel);
343 }
344 expander.IsExpanded(args.isexpanded);
345
346 // add frame to the parent container
347 UiObject* current = uic_current_obj(obj);
348 UI_APPLY_LAYOUT1(current, args);
349 current->container->Add(expander, true);
350
351 UIElement elm = expander;
352 UiWidget* widget = new UiWidget(elm);
353 ui_context_add_widget_destructor(current->ctx, widget);
354
355 Grid content = Grid();
356 expander.Content(content);
357
358 UiContainer* ctn = nullptr;
359 switch (args.subcontainer) {
360 default:
361 case UI_CONTAINER_VBOX: {
362 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
363 break;
364 }
365 case UI_CONTAINER_HBOX: {
366 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
367 break;
368 }
369 case UI_CONTAINER_GRID: {
370 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing);
371 break;
372 }
373 }
374 ui_context_add_container_destructor(current->ctx, ctn);
375
376 UiObject* newobj = uic_object_new(obj, widget);
377 newobj->container = ctn;
378 uic_obj_add(obj, newobj);
379
380 return widget;
381 }
382
383 // --------------------- UI ScrolledWindow ---------------------
384
385 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) {
386 ScrollViewer scrollW = ScrollViewer();
387
388 // add frame to the parent container
389 UiObject* current = uic_current_obj(obj);
390 UI_APPLY_LAYOUT1(current, args);
391 current->container->Add(scrollW, true);
392
393 UIElement elm = scrollW;
394 UiWidget* widget = new UiWidget(elm);
395 ui_context_add_widget_destructor(current->ctx, widget);
396
397 // create child container
398 Grid content = Grid();
399 scrollW.Content(content);
400
401 UiContainer* ctn = nullptr;
402 switch (args.subcontainer) {
403 default:
404 case UI_CONTAINER_VBOX: {
405 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
406 break;
407 }
408 case UI_CONTAINER_HBOX: {
409 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
410 break;
411 }
412 case UI_CONTAINER_GRID: {
413 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing);
414 break;
415 }
416 }
417 ui_context_add_container_destructor(current->ctx, ctn);
418
419 UiObject* newobj = uic_object_new(obj, widget);
420 newobj->container = ctn;
421 uic_obj_add(obj, newobj);
422
423 return widget;
424 }
425
426 // --------------------- UI TabView ---------------------
427
428 UiTabViewContainer::UiTabViewContainer(UiTabView* tabview) {
429 this->tabview = tabview;
430 }
431
432 void UiTabViewContainer::Add(FrameworkElement control, UiBool fill) {
433 // noop
434 }
435
436 static UiObject* create_subcontainer_obj(UiObject* current, Grid subcontainer, UiSubContainerType type, int margin, int spacing, int columnspacing, int rowspacing) {
437 UiContainer* ctn = nullptr;
438 switch (type) {
439 default:
440 case UI_CONTAINER_VBOX: {
441 ctn = new UiBoxContainer(subcontainer, UI_BOX_CONTAINER_VBOX, margin, spacing);
442 break;
443 }
444 case UI_CONTAINER_HBOX: {
445 ctn = new UiBoxContainer(subcontainer, UI_BOX_CONTAINER_HBOX, margin, spacing);
446 break;
447 }
448 case UI_CONTAINER_GRID: {
449 ctn = new UiGridContainer(subcontainer, margin, columnspacing, rowspacing);
450 break;
451 }
452 }
453 ui_context_add_container_destructor(current->ctx, ctn);
454
455 UIElement elm = subcontainer;
456 UiWidget* widget = new UiWidget(elm);
457 ui_context_add_widget_destructor(current->ctx, widget);
458 UiObject* newobj = uic_object_new(current, widget);
459 newobj->container = ctn;
460 return newobj;
461 }
462
463 UiPivotTabView::UiPivotTabView(UiObject* obj, Pivot pivot, UiTabViewArgs args) {
464 this->current = obj;
465 this->pivot = pivot;
466 this->margin = args.margin;
467 this->spacing = args.spacing;
468 this->columnspacing = args.columnspacing;
469 this->rowspacing = args.rowspacing;
470 }
471
472 UiObject* UiPivotTabView::AddTab(const char* label) {
473 TextBlock text = TextBlock();
474 wchar_t* wlabel = str2wstr(label, nullptr);
475 winrt::hstring hstr(wlabel);
476 text.Text(hstr);
477 free(wlabel);
478
479 PivotItem item = PivotItem();
480 item.Header(text);
481
482 // sub container
483 Grid subcontainer = Grid();
484 item.Content(subcontainer);
485 pivot.Items().Append(item);
486
487 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
488 }
489
490 FrameworkElement UiPivotTabView::GetFrameworkElement() {
491 return pivot;
492 }
493
494 static UiTabView* tabview_pivot_create(UiObject* obj, UiTabViewArgs args) {
495 Pivot pivot = Pivot();
496 UiPivotTabView* tabview = new UiPivotTabView(obj, pivot, args);
497
498 return tabview;
499 }
500
501 UiMainTabView::UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args) {
502 this->current = obj;
503 this->tabview = tabview;
504 this->margin = args.margin;
505 this->spacing = args.spacing;
506 this->columnspacing = args.columnspacing;
507 this->rowspacing = args.rowspacing;
508 }
509
510 UiObject* UiMainTabView::AddTab(const char* label) {
511 TextBlock text = TextBlock();
512 wchar_t* wlabel = str2wstr(label, nullptr);
513 winrt::hstring hstr(wlabel);
514 text.Text(hstr);
515 free(wlabel);
516
517 TabViewItem item = TabViewItem();
518 item.Header(text);
519 item.CanDrag(false);
520 item.IsClosable(false);
521
522 // sub container
523 Grid subcontainer = Grid();
524 item.Content(subcontainer);
525 tabview.TabItems().Append(item);
526
527 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
528 }
529
530 FrameworkElement UiMainTabView::GetFrameworkElement() {
531 return tabview;
532 }
533
534 static UiTabView* tabview_main_create(UiObject* obj, UiTabViewArgs args) {
535 TabView tabview = TabView();
536 tabview.IsAddTabButtonVisible(false);
537 //tabview.CanDragTabs(false);
538 //tabview.CanReorderTabs(false);
539 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args);
540
541 return uitabview;
542 }
543
544 UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type) {
545 this->current = obj;
546 this->navigationview = navigationview;
547 this->type = type;
548 this->margin = args.margin;
549 this->spacing = args.spacing;
550 this->columnspacing = args.columnspacing;
551 this->rowspacing = args.rowspacing;
552
553 if (type == UI_TABVIEW_NAVIGATION_TOP) {
554 navigationview.PaneDisplayMode(NavigationViewPaneDisplayMode::Top);
555 }
556
557 navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged });
558 }
559
560 UiObject* UiNavigationTabView::AddTab(const char* label) {
561 TextBlock text = TextBlock();
562 wchar_t* wlabel = str2wstr(label, nullptr);
563 winrt::hstring hstr(wlabel);
564 text.Text(hstr);
565 free(wlabel);
566
567 NavigationViewItem item = NavigationViewItem();
568 item.Content(text);
569
570 // sub container
571 Grid subcontainer = Grid();
572 if (pages.size() == 0) {
573 navigationview.Content(subcontainer);
574 navigationview.SelectedItem(item);
575 }
576
577 navigationview.MenuItems().Append(item);
578 auto page = std::tuple<NavigationViewItem, FrameworkElement>{ item, subcontainer };
579 pages.push_back(page);
580
581 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
582 }
583
584 FrameworkElement UiNavigationTabView::GetFrameworkElement() {
585 return navigationview;
586 }
587
588 void UiNavigationTabView::SelectionChanged(NavigationView const& sender, NavigationViewSelectionChangedEventArgs const& args) {
589 for (auto page : pages) {
590 NavigationViewItem item = std::get<0>(page);
591 FrameworkElement elm = std::get<1>(page);
592 if (item == navigationview.SelectedItem()) {
593 navigationview.Content(elm);
594 break;
595 }
596 }
597 }
598
599 static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args, UiTabViewType type) {
600 NavigationView navigationview = NavigationView();
601 UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, type);
602 navigationview.IsBackButtonVisible(NavigationViewBackButtonVisible::Collapsed);
603 navigationview.IsSettingsVisible(false);
604
605 return tabview;
606 }
607
608 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) {
609 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview;
610 UiTabView* tabview = nullptr;
611 switch (type) {
612 default: {
613 tabview = tabview_pivot_create(obj, args);
614 break;
615 }
616 case UI_TABVIEW_DOC: {
617 tabview = tabview_main_create(obj, args);
618 break;
619 }
620 case UI_TABVIEW_NAVIGATION_SIDE: {
621 tabview = tabview_navigationview_create(obj, args, type);
622 break;
623 }
624 case UI_TABVIEW_NAVIGATION_TOP: {
625 tabview = tabview_navigationview_create(obj, args, type);
626 break;
627 }
628 case UI_TABVIEW_NAVIGATION_TOP2: {
629 tabview = tabview_pivot_create(obj, args);
630 break;
631 }
632 }
633 UiTabViewContainer* ctn = new UiTabViewContainer(tabview);
634
635 // add frame to the parent container
636 UiObject* current = uic_current_obj(obj);
637 UI_APPLY_LAYOUT1(current, args);
638 current->container->Add(tabview->GetFrameworkElement(), true);
639
640 UIElement elm = tabview->GetFrameworkElement();
641 UiWidget* widget = new UiWidget(elm);
642 ui_context_add_widget_destructor(current->ctx, widget);
643 widget->data1 = tabview;
644
645 UiObject* newobj = uic_object_new(obj, widget);
646 newobj->container = ctn;
647 uic_obj_add(obj, newobj);
648
649 return widget;
650 }
651
652 void ui_tab_create(UiObject* obj, const char* title) {
653 UiObject* current = uic_current_obj(obj);
654 UiTabView* tabview = (UiTabView*)current->widget->data1;
655 UiObject* newobj = tabview->AddTab(title);
656 uic_obj_add(current, newobj);
657 }
658
659 /*
660 * -------------------- Layout Functions --------------------
661 *
662 * functions for setting layout attributes for the current container
663 *
664 */
665
666 void ui_layout_fill(UiObject* obj, UiBool fill) {
667 UiContainer* ct = uic_get_current_container(obj);
668 ct->layout.fill = ui_bool2lb(fill);
669 }
670
671 void ui_layout_hexpand(UiObject* obj, UiBool expand) {
672 UiContainer* ct = uic_get_current_container(obj);
673 ct->layout.hexpand = expand;
674 }
675
676 void ui_layout_vexpand(UiObject* obj, UiBool expand) {
677 UiContainer* ct = uic_get_current_container(obj);
678 ct->layout.vexpand = expand;
679 }
680
681 void ui_layout_width(UiObject* obj, int width) {
682 UiContainer* ct = uic_get_current_container(obj);
683 ct->layout.width = width;
684 }
685
686 void ui_layout_height(UiObject* obj, int height) {
687 UiContainer* ct = uic_get_current_container(obj);
688 ct->layout.height = height;
689 }
690
691 void ui_layout_colspan(UiObject* obj, int cols) {
692 UiContainer* ct = uic_get_current_container(obj);
693 ct->layout.colspan = cols;
694 }
695
696 void ui_layout_rowspan(UiObject* obj, int rows) {
697 UiContainer* ct = uic_get_current_container(obj);
698 ct->layout.rowspan = rows;
699 }
700
701 void ui_newline(UiObject* obj) {
702 UiContainer* ct = uic_get_current_container(obj);
703 ct->layout.newline = TRUE;
704 }
705

mercurial