diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 12:06:13 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 12:06:13 +0100 |
| commit | 70784357c804d3411bb93fa6e0a74c9ffcd3d3ad (patch) | |
| tree | 37ae4c8b0df68e59658ccbebb6bb2abf17f43d76 /crates/gipfel-web/src/widgets.rs | |
| parent | 9e1d138a29aafc52d2da68b66f7d6ea00081134f (diff) | |
web: W3 — compass strip, parameter sliders, collision-free labels
- compass.rs: canvas port of the desktop Aligned compass strip —
adaptive tick step, direction labels (red N), center triangle and
azimuth readout, drag to rotate the view (Newton inverse projection,
same solver as desktop; round-trip tests ported and passing)
- sidebar sections like the desktop: Viewpoint (lat/lon/height number
inputs), Orientation (azimuth/focal/pitch/roll sliders, desktop
ranges), Projection (fit-distortion toggle), Display (visibility
with the 0.11-r inversion, label size 8-28 px)
- every control applies to the Panorama immediately (focal maps via
scale = focal * w / 35, same formula as the metadata path)
- marker labels: ported the desktop layout_label_y collision push-up
with yellow leader lines (cross, vertical, horizontal), label font
size live-adjustable
- main area split: canvas + 56 px compass strip
Diffstat (limited to 'crates/gipfel-web/src/widgets.rs')
| -rw-r--r-- | crates/gipfel-web/src/widgets.rs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/crates/gipfel-web/src/widgets.rs b/crates/gipfel-web/src/widgets.rs new file mode 100644 index 0000000..f93f424 --- /dev/null +++ b/crates/gipfel-web/src/widgets.rs @@ -0,0 +1,76 @@ +//! Small form controls: full-width slider with value readout above +//! (mirrors the desktop `slider_item` layout) and a numeric input row. + +use web_sys::HtmlInputElement; +use yew::prelude::*; + +#[derive(Properties, PartialEq)] +pub struct SliderProps { + pub label: AttrValue, + /// formatted value shown right of the label + pub display: AttrValue, + pub value: f64, + pub min: f64, + pub max: f64, + pub step: f64, + pub onchange: Callback<f64>, +} + +#[function_component(SliderItem)] +pub fn slider_item(p: &SliderProps) -> Html { + let onchange = { + let onchange = p.onchange.clone(); + Callback::from(move |e: Event| { + let input: HtmlInputElement = e.target_unchecked_into(); + if let Ok(v) = input.value().parse::<f64>() { + onchange.emit(v); + } + }) + }; + html! { + <div class="slider"> + <div class="sliderhead"> + <span>{ p.label.as_ref().to_string() }</span> + <span class="val">{ p.display.as_ref().to_string() }</span> + </div> + <input + type="range" + min={p.min.to_string()} + max={p.max.to_string()} + step={p.step.to_string()} + value={p.value.to_string()} + {onchange} + /> + </div> + } +} + +#[derive(Properties, PartialEq)] +pub struct NumProps { + pub label: AttrValue, + pub value: f64, + pub step: f64, + #[prop_or(2)] + pub decimals: usize, + pub onchange: Callback<f64>, +} + +#[function_component(NumItem)] +pub fn num_item(p: &NumProps) -> Html { + let onchange = { + let onchange = p.onchange.clone(); + Callback::from(move |e: Event| { + let input: HtmlInputElement = e.target_unchecked_into(); + if let Ok(v) = input.value().parse::<f64>() { + onchange.emit(v); + } + }) + }; + let display = format!("{:.*}", p.decimals, p.value); + html! { + <label class="numrow"> + <span>{ p.label.as_ref().to_string() }</span> + <input type="number" step={p.step.to_string()} value={display} {onchange} /> + </label> + } +} |
