Mobile gestures: item tap/drag/double-tap/long-press on original windows

Port the EterPythonLib CSlotWindow/CGridSlotWindow mouse handlers
(select, drop, use, right click, tooltips, grid picking/CheckMoving) and
CWindowManager IsDragging/right button, which were missing so item
interaction did not work on desktop either. app.SetMouseHandler now
renders the attached icon, app.IsPressed reads real key state, desktop
double clicks reach the window manager.

The touch router maps UI touches to the original mouse: tap = click at
the touch-down point, drag = press-and-drag, double tap = double click,
long press on an item slot = touch.SetLongPressEvent, which opens the
ui_mobile_actions item sheet (use / split / quick slot via virtual
Shift/Ctrl). New ava2.inventory_touch test drives uiinventory.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-13 05:16:12 +09:00
co-authored by Claude Opus 5.5
parent 908838c8f9
commit 6244b1d860
17 changed files with 1301 additions and 81 deletions
+42
View File
@@ -1453,3 +1453,45 @@ the app is in the background (iOS suspends SDL_AppIterate). Android still
uses the classic loop. Paths the client opens without lower-casing them
would fail on iOS; none showed up in the login screen or the game phase,
but character select and a real-server login have not been run on iOS yet.
### 2026-10-13 Mobile gestures — item and window interaction
- Before this step the port's `CSlotWindow` had no mouse handlers, so item
pick-up, drop, equip, double-click use, right-click and hover tooltips did
not work on desktop either. Ported from EterPythonLib, 1:1:
- `PythonSlotWindow.cpp` handlers: left down → OnSelectItemSlot/OnSelectEmptySlot,
the drop on left up, right down, double click → OnUseSlot, over/over-out
tooltips, RefreshSlot.
- `PythonGridSlotWindow.cpp`: the slot vector, GetPickedSlotList,
OnRefreshSlot, CheckMoving, the grid GetPickedSlotPointer.
- `CWindowManager`: IsDragging (the 10 px rule), mouse over on every move,
right button down/up with DeattachIcon.
- `app.SetMouseHandler` now stores the handler. app_loop calls its
Update/Render after the phase window, so the attached icon follows the
pointer. `app.IsPressed` reads the real keyboard state, so desktop
Shift-split and Ctrl-quickslot work. Desktop double clicks
(`clicks >= 2`) reach RunMouseLeftButtonDoubleClick. Keys are released on
focus loss and when the app goes to the background.
- Touch router UI gestures:
- A tap sends move, down and up at the touch-down point.
- A drag past tap_slop presses at the start point.
- A double tap (within 300 ms and 40 px) becomes a double click.
- A long press (450 ms) on an item slot calls `touch.SetLongPressEvent`.
- The callback opens `ui_mobile_actions.ItemActionSheet` with Use, Split and
Quick slot. Split and Quick slot run the original Shift/Ctrl branches via
`touch.SetVirtualKey`.
- Mapping table: docs/MOBILE-ARCHITECTURE.md, "物品与窗口手势".
Verified: the new `ava2.inventory_touch` test drives the original
uiinventory.py through the router and the window manager. It covers the
hover tooltip, tap pick-up and tap drop (move packet 0→5), drag 0→6,
double-tap use, the long-press sheet (Use, Split opens dlgPickMoney,
Quick slot), tap-outside close, long press on an empty cell, and
app.IsPressed. `touch_router_test` covers the gesture timing. The phone
simulation (`--phone --touch`) draws no software cursor. Desktop 55/55.
Outstanding:
- Gestures have not been tried on an Android or iOS device yet.
- Drop and sell are drag-only; the sheet has no buttons for them.
- A button's zero-size TextLine sits at the button's exact centre pixel,
and IsIn is inclusive, as in the original. Only that one pixel misses
the button.