make/vs/testapp/main.c

branch
newapi
changeset 188
fbbae6738252
parent 187
24ce2c326d85
child 189
4daddc326877
equal deleted inserted replaced
187:24ce2c326d85 188:fbbae6738252
35 #include <ui/ui.h> 35 #include <ui/ui.h>
36 36
37 typedef struct WindowData { 37 typedef struct WindowData {
38 UiInteger* check; 38 UiInteger* check;
39 UiInteger* toggle; 39 UiInteger* toggle;
40 UiInteger* radio;
40 } WindowData; 41 } WindowData;
41 42
42 void action1(UiEvent* event, void* data) { 43 void action1(UiEvent* event, void* data) {
43 char* action = data; 44 char* action = data;
44 45
45 WindowData* wdata = event->window; 46 WindowData* wdata = event->window;
46 int64_t is_checked = wdata->check->get(wdata->check); 47 int64_t is_checked = wdata->check->get(wdata->check);
48 int64_t radio = wdata->radio->get(wdata->radio);
47 49
48 printf("data: %s %d\n", data, is_checked); 50 printf("data: %s %d\n", data, is_checked);
49 } 51 }
50 52
51 void action_set_checkbox(UiEvent* event, void* data) { 53 void action_set_checkbox(UiEvent* event, void* data) {
59 UiObject* obj = ui_window("Test", NULL); 61 UiObject* obj = ui_window("Test", NULL);
60 WindowData* wdata = ui_malloc(obj->ctx, sizeof(WindowData)); 62 WindowData* wdata = ui_malloc(obj->ctx, sizeof(WindowData));
61 obj->window = wdata; 63 obj->window = wdata;
62 wdata->check = ui_int_new(obj->ctx, "check"); 64 wdata->check = ui_int_new(obj->ctx, "check");
63 wdata->toggle = ui_int_new(obj->ctx, "toggle"); 65 wdata->toggle = ui_int_new(obj->ctx, "toggle");
66 wdata->radio = ui_int_new(obj->ctx, "radio");
64 67
65 UI_GRID_SP(obj, 10, 5, 20) { 68 UI_GRID_SP(obj, 10, 5, 20) {
66 ui_button(obj, .label="Button1", .onclick=action1, .onclickdata="action1"); 69 ui_button(obj, .label="Button1", .onclick=action1, .onclickdata="action1");
67 ui_button(obj, .label="Button2", .onclick=action1, .onclickdata="action2"); 70 ui_button(obj, .label="Button2", .onclick=action1, .onclickdata="action2");
68 ui_button(obj, .label="Button3", .onclick=action1, .onclickdata="action3", .hexpand=true); 71 ui_button(obj, .label="Button3", .onclick=action1, .onclickdata="action3", .hexpand=true);
75 ui_button(obj, .label="Very Long Button Label Text ____________ Test", .onclick=action_set_checkbox); 78 ui_button(obj, .label="Very Long Button Label Text ____________ Test", .onclick=action_set_checkbox);
76 ui_newline(obj); 79 ui_newline(obj);
77 80
78 ui_checkbox(obj, .label = "Option 1", .value = wdata->check); 81 ui_checkbox(obj, .label = "Option 1", .value = wdata->check);
79 ui_togglebutton(obj, .label = "Option 2", .value = wdata->toggle); 82 ui_togglebutton(obj, .label = "Option 2", .value = wdata->toggle);
83 ui_newline(obj);
84
85 ui_layout_colspan(obj, 3);
86 ui_layout_fill(obj, FALSE);
87 UI_HBOX(obj) {
88 ui_radiobutton(obj, .label = "Radio 1", .value = wdata->radio);
89 ui_radiobutton(obj, .label = "Radio 2", .value = wdata->radio);
90 ui_radiobutton(obj, .label = "Radio 3", .value = wdata->radio);
91 }
80 } 92 }
81 93
82 ui_show(obj); 94 ui_show(obj);
83 } 95 }
84 96

mercurial