Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 01:08:53 +00:00
1 parent dccbfd7d86
commit 17f81c60c8
20 files changed
+636 -447

No files matched your search

+19 -11
View File
@@ -14,7 +14,7 @@
///|
/// How long a stationary hold takes to become a long press.
pub let hold_ms : Int = 500
pub let hold_ms : Int32 = 500
///|
/// How far (px) the pointer may travel before it stops being a tap or a hold.
@@ -23,23 +23,23 @@ pub let slop : Double = 10.0
///|
#derive(Eq, Debug)
pub(all) enum Input {
Down(x~ : Double, y~ : Double, chain~ : Array[Int])
Down(x~ : Double, y~ : Double, chain~ : Array[Int32])
Move(x~ : Double, y~ : Double)
Up(x~ : Double, y~ : Double)
Cancel
/// The timer started by `Schedule(_, token)` fired.
Hold(Int)
Hold(Int32)
}
///|
#derive(Eq, Debug)
pub(all) enum Out {
/// Start a timer of this many ms, then send `Hold(token)`.
Schedule(Int, Int)
Schedule(Int32, Int32)
/// The pointer went down on this chain (the app may act at once, e.g. grab a widget).
Began(chain~ : Array[Int], x~ : Double, y~ : Double)
Tap(chain~ : Array[Int])
Press(chain~ : Array[Int])
Began(chain~ : Array[Int32], x~ : Double, y~ : Double)
Tap(chain~ : Array[Int32])
Press(chain~ : Array[Int32])
/// The pointer is at x, y; it went down at x0, y0.
Drag(x~ : Double, y~ : Double, x0~ : Double, y0~ : Double)
/// The pointer is up. `moved`: it travelled past the slop; `held`: a press fired.
@@ -53,13 +53,21 @@ pub(all) struct State {
mut y0 : Double
mut moved : Bool
mut held : Bool
mut chain : Array[Int]
mut token : Int
mut chain : Array[Int32]
mut token : Int32
}
///|
pub fn State::new() -> State {
{ down: false, x0: 0.0, y0: 0.0, moved: false, held: false, chain: [], token: 0 }
{
down: false,
x0: 0.0,
y0: 0.0,
moved: false,
held: false,
chain: [],
token: 0,
}
}
///|
@@ -130,7 +138,7 @@ pub(all) enum Swipe {
///|
/// A touch that travelled dx, dy px in dt ms is a swipe when it was quick, long enough
/// and more vertical than horizontal.
pub fn classify_swipe(dx : Double, dy : Double, dt : Int) -> Swipe? {
pub fn classify_swipe(dx : Double, dy : Double, dt : Int32) -> Swipe? {
if dt >= 700 || dy.abs() < 60.0 || dx.abs() > dy.abs() {
None
} else if dy > 0.0 {