diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-05 15:03:38 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-05 15:03:38 +0200 |
commit | a3457b5d756f434e887288341559a9e5fa6f9f69 (patch) | |
tree | 5e627e6eba584b0be4c47256695f8c39efc6915a /src/ui/labelwidget.c | |
parent | 71f3f34782aa6050ede4bf143fa6028653adae6d (diff) |
Defined a set of UI icons; use in menus
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r-- | src/ui/labelwidget.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 83deafe2..3ebec790 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -247,9 +247,11 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
247 | (iRect){ addX_I2(add_I2(bounds.pos, padding_(flags)), -2 * gap_UI), | 247 | (iRect){ addX_I2(add_I2(bounds.pos, padding_(flags)), -2 * gap_UI), |
248 | init_I2(iconPad, lineHeight_Text(d->font)) }, | 248 | init_I2(iconPad, lineHeight_Text(d->font)) }, |
249 | iTrue, | 249 | iTrue, |
250 | flags & pressed_WidgetFlag ? fg | 250 | startsWith_String(&d->label, uiTextCaution_ColorEscape) |
251 | : isHover ? uiIconHover_ColorId | 251 | ? uiTextCaution_ColorId |
252 | : uiIcon_ColorId, | 252 | : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg |
253 | : isHover ? uiIconHover_ColorId | ||
254 | : uiIcon_ColorId, | ||
253 | "%s", | 255 | "%s", |
254 | cstr_String(&str)); | 256 | cstr_String(&str)); |
255 | deinit_String(&str); | 257 | deinit_String(&str); |
@@ -410,16 +412,17 @@ void setIcon_LabelWidget(iLabelWidget *d, iChar icon) { | |||
410 | } | 412 | } |
411 | 413 | ||
412 | iBool checkIcon_LabelWidget(iLabelWidget *d) { | 414 | iBool checkIcon_LabelWidget(iLabelWidget *d) { |
413 | if (!d->icon) { | 415 | iStringConstIterator iter; |
414 | iStringConstIterator iter; | 416 | init_StringConstIterator(&iter, &d->label); |
415 | init_StringConstIterator(&iter, &d->label); | 417 | const iChar icon = iter.value; |
416 | const iChar icon = iter.value; | 418 | next_StringConstIterator(&iter); |
417 | next_StringConstIterator(&iter); | 419 | if (iter.value == ' ' && icon >= 0x100) { |
418 | if (iter.value == ' ' && icon >= 0x100) { | 420 | d->icon = icon; |
419 | d->icon = icon; | 421 | remove_Block(&d->label.chars, 0, iter.next - constBegin_String(&d->label)); |
420 | remove_Block(&d->label.chars, 0, iter.next - constBegin_String(&d->label)); | 422 | return iTrue; |
421 | return iTrue; | 423 | } |
422 | } | 424 | else { |
425 | d->icon = 0; | ||
423 | } | 426 | } |
424 | return iFalse; | 427 | return iFalse; |
425 | } | 428 | } |