diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-15 12:46:12 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-15 12:46:12 +0300 |
commit | 00a67e05bd6b1b2a8a8a65b3611c59c3a253e755 (patch) | |
tree | d29ca21e29e53b11d700756f2eafeec1e780a4c5 /src/ui/labelwidget.c | |
parent | c013b8f50c102df14ecf8327ca1a3cb023247086 (diff) |
Mobile: Draw Identity button as outline
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r-- | src/ui/labelwidget.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index febaa15b..09c5812b 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -44,6 +44,7 @@ struct Impl_LabelWidget { | |||
44 | struct { | 44 | struct { |
45 | uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ | 45 | uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ |
46 | uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ | 46 | uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ |
47 | uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ | ||
47 | } flags; | 48 | } flags; |
48 | }; | 49 | }; |
49 | 50 | ||
@@ -348,14 +349,14 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
348 | cstr_String(&d->label)); | 349 | cstr_String(&d->label)); |
349 | } | 350 | } |
350 | else { | 351 | else { |
351 | drawCentered_Text(d->font, | 352 | drawCenteredOutline_Text( |
352 | adjusted_Rect(bounds, | 353 | d->font, |
353 | add_I2(zero_I2(), init_I2(iconPad, 0)), | 354 | adjusted_Rect(bounds, add_I2(zero_I2(), init_I2(iconPad, 0)), neg_I2(zero_I2())), |
354 | neg_I2(zero_I2())), | 355 | d->flags.alignVisual, |
355 | d->flags.alignVisual, | 356 | d->flags.drawAsOutline ? fg : none_ColorId, |
356 | fg, | 357 | d->flags.drawAsOutline ? d->widget.bgColor : fg, |
357 | "%s", | 358 | "%s", |
358 | cstr_String(&d->label)); | 359 | cstr_String(&d->label)); |
359 | } | 360 | } |
360 | if (flags & chevron_WidgetFlag) { | 361 | if (flags & chevron_WidgetFlag) { |
361 | const iRect chRect = rect; | 362 | const iRect chRect = rect; |
@@ -442,6 +443,7 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | |||
442 | setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); | 443 | setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); |
443 | d->flags.alignVisual = iFalse; | 444 | d->flags.alignVisual = iFalse; |
444 | d->flags.noAutoMinHeight = iFalse; | 445 | d->flags.noAutoMinHeight = iFalse; |
446 | d->flags.drawAsOutline = iFalse; | ||
445 | updateSize_LabelWidget(d); | 447 | updateSize_LabelWidget(d); |
446 | updateKey_LabelWidget_(d); /* could be bound to another key */ | 448 | updateKey_LabelWidget_(d); /* could be bound to another key */ |
447 | } | 449 | } |
@@ -481,6 +483,10 @@ void setNoAutoMinHeight_LabelWidget(iLabelWidget *d, iBool noAutoMinHeight) { | |||
481 | } | 483 | } |
482 | } | 484 | } |
483 | 485 | ||
486 | void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { | ||
487 | d->flags.drawAsOutline = drawAsOutline; | ||
488 | } | ||
489 | |||
484 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { | 490 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { |
485 | set_String(&d->label, text); | 491 | set_String(&d->label, text); |
486 | set_String(&d->srcLabel, text); | 492 | set_String(&d->srcLabel, text); |