From f20429147745a0f8a8c1757c99687eae2f7aec2f Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 11:18:08 +0000 Subject: [PATCH] PreviewPane: an aspect sets the well's height from its width; Export As shows a square preview beside its settings --- .../src/patterns/form_dialogs/export/as_dialog.rs | 2 +- crates/ui-patterns/src/patterns/form_dialogs/preview.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/export/as_dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/export/as_dialog.rs index 6e15e7f350..4380b114a3 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/export/as_dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/export/as_dialog.rs @@ -401,7 +401,7 @@ impl Pass<'_> { fn preview(&self, ui: &mut Ui, options: &ExportOptions, held: &mut Held) { let words = self.words; let state = held.shown.as_ref().map_or(PreviewState::Pending(None), |shown| shown.state.clone()); - let pane = PreviewPane::state(words.preview.clone(), state, &held.view).click_centres(true).show(ui); + let pane = PreviewPane::state(words.preview.clone(), state, &held.view).click_centres(true).aspect(1.0).show(ui); held.view = pane.view.unwrap_or(pane.shown); let name = self.formats.iter().find(|format| format.id == options.format).map_or("", |format| format.name).to_uppercase(); let estimate = match held.shown.as_ref().and_then(|shown| shown.estimate) { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/preview.rs b/crates/ui-patterns/src/patterns/form_dialogs/preview.rs index 5a48104df3..d3bc422f8f 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/preview.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/preview.rs @@ -235,6 +235,10 @@ pub struct PreviewPane<'a> { /// Whether a click centres the view on the point clicked. #[prop] click_centres: bool, + /// The well's width over its height: the pane is as tall as its width over this. Without one, the height is the + /// one its container gives, at least the plot height. + #[prop] + aspect: Option, /// The view after this pass, when the user changed it. moved: Option, /// The well took the second press of a double click this pass. @@ -264,6 +268,7 @@ impl PreviewPane<'_> { state, view: view.clone(), click_centres: true, + aspect: None, moved: None, double_clicked: false, overlay: None, @@ -393,7 +398,8 @@ impl Component for PreviewPane<'_> { } fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { - Vec2::new(cx.picture_width(cx.tokens.size.plot.width, f32::INFINITY), 0.0) + let width = cx.picture_width(cx.tokens.size.plot.width, f32::INFINITY); + Vec2::new(width, self.aspect.filter(|aspect| *aspect > 0.0).map_or(0.0, |aspect| width / aspect)) } fn sense(&self) -> Sense {