diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-04 07:40:56 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-04 07:40:56 +0200 |
commit | 723fcbf263bd2f5ff6c259a47091ebf685b50723 (patch) | |
tree | 5ed11977ee09fa542ed62a12c73117a27140d04e /src/ui/touch.c | |
parent | ad86fbe2cffa2bea07d004782e711932c5c91a79 (diff) |
Mobile: Sidebar is now a vertically sliding panel
Switched the phone sidebar to use the iOS half/full-height sliding sheet design. This is better for finger reachability and for retaining access to the current page.
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r-- | src/ui/touch.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c index 195d1dff..aee5a383 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -589,9 +589,18 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
589 | divvf_F3(&touch->accum, 6); | 589 | divvf_F3(&touch->accum, 6); |
590 | divfv_I2(&pixels, 6); | 590 | divfv_I2(&pixels, 6); |
591 | /* Allow scrolling a scrollable widget. */ | 591 | /* Allow scrolling a scrollable widget. */ |
592 | iWidget *flow = findOverflowScrollable_Widget(touch->affinity); | 592 | if (touch->affinity && touch->affinity->flags2 & slidingSheetDraggable_WidgetFlag2) { |
593 | if (flow) { | 593 | extern iWidgetClass Class_SidebarWidget; /* The only type of sliding sheet for now. */ |
594 | touch->affinity = flow; | 594 | iWidget *slider = findParentClass_Widget(touch->affinity, &Class_SidebarWidget); |
595 | if (slider) { | ||
596 | touch->affinity = slider; | ||
597 | } | ||
598 | } | ||
599 | else { | ||
600 | iWidget *flow = findOverflowScrollable_Widget(touch->affinity); | ||
601 | if (flow) { | ||
602 | touch->affinity = flow; | ||
603 | } | ||
595 | } | 604 | } |
596 | } | 605 | } |
597 | else { | 606 | else { |
@@ -617,11 +626,13 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
617 | if (touch->axis == y_TouchAxis) { | 626 | if (touch->axis == y_TouchAxis) { |
618 | pixels.x = 0; | 627 | pixels.x = 0; |
619 | } | 628 | } |
620 | // printf("%p (%s) py: %i wy: %f acc: %f edge: %d\n", | 629 | #if 0 |
621 | // touch->affinity, | 630 | printf("%p (%s) py: %i wy: %f acc: %f edge: %d\n", |
622 | // class_Widget(touch->affinity)->name, | 631 | touch->affinity, |
623 | // pixels.y, y_F3(amount), y_F3(touch->accum), | 632 | class_Widget(touch->affinity)->name, |
624 | // touch->edge); | 633 | pixels.y, y_F3(amount), y_F3(touch->accum), |
634 | touch->edge); | ||
635 | #endif | ||
625 | if (pixels.x || pixels.y) { | 636 | if (pixels.x || pixels.y) { |
626 | //setFocus_Widget(NULL); | 637 | //setFocus_Widget(NULL); |
627 | dispatchMotion_Touch_(touch->startPos /*pos[0]*/, 0); | 638 | dispatchMotion_Touch_(touch->startPos /*pos[0]*/, 0); |
@@ -801,6 +812,16 @@ void widgetDestroyed_Touch(iWidget *widget) { | |||
801 | } | 812 | } |
802 | } | 813 | } |
803 | 814 | ||
815 | void transferAffinity_Touch(iWidget *src, iWidget *dst) { | ||
816 | iTouchState *d = touchState_(); | ||
817 | iForEach(Array, i, d->touches) { | ||
818 | iTouch *touch = i.value; | ||
819 | if (touch->affinity == src) { | ||
820 | touch->affinity = dst; | ||
821 | } | ||
822 | } | ||
823 | } | ||
824 | |||
804 | iInt2 latestPosition_Touch(void) { | 825 | iInt2 latestPosition_Touch(void) { |
805 | return touchState_()->currentTouchPos; | 826 | return touchState_()->currentTouchPos; |
806 | } | 827 | } |