mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-12 05:22:48 +00:00
Read pen and finger Pointer Events in the web shell (capture phase) instead of eframe's touch handlers, which can't tell a pen from a finger and see every touch twice. The pen drives the pointer with its pressure and hovers; fingers are touch contacts for pinch, two-finger pan and undo/redo taps. Once a pen has been seen (remembered in localStorage), a finger or a resting palm never presses a tool on the canvas, and a pen landing cancels fingers already down. A long press drops the tool press and opens the context menu. The page no longer scrolls, zooms or selects under touch, and the canvas stays inside the safe areas of a full-screen app.
37 lines
1.4 KiB
Rust
37 lines
1.4 KiB
Rust
//! VectorCraft in the browser.
|
|
//!
|
|
//! Runs the same [`vectorcraft_ui_egui::VectorcraftApp`] as the desktop app through eframe's web
|
|
//! runner (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release`
|
|
//! from this directory; see `docs/development.md` ("Web build").
|
|
//!
|
|
//! Differences from the desktop app:
|
|
//! - no TCP control server (browsers can't listen on sockets);
|
|
//! - File → Open uses the browser file picker; bytes arrive asynchronously through
|
|
//! `Services::inbox`;
|
|
//! - Save / Export trigger a browser download;
|
|
//! - dropped files are read asynchronously by `web::WebShell` and delivered through the inbox;
|
|
//! - pen and finger input is read from Pointer Events by `pencil` (Apple Pencil pressure and
|
|
//! hover, palm rejection, fingers navigate once a pen has been seen).
|
|
//!
|
|
//! URL query flags: `?webgl` forces the WebGL2 backend instead of WebGPU; `?lang=es` (any
|
|
//! language code) stands in for the browser's languages when the interface language is Automatic.
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod fonts;
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod locks;
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod pencil;
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod web;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
fn main() {
|
|
web::start();
|
|
}
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
fn main() {
|
|
eprintln!("vectorcraft-web only runs in the browser: build it with `trunk build --release` in apps/vectorcraft-web");
|
|
}
|