summaryrefslogtreecommitdiff
path: root/src/ui/paint.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-17 21:28:07 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-17 21:28:07 +0300
commitc94469c3b5e46fa15939de271e6a4e1cc812dea3 (patch)
tree8ccb30ff4a48726dc945296a95d1d5007cf331dd /src/ui/paint.c
parentab10c23969bb7d7be73613d50ae2a3755da39fb0 (diff)
SidebarWidget: Animate show/hide
Also addressed clipping issues when using multiple roots.
Diffstat (limited to 'src/ui/paint.c')
-rw-r--r--src/ui/paint.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c
index faaf403d..c575d5fc 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -62,20 +62,19 @@ void endTarget_Paint(iPaint *d) {
62} 62}
63 63
64void setClip_Paint(iPaint *d, iRect rect) { 64void setClip_Paint(iPaint *d, iRect rect) {
65 if (rect.pos.y < 0) { 65 rect = intersect_Rect(rect, rect_Root(get_Root()));
66 const int off = rect.pos.y; 66 if (isEmpty_Rect(rect)) {
67 rect.pos.y -= off; 67 rect = init_Rect(0, 0, 1, 1);
68 rect.size.y = iMax(0, rect.size.y + off);
69 }
70 if (rect.pos.x < 0) {
71 const int off = rect.pos.x;
72 rect.pos.x -= off;
73 rect.size.x = iMax(0, rect.size.x + off);
74 } 68 }
75 SDL_RenderSetClipRect(renderer_Paint_(d), (const SDL_Rect *) &rect); 69 SDL_RenderSetClipRect(renderer_Paint_(d), (const SDL_Rect *) &rect);
76} 70}
77 71
78void unsetClip_Paint(iPaint *d) { 72void unsetClip_Paint(iPaint *d) {
73 if (numRoots_Window(get_Window()) > 1) {
74 const iRect rect = rect_Root(get_Root());
75 SDL_RenderSetClipRect(renderer_Paint_(d), (const SDL_Rect *) &rect);
76 return;
77 }
79#if SDL_VERSION_ATLEAST(2, 0, 12) 78#if SDL_VERSION_ATLEAST(2, 0, 12)
80 SDL_RenderSetClipRect(renderer_Paint_(d), NULL); 79 SDL_RenderSetClipRect(renderer_Paint_(d), NULL);
81#else 80#else