Changeset 1769693 in mainline for uspace/app/uidemo/uidemo.c
- Timestamp:
- 2020-10-19T20:17:11Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba09d06
- Parents:
- de9992c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
rde9992c r1769693 42 42 #include <ui/pbutton.h> 43 43 #include <ui/resource.h> 44 #include <ui/wdecor.h> 44 45 #include "uidemo.h" 45 46 46 47 static void wnd_close_event(void *); 48 static void wnd_focus_event(void *); 47 49 static void wnd_kbd_event(void *, kbd_event_t *); 48 50 static void wnd_pos_event(void *, pos_event_t *); 51 static void wnd_unfocus_event(void *); 49 52 50 53 static display_wnd_cb_t wnd_cb = { 51 54 .close_event = wnd_close_event, 55 .focus_event = wnd_focus_event, 52 56 .kbd_event = wnd_kbd_event, 53 .pos_event = wnd_pos_event 57 .pos_event = wnd_pos_event, 58 .unfocus_event = wnd_unfocus_event 54 59 }; 55 60 … … 60 65 }; 61 66 67 static void wd_move(ui_wdecor_t *, void *, gfx_coord2_t *); 68 69 static ui_wdecor_cb_t wdecor_cb = { 70 .move = wd_move 71 }; 72 62 73 static bool quit = false; 63 74 … … 73 84 printf("Close event\n"); 74 85 quit = true; 86 } 87 88 /** Handle window focus event. */ 89 static void wnd_focus_event(void *arg) 90 { 91 ui_demo_t *demo = (ui_demo_t *) arg; 92 93 if (demo->wdecor != NULL) { 94 ui_wdecor_set_active(demo->wdecor, true); 95 ui_wdecor_paint(demo->wdecor); 96 } 75 97 } 76 98 … … 88 110 ui_demo_t *demo = (ui_demo_t *) arg; 89 111 112 /* Make sure we don't process events until fully initialized */ 113 if (demo->wdecor == NULL || demo->pb1 == NULL || demo->pb2 == NULL) 114 return; 115 116 ui_wdecor_pos_event(demo->wdecor, event); 90 117 ui_pbutton_pos_event(demo->pb1, event); 91 118 ui_pbutton_pos_event(demo->pb2, event); 119 } 120 121 /** Handle window unfocus event. */ 122 static void wnd_unfocus_event(void *arg) 123 { 124 ui_demo_t *demo = (ui_demo_t *) arg; 125 126 if (demo->wdecor != NULL) { 127 ui_wdecor_set_active(demo->wdecor, false); 128 ui_wdecor_paint(demo->wdecor); 129 } 92 130 } 93 131 … … 106 144 printf("Clicked 'Cancel' button\n"); 107 145 } 146 } 147 148 /** Window decoration requested window move. 149 * 150 * @param wdecor Window decoration 151 * @param arg Argument (demo) 152 * @param pos Position where the title bar was pressed 153 */ 154 static void wd_move(ui_wdecor_t *wdecor, void *arg, gfx_coord2_t *pos) 155 { 156 ui_demo_t *demo = (ui_demo_t *) arg; 157 158 (void) display_window_move_req(demo->dwindow, pos); 108 159 } 109 160 … … 135 186 params.rect.p1.y = 100; 136 187 188 memset((void *) &demo, 0, sizeof(demo)); 189 137 190 rc = display_window_create(display, ¶ms, &wnd_cb, (void *) &demo, 138 191 &window); … … 142 195 } 143 196 197 demo.dwindow = window; 198 144 199 rc = display_window_get_gc(window, &gc); 145 200 if (rc != EOK) { … … 155 210 return rc; 156 211 } 212 213 printf("Create window decoration\n"); 214 rc = ui_wdecor_create(ui_res, "UI Demo", &demo.wdecor); 215 if (rc != EOK) { 216 printf("Error creating window decoration.\n"); 217 return rc; 218 } 219 220 ui_wdecor_set_rect(demo.wdecor, ¶ms.rect); 221 ui_wdecor_set_cb(demo.wdecor, &wdecor_cb, (void *) &demo); 157 222 158 223 rc = ui_pbutton_create(ui_res, "Confirm", &demo.pb1); … … 207 272 color = NULL; 208 273 274 rc = ui_wdecor_paint(demo.wdecor); 275 if (rc != EOK) { 276 printf("Error painting window decoration.\n"); 277 return rc; 278 } 279 209 280 rc = ui_pbutton_paint(demo.pb1); 210 281 if (rc != EOK) { … … 223 294 } 224 295 296 ui_wdecor_destroy(demo.wdecor); 225 297 ui_pbutton_destroy(demo.pb1); 226 298 ui_pbutton_destroy(demo.pb2);
Note:
See TracChangeset
for help on using the changeset viewer.