Changeset 86fff971 in mainline for uspace/lib/ui/src/wdecor.c


Ignore:
Timestamp:
2022-04-04T18:49:30Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd05ea6
Parents:
d68239a1
Message:

'X' does not mark the spot

Stop misusing 'X' character as a cross mark, create a routine for
drawing a cross and use it as a custom decoration for the close button.
Also use it for checkbox cross.

File:
1 edited

Legend:

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

    rd68239a1 r86fff971  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5050
    5151static void ui_wdecor_btn_clicked(ui_pbutton_t *, void *);
     52static errno_t ui_wdecor_btn_close_paint(ui_pbutton_t *, void *,
     53    gfx_coord2_t *);
    5254
    5355static ui_pbutton_cb_t ui_wdecor_btn_close_cb = {
    5456        .clicked = ui_wdecor_btn_clicked
     57};
     58
     59static ui_pbutton_decor_ops_t ui_wdecor_btn_close_decor_ops = {
     60        .paint = ui_wdecor_btn_close_paint
    5561};
    5662
     
    6268        wdecor_tbar_h = 22,
    6369        wdecor_frame_w = 4,
    64         wdecor_frame_w_text = 1
     70        wdecor_frame_w_text = 1,
     71        wdecor_close_cross_n = 5,
     72        wdecor_close_cross_w = 2,
     73        wdecor_close_cross_h = 1
    6574};
    6675
     
    98107        ui_pbutton_set_cb(wdecor->btn_close, &ui_wdecor_btn_close_cb,
    99108            (void *)wdecor);
     109
     110        ui_pbutton_set_decor_ops(wdecor->btn_close,
     111            &ui_wdecor_btn_close_decor_ops, (void *)wdecor);
    100112
    101113        wdecor->res = resource;
     
    647659}
    648660
     661/** Paint close button decoration.
     662 *
     663 * @param pbutton Push button
     664 * @param arg Argument (ui_wdecor_t *)
     665 * @param pos Center position
     666 */
     667static errno_t ui_wdecor_btn_close_paint(ui_pbutton_t *pbutton,
     668    void *arg, gfx_coord2_t *pos)
     669{
     670        ui_wdecor_t *wdecor = (ui_wdecor_t *)arg;
     671        gfx_coord2_t p;
     672        errno_t rc;
     673
     674        rc = gfx_set_color(wdecor->res->gc, wdecor->res->btn_text_color);
     675        if (rc != EOK)
     676                return rc;
     677
     678        p.x = pos->x - 1;
     679        p.y = pos->y - 1;
     680        return ui_paint_cross(wdecor->res->gc, &p, wdecor_close_cross_n,
     681            wdecor_close_cross_w, wdecor_close_cross_h);
     682}
     683
    649684/** @}
    650685 */
Note: See TracChangeset for help on using the changeset viewer.