diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/mobile.c | 6 | ||||
-rw-r--r-- | src/ui/touch.c | 16 | ||||
-rw-r--r-- | src/ui/widget.c | 9 | ||||
-rw-r--r-- | src/ui/widget.h | 3 |
4 files changed, 20 insertions, 14 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c index 1c7cad8e..9e877968 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c | |||
@@ -392,8 +392,11 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
392 | setFlags_Widget(detailStack, resizeWidthOfChildren_WidgetFlag, iTrue); | 392 | setFlags_Widget(detailStack, resizeWidthOfChildren_WidgetFlag, iTrue); |
393 | addChild_Widget(mainDetailSplit, iClob(detailStack)); | 393 | addChild_Widget(mainDetailSplit, iClob(detailStack)); |
394 | } | 394 | } |
395 | //setFlags_Widget(topPanel, topPanelOffset_WidgetFlag, iTrue); /* slide with children */ | ||
396 | addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId)))); | 395 | addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId)))); |
396 | /* Slide top panel with detail panels. */ { | ||
397 | setFlags_Widget(topPanel, refChildrenOffset_WidgetFlag, iTrue); | ||
398 | topPanel->offsetRef = detailStack; | ||
399 | } | ||
397 | if (prefsTabs) { | 400 | if (prefsTabs) { |
398 | iRelease(removeChild_Widget(sheet, child_Widget(sheet, 0))); /* heading */ | 401 | iRelease(removeChild_Widget(sheet, child_Widget(sheet, 0))); /* heading */ |
399 | iRelease(removeChild_Widget(sheet, findChild_Widget(sheet, "dialogbuttons"))); | 402 | iRelease(removeChild_Widget(sheet, findChild_Widget(sheet, "dialogbuttons"))); |
@@ -561,7 +564,6 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
561 | } | 564 | } |
562 | addPanelChild_(owner, NULL, 0, 0, prevElement); | 565 | addPanelChild_(owner, NULL, 0, 0, prevElement); |
563 | destroy_Widget(pageContent); | 566 | destroy_Widget(pageContent); |
564 | // setFlags_Widget(owner, drawBackgroundToBottom_WidgetFlag, iTrue); | ||
565 | } | 567 | } |
566 | destroyPending_Root(sheet->root); | 568 | destroyPending_Root(sheet->root); |
567 | /* Additional elements for preferences. */ | 569 | /* Additional elements for preferences. */ |
diff --git a/src/ui/touch.c b/src/ui/touch.c index c373ebd3..e8f53bca 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -453,8 +453,8 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
453 | if (edge == left_TouchEdge) { | 453 | if (edge == left_TouchEdge) { |
454 | dragging = findSlidePanel_Widget_(aff); | 454 | dragging = findSlidePanel_Widget_(aff); |
455 | if (dragging) { | 455 | if (dragging) { |
456 | printf("Selected for dragging: "); | 456 | // printf("Selected for dragging: "); |
457 | identify_Widget(dragging); | 457 | // identify_Widget(dragging); |
458 | setFlags_Widget(dragging, dragged_WidgetFlag, iTrue); | 458 | setFlags_Widget(dragging, dragged_WidgetFlag, iTrue); |
459 | } | 459 | } |
460 | } | 460 | } |
@@ -556,7 +556,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
556 | } | 556 | } |
557 | /* Edge swipe aborted? */ | 557 | /* Edge swipe aborted? */ |
558 | if (touch->edge == left_TouchEdge) { | 558 | if (touch->edge == left_TouchEdge) { |
559 | if (fing->dx < 0) { | 559 | if (fing->dx < 0 && x_F3(touch->pos[0]) < tapRadiusPt_ * window->pixelRatio) { |
560 | touch->edge = none_TouchEdge; | 560 | touch->edge = none_TouchEdge; |
561 | if (touch->edgeDragging) { | 561 | if (touch->edgeDragging) { |
562 | setFlags_Widget(touch->edgeDragging, dragged_WidgetFlag, iFalse); | 562 | setFlags_Widget(touch->edgeDragging, dragged_WidgetFlag, iFalse); |
@@ -631,17 +631,19 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
631 | continue; | 631 | continue; |
632 | } | 632 | } |
633 | /* Edge swipes do not generate momentum. */ | 633 | /* Edge swipes do not generate momentum. */ |
634 | const size_t lastIndex = iMin(touch->posCount - 1, lastIndex_Touch_); | ||
634 | const uint32_t duration = nowTime - touch->startTime; | 635 | const uint32_t duration = nowTime - touch->startTime; |
635 | const iFloat3 gestureVector = sub_F3(pos, touch->startPos); | 636 | const iFloat3 gestureVector = sub_F3(pos, touch->pos[lastIndex]); |
636 | iFloat3 velocity = zero_F3(); | 637 | iFloat3 velocity = zero_F3(); |
637 | if (touch->edge && fabsf(2 * x_F3(gestureVector)) > fabsf(y_F3(gestureVector)) && | 638 | if (touch->edge && fabsf(2 * x_F3(gestureVector)) > fabsf(y_F3(gestureVector)) && |
638 | !isStationary_Touch_(touch)) { | 639 | !isStationary_Touch_(touch)) { |
639 | dispatchClick_Touch_(touch, touch->edge == left_TouchEdge ? SDL_BUTTON_X1 | 640 | const int swipeDir = x_F3(gestureVector) > 0 ? +1 : -1; |
640 | : SDL_BUTTON_X2); | 641 | dispatchClick_Touch_(touch, |
642 | touch->edge == left_TouchEdge && swipeDir > 0 ? SDL_BUTTON_X1 : | ||
643 | touch->edge == right_TouchEdge && swipeDir < 0 ? SDL_BUTTON_X2 : 0); | ||
641 | setHover_Widget(NULL); | 644 | setHover_Widget(NULL); |
642 | } | 645 | } |
643 | else { | 646 | else { |
644 | const size_t lastIndex = iMin(touch->posCount - 1, lastIndex_Touch_); | ||
645 | const uint32_t elapsed = fing->timestamp - touch->posTime[lastIndex]; | 647 | const uint32_t elapsed = fing->timestamp - touch->posTime[lastIndex]; |
646 | const float minVelocity = 400.0f; | 648 | const float minVelocity = 400.0f; |
647 | if (elapsed < 150) { | 649 | if (elapsed < 150) { |
diff --git a/src/ui/widget.c b/src/ui/widget.c index 475e7c1f..3439fb1b 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -58,6 +58,7 @@ void init_Widget(iWidget *d) { | |||
58 | d->rect = zero_Rect(); | 58 | d->rect = zero_Rect(); |
59 | d->minSize = zero_I2(); | 59 | d->minSize = zero_I2(); |
60 | d->sizeRef = NULL; | 60 | d->sizeRef = NULL; |
61 | d->offsetRef = NULL; | ||
61 | d->bgColor = none_ColorId; | 62 | d->bgColor = none_ColorId; |
62 | d->frameColor = none_ColorId; | 63 | d->frameColor = none_ColorId; |
63 | init_Anim(&d->visualOffset, 0.0f); | 64 | init_Anim(&d->visualOffset, 0.0f); |
@@ -755,13 +756,13 @@ static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) { | |||
755 | pos->y += off; | 756 | pos->y += off; |
756 | } | 757 | } |
757 | } | 758 | } |
758 | if (d->flags & topPanelOffset_WidgetFlag) { | 759 | if (d->flags & refChildrenOffset_WidgetFlag) { |
759 | iConstForEach(ObjectList, i, children_Widget(parent_Widget(d))) { | 760 | iConstForEach(ObjectList, i, children_Widget(d->offsetRef)) { |
760 | const iWidget *child = i.object; | 761 | const iWidget *child = i.object; |
761 | if (child == d) continue; | 762 | if (child == d) continue; |
762 | if (child->flags & (visualOffset_WidgetFlag | dragged_WidgetFlag)) { | 763 | if (child->flags & (visualOffset_WidgetFlag | dragged_WidgetFlag)) { |
763 | const int invOff = size_Root(d->root).x - iRound(value_Anim(&child->visualOffset)); | 764 | const int invOff = size_Root(d->root).x - iRound(value_Anim(&child->visualOffset)); |
764 | pos->x -= invOff / 3; | 765 | pos->x -= invOff / 4; |
765 | } | 766 | } |
766 | } | 767 | } |
767 | } | 768 | } |
@@ -1092,7 +1093,7 @@ void drawBackground_Widget(const iWidget *d) { | |||
1092 | iPaint p; | 1093 | iPaint p; |
1093 | init_Paint(&p); | 1094 | init_Paint(&p); |
1094 | p.alpha = 0x50; | 1095 | p.alpha = 0x50; |
1095 | if (flags_Widget(d) & visualOffset_WidgetFlag) { | 1096 | if (flags_Widget(d) & (visualOffset_WidgetFlag | dragged_WidgetFlag)) { |
1096 | const float area = d->rect.size.x * d->rect.size.y; | 1097 | const float area = d->rect.size.x * d->rect.size.y; |
1097 | const float visibleArea = area_Rect(intersect_Rect(bounds_Widget(d), rect_Root(d->root))); | 1098 | const float visibleArea = area_Rect(intersect_Rect(bounds_Widget(d), rect_Root(d->root))); |
1098 | p.alpha *= (area > 0 ? visibleArea / area : 0.0f); | 1099 | p.alpha *= (area > 0 ? visibleArea / area : 0.0f); |
diff --git a/src/ui/widget.h b/src/ui/widget.h index 53dbbff2..79d45f23 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h | |||
@@ -119,7 +119,7 @@ enum iWidgetFlag { | |||
119 | #define noFadeBackground_WidgetFlag iBit64(60) | 119 | #define noFadeBackground_WidgetFlag iBit64(60) |
120 | #define destroyPending_WidgetFlag iBit64(61) /* TODO: needed? */ | 120 | #define destroyPending_WidgetFlag iBit64(61) /* TODO: needed? */ |
121 | #define edgeDraggable_WidgetFlag iBit64(62) | 121 | #define edgeDraggable_WidgetFlag iBit64(62) |
122 | #define topPanelOffset_WidgetFlag iBit64(63) /* visual offset determined by the offset of siblings */ | 122 | #define refChildrenOffset_WidgetFlag iBit64(63) /* visual offset determined by the offset of referenced children */ |
123 | 123 | ||
124 | enum iWidgetAddPos { | 124 | enum iWidgetAddPos { |
125 | back_WidgetAddPos, | 125 | back_WidgetAddPos, |
@@ -138,6 +138,7 @@ struct Impl_Widget { | |||
138 | iRect rect; | 138 | iRect rect; |
139 | iInt2 minSize; | 139 | iInt2 minSize; |
140 | iWidget * sizeRef; | 140 | iWidget * sizeRef; |
141 | iWidget * offsetRef; | ||
141 | int padding[4]; /* left, top, right, bottom */ | 142 | int padding[4]; /* left, top, right, bottom */ |
142 | iAnim visualOffset; | 143 | iAnim visualOffset; |
143 | int bgColor; | 144 | int bgColor; |