diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-15 17:51:04 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-15 17:51:04 +0300 |
commit | a8fa5c21f0bc81f3f144ee29e16deab3f91296d4 (patch) | |
tree | 902304d7f63f620bb272bbc7d0a33d53e15d2a98 /src/ui/labelwidget.c | |
parent | 941c92e80ab5981f7f65a6780552416b998b0425 (diff) |
Fixed visual artifact during sidebar animation
The sidebars are not supposed to have borders or background fades.
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r-- | src/ui/labelwidget.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 46ef5d1f..b68ab793 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -46,6 +46,7 @@ struct Impl_LabelWidget { | |||
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 | uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ |
48 | uint8_t noTopFrame : 1; | 48 | uint8_t noTopFrame : 1; |
49 | uint8_t wrap : 1; | ||
49 | } flags; | 50 | } flags; |
50 | }; | 51 | }; |
51 | 52 | ||
@@ -317,7 +318,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
317 | cstr_String(&str)); | 318 | cstr_String(&str)); |
318 | deinit_String(&str); | 319 | deinit_String(&str); |
319 | } | 320 | } |
320 | if (flags & wrapText_WidgetFlag) { | 321 | if (d->flags.wrap) { |
321 | const iRect inner = adjusted_Rect(innerBounds_Widget(w), init_I2(iconPad, 0), zero_I2()); | 322 | const iRect inner = adjusted_Rect(innerBounds_Widget(w), init_I2(iconPad, 0), zero_I2()); |
322 | const int wrap = inner.size.x; | 323 | const int wrap = inner.size.x; |
323 | drawWrapRange_Text(d->font, topLeft_Rect(inner), wrap, fg, range_String(&d->label)); | 324 | drawWrapRange_Text(d->font, topLeft_Rect(inner), wrap, fg, range_String(&d->label)); |
@@ -372,7 +373,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
372 | 373 | ||
373 | static void sizeChanged_LabelWidget_(iLabelWidget *d) { | 374 | static void sizeChanged_LabelWidget_(iLabelWidget *d) { |
374 | iWidget *w = as_Widget(d); | 375 | iWidget *w = as_Widget(d); |
375 | if (flags_Widget(w) & wrapText_WidgetFlag) { | 376 | if (d->flags.wrap) { |
376 | if (flags_Widget(w) & fixedHeight_WidgetFlag) { | 377 | if (flags_Widget(w) & fixedHeight_WidgetFlag) { |
377 | /* Calculate a new height based on the wrapping. */ | 378 | /* Calculate a new height based on the wrapping. */ |
378 | w->rect.size.y = advanceWrapRange_Text( | 379 | w->rect.size.y = advanceWrapRange_Text( |
@@ -410,7 +411,7 @@ void updateSize_LabelWidget(iLabelWidget *d) { | |||
410 | w->minSize.y = size.y; /* vertically text must remain visible */ | 411 | w->minSize.y = size.y; /* vertically text must remain visible */ |
411 | } | 412 | } |
412 | /* Wrapped text implies that width must be defined by arrangement. */ | 413 | /* Wrapped text implies that width must be defined by arrangement. */ |
413 | if (!(flags & (fixedWidth_WidgetFlag | wrapText_WidgetFlag))) { | 414 | if (~flags & fixedWidth_WidgetFlag && !d->flags.wrap) { |
414 | w->rect.size.x = size.x; | 415 | w->rect.size.x = size.x; |
415 | } | 416 | } |
416 | if (~flags & fixedHeight_WidgetFlag) { | 417 | if (~flags & fixedHeight_WidgetFlag) { |
@@ -442,10 +443,11 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | |||
442 | d->kmods = 0; | 443 | d->kmods = 0; |
443 | init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); | 444 | init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); |
444 | setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); | 445 | setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); |
445 | d->flags.alignVisual = iFalse; | 446 | d->flags.alignVisual = iFalse; |
446 | d->flags.noAutoMinHeight = iFalse; | 447 | d->flags.noAutoMinHeight = iFalse; |
447 | d->flags.drawAsOutline = iFalse; | 448 | d->flags.drawAsOutline = iFalse; |
448 | d->flags.noTopFrame = iFalse; | 449 | d->flags.noTopFrame = iFalse; |
450 | d->flags.wrap = iFalse; | ||
449 | updateSize_LabelWidget(d); | 451 | updateSize_LabelWidget(d); |
450 | updateKey_LabelWidget_(d); /* could be bound to another key */ | 452 | updateKey_LabelWidget_(d); /* could be bound to another key */ |
451 | } | 453 | } |
@@ -489,8 +491,14 @@ void setNoTopFrame_LabelWidget(iLabelWidget *d, iBool noTopFrame) { | |||
489 | d->flags.noTopFrame = noTopFrame; | 491 | d->flags.noTopFrame = noTopFrame; |
490 | } | 492 | } |
491 | 493 | ||
494 | void setWrap_LabelWidget(iLabelWidget *d, iBool wrap) { | ||
495 | d->flags.wrap = wrap; | ||
496 | } | ||
497 | |||
492 | void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { | 498 | void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { |
493 | d->flags.drawAsOutline = drawAsOutline; | 499 | if (d) { |
500 | d->flags.drawAsOutline = drawAsOutline; | ||
501 | } | ||
494 | } | 502 | } |
495 | 503 | ||
496 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { | 504 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { |
@@ -554,6 +562,10 @@ iChar icon_LabelWidget(const iLabelWidget *d) { | |||
554 | return d->icon; | 562 | return d->icon; |
555 | } | 563 | } |
556 | 564 | ||
565 | iBool isWrapped_LabelWidget(const iLabelWidget *d) { | ||
566 | return d->flags.wrap; | ||
567 | } | ||
568 | |||
557 | const iString *text_LabelWidget(const iLabelWidget *d) { | 569 | const iString *text_LabelWidget(const iLabelWidget *d) { |
558 | if (!d) return collectNew_String(); | 570 | if (!d) return collectNew_String(); |
559 | return &d->label; | 571 | return &d->label; |