214 } else { |
214 } else { |
215 ui_set_group(ctx, 2); |
215 ui_set_group(ctx, 2); |
216 } |
216 } |
217 } |
217 } |
218 |
218 |
|
219 static UiObject *ref_window; |
|
220 |
|
221 void action_button_ref(UiEvent *event, void *userdata) { |
|
222 UiObject *obj = event->obj; |
|
223 printf("action_button_ref: %u\n", obj->ref); |
|
224 ui_object_ref(obj); |
|
225 ref_window = obj; |
|
226 } |
|
227 |
|
228 void action_button_unref(UiEvent *event, void *userdata) { |
|
229 UiObject *obj = userdata; |
|
230 printf("action_button_unref: %u\n", obj->ref); |
|
231 ui_object_unref(obj); |
|
232 } |
|
233 |
|
234 void action_toolbar_unrefwindow(UiEvent *event, void *userdata) { |
|
235 UiObject *obj = ui_simple_window("Unref", NULL); |
|
236 ui_grid(obj, .margin = 20) { |
|
237 ui_button(obj, .label = "Unref", .onclick = action_button_unref, .onclickdata = ref_window); |
|
238 } |
|
239 ui_show(obj); |
|
240 } |
|
241 |
219 void application_startup(UiEvent *event, void *data) { |
242 void application_startup(UiEvent *event, void *data) { |
220 // global list |
243 // global list |
221 UiContext *global = ui_global_context(); |
244 UiContext *global = ui_global_context(); |
222 menu_list = ui_list_new(global, "menulist"); |
245 menu_list = ui_list_new(global, "menulist"); |
223 ui_list_append(menu_list, "menu list item 1"); |
246 ui_list_append(menu_list, "menu list item 1"); |
281 } |
304 } |
282 } |
305 } |
283 ui_tab(obj, "Tab 2") { |
306 ui_tab(obj, "Tab 2") { |
284 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); |
307 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); |
285 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); |
308 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); |
286 ui_button(obj, .label = "Button 3", .onclick=action_tab2_button); |
309 ui_button(obj, .label = "Obj Ref", .onclick=action_button_ref); |
287 ui_button(obj, .label = "Button 4", .onclick=action_tab2_button); |
310 ui_button(obj, .label = "Obj Unref", .onclick=action_button_unref, .onclickdata = obj); |
288 ui_button(obj, .label = "Button 5", .onclick=action_tab2_button); |
311 ui_button(obj, .label = "Button 5", .onclick=action_tab2_button); |
289 ui_button(obj, .label = "Button 6", .onclick=action_tab2_button); |
312 ui_button(obj, .label = "Button 6", .onclick=action_tab2_button); |
290 } |
313 } |
291 ui_tab(obj, "Tab 3") { |
314 ui_tab(obj, "Tab 3") { |
292 UiTabViewArgs args = {0}; |
315 UiTabViewArgs args = {0}; |
347 } |
370 } |
348 |
371 |
349 ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button); |
372 ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button); |
350 ui_toolbar_item("Test2", .label = "New Window", .onclick = action_toolbar_newwindow); |
373 ui_toolbar_item("Test2", .label = "New Window", .onclick = action_toolbar_newwindow); |
351 ui_toolbar_item("Test3", .label = "Dialog", .onclick = action_toolbar_dialog); |
374 ui_toolbar_item("Test3", .label = "Dialog", .onclick = action_toolbar_dialog); |
352 ui_toolbar_item("Test4", .label = "Test 4", .onclick = action_toolbar_button); |
375 ui_toolbar_item("Test4", .label = "Unref Window", .onclick = action_toolbar_unrefwindow); |
353 ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button); |
376 ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button); |
354 ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button); |
377 ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button); |
355 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button); |
378 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button); |
356 ui_toolbar_menu("Menu", .label = "Menu") { |
379 ui_toolbar_menu("Menu", .label = "Menu") { |
357 ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL); |
380 ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL); |