diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-06 16:02:41 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-06 16:03:17 +0200 |
commit | 5b80af0e983db5e3d09e207c9fce6790b53dea4d (patch) | |
tree | 614a227b3aeade6a2ff3b43424c4f3ea45adc1fc /src/ui/widget.c | |
parent | af0aaf36dcde341d5eb43214297df71eefc90829 (diff) |
Rasterize a few glyphs on every frame
Also various widget fixes/improvements.
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index 2381548a..dca07db2 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -56,6 +56,9 @@ iPtrArray *onTop_RootData_(void) { | |||
56 | void destroyPending_Widget(void) { | 56 | void destroyPending_Widget(void) { |
57 | iForEach(PtrSet, i, rootData_.pendingDestruction) { | 57 | iForEach(PtrSet, i, rootData_.pendingDestruction) { |
58 | iWidget *widget = *i.value; | 58 | iWidget *widget = *i.value; |
59 | if (!isFinished_Anim(&widget->visualOffset)) { | ||
60 | continue; | ||
61 | } | ||
59 | if (widget->parent) { | 62 | if (widget->parent) { |
60 | removeChild_Widget(widget->parent, widget); | 63 | removeChild_Widget(widget->parent, widget); |
61 | } | 64 | } |
@@ -680,12 +683,22 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
680 | } | 683 | } |
681 | 684 | ||
682 | void drawBackground_Widget(const iWidget *d) { | 685 | void drawBackground_Widget(const iWidget *d) { |
683 | if (d->flags & (hidden_WidgetFlag | noBackground_WidgetFlag)) { | 686 | if (d->flags & noBackground_WidgetFlag) { |
687 | return; | ||
688 | } | ||
689 | if (d->flags & hidden_WidgetFlag && ~d->flags & visualOffset_WidgetFlag) { | ||
684 | return; | 690 | return; |
685 | } | 691 | } |
686 | /* Popup menus have a shadowed border. */ | 692 | /* Popup menus have a shadowed border. */ |
687 | const iBool shadowBorder = | 693 | iBool shadowBorder = (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) != 0; |
688 | (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) != 0; | 694 | iBool fadeBackground = (d->bgColor >= 0 || d->frameColor >= 0) && |
695 | d->flags & mouseModal_WidgetFlag; | ||
696 | if (deviceType_App() == phone_AppDeviceType) { | ||
697 | if (shadowBorder) { | ||
698 | fadeBackground = iTrue; | ||
699 | shadowBorder = iFalse; | ||
700 | } | ||
701 | } | ||
689 | if (shadowBorder) { | 702 | if (shadowBorder) { |
690 | iPaint p; | 703 | iPaint p; |
691 | init_Paint(&p); | 704 | init_Paint(&p); |
@@ -696,31 +709,32 @@ void drawBackground_Widget(const iWidget *d) { | |||
696 | fillRect_Paint(&p, shadowRect, isLight ? white_ColorId : black_ColorId); | 709 | fillRect_Paint(&p, shadowRect, isLight ? white_ColorId : black_ColorId); |
697 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); | 710 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); |
698 | } | 711 | } |
712 | if (fadeBackground) { | ||
713 | iPaint p; | ||
714 | init_Paint(&p); | ||
715 | p.alpha = 0x50; | ||
716 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); | ||
717 | int fadeColor; | ||
718 | switch (colorTheme_App()) { | ||
719 | default: | ||
720 | fadeColor = black_ColorId; | ||
721 | break; | ||
722 | case light_ColorTheme: | ||
723 | fadeColor = gray25_ColorId; | ||
724 | break; | ||
725 | case pureWhite_ColorTheme: | ||
726 | fadeColor = gray50_ColorId; | ||
727 | break; | ||
728 | } | ||
729 | fillRect_Paint(&p, | ||
730 | initCorners_Rect(zero_I2(), rootSize_Window(get_Window())), | ||
731 | fadeColor); | ||
732 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); | ||
733 | } | ||
699 | if (d->bgColor >= 0 || d->frameColor >= 0) { | 734 | if (d->bgColor >= 0 || d->frameColor >= 0) { |
700 | iRect rect = bounds_Widget(d); | 735 | iRect rect = bounds_Widget(d); |
701 | iPaint p; | 736 | iPaint p; |
702 | init_Paint(&p); | 737 | init_Paint(&p); |
703 | /* Dialogs fade out the entire background. */ | ||
704 | if (d->flags & mouseModal_WidgetFlag) { | ||
705 | p.alpha = 0x50; | ||
706 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); | ||
707 | int fadeColor; | ||
708 | switch (colorTheme_App()) { | ||
709 | default: | ||
710 | fadeColor = black_ColorId; | ||
711 | break; | ||
712 | case light_ColorTheme: | ||
713 | fadeColor = gray25_ColorId; | ||
714 | break; | ||
715 | case pureWhite_ColorTheme: | ||
716 | fadeColor = gray50_ColorId; | ||
717 | break; | ||
718 | } | ||
719 | fillRect_Paint(&p, | ||
720 | initCorners_Rect(zero_I2(), rootSize_Window(get_Window())), | ||
721 | fadeColor); | ||
722 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); | ||
723 | } | ||
724 | if (d->bgColor >= 0) { | 738 | if (d->bgColor >= 0) { |
725 | #if defined (iPlatformAppleMobile) | 739 | #if defined (iPlatformAppleMobile) |
726 | if (d->flags & (drawBackgroundToHorizontalSafeArea_WidgetFlag | | 740 | if (d->flags & (drawBackgroundToHorizontalSafeArea_WidgetFlag | |