From 95e6b3a344d5ef117cb16e7e89de39f53883ed3e Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 24 Feb 2021 19:27:32 +0200 Subject: Modal dialogs fade the background --- src/ui/widget.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ui/widget.c b/src/ui/widget.c index c1b95130..2bdda691 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c @@ -681,6 +681,26 @@ void drawBackground_Widget(const iWidget *d) { iRect rect = bounds_Widget(d); iPaint p; init_Paint(&p); + if (d->flags & mouseModal_WidgetFlag) { + p.alpha = 128; + SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); + int fadeColor; + switch (colorTheme_App()) { + default: + fadeColor = black_ColorId; + break; + case light_ColorTheme: + fadeColor = gray25_ColorId; + break; + case pureWhite_ColorTheme: + fadeColor = gray50_ColorId; + break; + } + fillRect_Paint(&p, + initCorners_Rect(zero_I2(), rootSize_Window(get_Window())), + fadeColor); + SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); + } if (d->bgColor >= 0) { #if defined (iPlatformAppleMobile) if (d->flags & (drawBackgroundToHorizontalSafeArea_WidgetFlag | -- cgit v1.2.3