Changeset 10cb47e in mainline
- Timestamp:
- 2016-08-31T15:43:01Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bdfdc51c
- Parents:
- 58563585
- Location:
- uspace
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/barber/barber.c
r58563585 r10cb47e 308 308 309 309 winreg = argv[1]; 310 window_t *main_window = window_open(argv[1], 310 window_t *main_window = window_open(argv[1], NULL, 311 311 WINDOW_MAIN | WINDOW_DECORATED, "barber"); 312 312 if (!main_window) { … … 315 315 } 316 316 317 frame_canvas = create_canvas(window_root(main_window), 317 frame_canvas = create_canvas(window_root(main_window), NULL, 318 318 FRAME_WIDTH, FRAME_HEIGHT, frames[frame]); 319 319 -
uspace/app/fontviewer/fontviewer.c
r58563585 r10cb47e 260 260 } 261 261 262 main_window = window_open(argv[1], WINDOW_MAIN, "fontviewer");262 main_window = window_open(argv[1], NULL, WINDOW_MAIN, "fontviewer"); 263 263 if (!main_window) { 264 264 printf("Cannot open main window.\n"); … … 282 282 } 283 283 284 canvas = create_canvas(window_root(main_window), 284 canvas = create_canvas(window_root(main_window), NULL, 285 285 WINDOW_WIDTH, WINDOW_HEIGHT, surface); 286 286 if (canvas == NULL) { -
uspace/app/vdemo/vdemo.c
r58563585 r10cb47e 85 85 lbl->confirm = on_confirm; 86 86 lbl->cancel = on_cancel; 87 bool initialized = init_label( 88 &lbl->label, parent, caption,points, background, foreground);87 bool initialized = init_label(&lbl->label, parent, NULL, caption, 88 points, background, foreground); 89 89 lbl->label.widget.destroy = my_label_destroy; 90 90 return initialized; … … 110 110 { 111 111 if (argc >= 2) { 112 window_t *main_window = window_open(argv[1], 112 window_t *main_window = window_open(argv[1], NULL, 113 113 WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vdemo"); 114 114 if (!main_window) { … … 128 128 my_label_t *lbl_action = create_my_label(NULL, "Hello there!", 16, 129 129 lbl_bg, lbl_text); 130 button_t *btn_confirm = create_button(NULL, "Confirm", 16, btn_bg, 131 btn_fg, btn_text); 132 button_t *btn_cancel = create_button(NULL, "Cancel", 16, btn_bg, 133 btn_fg, btn_text); 134 grid_t *grid = create_grid(window_root(main_window), 2, 2, grd_bg); 130 button_t *btn_confirm = create_button(NULL, NULL, "Confirm", 16, 131 btn_bg, btn_fg, btn_text); 132 button_t *btn_cancel = create_button(NULL, NULL, "Cancel", 16, 133 btn_bg, btn_fg, btn_text); 134 grid_t *grid = create_grid(window_root(main_window), NULL, 2, 2, 135 grd_bg); 135 136 if (!lbl_action || !btn_confirm || !btn_cancel || !grid) { 136 137 window_close(main_window); -
uspace/app/viewer/viewer.c
r58563585 r10cb47e 157 157 } 158 158 } else { 159 canvas = create_canvas(window_root(main_window), 159 canvas = create_canvas(window_root(main_window), NULL, 160 160 img_width, img_height, local_surface); 161 161 if (canvas == NULL) { … … 219 219 flags |= WINDOW_DECORATED; 220 220 221 main_window = window_open(argv[1], flags, "viewer");221 main_window = window_open(argv[1], NULL, flags, "viewer"); 222 222 if (!main_window) { 223 223 printf("Cannot open main window.\n"); -
uspace/app/vlaunch/vlaunch.c
r58563585 r10cb47e 85 85 } 86 86 87 static void on_ vterm(widget_t *widget, void *data)87 static void on_btn_click(widget_t *widget, void *data) 88 88 { 89 app_launch("/app/vterm"); 90 } 91 92 static void on_vdemo(widget_t *widget, void *data) 93 { 94 app_launch("/app/vdemo"); 95 } 96 97 static void on_vlaunch(widget_t *widget, void *data) 98 { 99 app_launch("/app/vlaunch"); 89 const char *app = (const char *) widget_get_data(widget); 90 app_launch(app); 100 91 } 101 92 … … 114 105 115 106 winreg = argv[1]; 116 window_t *main_window = window_open(argv[1], 107 window_t *main_window = window_open(argv[1], NULL, 117 108 WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vlaunch"); 118 109 if (!main_window) { … … 130 121 pixel_t lbl_text = PIXEL(255, 0, 0, 0); 131 122 132 canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT,123 canvas_t *logo_canvas = create_canvas(NULL, NULL, LOGO_WIDTH, LOGO_HEIGHT, 133 124 logo); 134 label_t *lbl_caption = create_label(NULL, "Launch application:", 16,135 lbl_bg, lbl_text);136 button_t *btn_vterm = create_button(NULL, " vterm", 16, btn_bg,137 btn_fg, btn_text);138 button_t *btn_vdemo = create_button(NULL, " vdemo", 16, btn_bg,139 btn_fg, btn_text);140 button_t *btn_vlaunch = create_button(NULL, " vlaunch", 16, btn_bg,141 btn_fg, btn_text);142 grid_t *grid = create_grid(window_root(main_window), 1, 5, grd_bg);125 label_t *lbl_caption = create_label(NULL, NULL, "Launch application:", 126 16, lbl_bg, lbl_text); 127 button_t *btn_vterm = create_button(NULL, "/app/vterm", "vterm", 128 16, btn_bg, btn_fg, btn_text); 129 button_t *btn_vdemo = create_button(NULL, "/app/vdemo", "vdemo", 130 16, btn_bg, btn_fg, btn_text); 131 button_t *btn_vlaunch = create_button(NULL, "/app/vlaunch", "vlaunch", 132 16, btn_bg, btn_fg, btn_text); 133 grid_t *grid = create_grid(window_root(main_window), NULL, 1, 5, grd_bg); 143 134 144 135 if ((!logo_canvas) || (!lbl_caption) || (!btn_vterm) || … … 149 140 } 150 141 151 sig_connect(&btn_vterm->clicked, NULL, on_vterm);152 sig_connect(&btn_vdemo->clicked, NULL, on_vdemo);153 sig_connect(&btn_vlaunch->clicked, NULL, on_vlaunch);142 sig_connect(&btn_vterm->clicked, &btn_vterm->widget, on_btn_click); 143 sig_connect(&btn_vdemo->clicked, &btn_vdemo->widget, on_btn_click); 144 sig_connect(&btn_vlaunch->clicked, &btn_vlaunch->widget, on_btn_click); 154 145 155 146 grid->add(grid, &logo_canvas->widget, 0, 0, 1, 1); -
uspace/app/vterm/vterm.c
r58563585 r10cb47e 49 49 } 50 50 51 window_t *main_window = window_open(argv[1], 51 window_t *main_window = window_open(argv[1], NULL, 52 52 WINDOW_MAIN | WINDOW_DECORATED, "vterm"); 53 53 if (!main_window) { … … 58 58 window_resize(main_window, 0, 0, 648, 508, WINDOW_PLACEMENT_ANY); 59 59 terminal_t *terminal_widget = 60 create_terminal(window_root(main_window), 640, 480);60 create_terminal(window_root(main_window), NULL, 640, 480); 61 61 if (!terminal_widget) { 62 62 window_close(main_window); -
uspace/lib/gui/button.c
r58563585 r10cb47e 147 147 } 148 148 149 bool init_button(button_t *btn, widget_t *parent, const char *caption, 150 uint16_t points, pixel_t background, pixel_t foreground, pixel_t text) 151 { 152 widget_init(&btn->widget, parent); 149 bool init_button(button_t *btn, widget_t *parent, const void *data, 150 const char *caption, uint16_t points, pixel_t background, 151 pixel_t foreground, pixel_t text) 152 { 153 widget_init(&btn->widget, parent, data); 153 154 154 155 btn->widget.destroy = button_destroy; … … 191 192 } 192 193 193 button_t *create_button(widget_t *parent, const char *caption, uint16_t points,194 pixel_t background, pixel_t foreground, pixel_t text)194 button_t *create_button(widget_t *parent, const void *data, const char *caption, 195 uint16_t points, pixel_t background, pixel_t foreground, pixel_t text) 195 196 { 196 197 button_t *btn = (button_t *) malloc(sizeof(button_t)); … … 198 199 return NULL; 199 200 200 if (init_button(btn, parent, caption, points, background, foreground,201 if (init_button(btn, parent, data, caption, points, background, foreground, 201 202 text)) 202 203 return btn; -
uspace/lib/gui/button.h
r58563585 r10cb47e 56 56 } button_t; 57 57 58 extern bool init_button(button_t *, widget_t *, const char *, uint16_t, pixel_t,59 pixel_t, pixel_t);60 extern button_t *create_button(widget_t *, const char *, uint16_t, pixel_t,61 pixel_t, pixel_t );58 extern bool init_button(button_t *, widget_t *, const void *, const char *, 59 uint16_t, pixel_t, pixel_t, pixel_t); 60 extern button_t *create_button(widget_t *, const void *, const char *, uint16_t, 61 pixel_t, pixel_t, pixel_t); 62 62 extern void deinit_button(button_t *); 63 63 -
uspace/lib/gui/canvas.c
r58563585 r10cb47e 123 123 } 124 124 125 bool init_canvas(canvas_t *canvas, widget_t *parent, sysarg_t width,126 sysarg_t height, surface_t *surface)125 bool init_canvas(canvas_t *canvas, widget_t *parent, const void *data, 126 sysarg_t width, sysarg_t height, surface_t *surface) 127 127 { 128 widget_init(&canvas->widget, parent );128 widget_init(&canvas->widget, parent, data); 129 129 130 130 canvas->widget.width = width; … … 161 161 } 162 162 163 canvas_t *create_canvas(widget_t *parent, sysarg_t width, sysarg_t height,164 s urface_t *surface)163 canvas_t *create_canvas(widget_t *parent, const void *data, sysarg_t width, 164 sysarg_t height, surface_t *surface) 165 165 { 166 166 canvas_t *canvas = (canvas_t *) malloc(sizeof(canvas_t)); … … 168 168 return NULL; 169 169 170 if (init_canvas(canvas, parent, width, height, surface))170 if (init_canvas(canvas, parent, data, width, height, surface)) 171 171 return canvas; 172 172 -
uspace/lib/gui/canvas.h
r58563585 r10cb47e 53 53 } canvas_t; 54 54 55 extern bool init_canvas(canvas_t *, widget_t *, sysarg_t, sysarg_t, 55 extern bool init_canvas(canvas_t *, widget_t *, const void *, sysarg_t, 56 sysarg_t, surface_t *); 57 extern canvas_t *create_canvas(widget_t *, const void *, sysarg_t, sysarg_t, 56 58 surface_t *); 57 extern canvas_t *create_canvas(widget_t *, sysarg_t, sysarg_t, surface_t *);58 59 extern bool update_canvas(canvas_t *, surface_t *); 59 60 extern void deinit_canvas(canvas_t *); -
uspace/lib/gui/connection.c
r58563585 r10cb47e 198 198 list_foreach(sig_node->slots, link, slot_node_t, cur) { 199 199 void *data_copy = NULL; 200 if (data != NULL) {200 if (data != NULL) 201 201 data_copy = malloc(data_size); 202 }203 if (data_copy != NULL) {202 203 if (data_copy != NULL) 204 204 memcpy(data_copy, data, data_size); 205 }205 206 206 window_event_t *event = 207 208 207 (window_event_t *) malloc(sizeof(window_event_t)); 208 209 209 if (event) { 210 210 link_initialize(&event->link); … … 215 215 prodcons_produce(&cur->widget->window->events, &event->link); 216 216 } else { 217 if (data_copy != NULL) {217 if (data_copy != NULL) 218 218 free(data_copy); 219 }220 219 } 221 220 } -
uspace/lib/gui/grid.c
r58563585 r10cb47e 363 363 } 364 364 365 bool init_grid(grid_t *grid, widget_t *parent, size_t cols, size_t rows,366 pixel_t background)365 bool init_grid(grid_t *grid, widget_t *parent, const void *data, size_t cols, 366 size_t rows, pixel_t background) 367 367 { 368 368 if ((cols == 0) || (rows == 0)) … … 376 376 memset(grid->layout, 0, cols * rows * sizeof(grid_cell_t)); 377 377 378 widget_init(&grid->widget, parent );378 widget_init(&grid->widget, parent, data); 379 379 380 380 grid->widget.destroy = grid_destroy; … … 393 393 } 394 394 395 grid_t *create_grid(widget_t *parent, size_t cols, size_t rows, pixel_t background) 395 grid_t *create_grid(widget_t *parent, const void *data, size_t cols, 396 size_t rows, pixel_t background) 396 397 { 397 398 grid_t *grid = (grid_t *) malloc(sizeof(grid_t)); … … 399 400 return NULL; 400 401 401 if (init_grid(grid, parent, cols, rows, background))402 if (init_grid(grid, parent, data, cols, rows, background)) 402 403 return grid; 403 404 -
uspace/lib/gui/grid.h
r58563585 r10cb47e 56 56 } grid_t; 57 57 58 extern bool init_grid(grid_t *, widget_t *, size_t, size_t, pixel_t); 59 extern grid_t *create_grid(widget_t *, size_t, size_t, pixel_t); 58 extern bool init_grid(grid_t *, widget_t *, const void *, size_t, size_t, 59 pixel_t); 60 extern grid_t *create_grid(widget_t *, const void *, size_t, size_t, pixel_t); 60 61 extern void deinit_grid(grid_t *); 61 62 -
uspace/lib/gui/label.c
r58563585 r10cb47e 140 140 } 141 141 142 bool init_label(label_t *lbl, widget_t *parent, const char *caption,143 uint16_t points, pixel_t background, pixel_t text)144 { 145 widget_init(&lbl->widget, parent );142 bool init_label(label_t *lbl, widget_t *parent, const void *data, 143 const char *caption, uint16_t points, pixel_t background, pixel_t text) 144 { 145 widget_init(&lbl->widget, parent, data); 146 146 147 147 lbl->widget.destroy = label_destroy; … … 184 184 } 185 185 186 label_t *create_label(widget_t *parent, const char *caption, uint16_t points,187 pixel_t background, pixel_t text)186 label_t *create_label(widget_t *parent, const void *data, const char *caption, 187 uint16_t points, pixel_t background, pixel_t text) 188 188 { 189 189 label_t *lbl = (label_t *) malloc(sizeof(label_t)); … … 191 191 return NULL; 192 192 193 if (init_label(lbl, parent, caption, points, background, text))193 if (init_label(lbl, parent, data, caption, points, background, text)) 194 194 return lbl; 195 195 -
uspace/lib/gui/label.h
r58563585 r10cb47e 55 55 } label_t; 56 56 57 extern bool init_label(label_t *, widget_t *, const char *, uint16_t, pixel_t,58 pixel_t);59 extern label_t *create_label(widget_t *, const char *, uint16_t, pixel_t,60 pixel_t );57 extern bool init_label(label_t *, widget_t *, const void *, const char *, 58 uint16_t, pixel_t, pixel_t); 59 extern label_t *create_label(widget_t *, const void *, const char *, uint16_t, 60 pixel_t, pixel_t); 61 61 extern void deinit_label(label_t *); 62 62 -
uspace/lib/gui/minimal.c
r58563585 r10cb47e 112 112 } 113 113 114 bool init_minimal(minimal_t *min, widget_t *parent, pixel_t a, pixel_t b) 114 bool init_minimal(minimal_t *min, widget_t *parent, const void *data, pixel_t a, 115 pixel_t b) 115 116 { 116 widget_init(&min->widget, parent );117 widget_init(&min->widget, parent, data); 117 118 118 119 min->widget.destroy = minimal_destroy; … … 129 130 } 130 131 131 minimal_t *create_minimal(widget_t *parent, pixel_t a, pixel_t b) 132 minimal_t *create_minimal(widget_t *parent, const void *data, pixel_t a, 133 pixel_t b) 132 134 { 133 135 minimal_t *min = (minimal_t *) malloc(sizeof(minimal_t)); … … 136 138 } 137 139 138 if (init_minimal(min, parent, a, b)) {140 if (init_minimal(min, parent, data, a, b)) { 139 141 return min; 140 142 } else { -
uspace/lib/gui/minimal.h
r58563585 r10cb47e 49 49 } minimal_t; 50 50 51 extern bool init_minimal(minimal_t *, widget_t *, pixel_t, pixel_t); 52 extern minimal_t *create_minimal(widget_t *, pixel_t, pixel_t); 51 extern bool init_minimal(minimal_t *, widget_t *, const void *, pixel_t, 52 pixel_t); 53 extern minimal_t *create_minimal(widget_t *, const void *, pixel_t, pixel_t); 53 54 extern void deinit_minimal(minimal_t *); 54 55 … … 57 58 /** @} 58 59 */ 59 -
uspace/lib/gui/terminal.c
r58563585 r10cb47e 696 696 } 697 697 698 bool init_terminal(terminal_t *term, widget_t *parent, sysarg_t width,699 sysarg_t height)700 { 701 widget_init(&term->widget, parent );698 bool init_terminal(terminal_t *term, widget_t *parent, const void *data, 699 sysarg_t width, sysarg_t height) 700 { 701 widget_init(&term->widget, parent, data); 702 702 703 703 link_initialize(&term->link); … … 771 771 } 772 772 773 terminal_t *create_terminal(widget_t *parent, sysarg_t width, sysarg_t height) 773 terminal_t *create_terminal(widget_t *parent, const void *data, sysarg_t width, 774 sysarg_t height) 774 775 { 775 776 terminal_t *term = (terminal_t *) malloc(sizeof(terminal_t)); … … 777 778 return NULL; 778 779 779 bool ret = init_terminal(term, parent, width, height);780 bool ret = init_terminal(term, parent, data, width, height); 780 781 if (!ret) { 781 782 free(term); -
uspace/lib/gui/terminal.h
r58563585 r10cb47e 70 70 } terminal_t; 71 71 72 extern bool init_terminal(terminal_t *, widget_t *, sysarg_t, sysarg_t); 73 extern terminal_t *create_terminal(widget_t *, sysarg_t, sysarg_t); 72 extern bool init_terminal(terminal_t *, widget_t *, const void *, sysarg_t, 73 sysarg_t); 74 extern terminal_t *create_terminal(widget_t *, const void *, sysarg_t, 75 sysarg_t); 74 76 extern void deinit_terminal(terminal_t *); 75 77 -
uspace/lib/gui/widget.c
r58563585 r10cb47e 36 36 #include "widget.h" 37 37 38 void widget_init(widget_t *widget, widget_t *parent) 38 /** Link widget with parent and initialize default position and size. */ 39 void widget_init(widget_t *widget, widget_t *parent, const void *data) 39 40 { 40 41 link_initialize(&widget->link); 41 42 list_initialize(&widget->children); 43 42 44 if (parent) { 43 45 widget->parent = parent; … … 48 50 widget->window = NULL; 49 51 } 50 52 53 widget->data = data; 54 51 55 widget->hpos = 0; 52 56 widget->vpos = 0; 53 57 widget->width = 0; 54 58 widget->height = 0; 55 59 56 60 widget->width_min = 0; 57 61 widget->height_min = 0; … … 62 66 } 63 67 68 /** Change position and size of the widget. */ 64 69 void widget_modify(widget_t *widget, sysarg_t hpos, sysarg_t vpos, 65 70 sysarg_t width, sysarg_t height) … … 71 76 } 72 77 78 /** Get custom client data */ 79 const void *widget_get_data(widget_t *widget) 80 { 81 return widget->data; 82 } 83 84 /** Unlink widget from its parent. */ 73 85 void widget_deinit(widget_t *widget) 74 86 { 75 if (widget->parent) {87 if (widget->parent) 76 88 list_remove(&widget->link); 77 }78 89 } 79 90 -
uspace/lib/gui/widget.h
r58563585 r10cb47e 53 53 struct widget { 54 54 link_t link; 55 widget_t *parent; /**< Parent widget of this widget. NULL for root widget. */ 56 list_t children; /**< Children widgets of this widget. */ 57 window_t *window; /**< Window into which this widget belongs. */ 58 55 widget_t *parent; /**< Parent widget of this widget. NULL for root widget. */ 56 list_t children; /**< Children widgets of this widget. */ 57 window_t *window; /**< Window into which this widget belongs. */ 58 const void *data; /**< Custom client data. */ 59 59 60 sysarg_t hpos; /**< Horizontal position in window coordinates. */ 60 61 sysarg_t vpos; /**< Vertical position in window coordinates. */ … … 128 129 */ 129 130 130 /** Link widget with parent and initialize default position and size. */ 131 extern void widget_init(widget_t *, widget_t *); 132 /** Just convenience function to change position and size of the widget. */ 131 extern void widget_init(widget_t *, widget_t *, const void *); 133 132 extern void widget_modify(widget_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t); 134 /** Unlink widget from its parent. */ 133 extern const void *widget_get_data(widget_t *); 135 134 extern void widget_deinit(widget_t *); 136 135 -
uspace/lib/gui/window.c
r58563585 r10cb47e 591 591 } 592 592 593 window_t *window_open(const char *winreg, window_flags_t flags,594 const char *caption)593 window_t *window_open(const char *winreg, const void *data, 594 window_flags_t flags, const char *caption) 595 595 { 596 596 window_t *win = (window_t *) malloc(sizeof(window_t)); … … 604 604 fibril_mutex_initialize(&win->guard); 605 605 606 widget_init(&win->root, NULL );606 widget_init(&win->root, NULL, data); 607 607 win->root.window = win; 608 608 win->root.destroy = root_destroy; -
uspace/lib/gui/window.h
r58563585 r10cb47e 67 67 * whole application. Note that opened window does not have any surface yet. 68 68 */ 69 extern window_t *window_open(const char *, window_flags_t, const char *); 69 extern window_t *window_open(const char *, const void *, window_flags_t, 70 const char *); 70 71 71 72 /**
Note:
See TracChangeset
for help on using the changeset viewer.