feat(mobile): canvas-only mobile mode — pinch-zoom/pan/tap gestures + chrome-less editors
On a mobile device (or ?mobile=1) the editors run canvas-only with touch gestures driving the view: - touch-gestures.ts: pure recognizer (unit-tested) + DOM shim installed in boot preRun — one-finger drag → synthetic middle-drag (pan), pinch → synthetic wheel at the centroid (zoom-to-cursor), tap → left click. preRun registration order is what lets stopImmediatePropagation suppress the wx layer's single-finger→LEFT-drag touch mapping. - kicadSetChrome(bool) embind: hides all AUI panes except DrawFrame + the menubar/status bar via generic wx APIs (kicad fork untouched); boot polls it after runtime init. Pairs with the wxwidgets IsShown layout fix. - mobile-mode.ts: ?mobile=1/0 override or UA-CH/coarse-pointer autodetect; shell hides its overlays and the inherent-to-mobile preflight warnings. - e2e: mobile-chromium project (Pixel 7) + 4 specs (chrome-less, tap, pinch, pan) with screenshot-invertibility assertions; also fixes tool-switch.spec's stale pre-scope-refactor URLs (was broken on main). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
3a2255c817
commit
dc7c60f723
13 changed files with 1039 additions and 24 deletions
|
|
@ -29,6 +29,10 @@
|
|||
#include <wx/app.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/window.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <wx/aui/framemanager.h>
|
||||
#include <kiway.h>
|
||||
#include <kiway_player.h>
|
||||
|
||||
|
|
@ -120,6 +124,52 @@ static bool kicadOpenFile( std::string path )
|
|||
}
|
||||
|
||||
|
||||
// Canvas-only mobile chrome toggle (features/mobile): hide/show every AUI pane
|
||||
// except the central draw canvas, plus the menubar and status bar, so the GAL
|
||||
// canvas fills the frame. Generic wxFrame/wxAui surface only (keeps this TU
|
||||
// header-light and serves both editor frames). Hidden bars release their space
|
||||
// because the wasm port's frame client-area math skips !IsShown() bars (native
|
||||
// parity, see wxwidgets/src/wasm/frame.cpp). Returns false until the editor
|
||||
// frame exists — main() builds it after runtime init — so JS polls this.
|
||||
static bool kicadSetChrome( bool aShow )
|
||||
{
|
||||
wxFrame* frame =
|
||||
wxTheApp ? dynamic_cast<wxFrame*>( wxTheApp->GetTopWindow() ) : nullptr;
|
||||
|
||||
if( !frame )
|
||||
return false;
|
||||
|
||||
if( wxMenuBar* menuBar = frame->GetMenuBar() )
|
||||
menuBar->Show( aShow );
|
||||
|
||||
// Kept alive rather than detached: KiCad SetStatusText()s on every cursor
|
||||
// move, and wxFrameBase wxCHECKs a null status bar.
|
||||
if( wxStatusBar* statusBar = frame->GetStatusBar() )
|
||||
statusBar->Show( aShow );
|
||||
|
||||
if( wxAuiManager* mgr = wxAuiManager::GetManager( frame ) )
|
||||
{
|
||||
wxAuiPaneInfoArray& panes = mgr->GetAllPanes();
|
||||
|
||||
for( size_t i = 0; i < panes.GetCount(); ++i )
|
||||
{
|
||||
wxAuiPaneInfo& pane = panes.Item( i );
|
||||
|
||||
// keep the central editor canvas (named "DrawFrame" in both editors)
|
||||
if( pane.dock_direction == wxAUI_DOCK_CENTER || pane.name == wxT( "DrawFrame" ) )
|
||||
continue;
|
||||
|
||||
pane.Show( aShow );
|
||||
}
|
||||
|
||||
mgr->Update();
|
||||
}
|
||||
|
||||
frame->SendSizeEvent();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// C++ → JS save notification. Called from BOTH fork save chokepoints
|
||||
// (PCB_EDIT_FRAME::SavePcbFile and SCH_EDIT_FRAME::saveSchematicFile) — one shared
|
||||
// definition serves the merged image. No-op without a JS listener.
|
||||
|
|
@ -275,6 +325,9 @@ EMSCRIPTEN_BINDINGS(kicad_editor) {
|
|||
// Programmatic file open (preferred over UI automation from the web app).
|
||||
function("kicadOpenFile", &kicadOpenFile);
|
||||
|
||||
// Canvas-only mobile mode (features/mobile).
|
||||
function("kicadSetChrome", &kicadSetChrome);
|
||||
|
||||
// Yjs collaborative bridge entry points — same JS contract as the standalone
|
||||
// bundles, dispatched on the active editor frame.
|
||||
function("kicadCollabApply", &collabApply);
|
||||
|
|
|
|||
Loading…
Reference in a new issue