summaryrefslogtreecommitdiff
path: root/src/ui/touch.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-06 08:28:58 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-06 08:28:58 +0200
commita73b54d8ab2164984c884caafb2e8f53d6557133 (patch)
tree2f0b2ff5dda324a379c6f9b6e37a918cd9fc3a58 /src/ui/touch.c
parent78dcb6d388155454cfd042072419eb03080ad57d (diff)
Mobile: Widget interaction and appearance
Overflow-scrollable allows momentum scrolls. Adjusting fonts in phone sheets.
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r--src/ui/touch.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c
index e3c7b9a1..27db0073 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -245,6 +245,16 @@ static void dispatchButtonUp_Touch_(iFloat3 pos) {
245 }); 245 });
246} 246}
247 247
248static iWidget *findOverflowScrollable_Widget_(iWidget *d) {
249 const iInt2 rootSize = rootSize_Window(get_Window());
250 for (iWidget *w = d; w; w = parent_Widget(w)) {
251 if (flags_Widget(w) & overflowScrollable_WidgetFlag && height_Widget(w) > rootSize.y) {
252 return w;
253 }
254 }
255 return NULL;
256}
257
248iBool processEvent_Touch(const SDL_Event *ev) { 258iBool processEvent_Touch(const SDL_Event *ev) {
249 /* We only handle finger events here. */ 259 /* We only handle finger events here. */
250 if (ev->type != SDL_FINGERDOWN && ev->type != SDL_FINGERMOTION && ev->type != SDL_FINGERUP) { 260 if (ev->type != SDL_FINGERDOWN && ev->type != SDL_FINGERMOTION && ev->type != SDL_FINGERUP) {
@@ -329,6 +339,11 @@ iBool processEvent_Touch(const SDL_Event *ev) {
329 the first one. */ 339 the first one. */
330 divvf_F3(&touch->accum, 6); 340 divvf_F3(&touch->accum, 6);
331 divfv_I2(&pixels, 6); 341 divfv_I2(&pixels, 6);
342 /* Allow scrolling a scrollable widget. */
343 iWidget *flow = findOverflowScrollable_Widget_(touch->affinity);
344 if (flow) {
345 touch->affinity = flow;
346 }
332 } 347 }
333 else { 348 else {
334 touch->accum = zero_F3(); 349 touch->accum = zero_F3();
@@ -367,6 +382,7 @@ iBool processEvent_Touch(const SDL_Event *ev) {
367// class_Widget(touch->affinity)->name, 382// class_Widget(touch->affinity)->name,
368// pixels.y, y_F3(amount), y_F3(touch->accum)); 383// pixels.y, y_F3(amount), y_F3(touch->accum));
369 if (pixels.x || pixels.y) { 384 if (pixels.x || pixels.y) {
385 setFocus_Widget(NULL);
370 dispatchMotion_Touch_(pos, 0); 386 dispatchMotion_Touch_(pos, 0);
371 dispatchEvent_Widget(touch->affinity, (SDL_Event *) &(SDL_MouseWheelEvent){ 387 dispatchEvent_Widget(touch->affinity, (SDL_Event *) &(SDL_MouseWheelEvent){
372 .type = SDL_MOUSEWHEEL, 388 .type = SDL_MOUSEWHEEL,