diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-03 08:46:49 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-03 08:46:49 +0300 |
commit | 47e7811386c9b06fd7b458e9afb527018ad80c03 (patch) | |
tree | 07e8b72a726cfae3060647d152ce797663332b30 | |
parent | 311a59df5552ae7ad52e1f001487112a300889c0 (diff) |
Paint: Fixed build with older SDL versions
IssueID #259
-rw-r--r-- | src/ui/paint.c | 5 | ||||
-rw-r--r-- | src/ui/window.c | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c index 8843e2e2..faaf403d 100644 --- a/src/ui/paint.c +++ b/src/ui/paint.c | |||
@@ -79,8 +79,9 @@ void unsetClip_Paint(iPaint *d) { | |||
79 | #if SDL_VERSION_ATLEAST(2, 0, 12) | 79 | #if SDL_VERSION_ATLEAST(2, 0, 12) |
80 | SDL_RenderSetClipRect(renderer_Paint_(d), NULL); | 80 | SDL_RenderSetClipRect(renderer_Paint_(d), NULL); |
81 | #else | 81 | #else |
82 | const SDL_Rect winRect = { 0, 0, d->dst->root->rect.size.x, d->dst->root->rect.size.y }; | 82 | const iRect rect = |
83 | SDL_RenderSetClipRect(renderer_Paint_(d), &winRect); | 83 | current_Root() ? rect_Root(get_Root()) : (iRect){ zero_I2(), get_Window()->size }; |
84 | SDL_RenderSetClipRect(renderer_Paint_(d), (const SDL_Rect *) &rect); | ||
84 | #endif | 85 | #endif |
85 | } | 86 | } |
86 | 87 | ||
diff --git a/src/ui/window.c b/src/ui/window.c index 80504aae..39adba83 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -998,6 +998,8 @@ void draw_Window(iWindow *d) { | |||
998 | #endif | 998 | #endif |
999 | const int winFlags = SDL_GetWindowFlags(d->win); | 999 | const int winFlags = SDL_GetWindowFlags(d->win); |
1000 | const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; | 1000 | const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; |
1001 | iPaint p; | ||
1002 | init_Paint(&p); | ||
1001 | /* Clear the window. The clear color is visible as a border around the window | 1003 | /* Clear the window. The clear color is visible as a border around the window |
1002 | when the custom frame is being used. */ { | 1004 | when the custom frame is being used. */ { |
1003 | #if defined (iPlatformAppleMobile) | 1005 | #if defined (iPlatformAppleMobile) |
@@ -1008,6 +1010,7 @@ void draw_Window(iWindow *d) { | |||
1008 | ? uiAnnotation_ColorId | 1010 | ? uiAnnotation_ColorId |
1009 | : uiSeparator_ColorId); | 1011 | : uiSeparator_ColorId); |
1010 | #endif | 1012 | #endif |
1013 | unsetClip_Paint(&p); /* update clip to full window */ | ||
1011 | SDL_SetRenderDrawColor(d->render, back.r, back.g, back.b, 255); | 1014 | SDL_SetRenderDrawColor(d->render, back.r, back.g, back.b, 255); |
1012 | SDL_RenderClear(d->render); | 1015 | SDL_RenderClear(d->render); |
1013 | } | 1016 | } |
@@ -1019,6 +1022,7 @@ void draw_Window(iWindow *d) { | |||
1019 | iRoot *root = d->roots[i]; | 1022 | iRoot *root = d->roots[i]; |
1020 | if (root) { | 1023 | if (root) { |
1021 | setCurrent_Root(root); | 1024 | setCurrent_Root(root); |
1025 | unsetClip_Paint(&p); /* update clip to current root */ | ||
1022 | draw_Widget(root->widget); | 1026 | draw_Widget(root->widget); |
1023 | #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) | 1027 | #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) |
1024 | /* App icon. */ | 1028 | /* App icon. */ |
@@ -1040,8 +1044,6 @@ void draw_Window(iWindow *d) { | |||
1040 | #endif | 1044 | #endif |
1041 | /* Root separator and keyboard focus indicator. */ | 1045 | /* Root separator and keyboard focus indicator. */ |
1042 | if (numRoots_Window(d) > 1){ | 1046 | if (numRoots_Window(d) > 1){ |
1043 | iPaint p; | ||
1044 | init_Paint(&p); | ||
1045 | const iRect bounds = bounds_Widget(root->widget); | 1047 | const iRect bounds = bounds_Widget(root->widget); |
1046 | if (i == 1) { | 1048 | if (i == 1) { |
1047 | fillRect_Paint(&p, (iRect){ | 1049 | fillRect_Paint(&p, (iRect){ |