Changeset 8a9a41e in mainline for uspace/lib/ui/src/menu.c


Ignore:
Timestamp:
2021-10-24T08:28:43Z (2 years ago)
Author:
GitHub <noreply@…>
Children:
f628215
Parents:
2ce943a (diff), cd981f2a (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.
git-author:
Erik Kučák <35500848+Riko196@…> (2021-10-24 08:28:43)
git-committer:
GitHub <noreply@…> (2021-10-24 08:28:43)
Message:

Merge branch 'HelenOS:master' into master

File:
1 edited

Legend:

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

    r2ce943a r8a9a41e  
    5858        menu_frame_h = 4,
    5959        menu_frame_w_text = 2,
    60         menu_frame_h_text = 1
     60        menu_frame_h_text = 1,
     61        menu_frame_h_margin_text = 1
    6162};
    6263
     
    276277 * @return EOK on success or an error code
    277278 */
     279errno_t ui_menu_paint_bg_gfx(ui_menu_t *menu, gfx_coord2_t *spos)
     280{
     281        ui_resource_t *res;
     282        ui_menu_geom_t geom;
     283        gfx_rect_t bg_rect;
     284        errno_t rc;
     285
     286        res = ui_menu_get_res(menu);
     287        ui_menu_get_geom(menu, spos, &geom);
     288
     289        /* Paint menu frame */
     290
     291        rc = gfx_set_color(res->gc, res->wnd_face_color);
     292        if (rc != EOK)
     293                goto error;
     294
     295        rc = ui_paint_outset_frame(res, &geom.outer_rect, &bg_rect);
     296        if (rc != EOK)
     297                goto error;
     298
     299        /* Paint menu background */
     300
     301        rc = gfx_set_color(res->gc, res->wnd_face_color);
     302        if (rc != EOK)
     303                goto error;
     304
     305        rc = gfx_fill_rect(res->gc, &bg_rect);
     306        if (rc != EOK)
     307                goto error;
     308
     309        return EOK;
     310error:
     311        return rc;
     312}
     313
     314/** Paint menu.
     315 *
     316 * @param menu Menu
     317 * @param spos Starting position (top-left corner)
     318 * @return EOK on success or an error code
     319 */
     320errno_t ui_menu_paint_bg_text(ui_menu_t *menu, gfx_coord2_t *spos)
     321{
     322        ui_resource_t *res;
     323        ui_menu_geom_t geom;
     324        gfx_rect_t rect;
     325        errno_t rc;
     326
     327        res = ui_menu_get_res(menu);
     328        ui_menu_get_geom(menu, spos, &geom);
     329
     330        /* Paint menu background */
     331
     332        rc = gfx_set_color(res->gc, res->wnd_face_color);
     333        if (rc != EOK)
     334                goto error;
     335
     336        rc = gfx_fill_rect(res->gc, &geom.outer_rect);
     337        if (rc != EOK)
     338                goto error;
     339
     340        /* Paint menu box */
     341
     342        rect = geom.outer_rect;
     343        rect.p0.x += menu_frame_h_margin_text;
     344        rect.p1.x -= menu_frame_h_margin_text;
     345
     346        rc = ui_paint_text_box(res, &rect, ui_box_single, res->wnd_face_color);
     347        if (rc != EOK)
     348                goto error;
     349
     350        return EOK;
     351error:
     352        return rc;
     353}
     354
     355/** Paint menu.
     356 *
     357 * @param menu Menu
     358 * @param spos Starting position (top-left corner)
     359 * @return EOK on success or an error code
     360 */
    278361errno_t ui_menu_paint(ui_menu_t *menu, gfx_coord2_t *spos)
    279362{
     
    282365        ui_menu_entry_t *mentry;
    283366        ui_menu_geom_t geom;
    284         gfx_rect_t bg_rect;
    285367        errno_t rc;
    286368
     
    288370        ui_menu_get_geom(menu, spos, &geom);
    289371
    290         /* Paint menu frame */
    291 
    292         rc = gfx_set_color(res->gc, res->wnd_face_color);
    293         if (rc != EOK)
    294                 goto error;
    295 
    296         rc = ui_paint_outset_frame(res, &geom.outer_rect, &bg_rect);
    297         if (rc != EOK)
    298                 goto error;
    299 
    300         /* Paint menu background */
    301 
    302         rc = gfx_set_color(res->gc, res->wnd_face_color);
    303         if (rc != EOK)
    304                 goto error;
    305 
    306         rc = gfx_fill_rect(res->gc, &bg_rect);
     372        /* Paint menu frame and background */
     373        if (res->textmode)
     374                rc = ui_menu_paint_bg_text(menu, spos);
     375        else
     376                rc = ui_menu_paint_bg_gfx(menu, spos);
    307377        if (rc != EOK)
    308378                goto error;
Note: See TracChangeset for help on using the changeset viewer.