From 5f8428d01241ed0a3376ecf9b671939a858d2465 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 15:01:31 +0100 Subject: web: FOV visibility limit, GPX controls in Display, collapsible sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - port of the desktop bump() lens-FOV clamp: max_view_angle is the angle at which the (distorted) projection reaches the image edge; peaks beyond it cannot be inside the photo even when the fitted distortion folds their projection back into the image. Recomputed each render (idempotent, only rebuilds visibility on change) — this is what let impossible peaks show up at high visibility settings - 'Load GPX Track…' moved from the top into the Display section next to the Track width slider (optional, advanced) - collapsible control panel: collapse button in the sidebar corner, floating hamburger button over the canvas when hidden; starts collapsed on viewports narrower than 900px --- crates/wipfel/src/app.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'crates/wipfel/src/app.rs') diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs index d0c8ecd..6e0ef0b 100644 --- a/crates/wipfel/src/app.rs +++ b/crates/wipfel/src/app.rs @@ -17,7 +17,7 @@ use yew::prelude::*; use crate::bridge; use crate::canvas_view::{CanvasView, DotView, MarkerView, TrackView, ViewCallbacks, ViewState}; -use crate::compass::{Compass, CompassData}; +use crate::compass::{alph_at_img_x, Compass, CompassData}; use crate::markers::{self, Marker}; use crate::widgets::{NumItem, SliderItem}; @@ -164,6 +164,16 @@ pub fn app() -> Html { let find_peak = use_state(|| Option::::None); let show_hidden = use_state(|| false); let peak_labels = use_state(|| false); + // collapsible control panel (desktop nav bar behaviour): start + // collapsed on narrow screens + let nav_open = use_state(|| { + bridge::window() + .inner_width() + .ok() + .and_then(|w| w.as_f64()) + .unwrap_or(1200.0) + >= 900.0 + }); // hill indices of the GPS track, in file order let track = use_state(Vec::::new); let track_width = use_state(|| 200.0f64); @@ -755,6 +765,29 @@ pub fn app() -> Html { }, }; + // Lens FOV visibility limit, port of the desktop bump(): the angle at + // which the (possibly distorted) projection reaches the image edge. + // Peaks beyond it cannot be inside the photo even if the fitted + // distortion folds their projection back into the image. Running this + // every render is idempotent and cheap; visibility is only rebuilt + // when the limit actually changed. + { + let mut p = pan.borrow_mut(); + let limit = if img_size.0 > 0 { + let c = p.parms.a_center; + let proj = gipfel_core::projection::projection_from_type(p.projection_type); + let a_edge = alph_at_img_x(p.projection_type, &*proj, &p.parms, img_size.0 as f64 / 2.0, c); + (a_edge - c).abs() + } else { + 0.0 + }; + if (limit - p.max_view_angle).abs() > 1e-9 { + p.max_view_angle = limit; + let known: Vec = markers.iter().map(|m| m.hill).collect(); + p.update_visible_mountains(Some(&known)); + } + } + // overlay data for the canvas let marker_views: Vec = { let p = pan.borrow(); @@ -805,16 +838,26 @@ pub fn app() -> Html { .collect() }; + let collapse_cb = { + let nav_open = nav_open.clone(); + Callback::from(move |_: MouseEvent| nav_open.set(false)) + }; + let expand_cb = { + let nav_open = nav_open.clone(); + Callback::from(move |_: MouseEvent| nav_open.set(true)) + }; + let zoom_pct = (view.scale * 100.0).round(); let n_markers = markers.len(); html! {
-