Changeset 1c6c3e1d in mainline for uspace/lib/ui/src/menuentry.c


Ignore:
Timestamp:
2023-10-22T17:55:33Z (14 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
ticket/834-toolchain-update
Children:
350ec74
Parents:
315d487 (diff), 133461c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ticket

File:
1 edited

Legend:

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

    r315d487 r1c6c3e1d  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    163163}
    164164
     165/** Set menu entry disabled flag.
     166 *
     167 * @param mentry Menu entry
     168 * @param disabled @c true iff entry is to be disabled, @c false otherwise
     169 */
     170void ui_menu_entry_set_disabled(ui_menu_entry_t *mentry, bool disabled)
     171{
     172        mentry->disabled = disabled;
     173}
     174
     175/** Get menu entry disabled flag.
     176 *
     177 * @param mentry Menu entry
     178 * @return disabled @c true iff entry is disabled, @c false otherwise
     179 */
     180bool ui_menu_entry_is_disabled(ui_menu_entry_t *mentry)
     181{
     182        return mentry->disabled;
     183}
     184
    165185/** Get first menu entry in menu.
    166186 *
     
    241261         * This needs to work even if the menu is not open, so we cannot
    242262         * use the menu's resource, which is only created after the menu
    243          * is open (and its window is created). Use the menu bar's
     263         * is open (and its window is created). Use the parent window's
    244264         * resource instead.
    245265         */
    246         res = ui_window_get_res(mentry->menu->mbar->window);
     266        res = ui_window_get_res(mentry->menu->parent);
    247267
    248268        *caption_w = ui_text_width(res->font, mentry->caption);
     
    267287         * This needs to work even if the menu is not open, so we cannot
    268288         * use the menu's resource, which is only created after the menu
    269          * is open (and its window is created). Use the menu bar's
     289         * is open (and its window is created). Use the parent window's
    270290         * resource instead.
    271291         */
    272         res = ui_window_get_res(menu->mbar->window);
     292        res = ui_window_get_res(menu->parent);
    273293
    274294        if (res->textmode)
     
    306326         * This needs to work even if the menu is not open, so we cannot
    307327         * use the menu's resource, which is only created after the menu
    308          * is open (and its window is created). Use the menu bar's
     328         * is open (and its window is created). Use the parent window's
    309329         * resource instead.
    310330         */
    311         res = ui_window_get_res(mentry->menu->mbar->window);
     331        res = ui_window_get_res(mentry->menu->parent);
    312332
    313333        if (res->textmode) {
     
    372392                fmt.hgl_color = res->wnd_sel_text_hgl_color;
    373393                bg_color = res->wnd_sel_text_bg_color;
     394        } else if (mentry->disabled) {
     395                fmt.color = res->wnd_dis_text_color;
     396                fmt.hgl_color = res->wnd_dis_text_color;
     397                bg_color = res->wnd_face_color;
    374398        } else {
    375399                fmt.color = res->wnd_text_color;
     
    445469                return;
    446470
    447         if (mentry->separator)
     471        if (mentry->separator || mentry->disabled)
    448472                return;
    449473
     
    474498void ui_menu_entry_activate(ui_menu_entry_t *mentry)
    475499{
    476         /* Deactivate menu bar, close menu */
    477         ui_menu_bar_deactivate(mentry->menu->mbar);
     500        /* Close menu */
     501        ui_menu_close_req(mentry->menu);
    478502
    479503        /* Call back */
Note: See TracChangeset for help on using the changeset viewer.