Changeset b71c0fc in mainline for uspace/lib/ui/src
- Timestamp:
- 2020-11-07T16:07:22Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d55ab823
- Parents:
- fa01c05
- Location:
- uspace/lib/ui/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/control.c
rfa01c05 rb71c0fc 81 81 * extended data). 82 82 * 83 * @param control Control 83 * @param control Control or @c NULL 84 84 */ 85 85 void ui_control_destroy(ui_control_t *control) 86 86 { 87 if (control == NULL) 88 return; 89 87 90 return control->ops->destroy(control->ext); 88 91 } -
uspace/lib/ui/src/fixed.c
rfa01c05 rb71c0fc 44 44 #include "../private/fixed.h" 45 45 46 static void ui_fixed_ctl_destroy(void *); 47 static errno_t ui_fixed_ctl_paint(void *); 48 static ui_evclaim_t ui_fixed_ctl_pos_event(void *, pos_event_t *); 49 50 /** Push button control ops */ 51 ui_control_ops_t ui_fixed_ops = { 52 .destroy = ui_fixed_ctl_destroy, 53 .paint = ui_fixed_ctl_paint, 54 .pos_event = ui_fixed_ctl_pos_event 55 }; 56 46 57 /** Create new fixed layout. 47 58 * … … 52 63 { 53 64 ui_fixed_t *fixed; 65 errno_t rc; 54 66 55 67 fixed = calloc(1, sizeof(ui_fixed_t)); 56 68 if (fixed == NULL) 57 69 return ENOMEM; 70 71 rc = ui_control_new(&ui_fixed_ops, (void *) fixed, &fixed->control); 72 if (rc != EOK) { 73 free(fixed); 74 return rc; 75 } 58 76 59 77 list_initialize(&fixed->elem); … … 83 101 } 84 102 103 ui_control_delete(fixed->control); 85 104 free(fixed); 105 } 106 107 /** Get base control from fixed layout. 108 * 109 * @param fixed Fixed layout 110 * @return Control 111 */ 112 ui_control_t *ui_fixed_ctl(ui_fixed_t *fixed) 113 { 114 return fixed->control; 86 115 } 87 116 … … 203 232 } 204 233 234 /** Destroy fixed layout control. 235 * 236 * @param arg Argument (ui_fixed_t *) 237 */ 238 void ui_fixed_ctl_destroy(void *arg) 239 { 240 ui_fixed_t *fixed = (ui_fixed_t *) arg; 241 242 ui_fixed_destroy(fixed); 243 } 244 245 /** Paint fixed layout control. 246 * 247 * @param arg Argument (ui_fixed_t *) 248 * @return EOK on success or an error code 249 */ 250 errno_t ui_fixed_ctl_paint(void *arg) 251 { 252 ui_fixed_t *fixed = (ui_fixed_t *) arg; 253 254 return ui_fixed_paint(fixed); 255 } 256 257 /** Handle fixed layout control position event. 258 * 259 * @param arg Argument (ui_fixed_t *) 260 * @param pos_event Position event 261 * @return @c ui_claimed iff the event is claimed 262 */ 263 ui_evclaim_t ui_fixed_ctl_pos_event(void *arg, pos_event_t *event) 264 { 265 ui_fixed_t *fixed = (ui_fixed_t *) arg; 266 267 return ui_fixed_pos_event(fixed, event); 268 } 269 205 270 /** @} 206 271 */ -
uspace/lib/ui/src/window.c
rfa01c05 rb71c0fc 42 42 #include <mem.h> 43 43 #include <stdlib.h> 44 #include <ui/control.h> 44 45 #include <ui/resource.h> 45 46 #include <ui/wdecor.h> 46 47 #include <ui/window.h> 48 #include "../private/control.h" 47 49 #include "../private/dummygc.h" 48 50 #include "../private/resource.h" … … 170 172 return; 171 173 174 ui_control_destroy(window->control); 172 175 ui_wdecor_destroy(window->wdecor); 173 176 ui_resource_destroy(window->res); … … 177 180 } 178 181 182 /** Add control to window. 183 * 184 * Only one control can be added to a window. If more than one control 185 * is added, the results are undefined. 186 * 187 * @param fixed Fixed layout 188 * @param control Control 189 * @return EOK on success, ENOMEM if out of memory 190 */ 191 void ui_window_add(ui_window_t *window, ui_control_t *control) 192 { 193 assert(window->control == NULL); 194 195 window->control = control; 196 control->elemp = (void *) window; 197 } 198 199 /** Remove control from window. 200 * 201 * @param window Window 202 * @param control Control 203 */ 204 void ui_window_remove(ui_window_t *window, ui_control_t *control) 205 { 206 assert(window->control == control); 207 assert((ui_window_t *) control->elemp == window); 208 209 window->control = NULL; 210 control->elemp = NULL; 211 } 212 179 213 /** Set window callbacks. 180 214 * … … 343 377 if (window->cb != NULL && window->cb->pos != NULL) 344 378 window->cb->pos(window, window->arg, pos); 379 else 380 ui_window_def_pos(window, pos); 345 381 } 346 382 … … 375 411 return rc; 376 412 413 if (window->control != NULL) 414 return ui_control_paint(window->control); 415 377 416 return EOK; 378 417 } 379 418 419 /** Default window position event routine. 420 * 421 * @param window Window 422 * @return EOK on success or an error code 423 */ 424 void ui_window_def_pos(ui_window_t *window, pos_event_t *pos) 425 { 426 if (window->control != NULL) 427 ui_control_pos_event(window->control, pos); 428 } 429 380 430 /** @} 381 431 */
Note:
See TracChangeset
for help on using the changeset viewer.