diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 17:33:46 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 17:33:46 +0100 |
| commit | 1efd65ef8912b5099b65ecd5029c41481eab6757 (patch) | |
| tree | 56babccc565eb672911d683365ddb5f6c5fea87a /crates/wipfel | |
| parent | 39297aa49feed815d68b8955769bd3afa3febf10 (diff) | |
web: pinch probe with pointer-event counters (build 27g)
Diffstat (limited to 'crates/wipfel')
| -rw-r--r-- | crates/wipfel/src/app.rs | 4 | ||||
| -rw-r--r-- | crates/wipfel/src/canvas_view.rs | 23 |
2 files changed, 22 insertions, 5 deletions
diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs index 60a4a15..843aaa0 100644 --- a/crates/wipfel/src/app.rs +++ b/crates/wipfel/src/app.rs @@ -149,7 +149,7 @@ fn find_peak_panel(p: &FpProps) -> Html { pub fn app() -> Html { let bitmap = use_state(|| None::<web_sys::ImageBitmap>); let view = use_state(ViewState::default); - let status = use_state(|| "No image loaded · build 27f".to_string()); + let status = use_state(|| "No image loaded · build 27g".to_string()); let db_status = use_state(|| "Loading hill database…".to_string()); let fit_info = use_state(String::new); let tick = use_state(|| 0u32); @@ -670,13 +670,11 @@ pub fn app() -> Html { zoom: { let view = view.clone(); let user_moved = user_moved.clone(); - let status = status.clone(); Callback::from(move |(cx, cy, factor): (f64, f64, f64)| { *user_moved.borrow_mut() = true; let v = &*view; let ns = (v.scale * factor).clamp(0.02, 64.0); let k = ns / v.scale; - status.set(format!("zoom cb f={factor:.3} s {:.4}->{:.4}", v.scale, ns)); view.set(ViewState { scale: ns, ox: cx - (cx - v.ox) * k, diff --git a/crates/wipfel/src/canvas_view.rs b/crates/wipfel/src/canvas_view.rs index f86683f..bcff21f 100644 --- a/crates/wipfel/src/canvas_view.rs +++ b/crates/wipfel/src/canvas_view.rs @@ -114,6 +114,8 @@ pub fn canvas_view(props: &Props) -> Html { pts: Vec::new(), pinch: None, }); + // event counters for pinch diagnostics (pointerdown / pointermove) + let evcount = use_mut_ref(|| (0u32, 0u32)); // redraw on every view/bitmap/marker change and on resize ticks { @@ -378,6 +380,7 @@ pub fn canvas_view(props: &Props) -> Html { let view = props.view.clone(); let bitmap = props.bitmap.clone(); let debug = props.callbacks.debug.clone(); + let evcount = evcount.clone(); Callback::from(move |e: PointerEvent| { e.prevent_default(); let rect = canvas_ref @@ -428,7 +431,15 @@ pub fn canvas_view(props: &Props) -> Html { let _ = c.set_pointer_capture(e.pointer_id()); } } - debug.emit(format!("pointerdown id={} pts={n}", e.pointer_id())); + debug.emit(format!( + "pd#{} id={} pts={n}", + { + let mut c = evcount.borrow_mut(); + c.0 += 1; + c.0 + }, + e.pointer_id() + )); }) }; @@ -441,6 +452,7 @@ pub fn canvas_view(props: &Props) -> Html { let to_img = to_img.clone(); let canvas_ref = props.canvas_ref.clone(); let debug = props.callbacks.debug.clone(); + let evcount = evcount.clone(); let scale = props.view.scale; Callback::from(move |e: PointerEvent| { // update the pointer table and handle two-finger pinch @@ -479,7 +491,14 @@ pub fn canvas_view(props: &Props) -> Html { d.pinch = Some((dist, cx, cy)); d.moved = true; let dbg = match ev { - Some((f, ..)) => format!("pinch d={dist:.0} f={f:.3} s={:.4}", scale), + Some((f, ..)) => { + let (pd, mv) = { + let mut c = evcount.borrow_mut(); + c.1 += 1; + (c.0, c.1) + }; + format!("pinch d={dist:.0} f={f:.3} pd={pd} mv={mv} s={:.4}", scale) + } None => format!("pinch d={dist:.0} seed"), }; (ev, dbg) |
