ui/winui/container.cpp

changeset 613
dac25dd922a2
parent 478
6292f93c2213
child 614
a6e70dead6bd
equal deleted inserted replaced
612:8570430391b3 613:dac25dd922a2
32 32
33 #include "../common/context.h" 33 #include "../common/context.h"
34 #include "../common/object.h" 34 #include "../common/object.h"
35 35
36 #include "util.h" 36 #include "util.h"
37 #include "../ui/widget.h"
37 38
38 39
39 void ui_container_begin_close(UiObject* obj) { 40 void ui_container_begin_close(UiObject* obj) {
40 UiContainer* ct = uic_get_current_container(obj); 41 UiContainer* ct = uic_get_current_container(obj);
41 ct->close = 1; 42 ct->close = 1;
49 } 50 }
50 return 1; 51 return 1;
51 } 52 }
52 53
53 54
54 UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) { 55 UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs *args) {
55 UiObject* current = uic_current_obj(obj); 56 UiObject* current = uic_current_obj(obj);
56 57
57 UIWIDGET widget = create_widget(obj, args, userdata); 58 UIWIDGET widget = create_widget(obj, args, userdata);
58 FrameworkElement w = widget->uielement.as<FrameworkElement>(); 59 FrameworkElement w = widget->uielement.as<FrameworkElement>();
59 60
60 UI_APPLY_LAYOUT1(current, args); 61 UI_APPLY_LAYOUT2(current, args);
61 62
62 current->container->Add(w, false); 63 current->container->Add(w, false);
63 64
64 return widget; 65 return widget;
65 } 66 }
66 67
67 // --------------------- UiBoxContainer --------------------- 68 // --------------------- UiBoxContainer ---------------------
68 69
69 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs args, UiBoxContainerType type) { 70 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs *args, UiBoxContainerType type) {
70 UiObject* current = uic_current_obj(obj); 71 UiObject* current = uic_current_obj(obj);
71 UI_APPLY_LAYOUT1(current, args); 72 UI_APPLY_LAYOUT2(current, args);
72 73
73 Grid grid = Grid(); 74 Grid grid = Grid();
74 current->container->Add(grid, true); 75 current->container->Add(grid, true);
75 76
76 UIElement elm = grid; 77 UIElement elm = grid;
77 UiWidget* widget = new UiWidget(elm); 78 UiWidget* widget = new UiWidget(elm);
78 ui_context_add_widget_destructor(current->ctx, widget); 79 ui_context_add_widget_destructor(current->ctx, widget);
79 80
80 UiObject* newobj = uic_object_new(obj, widget); 81 UiObject* newobj = uic_object_new(obj, widget);
81 newobj->container = new UiBoxContainer(grid, type, args.margin, args.spacing); 82 newobj->container = new UiBoxContainer(grid, type, args->margin, args->spacing);
82 ui_context_add_container_destructor(current->ctx, newobj->container); 83 ui_context_add_container_destructor(current->ctx, newobj->container);
83 uic_obj_add(obj, newobj); 84 uic_obj_add(obj, newobj);
84 85
85 return widget; 86 return widget;
86 } 87 }
87 88
88 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) { 89 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs *args) {
89 return ui_box(obj, args, UI_BOX_CONTAINER_VBOX); 90 return ui_box(obj, args, UI_BOX_CONTAINER_VBOX);
90 } 91 }
91 92
92 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) { 93 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs *args) {
93 return ui_box(obj, args, UI_BOX_CONTAINER_HBOX); 94 return ui_box(obj, args, UI_BOX_CONTAINER_HBOX);
94 } 95 }
95 96
96 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) { 97 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) {
97 this->grid = grid; 98 this->grid = grid;
859 860
860 // --------------------- UI Headerbar --------------------- 861 // --------------------- UI Headerbar ---------------------
861 862
862 // TODO: replace placeholder implementation 863 // TODO: replace placeholder implementation
863 864
864 UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) { 865 UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs *args) {
865 UiContainerArgs boxargs = { }; 866 UiContainerArgs boxargs = { };
866 boxargs.fill = UI_OFF; 867 boxargs.fill = UI_OFF;
867 return ui_hbox_create(obj, boxargs); 868 return ui_hbox_create(obj, &boxargs);
868 } 869 }
869 870
870 UIEXPORT void ui_headerbar_start_create(UiObject *obj) { 871 UIEXPORT void ui_headerbar_start_create(UiObject *obj) {
871 UiContainerArgs boxargs = { }; 872 UiContainerArgs boxargs = { };
872 boxargs.fill = UI_OFF; 873 boxargs.fill = UI_OFF;
873 ui_hbox_create(obj, boxargs); 874 ui_hbox_create(obj, &boxargs);
874 } 875 }
875 876
876 UIEXPORT void ui_headerbar_center_create(UiObject *obj) { 877 UIEXPORT void ui_headerbar_center_create(UiObject *obj) {
877 UiContainerArgs boxargs = { }; 878 UiContainerArgs boxargs = { };
878 boxargs.fill = UI_OFF; 879 boxargs.fill = UI_OFF;
879 ui_hbox_create(obj, boxargs); 880 ui_hbox_create(obj, &boxargs);
880 } 881 }
881 882
882 UIEXPORT void ui_headerbar_end_create(UiObject *obj) { 883 UIEXPORT void ui_headerbar_end_create(UiObject *obj) {
883 UiContainerArgs boxargs = { }; 884 UiContainerArgs boxargs = { };
884 boxargs.fill = UI_OFF; 885 boxargs.fill = UI_OFF;
885 ui_hbox_create(obj, boxargs); 886 ui_hbox_create(obj, &boxargs);
886 } 887 }
887 888
888 889
889 890
890 /* 891 /*

mercurial