Changeset 6aa85c1 in mainline for uspace/app/nav/menu.c


Ignore:
Timestamp:
2021-10-25T00:32:45Z (2 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b36ebb42
Parents:
5d466a1
git-author:
Jiri Svoboda <jiri@…> (2021-10-03 17:39:36)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
Message:

Add panel class and add unit tests for all classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/menu.c

    r5d466a1 r6aa85c1  
    4747/** Create navigator menu.
    4848 *
    49  * @param navigator Navigator
     49 * @param window Navigator window
    5050 * @param rmenu Place to store pointer to new menu
    5151 * @return EOK on success or an error code
    5252 */
    53 errno_t nav_menu_create(navigator_t *navigator, nav_menu_t **rmenu)
     53errno_t nav_menu_create(ui_window_t *window, nav_menu_t **rmenu)
    5454{
    5555        nav_menu_t *menu;
     
    6464                return ENOMEM;
    6565
    66         rc = ui_menu_bar_create(navigator->ui, navigator->window,
     66        menu->window = window;
     67        menu->ui = ui_window_get_ui(window);
     68
     69        rc = ui_menu_bar_create(menu->ui, menu->window,
    6770            &menu->menubar);
    6871        if (rc != EOK)
     
    7780                goto error;
    7881
    79         ui_menu_entry_set_cb(mexit, nav_file_exit, (void *) navigator);
     82        ui_menu_entry_set_cb(mexit, nav_file_exit, (void *) menu);
    8083
    81         ui_window_get_app_rect(navigator->window, &arect);
     84        ui_window_get_app_rect(menu->window, &arect);
    8285
    8386        rect.p0 = arect.p0;
     
    8689        ui_menu_bar_set_rect(menu->menubar, &rect);
    8790
    88         rc = ui_fixed_add(navigator->fixed, ui_menu_bar_ctl(menu->menubar));
    89         if (rc != EOK)
    90                 goto error;
    91 
    92         menu->navigator = navigator;
    9391        *rmenu = menu;
    9492        return EOK;
     
    104102void nav_menu_destroy(nav_menu_t *menu)
    105103{
    106         if (menu->menubar != NULL) {
    107                 ui_fixed_remove(menu->navigator->fixed,
    108                     ui_menu_bar_ctl(menu->menubar));
     104        if (menu->menubar != NULL)
    109105                ui_menu_bar_destroy(menu->menubar);
    110         }
    111106
    112107        free(menu);
     108}
     109
     110/** Return base UI control for the menu bar.
     111 *
     112 * @param menu Navigator menu
     113 * @return UI control
     114 */
     115ui_control_t *nav_menu_ctl(nav_menu_t *menu)
     116{
     117        return ui_menu_bar_ctl(menu->menubar);
    113118}
    114119
Note: See TracChangeset for help on using the changeset viewer.