Ignore:
File:
1 edited

Legend:

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

    rff6e91b rd7f82635  
    5858        menu_frame_h = 4,
    5959        menu_frame_w_text = 2,
    60         menu_frame_h_text = 1,
    61         menu_frame_h_margin_text = 1
     60        menu_frame_h_text = 1
    6261};
    6362
     
    277276 * @return EOK on success or an error code
    278277 */
    279 errno_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;
    310 error:
    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  */
    320 errno_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;
    351 error:
    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  */
    361278errno_t ui_menu_paint(ui_menu_t *menu, gfx_coord2_t *spos)
    362279{
     
    365282        ui_menu_entry_t *mentry;
    366283        ui_menu_geom_t geom;
     284        gfx_rect_t bg_rect;
    367285        errno_t rc;
    368286
     
    370288        ui_menu_get_geom(menu, spos, &geom);
    371289
    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);
     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);
    377307        if (rc != EOK)
    378308                goto error;
Note: See TracChangeset for help on using the changeset viewer.