Changeset 68d68e9 in mainline for uspace/lib/ui/src/pbutton.c


Ignore:
Timestamp:
2022-11-23T12:50:27Z (17 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c4a53280
Parents:
6e91475
Message:

Vary window button size to fit

If they get too narrow, we stop adding more buttons.

File:
1 edited

Legend:

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

    r6e91475 r68d68e9  
    5454enum {
    5555        ui_pb_press_dx = 1,
    56         ui_pb_press_dy = 1
     56        ui_pb_press_dy = 1,
     57        ui_pb_pad_x = 2,
     58        ui_pb_pad_x_text = 1
    5759};
    5860
     
    323325        gfx_text_fmt_t fmt;
    324326        gfx_rect_t rect;
     327        gfx_rect_t irect;
    325328        gfx_coord_t thickness;
    326329        bool depressed;
     
    360363        } else {
    361364                /* Text decoration */
     365                ui_paint_get_inset_frame_inside(pbutton->res, &rect, &irect);
    362366                gfx_text_fmt_init(&fmt);
    363367                fmt.font = pbutton->res->font;
     
    365369                fmt.halign = gfx_halign_center;
    366370                fmt.valign = gfx_valign_center;
     371                fmt.abbreviate = true;
     372                fmt.width = irect.p1.x - irect.p0.x - 2 * ui_pb_pad_x;
    367373
    368374                rc = gfx_puttext(&pos, &fmt, pbutton->caption);
     
    442448        fmt.halign = gfx_halign_center;
    443449        fmt.valign = gfx_valign_center;
     450        fmt.abbreviate = true;
     451        fmt.width = rect.p1.x - rect.p0.x - 2 * ui_pb_pad_x_text;
    444452
    445453        rc = gfx_puttext(&pos, &fmt, pbutton->caption);
Note: See TracChangeset for help on using the changeset viewer.