Changeset 62223ec in mainline for uspace/lib/ui/src


Ignore:
Timestamp:
2021-04-09T22:41:22Z (4 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f251883
Parents:
0262f16c
git-author:
Jiri Svoboda <jiri@…> (2021-04-01 21:04:11)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-04-09 22:41:22)
Message:

Close menu when window is unfocused

This of course means we need to do all the plumbing for delivering
unfocus event to UI controls.

Location:
uspace/lib/ui/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/control.c

    r0262f16c r62223ec  
    112112}
    113113
     114/** Inform UI control that window has been unfocused.
     115 *
     116 * @param control Control
     117 */
     118void ui_control_unfocus(ui_control_t *control)
     119{
     120        if (control->ops->unfocus != NULL)
     121                control->ops->unfocus(control->ext);
     122}
     123
    114124/** @}
    115125 */
  • uspace/lib/ui/src/fixed.c

    r0262f16c r62223ec  
    4747static errno_t ui_fixed_ctl_paint(void *);
    4848static ui_evclaim_t ui_fixed_ctl_pos_event(void *, pos_event_t *);
     49static void ui_fixed_ctl_unfocus(void *);
    4950
    5051/** Push button control ops */
     
    5253        .destroy = ui_fixed_ctl_destroy,
    5354        .paint = ui_fixed_ctl_paint,
    54         .pos_event = ui_fixed_ctl_pos_event
     55        .pos_event = ui_fixed_ctl_pos_event,
     56        .unfocus = ui_fixed_ctl_unfocus
    5557};
    5658
     
    232234}
    233235
     236/** Handle fixed layout window unfocus notification.
     237 *
     238 * @param fixed Fixed layout
     239 */
     240void ui_fixed_unfocus(ui_fixed_t *fixed)
     241{
     242        ui_fixed_elem_t *elem;
     243
     244        elem = ui_fixed_first(fixed);
     245        while (elem != NULL) {
     246                ui_control_unfocus(elem->control);
     247
     248                elem = ui_fixed_next(elem);
     249        }
     250}
     251
    234252/** Destroy fixed layout control.
    235253 *
     
    268286}
    269287
     288/** Handle fixed layout control window unfocus notification.
     289 *
     290 * @param arg Argument (ui_fixed_t *)
     291 */
     292void ui_fixed_ctl_unfocus(void *arg)
     293{
     294        ui_fixed_t *fixed = (ui_fixed_t *) arg;
     295
     296        ui_fixed_unfocus(fixed);
     297}
     298
    270299/** @}
    271300 */
  • uspace/lib/ui/src/menubar.c

    r0262f16c r62223ec  
    6060static errno_t ui_menu_bar_ctl_paint(void *);
    6161static ui_evclaim_t ui_menu_bar_ctl_pos_event(void *, pos_event_t *);
     62static void ui_menu_bar_ctl_unfocus(void *);
    6263
    6364/** Menu bar control ops */
     
    6566        .destroy = ui_menu_bar_ctl_destroy,
    6667        .paint = ui_menu_bar_ctl_paint,
    67         .pos_event = ui_menu_bar_ctl_pos_event
     68        .pos_event = ui_menu_bar_ctl_pos_event,
     69        .unfocus = ui_menu_bar_ctl_unfocus
    6870};
    6971
     
    328330}
    329331
     332/** Handle menu bar window unfocus notification.
     333 *
     334 * @param mbar Menu bar
     335 */
     336void ui_menu_bar_unfocus(ui_menu_bar_t *mbar)
     337{
     338        ui_menu_bar_select(mbar, NULL, NULL);
     339}
     340
    330341/** Destroy menu bar control.
    331342 *
     
    364375}
    365376
     377/** Handle menu bar control window unfocus notification.
     378 *
     379 * @param arg Argument (ui_menu_bar_t *)
     380 */
     381void ui_menu_bar_ctl_unfocus(void *arg)
     382{
     383        ui_menu_bar_t *mbar = (ui_menu_bar_t *) arg;
     384
     385        ui_menu_bar_unfocus(mbar);
     386}
     387
    366388/** @}
    367389 */
  • uspace/lib/ui/src/window.c

    r0262f16c r62223ec  
    815815        if (window->cb != NULL && window->cb->unfocus != NULL)
    816816                window->cb->unfocus(window, window->arg);
     817        else
     818                return ui_window_def_unfocus(window);
    817819}
    818820
     
    850852 *
    851853 * @param window Window
    852  * @return EOK on success or an error code
    853854 */
    854855void ui_window_def_pos(ui_window_t *window, pos_event_t *pos)
     
    856857        if (window->control != NULL)
    857858                ui_control_pos_event(window->control, pos);
     859}
     860
     861/** Default window unfocus routine.
     862 *
     863 * @param window Window
     864 * @return EOK on success or an error code
     865 */
     866void ui_window_def_unfocus(ui_window_t *window)
     867{
     868        if (window->control != NULL)
     869                ui_control_unfocus(window->control);
    858870}
    859871
Note: See TracChangeset for help on using the changeset viewer.