Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0262f16c in mainline for uspace/lib/ui/src/menu.c


Ignore:
Timestamp:
2021-04-09T22:41:22Z (8 months ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master
Children:
62223ec
Parents:
214aefb
git-author:
Jiri Svoboda <jiri@…> (2021-04-01 16:23:35)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-04-09 22:41:22)
Message:

Activate menu entry by clicking (instead of simple press)

This allows for visual feedback and also serves as the confirmation
of correctness/intent (same as with push button).

File:
1 edited

Legend:

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

    r214aefb r0262f16c  
    292292 * @param menu Menu
    293293 * @param spos Starting position (top-left corner)
    294  * @param ppos Press position
    295  */
    296 void ui_menu_press(ui_menu_t *menu, gfx_coord2_t *spos, gfx_coord2_t *ppos)
     294 * @param event Position event
     295 * @return ui_claimed iff the event was claimed
     296 */
     297ui_evclaim_t ui_menu_pos_event(ui_menu_t *menu, gfx_coord2_t *spos,
     298    pos_event_t *event)
    297299{
    298300        ui_menu_geom_t geom;
    299301        ui_menu_entry_t *mentry;
    300302        gfx_coord2_t pos;
     303        gfx_coord2_t epos;
     304        ui_evclaim_t claimed;
    301305
    302306        ui_menu_get_geom(menu, spos, &geom);
     307        epos.x = event->hpos;
     308        epos.y = event->vpos;
    303309
    304310        pos = geom.entries_rect.p0;
     
    306312        mentry = ui_menu_entry_first(menu);
    307313        while (mentry != NULL) {
    308                 ui_menu_entry_press(mentry, &pos, ppos);
     314                claimed = ui_menu_entry_pos_event(mentry, &pos, event);
     315                if (claimed == ui_claimed)
     316                        return ui_claimed;
    309317
    310318                pos.y += ui_menu_entry_height(mentry);
    311319                mentry = ui_menu_entry_next(mentry);
    312320        }
     321
     322        if (gfx_pix_inside_rect(&epos, &geom.outer_rect))
     323                return ui_claimed;
     324
     325        return ui_unclaimed;
    313326}
    314327
Note: See TracChangeset for help on using the changeset viewer.