ui/winui/container.cpp

branch
newapi
changeset 190
70fd1b24e395
parent 188
fbbae6738252
child 193
74c688cc1839
equal deleted inserted replaced
189:4daddc326877 190:70fd1b24e395
47 } 47 }
48 48
49 49
50 // --------------------- UiBoxContainer --------------------- 50 // --------------------- UiBoxContainer ---------------------
51 51
52 static UIWIDGET ui_box(UiObject* obj, UiBoxContainerType type) { 52 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs args, UiBoxContainerType type) {
53 UiContainer* ct = uic_get_current_container(obj); 53 UiObject* current = uic_current_obj(obj);
54 UI_APPLY_LAYOUT1(current, args);
54 55
55 Grid grid = Grid(); 56 Grid grid = Grid();
56 ct->Add(grid, true); 57 current->container->Add(grid, true);
57 58
58 UIElement elm = grid; 59 UIElement elm = grid;
59 UiWidget* widget = new UiWidget(elm); 60 UiWidget* widget = new UiWidget(elm);
60 61
61 UiObject* newobj = uic_object_new(obj, widget); 62 UiObject* newobj = uic_object_new(obj, widget);
62 newobj->container = new UiBoxContainer(grid, type); 63 newobj->container = new UiBoxContainer(grid, type, args.margin, args.spacing);
63 uic_obj_add(obj, newobj); 64 uic_obj_add(obj, newobj);
64 65
65 return widget; 66 return widget;
66 } 67 }
67 68
68 UIWIDGET ui_vbox(UiObject* obj) { 69 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) {
69 return ui_box(obj, UI_CONTAINER_VBOX); 70 return ui_box(obj, args, UI_CONTAINER_VBOX);
70 } 71 }
71 72
72 UIWIDGET ui_hbox(UiObject* obj) { 73 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) {
73 return ui_box(obj, UI_CONTAINER_HBOX); 74 return ui_box(obj, args, UI_CONTAINER_HBOX);
74 } 75 }
75 76
76 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type) { 77 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) {
77 this->grid = grid; 78 this->grid = grid;
78 this->type = type; 79 this->type = type;
79 80
80 GridLength gl; 81 GridLength gl;
81 gl.Value = 1; 82 gl.Value = 1;
134 } 135 }
135 136
136 137
137 // --------------------- UiGridContainer --------------------- 138 // --------------------- UiGridContainer ---------------------
138 139
139 UIWIDGET ui_grid(UiObject* obj) { 140 UIWIDGET ui_grid_create(UiObject* obj, UiContainerArgs args) {
140 return ui_grid_sp(obj, 0, 0, 0); 141 UiObject* current = uic_current_obj(obj);
141 } 142 UI_APPLY_LAYOUT1(current, args);
142
143 UIWIDGET ui_grid_sp(UiObject* obj, int margin, int columnspacing, int rowspacing) {
144 UiContainer* ct = uic_get_current_container(obj);
145 143
146 Grid grid = Grid(); 144 Grid grid = Grid();
147 ct->Add(grid, true); 145 current->container->Add(grid, true);
148 146
149 UIElement elm = grid; 147 UIElement elm = grid;
150 UiWidget* widget = new UiWidget(elm); 148 UiWidget* widget = new UiWidget(elm);
151 149
152 UiObject* newobj = uic_object_new(obj, widget); 150 UiObject* newobj = uic_object_new(obj, widget);
153 newobj->container = new UiGridContainer(grid, margin, columnspacing, rowspacing); 151 newobj->container = new UiGridContainer(grid, args.margin, args.columnspacing, args.rowspacing);
154 uic_obj_add(obj, newobj); 152 uic_obj_add(obj, newobj);
155 153
156 return widget; 154 return widget;
157 } 155 }
158 156

mercurial