PreviewPane: an aspect sets the well's height from its width; Export As shows a square preview beside its settings

This commit is contained in:
aiongg
2026-11-12 14:32:50 +00:00
parent efb011fe06
commit f204291477
2 changed files with 8 additions and 2 deletions
@@ -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) {
@@ -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<f32>,
/// The view after this pass, when the user changed it.
moved: Option<PreviewView>,
/// 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 {