Changeset 692c7f40 in mainline for uspace/app/nav/panel.c


Ignore:
Timestamp:
2021-10-25T00:32:45Z (3 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1eb0fafe
Parents:
2fb49522
git-author:
Jiri Svoboda <jiri@…> (2021-10-13 18:40:48)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
Message:

Panel activation

Active panel can be switched using the Tab key. Mouse activation is
not implemented.

File:
1 edited

Legend:

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

    r2fb49522 r692c7f40  
    6363 *
    6464 * @param window Containing window
     65 * @param active @c true iff panel should be active
    6566 * @param rpanel Place to store pointer to new panel
    6667 * @return EOK on success or an error code
    6768 */
    68 errno_t panel_create(ui_window_t *window, panel_t **rpanel)
     69errno_t panel_create(ui_window_t *window, bool active, panel_t **rpanel)
    6970{
    7071        panel_t *panel;
     
    9091                goto error;
    9192
     93        rc = gfx_color_new_ega(0x0f, &panel->act_border_color);
     94        if (rc != EOK)
     95                goto error;
     96
    9297        panel->window = window;
    9398        list_initialize(&panel->entries);
    9499        panel->entries_cnt = 0;
     100        panel->active = active;
    95101        *rpanel = panel;
    96102        return EOK;
     
    113119        gfx_color_delete(panel->color);
    114120        gfx_color_delete(panel->curs_color);
     121        gfx_color_delete(panel->act_border_color);
    115122        panel_clear_entries(panel);
    116123        ui_control_delete(panel->control);
     
    147154        pos.y = panel->rect.p0.y + 1 + entry_idx - panel->page_idx;
    148155
    149         if (entry == panel->cursor)
     156        if (entry == panel->cursor && panel->active)
    150157                fmt.color = panel->curs_color;
    151158        else
     
    182189        gfx_text_fmt_t fmt;
    183190        panel_entry_t *entry;
     191        ui_box_style_t bstyle;
     192        gfx_color_t *bcolor;
    184193        int i, lines;
    185194        errno_t rc;
     
    195204                return rc;
    196205
    197         rc = ui_paint_text_box(res, &panel->rect, ui_box_single,
    198             panel->color);
     206        if (panel->active) {
     207                bstyle = ui_box_double;
     208                bcolor = panel->act_border_color;
     209        } else {
     210                bstyle = ui_box_single;
     211                bcolor = panel->color;
     212        }
     213
     214        rc = ui_paint_text_box(res, &panel->rect, bstyle, bcolor);
    199215        if (rc != EOK)
    200216                return rc;
     
    228244ui_evclaim_t panel_kbd_event(panel_t *panel, kbd_event_t *event)
    229245{
     246        if (!panel->active)
     247                return ui_unclaimed;
     248
    230249        if (event->type == KEY_PRESS) {
    231250                if ((event->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
     
    255274        }
    256275
    257         return ui_unclaimed;
     276        return ui_claimed;
    258277}
    259278
     
    297316{
    298317        return panel->rect.p1.y - panel->rect.p0.y - 2;
     318}
     319
     320/** Determine if panel is active.
     321 *
     322 * @param panel Panel
     323 * @return @c true iff panel is active
     324 */
     325bool panel_is_active(panel_t *panel)
     326{
     327        return panel->active;
     328}
     329
     330/** Activate panel.
     331 *
     332 * @param panel Panel
     333 */
     334void panel_activate(panel_t *panel)
     335{
     336        panel->active = true;
     337        (void) panel_paint(panel);
     338}
     339
     340/** Deactivate panel.
     341 *
     342 * @param panel Panel
     343 */
     344void panel_deactivate(panel_t *panel)
     345{
     346        panel->active = false;
     347        (void) panel_paint(panel);
    299348}
    300349
Note: See TracChangeset for help on using the changeset viewer.