Tue, 08 Dec 2020 15:19:31 +0100
add container macros (GTK)
ui/gtk/container.c | file | annotate | diff | comparison | revisions | |
ui/gtk/container.h | file | annotate | diff | comparison | revisions | |
ui/ui/container.h | file | annotate | diff | comparison | revisions |
--- a/ui/gtk/container.c Tue Dec 08 14:00:12 2020 +0100 +++ b/ui/gtk/container.c Tue Dec 08 15:19:31 2020 +0100 @@ -36,6 +36,21 @@ #include "../common/context.h" #include "../common/object.h" + +void ui_container_begin_close(UiObject *obj) { + UiContainer *ct = uic_get_current_container(obj); + ct->close = 1; +} + +int ui_container_finish(UiObject *obj) { + UiContainer *ct = uic_get_current_container(obj); + if(ct->close) { + ui_end(obj); + return 0; + } + return 1; +} + GtkWidget* ui_gtk_vbox_new(int spacing) { #ifdef UI_GTK3 return gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing);
--- a/ui/gtk/container.h Tue Dec 08 14:00:12 2020 +0100 +++ b/ui/gtk/container.h Tue Dec 08 15:19:31 2020 +0100 @@ -71,6 +71,8 @@ void (*add)(UiContainer*, GtkWidget*, UiBool); UiLayout layout; + + int close; }; typedef struct UiBoxContainer {
--- a/ui/ui/container.h Tue Dec 08 14:00:12 2020 +0100 +++ b/ui/ui/container.h Tue Dec 08 15:19:31 2020 +0100 @@ -34,7 +34,15 @@ #ifdef __cplusplus extern "C" { #endif - + +#define UI_CTN(obj, ctn) for(ctn;ui_container_finish(obj);ui_container_begin_close(obj)) +#define UI_VBOX(obj) for(ui_vbox(obj);ui_container_finish(obj);ui_container_begin_close(obj)) +#define UI_HBOX(obj) for(ui_hbox(obj);ui_container_finish(obj);ui_container_begin_close(obj)) +#define UI_VBOX_SP(obj, margin, spacing) for(ui_vbox_sp(obj,margin,spacing);ui_container_finish(obj);ui_container_begin_close(obj)) +#define UI_HBOX_SP(obj, margin, spacing) for(ui_hbox_sp(obj,margin,spacing);ui_container_finish(obj);ui_container_begin_close(obj)) +#define UI_GRID(obj) for(ui_grid(obj);ui_container_finish(obj);ui_container_begin_close(obj)) +#define UI_GRID_SP(obj, margin, columnspacing, rowspacing) for(ui_grid_sp(obj,margin,columnspacing,rowspacing);ui_container_finish(obj);ui_container_begin_close(obj)) + void ui_end(UiObject *obj); UIWIDGET ui_vbox(UiObject *obj); @@ -71,6 +79,10 @@ UiObject* ui_document_tab(UiTabbedPane *view); +/* used for macro */ +void ui_container_begin_close(UiObject *obj); +int ui_container_finish(UiObject *obj); + #ifdef __cplusplus }