Menu: touch swipe-to-scroll with tap disambiguation, fling, wider scrollbar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b5e7241ac1
commit
35b7e2a44f
5 files changed
+206
-13
No files matched your search
@@ -91,6 +91,32 @@ public partial class MenuSpike : Node3D
|
||||
await Frame(3);
|
||||
}
|
||||
|
||||
// Touch down at `from`, slide to `to` while in contact, lift. fling = a fast 4-frame slide.
|
||||
private async Task TouchDrag(int hand, Vector2 from, Vector2 to, bool fling = false)
|
||||
{
|
||||
for (float d = 0.06f; d > -0.004f; d -= 0.004f)
|
||||
{
|
||||
TipAt(hand, from, d);
|
||||
await Frame();
|
||||
}
|
||||
// A fling lifts while still moving (as a real flick does); a slow drag stops, then lifts.
|
||||
int steps = fling ? 8 : 30;
|
||||
for (int i = 1; i <= steps; i++)
|
||||
{
|
||||
float lift = fling ? Mathf.Max(0f, i - 4) * 0.008f : 0f;
|
||||
TipAt(hand, from.Lerp(to, i / (float)steps), -0.004f + lift);
|
||||
await Frame();
|
||||
}
|
||||
float start = fling ? -0.004f + (steps - 4) * 0.008f : -0.004f;
|
||||
for (float d = start; d < 0.08f; d += 0.006f)
|
||||
{
|
||||
TipAt(hand, to, d);
|
||||
await Frame();
|
||||
}
|
||||
ClearHand(hand);
|
||||
await Frame(3);
|
||||
}
|
||||
|
||||
// Laser from 0.8 m, off-axis, aimed at the pixel.
|
||||
private void LaserAt(int hand, Vector2 pixel, bool trigger, Vector2 stick = default)
|
||||
{
|
||||
@@ -235,6 +261,34 @@ public partial class MenuSpike : Node3D
|
||||
await Frame(2);
|
||||
Check("stick: scroll down then up", scrolled > 50 && scrolledBack < scrolled, $"({scrolled} → {scrolledBack})");
|
||||
|
||||
// 6b) Touch swipe vs tap inside the scrollable log.
|
||||
Button logButton = new() { Text = "in-log button", CustomMinimumSize = new Vector2(0, 48) };
|
||||
int logButtonPresses = 0;
|
||||
logButton.Pressed += () => logButtonPresses++;
|
||||
_menu.LogScroll.GetChild(0).AddChild(logButton);
|
||||
_menu.LogScroll.GetChild(0).MoveChild(logButton, 0);
|
||||
_menu.LogScroll.ScrollVertical = 0;
|
||||
await Frame(5);
|
||||
int clicksBefore = _clicks;
|
||||
await TouchDrag(1, logPx, logPx + new Vector2(0, -150));
|
||||
int swiped = _menu.LogScroll.ScrollVertical;
|
||||
Check("touch: swipe up scrolls the log", swiped >= 120, $"(scroll 0 → {swiped})");
|
||||
Check("touch: swipe sends no click", _clicks == clicksBefore && logButtonPresses == 0, $"(clicks +{_clicks - clicksBefore})");
|
||||
await TouchDrag(1, logPx, logPx + new Vector2(0, 80), fling: true);
|
||||
await Frame(60);
|
||||
int flung = _menu.LogScroll.ScrollVertical;
|
||||
Check("touch: fast swipe down flings past the finger", flung < swiped - 60, $"({swiped} → {flung})");
|
||||
_menu.LogScroll.ScrollVertical = 0;
|
||||
await Frame(5);
|
||||
Vector2 btnPx = Center(logButton);
|
||||
await TouchDrag(1, btnPx, btnPx + new Vector2(6, 5));
|
||||
Check("touch: small-jitter tap on in-log button clicks", logButtonPresses == 1 && _menu.LogScroll.ScrollVertical == 0,
|
||||
$"(presses={logButtonPresses}, scroll={_menu.LogScroll.ScrollVertical})");
|
||||
VScrollBar vbar = _menu.LogScroll.GetVScrollBar();
|
||||
Rect2 br = vbar.GetGlobalRect();
|
||||
await TouchDrag(1, new Vector2(br.GetCenter().X, br.Position.Y + 10), new Vector2(br.GetCenter().X, br.End.Y - 10));
|
||||
Check("touch: scrollbar still drags directly", _menu.LogScroll.ScrollVertical > 100, $"(scroll={_menu.LogScroll.ScrollVertical})");
|
||||
|
||||
// 7) Recalibrate: disabled without a calibration node, enabled + calls it when present.
|
||||
await TouchPress(1, TabCenter(0));
|
||||
Check("Recalibrate disabled without group node", _menu.RecalibrateButton.Disabled);
|
||||
|
||||
Reference in new issue
Block a user