Changeset 58a67050 in mainline for uspace/lib/ui/src/label.c


Ignore:
Timestamp:
2020-10-21T22:26:33Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08a79303
Parents:
a2f173b
Message:

Support different label text alignment

File:
1 edited

Legend:

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

    ra2f173b r58a67050  
    6868
    6969        label->res = resource;
     70        label->halign = gfx_halign_left;
    7071        *rlabel = label;
    7172        return EOK;
     
    9293{
    9394        label->rect = *rect;
     95}
     96
     97/** Set label horizontal text alignment.
     98 *
     99 * @param label Label
     100 * @param halign Horizontal alignment
     101 */
     102void ui_label_set_halign(ui_label_t *label, gfx_halign_t halign)
     103{
     104        label->halign = halign;
    94105}
    95106
     
    135146                goto error;
    136147
    137         pos = label->rect.p0;
     148        switch (label->halign) {
     149        case gfx_halign_left:
     150        case gfx_halign_justify:
     151                pos.x = label->rect.p0.x;
     152                break;
     153        case gfx_halign_center:
     154                pos.x = (label->rect.p0.x + label->rect.p1.x) / 2;
     155                break;
     156        case gfx_halign_right:
     157                pos.y = label->rect.p1.x;
     158                break;
     159        }
     160
     161        pos.y = label->rect.p0.y;
    138162
    139163        gfx_text_fmt_init(&fmt);
    140         fmt.halign = gfx_halign_left;
     164        fmt.halign = label->halign;
    141165        fmt.valign = gfx_valign_top;
    142166
Note: See TracChangeset for help on using the changeset viewer.