# HG changeset patch # User Olaf Wintermann # Date 1453661836 -3600 # Node ID 500c085d2133773ee5129c2c2c5027c406b873fd # Parent fdd33964b35f007cfcfd562b8885e862a553910e added box spacing (Motif) diff -r fdd33964b35f -r 500c085d2133 application/main.c --- a/application/main.c Sun Jan 24 19:23:49 2016 +0100 +++ b/application/main.c Sun Jan 24 19:57:16 2016 +0100 @@ -110,22 +110,11 @@ //ui_mouse_handler(obj, w, click, NULL); ///* - ui_grid(obj); - - ui_button(obj, "Test", NULL, NULL); - ui_button(obj, "Test", NULL, NULL); - ui_newline(obj); - - ui_layout_gridwidth(obj, 2); - ui_button(obj, "Test", action_button, NULL); - ui_button(obj, "ABC", action_button2, NULL); - ui_newline(obj); - - ui_radiobutton(obj, "Radio1", &radio); - ui_radiobutton(obj, "Radio2", &radio); - ui_radiobutton(obj, "Radio3", &radio); - - + ui_vbox_sp(obj, 8, 4); + ui_button(obj, "Button", NULL, NULL); + ui_button(obj, "Button", NULL, NULL); + ui_button(obj, "Button", NULL, NULL); + ui_button(obj, "Button", NULL, NULL); ui_end(obj); //*/ diff -r fdd33964b35f -r 500c085d2133 ui/motif/container.c --- a/ui/motif/container.c Sun Jan 24 19:23:49 2016 +0100 +++ b/ui/motif/container.c Sun Jan 24 19:57:16 2016 +0100 @@ -66,7 +66,7 @@ } -UiContainer* ui_box_container(UiObject *obj, Widget box, UiBoxOrientation orientation) { +UiContainer* ui_box_container(UiObject *obj, Widget box, int margin, int spacing, UiBoxOrientation orientation) { UiBoxContainer *ct = ucx_mempool_calloc( obj->ctx->mempool, 1, @@ -75,6 +75,8 @@ ct->container.prepare = ui_box_container_prepare; ct->container.add = ui_box_container_add; ct->orientation = orientation; + ct->margin = margin; + ct->spacing = spacing; return (UiContainer*)ct; } @@ -108,6 +110,11 @@ w1 = XmNtopWidget; w2 = XmNbottomWidget; + // margin/spacing + XtSetArg(args[a], XmNleftOffset, bc->margin); a++; + XtSetArg(args[a], XmNrightOffset, bc->margin); a++; + + XtSetArg(args[a], XmNtopOffset, bc->prev_widget ? bc->spacing : bc->margin); a++; } else { f1 = XmNtopAttachment; f2 = XmNbottomAttachment; @@ -115,6 +122,12 @@ d2 = XmNrightAttachment; w1 = XmNleftWidget; w2 = XmNrightWidget; + + // margin/spacing + XtSetArg(args[a], XmNtopOffset, bc->margin); a++; + XtSetArg(args[a], XmNbottomOffset, bc->margin); a++; + + XtSetArg(args[a], XmNleftOffset, bc->prev_widget ? bc->spacing : bc->margin); a++; } XtSetArg(args[a], f1, XmATTACH_FORM); a++; XtSetArg(args[a], f2, XmATTACH_FORM); a++; @@ -344,7 +357,7 @@ ct->current = widget; } -UIWIDGET ui_box(UiObject *obj, UiBoxOrientation orientation) { +UIWIDGET ui_box(UiObject *obj, int margin, int spacing, UiBoxOrientation orientation) { UiContainer *ct = uic_get_current_container(obj); Arg args[16]; @@ -355,18 +368,26 @@ XtManageChild(form); UiObject *newobj = uic_object_new(obj, form); - newobj->container = ui_box_container(obj, form, orientation); + newobj->container = ui_box_container(obj, form, margin, spacing, orientation); uic_obj_add(obj, newobj); return form; } UIWIDGET ui_vbox(UiObject *obj) { - return ui_box(obj, UI_BOX_VERTICAL); + return ui_box(obj, 0, 0, UI_BOX_VERTICAL); } UIWIDGET ui_hbox(UiObject *obj) { - return ui_box(obj, UI_BOX_HORIZONTAL); + return ui_box(obj, 0, 0, UI_BOX_HORIZONTAL); +} + +UIWIDGET ui_vbox_sp(UiObject *obj, int margin, int spacing) { + return ui_box(obj, margin, spacing, UI_BOX_VERTICAL); +} + +UIWIDGET ui_hbox_sp(UiObject *obj, int margin, int spacing) { + return ui_box(obj, margin, spacing, UI_BOX_HORIZONTAL); } UIWIDGET ui_grid(UiObject *obj) { @@ -411,7 +432,7 @@ XtManageChild(sidebar); UiObject *left = uic_object_new(obj, sidebar); - left->container = ui_box_container(left, sidebar, UI_BOX_VERTICAL); + left->container = ui_box_container(left, sidebar, 0, 0, UI_BOX_VERTICAL); // add content widget XtSetArg (args[0], XmNpaneMaximum, 8000); @@ -419,7 +440,7 @@ XtManageChild(content); UiObject *right = uic_object_new(obj, content); - right->container = ui_box_container(right, content, UI_BOX_VERTICAL); + right->container = ui_box_container(right, content, 0, 0, UI_BOX_VERTICAL); uic_obj_add(obj, right); uic_obj_add(obj, left); diff -r fdd33964b35f -r 500c085d2133 ui/motif/container.h --- a/ui/motif/container.h Sun Jan 24 19:23:49 2016 +0100 +++ b/ui/motif/container.h Sun Jan 24 19:57:16 2016 +0100 @@ -86,6 +86,8 @@ Widget prev_widget; UiBool has_fill; UiBoxOrientation orientation; + int margin; + int spacing; }; struct UiGridContainer { @@ -126,7 +128,7 @@ Widget ui_frame_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); void ui_frame_container_add(UiContainer *ct, Widget widget); -UiContainer* ui_box_container(UiObject *obj, Widget box, UiBoxOrientation orientation); +UiContainer* ui_box_container(UiObject *obj, Widget box, int margin, int spacing, UiBoxOrientation orientation); Widget ui_box_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); void ui_box_container_add(UiContainer *ct, Widget widget); diff -r fdd33964b35f -r 500c085d2133 ui/motif/window.c --- a/ui/motif/window.c Sun Jan 24 19:23:49 2016 +0100 +++ b/ui/motif/window.c Sun Jan 24 19:57:16 2016 +0100 @@ -137,7 +137,7 @@ Widget content_form = XmCreateForm(frame, "content_form", NULL, 0); XtManageChild(content_form); - obj->container = ui_box_container(obj, content_form, UI_BOX_VERTICAL); + obj->container = ui_box_container(obj, content_form, 0, 0, UI_BOX_VERTICAL); XtManageChild(form);