added gridwidth layout option (GTK)

Sun, 24 Jan 2016 12:08:57 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 24 Jan 2016 12:08:57 +0100
changeset 109
b9808f916687
parent 108
fcf6d5fac8f5
child 110
36f1581b43e2

added gridwidth layout option (GTK)

application/main.c file | annotate | diff | comparison | revisions
ui/gtk/container.c file | annotate | diff | comparison | revisions
ui/gtk/container.h file | annotate | diff | comparison | revisions
ui/ui/toolkit.h file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Jan 24 11:59:58 2016 +0100
+++ b/application/main.c	Sun Jan 24 12:08:57 2016 +0100
@@ -105,43 +105,14 @@
     //ui_mouse_handler(obj, w, click, NULL);
     
 ///*
-    ui_vbox_sp(obj, 8, 8);
+    ui_grid(obj);
     
-    ui_layout_fill(obj, FALSE);
-    ui_grid_sp(obj, 0, 4, 4);
-    ui_label(obj, "Name");
-    ui_textfield(obj, NULL);
-    ui_newline(obj);
-    ui_label(obj, "Email");
-    ui_textfield(obj, NULL);
-    ui_end(obj);
-    
-    ui_separator(obj);
-    
-    ui_layout_fill(obj, FALSE);
-    ui_grid_sp(obj, 0, 4, 4);
-    ui_checkbox(obj, "Shit", NULL);
+    ui_button(obj, "Test", NULL, NULL);
+    ui_button(obj, "Test", NULL, NULL);
     ui_newline(obj);
-    ui_checkbox(obj, "Nein", NULL);
-    ui_checkbox(obj, "Nein", NULL);
-    ui_checkbox(obj, "Nein", NULL);
-    ui_end(obj);
     
-    ui_separator(obj);
-    
-    ui_layout_fill(obj, FALSE);
-    ui_grid_sp(obj, 0, 4, 4);
-    ui_radiobutton(obj, "better", &radio);
-    ui_newline(obj);
-    ui_radiobutton(obj, "smarter", &radio);
-    ui_newline(obj);
-    ui_radiobutton(obj, "awesome", &radio);
-    ui_end(obj);
-    
-    ui_space(obj);
-    
-    ui_button(obj, "OK", action_button, NULL);
-    ui_button(obj, "Activate", action_button2, NULL);
+    ui_layout_gridwidth(obj, 2);
+    ui_button(obj, "Test", NULL, NULL);
     
     ui_end(obj);
 //*/
--- a/ui/gtk/container.c	Sun Jan 24 11:59:58 2016 +0100
+++ b/ui/gtk/container.c	Sun Jan 24 12:08:57 2016 +0100
@@ -139,7 +139,9 @@
         gtk_widget_set_vexpand(widget, TRUE);
     }
     
-    gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1);
+    int gwidth = ct->layout.gridwidth > 0 ? ct->layout.gridwidth : 1;
+    
+    gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, gwidth, 1);
     grid->x++;
     
     ui_reset_layout(ct->layout);
@@ -473,6 +475,11 @@
     ct->layout.vexpand = ui_bool2lb(expand);
 }
 
+void ui_layout_gridwidth(UiObject *obj, int width) {
+    UiContainer *ct = uic_get_current_container(obj);
+    ct->layout.gridwidth = width;
+}
+
 void ui_newline(UiObject *obj) {
     UiContainer *ct = uic_get_current_container(obj);
     ct->layout.newline = TRUE;
--- a/ui/gtk/container.h	Sun Jan 24 11:59:58 2016 +0100
+++ b/ui/gtk/container.h	Sun Jan 24 12:08:57 2016 +0100
@@ -59,6 +59,7 @@
     char         *label;
     UiBool       hexpand;
     UiBool       vexpand;
+    int          gridwidth;
 };
 
 struct UiContainer {
--- a/ui/ui/toolkit.h	Sun Jan 24 11:59:58 2016 +0100
+++ b/ui/ui/toolkit.h	Sun Jan 24 12:08:57 2016 +0100
@@ -261,9 +261,12 @@
 void ui_tab(UiObject *obj, char *title);
 void ui_select_tab(UIWIDGET tabview, int tab);
 
+// box container layout functions
 void ui_layout_fill(UiObject *obj, UiBool fill);
+// grid container layout functions
 void ui_layout_hexpand(UiObject *obj, UiBool expand);
 void ui_layout_vexpand(UiObject *obj, UiBool expand);
+void ui_layout_gridwidth(UiObject *obj, int width);
 void ui_newline(UiObject *obj);
 
 

mercurial