diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-13 19:52:21 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-13 19:52:21 +0300 |
commit | 4cf52f29b926a924d838a3158d5c78b3337ee0ee (patch) | |
tree | df72c72e3edccb9ce88136c7caa6d3644b1c8349 /src/ui/paint.c | |
parent | aeb65e88297725634a4e55663e2ecc83805d9073 (diff) |
Mobile: New selection logic for InputWidget
Touch-based interaction requires a different kind of selection and copy/paste behavior. This isn't done yet; especially multi-line text still needs work.
Diffstat (limited to 'src/ui/paint.c')
-rw-r--r-- | src/ui/paint.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c index 71ebb81d..89de47d4 100644 --- a/src/ui/paint.c +++ b/src/ui/paint.c | |||
@@ -33,7 +33,8 @@ iLocalDef SDL_Renderer *renderer_Paint_(const iPaint *d) { | |||
33 | 33 | ||
34 | static void setColor_Paint_(const iPaint *d, int color) { | 34 | static void setColor_Paint_(const iPaint *d, int color) { |
35 | const iColor clr = get_Color(color & mask_ColorId); | 35 | const iColor clr = get_Color(color & mask_ColorId); |
36 | SDL_SetRenderDrawColor(renderer_Paint_(d), clr.r, clr.g, clr.b, clr.a * d->alpha / 255); | 36 | SDL_SetRenderDrawColor(renderer_Paint_(d), clr.r, clr.g, clr.b, |
37 | (color & opaque_ColorId ? 255 : clr.a) * d->alpha / 255); | ||
37 | } | 38 | } |
38 | 39 | ||
39 | void init_Paint(iPaint *d) { | 40 | void init_Paint(iPaint *d) { |
@@ -186,6 +187,22 @@ void drawLines_Paint(const iPaint *d, const iInt2 *points, size_t n, int color) | |||
186 | free(offsetPoints); | 187 | free(offsetPoints); |
187 | } | 188 | } |
188 | 189 | ||
190 | void drawPin_Paint(iPaint *d, iRect rangeRect, int dir, int pinColor) { | ||
191 | const int height = height_Rect(rangeRect); | ||
192 | iRect pin; | ||
193 | if (dir == 0) { | ||
194 | pin = (iRect){ add_I2(topLeft_Rect(rangeRect), init_I2(-gap_UI / 4, -gap_UI)), | ||
195 | init_I2(gap_UI / 2, height + gap_UI) }; | ||
196 | } | ||
197 | else { | ||
198 | pin = (iRect){ addX_I2(topRight_Rect(rangeRect), -gap_UI / 4), | ||
199 | init_I2(gap_UI / 2, height + gap_UI) }; | ||
200 | } | ||
201 | fillRect_Paint(d, pin, pinColor); | ||
202 | fillRect_Paint(d, initCentered_Rect(dir == 0 ? topMid_Rect(pin) : bottomMid_Rect(pin), | ||
203 | init1_I2(gap_UI * 2)), pinColor); | ||
204 | } | ||
205 | |||
189 | iInt2 size_SDLTexture(SDL_Texture *d) { | 206 | iInt2 size_SDLTexture(SDL_Texture *d) { |
190 | iInt2 size; | 207 | iInt2 size; |
191 | SDL_QueryTexture(d, NULL, NULL, &size.x, &size.y); | 208 | SDL_QueryTexture(d, NULL, NULL, &size.x, &size.y); |