Gesture: taps, long presses, drags and flings from pointer phases

What a finger or a mouse did, decided from raw Down/Move/Up/Cancel
phases over the app's own point type: a short press within the slop is a
tap at the press position, a press held past the long-press time (the
host's timer) a long press, movement past the slop a drag with its
deltas, a fast release a fling with a velocity (the last 100 ms of
movement before it: a finger held still before letting go flings
nothing). With it the scroll physics of a list (clamped offset, a
decaying fling that stops at the edges) and the topmost hit region under
a point.

Tested: tests/Gesture.
This commit is contained in:
Jorijn van der Graaf 2026-10-18 00:08:34 +02:00
commit f360a746c2
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
5 changed files with 348 additions and 9 deletions

View file

@ -78,9 +78,9 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
? LocalProject({ .projectFile = "../Crafter/Crafter.DB/project.cpp", .args = depArgs })
: GitProject({ .source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.DB.git" }, .args = depArgs });
// imsd-messages-core — numbers, time, the model, word wrap, the store and
// the sync logic: std + Crafter.DB, no GLib, so every test runs with no
// bus, no phone and no GPU.
// imsd-messages-core — numbers, time, the model, word wrap, gestures,
// the store and the sync logic: std + Crafter.DB, no GLib, so every
// test runs with no bus, no phone and no GPU.
static auto Core = std::make_unique<Configuration>();
Core->path = "./";
Core->name = "imsd-messages-core";
@ -89,7 +89,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
Core->type = ConfigurationType::LibraryStatic;
Core->dependencies = { db };
{
std::array<fs::path, 7> ifaces = {
std::array<fs::path, 8> ifaces = {
"interfaces/ImsdMessages",
"interfaces/ImsdMessages-Number",
"interfaces/ImsdMessages-Time",
@ -97,6 +97,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
"interfaces/ImsdMessages-Wrap",
"interfaces/ImsdMessages-Store",
"interfaces/ImsdMessages-Sync",
"interfaces/ImsdMessages-Gesture",
};
std::array<fs::path, 0> impls = {};
Core->GetInterfacesAndImplementations(ifaces, impls);
@ -148,6 +149,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
cfg.AddTest("Model").Dependencies({ Core.get() });
cfg.AddTest("Store").Dependencies({ Core.get(), db });
cfg.AddTest("Sync").Dependencies({ Core.get() });
cfg.AddTest("Gesture").Dependencies({ Core.get() });
// The bus library's decoding test includes GLib's headers: the library's
// compile flags (its link flags come with the library).
TestBuilder decode = cfg.AddTest("Decode");