From 5b0da20a5a2c14060d8f41c7f096778f621c01bc Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 28 Oct 2026 08:24:03 +0100 Subject: web: usability pass — panel state, conditional buttons, track placement, hover distance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - control panel starts open on all screen sizes (so the image picker is reachable on phones); it auto-collapses on narrow screens once an image is loaded - 'Fit to window' and the whole Track section only appear when an image is loaded - Track section moved directly below Display, above the pinned info texts (which now carry the margin-top: auto) - hover readout shows the distance to the peak in km, matching the desktop format 'name · height m · dist km' --- crates/wipfel/src/app.rs | 66 ++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 25 deletions(-) (limited to 'crates/wipfel/src/app.rs') diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs index 137e121..eae47d9 100644 --- a/crates/wipfel/src/app.rs +++ b/crates/wipfel/src/app.rs @@ -182,16 +182,10 @@ pub fn app() -> Html { let find_peak = use_state(|| Option::::None); let show_hidden = use_state(|| false); let peak_labels = use_state(|| true); - // 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 - }); + // collapsible control panel (desktop nav bar behaviour): open at + // start so the image picker is reachable even on phones; it + // collapses automatically once an image is loaded on a narrow screen + let nav_open = use_state(|| true); // hill indices of the GPS track, in file order let track = use_state(Vec::::new); let track_width = use_state(|| 200.0f64); @@ -362,6 +356,7 @@ pub fn app() -> Html { let img_size = img_size.clone(); let find_peak = find_peak.clone(); let user_moved = user_moved.clone(); + let nav_open = nav_open.clone(); Callback::from(move |(bytes, name): (Vec, String)| { let (bitmap, status, fit, pan, markers, fit_info) = (bitmap.clone(), status.clone(), fit.clone(), pan.clone(), markers.clone(), fit_info.clone()); @@ -369,9 +364,21 @@ pub fn app() -> Html { let img_size = img_size.clone(); let find_peak = find_peak.clone(); let user_moved = user_moved.clone(); + let nav_open = nav_open.clone(); spawn_local(async move { match bridge::decode_bitmap(&bytes).await { Ok(bmp) => { + // narrow screens: give the canvas the room once + // the setup phase is over + let narrow = bridge::window() + .inner_width() + .ok() + .and_then(|w| w.as_f64()) + .unwrap_or(1200.0) + < 900.0; + if narrow { + nav_open.set(false); + } let (w, h) = (bmp.width(), bmp.height()); let mut md = ImageMetaData::new(); md.load_image_from_bytes(&bytes); @@ -824,7 +831,12 @@ pub fn app() -> Html { let name = markers::nearest_hill(&p, ix, iy, 20.0 / view.scale, *show_hidden) .map(|i| { let h = &p.hills[i]; - format!("{} · {:.0} m", h.name, h.height) + format!( + "{} · {:.0} m · {:.2} km", + h.name, + h.height, + p.get_real_distance(i) / 1000.0 + ) }); hover.set(name); }) @@ -930,7 +942,9 @@ pub fn app() -> Html { { "More information…" } - + if bitmap.is_some() { + + } Html { if let Some(h) = hover.as_ref() {

{ h.clone() }

} +
{ "Track" }
+ + if !track.is_empty() { + + } } -

- { "Hover a dot to see the peak · click to mark it (or pick from the list) · drag to adjust · right-click to remove." } -

-

- { "The view is fitted as soon as markers are placed; more markers improve the fit." } -

-
{ "Track" }
- - if !track.is_empty() { - - } +
+

+ { "Hover a dot to see the peak · click to mark it (or pick from the list) · drag to adjust · right-click to remove." } +

+

+ { "The view is fitted as soon as markers are placed; more markers improve the fit." } +

+
-- cgit v1.2.3