summaryrefslogtreecommitdiff
path: root/src/ui/labelwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-25 10:59:28 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-25 10:59:28 +0300
commitc80331992585bfee3d65a7ba24f3a4b640c48735 (patch)
tree5eaa85a0a3a1c46bdca7cccfae0e7349e22f6d13 /src/ui/labelwidget.c
parent562a0d2d38c0621a296e8343270f3f1efc268156 (diff)
parent242e8231ea61278fe482020658be86c2dec0ae53 (diff)
Merge branch 'work/v1.7' into dev
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r--src/ui/labelwidget.c204
1 files changed, 127 insertions, 77 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index ef306ab9..cfc81863 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -44,11 +44,13 @@ struct Impl_LabelWidget {
44 iString command; 44 iString command;
45 iClick click; 45 iClick click;
46 struct { 46 struct {
47 uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ 47 uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */
48 uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ 48 uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */
49 uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ 49 uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */
50 uint8_t noTopFrame : 1; 50 uint8_t noTopFrame : 1;
51 uint8_t wrap : 1; 51 uint8_t wrap : 1;
52 uint8_t allCaps : 1;
53 uint8_t removeTrailingColon : 1;
52 } flags; 54 } flags;
53}; 55};
54 56
@@ -68,7 +70,7 @@ static iInt2 padding_LabelWidget_(const iLabelWidget *d, int corner) {
68 : corner == 1 ? init_I2(w->padding[2], w->padding[1]) 70 : corner == 1 ? init_I2(w->padding[2], w->padding[1])
69 : corner == 2 ? init_I2(w->padding[2], w->padding[3]) 71 : corner == 2 ? init_I2(w->padding[2], w->padding[3])
70 : init_I2(w->padding[0], w->padding[3])); 72 : init_I2(w->padding[0], w->padding[3]));
71#if defined (iPlatformAppleMobile) 73#if defined (iPlatformMobile)
72 return add_I2(widgetPad, 74 return add_I2(widgetPad,
73 init_I2(flags & tight_WidgetFlag ? 2 * gap_UI : (4 * gap_UI), 75 init_I2(flags & tight_WidgetFlag ? 2 * gap_UI : (4 * gap_UI),
74 (flags & extraPadding_WidgetFlag ? 1.5f : 1.0f) * 3 * gap_UI / 2)); 76 (flags & extraPadding_WidgetFlag ? 1.5f : 1.0f) * 3 * gap_UI / 2));
@@ -124,6 +126,11 @@ static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) {
124 updateKey_LabelWidget_(d); 126 updateKey_LabelWidget_(d);
125 return iFalse; 127 return iFalse;
126 } 128 }
129 else if (isCommand_Widget(w, ev, "focus.gained") ||
130 isCommand_Widget(w, ev, "focus.lost")) {
131 refresh_Widget(d);
132 return iFalse;
133 }
127 if (!isEmpty_String(&d->command)) { 134 if (!isEmpty_String(&d->command)) {
128#if 0 && defined (iPlatformAppleMobile) 135#if 0 && defined (iPlatformAppleMobile)
129 /* Touch allows activating any button on release. */ 136 /* Touch allows activating any button on release. */
@@ -159,8 +166,15 @@ static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) {
159 switch (ev->type) { 166 switch (ev->type) {
160 case SDL_KEYDOWN: { 167 case SDL_KEYDOWN: {
161 const int mods = ev->key.keysym.mod; 168 const int mods = ev->key.keysym.mod;
162 if (d->key && ev->key.keysym.sym == d->key && checkModifiers_(mods, d->kmods)) { 169 const int sym = ev->key.keysym.sym;
170 if (d->key && sym == d->key && checkModifiers_(mods, d->kmods)) {
171 trigger_LabelWidget_(d);
172 return iTrue;
173 }
174 if (isFocused_Widget(d) && mods == 0 &&
175 (sym == SDLK_RETURN || sym == SDLK_KP_ENTER)) {
163 trigger_LabelWidget_(d); 176 trigger_LabelWidget_(d);
177 refresh_Widget(d);
164 return iTrue; 178 return iTrue;
165 } 179 }
166 break; 180 break;
@@ -174,14 +188,17 @@ static void keyStr_LabelWidget_(const iLabelWidget *d, iString *str) {
174 toString_Sym(d->key, d->kmods, str); 188 toString_Sym(d->key, d->kmods, str);
175} 189}
176 190
177static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int *frame1, int *frame2) { 191static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int *frame1, int *frame2,
192 int *icon, int *meta) {
178 const iWidget *w = constAs_Widget(d); 193 const iWidget *w = constAs_Widget(d);
179 const int64_t flags = flags_Widget(w); 194 const int64_t flags = flags_Widget(w);
195 const iBool isFocus = (flags & focusable_WidgetFlag && isFocused_Widget(d));
180 const iBool isPress = (flags & pressed_WidgetFlag) != 0; 196 const iBool isPress = (flags & pressed_WidgetFlag) != 0;
181 const iBool isSel = (flags & selected_WidgetFlag) != 0; 197 const iBool isSel = (flags & selected_WidgetFlag) != 0;
182 const iBool isFrameless = (flags & frameless_WidgetFlag) != 0; 198 const iBool isFrameless = (flags & frameless_WidgetFlag) != 0;
183 const iBool isButton = d->click.button != 0; 199 const iBool isButton = d->click.button != 0;
184 const iBool isKeyRoot = (w->root == get_Window()->keyRoot); 200 const iBool isKeyRoot = (w->root == get_Window()->keyRoot);
201 const iBool isDarkTheme = isDark_ColorTheme(colorTheme_App());
185 /* Default color state. */ 202 /* Default color state. */
186 *bg = isButton && ~flags & noBackground_WidgetFlag ? (d->widget.bgColor != none_ColorId ? 203 *bg = isButton && ~flags & noBackground_WidgetFlag ? (d->widget.bgColor != none_ColorId ?
187 d->widget.bgColor : uiBackground_ColorId) 204 d->widget.bgColor : uiBackground_ColorId)
@@ -189,8 +206,12 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int
189 *fg = uiText_ColorId; 206 *fg = uiText_ColorId;
190 *frame1 = isButton ? uiEmboss1_ColorId : d->widget.frameColor; 207 *frame1 = isButton ? uiEmboss1_ColorId : d->widget.frameColor;
191 *frame2 = isButton ? uiEmboss2_ColorId : *frame1; 208 *frame2 = isButton ? uiEmboss2_ColorId : *frame1;
209 *icon = uiIcon_ColorId;
210 *meta = uiTextShortcut_ColorId;
192 if (flags & disabled_WidgetFlag && isButton) { 211 if (flags & disabled_WidgetFlag && isButton) {
193 *fg = uiTextDisabled_ColorId; 212 *icon = uiTextDisabled_ColorId;
213 *fg = uiTextDisabled_ColorId;
214 *meta = uiTextDisabled_ColorId;
194 } 215 }
195 if (isSel) { 216 if (isSel) {
196 *bg = uiBackgroundSelected_ColorId; 217 *bg = uiBackgroundSelected_ColorId;
@@ -210,9 +231,15 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int
210 } 231 }
211 } 232 }
212 } 233 }
234 if (isFocus) {
235 *frame1 = *frame2 = (isSel ? uiText_ColorId : uiInputFrameFocused_ColorId);
236 }
213 int colorEscape = none_ColorId; 237 int colorEscape = none_ColorId;
214 if (startsWith_String(&d->label, "\v")) { 238 if (startsWith_String(&d->label, "\v")) {
215 colorEscape = cstr_String(&d->label)[1] - asciiBase_ColorEscape; /* TODO: can be two bytes long */ 239 colorEscape = parseEscape_Color(cstr_String(&d->label), NULL);
240 }
241 if (colorEscape == uiTextCaution_ColorId) {
242 *icon = *meta = colorEscape;
216 } 243 }
217 if (isHover_LabelWidget_(d)) { 244 if (isHover_LabelWidget_(d)) {
218 if (isFrameless) { 245 if (isFrameless) {
@@ -221,43 +248,48 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int
221 } 248 }
222 else { 249 else {
223 /* Frames matching color escaped text. */ 250 /* Frames matching color escaped text. */
224 if (colorEscape != none_ColorId) { 251 if (colorEscape == uiTextCaution_ColorId) {
225 if (isDark_ColorTheme(colorTheme_App())) { 252 *frame1 = colorEscape;
226 *frame1 = colorEscape; 253 *frame2 = isDarkTheme ? darker_Color(*frame1) : lighter_Color(*frame1);
227 *frame2 = darker_Color(*frame1);
228 }
229 else {
230 *bg = *frame1 = *frame2 = colorEscape;
231 *fg = white_ColorId | permanent_ColorId;
232 }
233 } 254 }
234 else if (isSel) { 255 else if (isSel) {
235 *frame1 = uiEmbossSelectedHover1_ColorId; 256 *frame1 = uiEmbossSelectedHover1_ColorId;
236 *frame2 = uiEmbossSelectedHover2_ColorId; 257 *frame2 = uiEmbossSelectedHover2_ColorId;
237 } 258 }
238 else { 259 else {
239 if (isButton) *bg = uiBackgroundHover_ColorId;
240 *frame1 = uiEmbossHover1_ColorId; 260 *frame1 = uiEmbossHover1_ColorId;
241 *frame2 = uiEmbossHover2_ColorId; 261 *frame2 = uiEmbossHover2_ColorId;
242 } 262 }
243 } 263 }
264 if (colorEscape == uiTextCaution_ColorId) {
265 *icon = *meta = *fg = colorEscape;
266 *bg = isDarkTheme ? darker_Color(colorEscape) : lighter_Color(colorEscape);
267 }
268 }
269 if (d->forceFg >= 0) {
270 *fg = *icon = *meta = d->forceFg;
244 } 271 }
245 if (isPress) { 272 if (isPress) {
246 *bg = uiBackgroundPressed_ColorId | permanent_ColorId; 273 if (colorEscape == uiTextAction_ColorId || colorEscape == uiTextCaution_ColorId) {
247 if (isButton) { 274 *bg = colorEscape;
248 *frame1 = uiEmbossPressed1_ColorId; 275 *frame1 = *bg;
249 *frame2 = colorEscape != none_ColorId ? colorEscape : uiEmbossPressed2_ColorId; 276 *frame2 = *bg;
250 } 277 *fg = *icon = *meta = (isDarkTheme ? black_ColorId : white_ColorId) | permanent_ColorId;
251 if (colorEscape == none_ColorId || colorEscape == uiTextAction_ColorId) {
252 *fg = uiTextPressed_ColorId | permanent_ColorId;
253 } 278 }
254 else { 279 else {
255 *fg = isDark_ColorTheme(colorTheme_App()) ? white_ColorId : black_ColorId; 280 *bg = uiBackgroundPressed_ColorId | permanent_ColorId;
281 if (isButton) {
282 *frame1 = uiEmbossPressed1_ColorId;
283 *frame2 = colorEscape != none_ColorId ? colorEscape : uiEmbossPressed2_ColorId;
284 }
285 //if (colorEscape == none_ColorId || colorEscape == uiTextAction_ColorId) {
286 *fg = *icon = *meta = uiTextPressed_ColorId | permanent_ColorId;
287 // }
288 // else {
289 // *fg = (isDark_ColorTheme(colorTheme_App()) ? white_ColorId : black_ColorId) | permanent_ColorId;
290 // }
256 } 291 }
257 } 292 }
258 if (d->forceFg >= 0) {
259 *fg = d->forceFg;
260 }
261} 293}
262 294
263iLocalDef int iconPadding_LabelWidget_(const iLabelWidget *d) { 295iLocalDef int iconPadding_LabelWidget_(const iLabelWidget *d) {
@@ -287,13 +319,18 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
287 } 319 }
288 iPaint p; 320 iPaint p;
289 init_Paint(&p); 321 init_Paint(&p);
290 int bg, fg, frame, frame2; 322 int bg, fg, frame, frame2, iconColor, metaColor;
291 getColors_LabelWidget_(d, &bg, &fg, &frame, &frame2); 323 getColors_LabelWidget_(d, &bg, &fg, &frame, &frame2, &iconColor, &metaColor);
292 const iBool isCaution = startsWith_String(&d->label, uiTextCaution_ColorEscape); 324 const enum iColorId colorEscape = parseEscape_Color(cstr_String(&d->label), NULL);
325 const iBool isCaution = (colorEscape == uiTextCaution_ColorId);
293 if (bg >= 0) { 326 if (bg >= 0) {
294 fillRect_Paint(&p, rect, isCaution && isHover ? uiMarked_ColorId : bg); 327 fillRect_Paint(&p, rect, bg);
328 }
329 if (isFocused_Widget(w)) {
330 iRect frameRect = adjusted_Rect(rect, zero_I2(), init1_I2(-1));
331 drawRectThickness_Paint(&p, frameRect, gap_UI / 4, frame);
295 } 332 }
296 if (~flags & frameless_WidgetFlag) { 333 else if (~flags & frameless_WidgetFlag) {
297 iRect frameRect = adjusted_Rect(rect, zero_I2(), init1_I2(-1)); 334 iRect frameRect = adjusted_Rect(rect, zero_I2(), init1_I2(-1));
298 if (isButton) { 335 if (isButton) {
299 iInt2 points[] = { 336 iInt2 points[] = {
@@ -310,12 +347,18 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
310 } 347 }
311#endif 348#endif
312 drawLines_Paint(&p, points + 2, 3, frame2); 349 drawLines_Paint(&p, points + 2, 3, frame2);
313 drawLines_Paint( 350 drawLines_Paint(&p,
314 &p, points, !isHover && d->flags.noTopFrame ? 2 : 3, frame); 351 points,
352 isFocused_Widget(w) ? 3 : (!isHover && d->flags.noTopFrame ? 2 : 3),
353 frame);
315 } 354 }
316 } 355 }
317 setClip_Paint(&p, rect); 356 setClip_Paint(&p, rect);
318 const int iconPad = iconPadding_LabelWidget_(d); 357 const int iconPad = iconPadding_LabelWidget_(d);
358// const int iconColor = isCaution ? uiTextCaution_ColorId
359// : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg
360// : isHover ? uiIconHover_ColorId
361// : uiIcon_ColorId;
319 if (d->icon && d->icon != 0x20) { /* no need to draw an empty icon */ 362 if (d->icon && d->icon != 0x20) { /* no need to draw an empty icon */
320 iString str; 363 iString str;
321 initUnicodeN_String(&str, &d->icon, 1); 364 initUnicodeN_String(&str, &d->icon, 1);
@@ -329,16 +372,13 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
329 -gap_UI / 8)), 372 -gap_UI / 8)),
330 init_I2(iconPad, lineHeight_Text(d->font)) }, 373 init_I2(iconPad, lineHeight_Text(d->font)) },
331 iTrue, 374 iTrue,
332 isCaution ? uiTextCaution_ColorId 375 iconColor,
333 : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg
334 : isHover ? uiIconHover_ColorId
335 : uiIcon_ColorId,
336 "%s", 376 "%s",
337 cstr_String(&str)); 377 cstr_String(&str));
338 deinit_String(&str); 378 deinit_String(&str);
339 } 379 }
340 if (d->flags.wrap) { 380 if (d->flags.wrap) {
341 const iRect cont = contentBounds_LabelWidget_(d); //djusted_Rect(innerBounds_Widget(w), init_I2(iconPad, 0), zero_I2()); 381 const iRect cont = contentBounds_LabelWidget_(d);
342 drawWrapRange_Text( 382 drawWrapRange_Text(
343 d->font, topLeft_Rect(cont), width_Rect(cont), fg, range_String(&d->label)); 383 d->font, topLeft_Rect(cont), width_Rect(cont), fg, range_String(&d->label));
344 } 384 }
@@ -353,9 +393,11 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
353 add_I2(topRight_Rect(bounds), 393 add_I2(topRight_Rect(bounds),
354 addX_I2(negX_I2(padding_LabelWidget_(d, 1)), 394 addX_I2(negX_I2(padding_LabelWidget_(d, 1)),
355 deviceType_App() == tablet_AppDeviceType ? gap_UI : 0)), 395 deviceType_App() == tablet_AppDeviceType ? gap_UI : 0)),
356 flags & pressed_WidgetFlag ? fg 396 metaColor,/*
357 : isCaution ? uiTextCaution_ColorId 397 isHover || flags & pressed_WidgetFlag ? fg
358 : uiTextShortcut_ColorId, 398// : isCaution ? uiTextCaution_ColorId
399 : colorEscape != none_ColorId ? colorEscape
400 : uiTextShortcut_ColorId,*/
359 right_Alignment, 401 right_Alignment,
360 cstr_String(&str)); 402 cstr_String(&str));
361 deinit_String(&str); 403 deinit_String(&str);
@@ -385,7 +427,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
385 drawCentered_Text(d->font, 427 drawCentered_Text(d->font,
386 (iRect){ addX_I2(topRight_Rect(chRect), -iconPad), 428 (iRect){ addX_I2(topRight_Rect(chRect), -iconPad),
387 init_I2(chSize, height_Rect(chRect)) }, 429 init_I2(chSize, height_Rect(chRect)) },
388 iTrue, uiSeparator_ColorId, rightAngle_Icon); 430 iTrue, iconColor, rightAngle_Icon);
389 } 431 }
390 unsetClip_Paint(&p); 432 unsetClip_Paint(&p);
391} 433}
@@ -442,11 +484,18 @@ void updateSize_LabelWidget(iLabelWidget *d) {
442 484
443static void replaceVariables_LabelWidget_(iLabelWidget *d) { 485static void replaceVariables_LabelWidget_(iLabelWidget *d) {
444 translate_Lang(&d->label); 486 translate_Lang(&d->label);
487 if (d->flags.allCaps) {
488 set_String(&d->label, collect_String(upper_String(&d->label)));
489 }
490 if (d->flags.removeTrailingColon && endsWith_String(&d->label, ":")) {
491 removeEnd_String(&d->label, 1);
492 }
445} 493}
446 494
447void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { 495void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
448 iWidget *w = &d->widget; 496 iWidget *w = &d->widget;
449 init_Widget(w); 497 init_Widget(w);
498 iZap(d->flags);
450 d->font = uiLabel_FontId; 499 d->font = uiLabel_FontId;
451 d->forceFg = none_ColorId; 500 d->forceFg = none_ColorId;
452 d->icon = 0; 501 d->icon = 0;
@@ -463,12 +512,7 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
463 d->key = 0; 512 d->key = 0;
464 d->kmods = 0; 513 d->kmods = 0;
465 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); 514 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0);
466 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); 515 setFlags_Widget(w, focusable_WidgetFlag | hover_WidgetFlag, d->click.button != 0);
467 d->flags.alignVisual = iFalse;
468 d->flags.noAutoMinHeight = iFalse;
469 d->flags.drawAsOutline = iFalse;
470 d->flags.noTopFrame = iFalse;
471 d->flags.wrap = iFalse;
472 updateSize_LabelWidget(d); 516 updateSize_LabelWidget(d);
473 updateKey_LabelWidget_(d); /* could be bound to another key */ 517 updateKey_LabelWidget_(d); /* could be bound to another key */
474} 518}
@@ -499,6 +543,14 @@ void setText_LabelWidget(iLabelWidget *d, const iString *text) {
499 } 543 }
500} 544}
501 545
546void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
547 updateTextCStr_LabelWidget(d, text);
548 updateSize_LabelWidget(d);
549 if (isWrapped_LabelWidget(d)) {
550 sizeChanged_LabelWidget_(d);
551 }
552}
553
502void setAlignVisually_LabelWidget(iLabelWidget *d, iBool alignVisual) { 554void setAlignVisually_LabelWidget(iLabelWidget *d, iBool alignVisual) {
503 d->flags.alignVisual = alignVisual; 555 d->flags.alignVisual = alignVisual;
504} 556}
@@ -525,6 +577,20 @@ void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) {
525 } 577 }
526} 578}
527 579
580void setAllCaps_LabelWidget(iLabelWidget *d, iBool allCaps) {
581 if (d) {
582 d->flags.allCaps = allCaps;
583 replaceVariables_LabelWidget_(d);
584 }
585}
586
587void setRemoveTrailingColon_LabelWidget(iLabelWidget *d, iBool removeTrailingColon) {
588 if (d) {
589 d->flags.removeTrailingColon = removeTrailingColon;
590 replaceVariables_LabelWidget_(d);
591 }
592}
593
528void updateText_LabelWidget(iLabelWidget *d, const iString *text) { 594void updateText_LabelWidget(iLabelWidget *d, const iString *text) {
529 set_String(&d->label, text); 595 set_String(&d->label, text);
530 set_String(&d->srcLabel, text); 596 set_String(&d->srcLabel, text);
@@ -533,10 +599,12 @@ void updateText_LabelWidget(iLabelWidget *d, const iString *text) {
533} 599}
534 600
535void updateTextCStr_LabelWidget(iLabelWidget *d, const char *text) { 601void updateTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
536 setCStr_String(&d->label, text); 602 if (d) {
537 set_String(&d->srcLabel, &d->label); 603 setCStr_String(&d->label, text);
538 replaceVariables_LabelWidget_(d); 604 set_String(&d->srcLabel, &d->label);
539 refresh_Widget(&d->widget); 605 replaceVariables_LabelWidget_(d);
606 refresh_Widget(&d->widget);
607 }
540} 608}
541 609
542void updateTextAndResizeWidthCStr_LabelWidget(iLabelWidget *d, const char *text) { 610void updateTextAndResizeWidthCStr_LabelWidget(iLabelWidget *d, const char *text) {
@@ -544,13 +612,6 @@ void updateTextAndResizeWidthCStr_LabelWidget(iLabelWidget *d, const char *text)
544 d->widget.rect.size.x = defaultSize_LabelWidget(d).x; 612 d->widget.rect.size.x = defaultSize_LabelWidget(d).x;
545} 613}
546 614
547void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
548 setCStr_String(&d->label, text);
549 set_String(&d->srcLabel, &d->label);
550 replaceVariables_LabelWidget_(d);
551 updateSize_LabelWidget(d);
552}
553
554void setCommand_LabelWidget(iLabelWidget *d, const iString *command) { 615void setCommand_LabelWidget(iLabelWidget *d, const iString *command) {
555 set_String(&d->command, command); 616 set_String(&d->command, command);
556} 617}
@@ -567,19 +628,8 @@ iBool checkIcon_LabelWidget(iLabelWidget *d) {
567 d->icon = 0; 628 d->icon = 0;
568 return iFalse; 629 return iFalse;
569 } 630 }
570 iStringConstIterator iter; 631 d->icon = removeIconPrefix_String(&d->label);
571 init_StringConstIterator(&iter, &d->label); 632 return d->icon != 0;
572 const iChar icon = iter.value;
573 next_StringConstIterator(&iter);
574 if (iter.value == ' ' && icon >= 0x100) {
575 d->icon = icon;
576 remove_Block(&d->label.chars, 0, iter.next - constBegin_String(&d->label));
577 return iTrue;
578 }
579 else {
580 d->icon = 0;
581 }
582 return iFalse;
583} 633}
584 634
585iChar icon_LabelWidget(const iLabelWidget *d) { 635iChar icon_LabelWidget(const iLabelWidget *d) {