ui/winui/container.cpp

branch
newapi
changeset 190
70fd1b24e395
parent 188
fbbae6738252
child 193
74c688cc1839
--- a/ui/winui/container.cpp	Sun Oct 01 16:39:03 2023 +0200
+++ b/ui/winui/container.cpp	Sun Oct 01 16:53:02 2023 +0200
@@ -49,31 +49,32 @@
 
 // --------------------- UiBoxContainer ---------------------
 
-static UIWIDGET ui_box(UiObject* obj, UiBoxContainerType type) {
-	UiContainer* ct = uic_get_current_container(obj);
+static UIWIDGET ui_box(UiObject* obj, UiContainerArgs args, UiBoxContainerType type) {
+	UiObject* current = uic_current_obj(obj);
+	UI_APPLY_LAYOUT1(current, args);
 
 	Grid grid = Grid();
-	ct->Add(grid, true);
+	current->container->Add(grid, true);
 
 	UIElement elm = grid;
 	UiWidget* widget = new UiWidget(elm);
 
 	UiObject* newobj = uic_object_new(obj, widget);
-	newobj->container = new UiBoxContainer(grid, type);
+	newobj->container = new UiBoxContainer(grid, type, args.margin, args.spacing);
 	uic_obj_add(obj, newobj);
 
 	return widget;
 }
 
-UIWIDGET ui_vbox(UiObject* obj) {
-	return ui_box(obj, UI_CONTAINER_VBOX);
+UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) {
+	return ui_box(obj, args, UI_CONTAINER_VBOX);
 }
 
-UIWIDGET ui_hbox(UiObject* obj) {
-	return ui_box(obj, UI_CONTAINER_HBOX);
+UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) {
+	return ui_box(obj, args, UI_CONTAINER_HBOX);
 }
 
-UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type) {
+UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) {
 	this->grid = grid;
 	this->type = type;
 
@@ -136,21 +137,18 @@
 
 // --------------------- UiGridContainer ---------------------
 
-UIWIDGET ui_grid(UiObject* obj) {
-	return ui_grid_sp(obj, 0, 0, 0);
-}
-
-UIWIDGET ui_grid_sp(UiObject* obj, int margin, int columnspacing, int rowspacing) {
-	UiContainer* ct = uic_get_current_container(obj);
+UIWIDGET ui_grid_create(UiObject* obj, UiContainerArgs args) {
+	UiObject* current = uic_current_obj(obj);
+	UI_APPLY_LAYOUT1(current, args);
 
 	Grid grid = Grid();
-	ct->Add(grid, true);
+	current->container->Add(grid, true);
 
 	UIElement elm = grid;
 	UiWidget* widget = new UiWidget(elm);
 
 	UiObject* newobj = uic_object_new(obj, widget);
-	newobj->container = new UiGridContainer(grid, margin, columnspacing, rowspacing);
+	newobj->container = new UiGridContainer(grid, args.margin, args.columnspacing, args.rowspacing);
 	uic_obj_add(obj, newobj);
 
 	return widget;

mercurial