From a2a7f492a2c9dde6a6be27ba31bae382b802429b Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 16:34:53 +0000 Subject: [PATCH 1/8] Levels and Curves show the point picker row first, above the Channel select --- crates/imaging/src/ui/adjust/curves_panel.rs | 47 +++++++++---------- crates/imaging/src/ui/adjust/levels_panel.rs | 48 ++++++++++---------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/crates/imaging/src/ui/adjust/curves_panel.rs b/crates/imaging/src/ui/adjust/curves_panel.rs index 5c6966e40..f01d19b13 100644 --- a/crates/imaging/src/ui/adjust/curves_panel.rs +++ b/crates/imaging/src/ui/adjust/curves_panel.rs @@ -1,5 +1,5 @@ -//! [`CurvesPanel`]: the Curves adjustment around the [`CurveEditor`]: the Channel select, the mode -//! icons (points, pencil), Smooth, the point pickers, the other channels overlaid on the composite +//! [`CurvesPanel`]: the Curves adjustment around the [`CurveEditor`]: the point pickers, the Channel +//! select, the mode icons (points, pencil), Smooth, the other channels overlaid on the composite //! and the hint line; and the ⌘/Ctrl-click-on-the-image helper //! ([`CurvesPanel::add_point_from_sample`]). @@ -139,15 +139,15 @@ type SamplerFn<'a> = Box Vec + 'a>; /// The Curves adjustment: Image › Adjustments › Curves and a Curves layer's Properties panel. /// -/// Top to bottom: -/// 1. The Channel select ([`ToneChannels`]); an isolated channel is the only entry, its name shown exactly as the +/// Top to bottom (PhotoCraft's order): +/// 1. With [`pickers`](Self::pickers), the point picker row. +/// 2. The Channel select ([`ToneChannels`]); an isolated channel is the only entry, its name shown exactly as the /// host gave it. -/// 2. The mode row: two icon-only toggle buttons ("Edit points to modify the curve", "Draw to modify the curve", the +/// 3. The mode row: two icon-only toggle buttons ("Edit points to modify the curve", "Draw to modify the curve", the /// current one pressed) and Smooth (enabled in pencil mode only). -/// 3. The [`CurveEditor`] for the shown channel: in its colour, over its histogram, in pencil mode for a drawn curve, +/// 4. The [`CurveEditor`] for the shown channel: in its colour, over its histogram, in pencil mode for a drawn curve, /// and, on a composite only, the other channels' curves as overlays (Photoshop; none for an isolated channel). -/// 4. The hint line, with the key names from the platform's shortcut words. -/// 5. With [`pickers`](Self::pickers), the point picker row. +/// 5. The hint line, with the key names from the platform's shortcut words. /// /// - **Smooth** replaces the shown map with its moving average over 7 levels (radius 3, shrunk at the ends so the /// first and last levels keep their values: PhotoCraft's `smooth_curve_map`), as one `Set`. @@ -168,7 +168,7 @@ pub struct CurvesPanel<'a> { /// The host's interpolation of point curves ([`CurveEditor::sampler`]). #[prop(boxed = "Fn(&[[f32; 2]]) -> Vec + 'a")] sampler: Option>, - /// The armed point picker; the picker row shows when it is given. + /// The armed point picker; the picker row shows, first, when it is given. #[prop] pickers: Option>>, /// The document canvas the ⌘/Ctrl-click and the eyedroppers reach under the dialog. @@ -313,6 +313,21 @@ impl<'a> CurvesPanel<'a> { // Alt+2…Alt+6 pick the Channel select's entry in a dialog; Properties has no such keys. let stack = if context.is_dialog() { stack.command_scope(ToneChannelCommands::SCOPE) } else { stack }; let group = stack.show(ui, |ui, cx| { + if let Some(armed) = pickers.as_mut() { + let mut row = TonePickerRow::new(armed.reborrowed()); + if pickers_unavailable { + row = row.unavailable(); + } + if let Some(canvas) = canvas { + row = row.canvas(canvas); + } + for each in TonePicker::ALL { + let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray())); + row = row.enabled_picker(each, usable); + } + picker = row.show(ui).change; + } + let value = match curves.reborrow().read(cx) { Some(Mixed::Same(value)) => value, _ => ToneCurves::identity(&channels), @@ -406,20 +421,6 @@ impl<'a> CurvesPanel<'a> { } edit = events; - if let Some(armed) = pickers.as_mut() { - let mut row = TonePickerRow::new(armed.reborrowed()); - if pickers_unavailable { - row = row.unavailable(); - } - if let Some(canvas) = canvas { - row = row.canvas(canvas); - } - for each in TonePicker::ALL { - let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray())); - row = row.enabled_picker(each, usable); - } - picker = row.show(ui).change; - } // An edit belongs to the channel it was drawn for; a switch shows from the next pass, with no selection. shown_channel = if picked == channel || !edit.is_empty() { channel } else { picked }; write_shown(&mut channel_bind, cx, stored, shown_channel); diff --git a/crates/imaging/src/ui/adjust/levels_panel.rs b/crates/imaging/src/ui/adjust/levels_panel.rs index 9e5c44d1b..62951796c 100644 --- a/crates/imaging/src/ui/adjust/levels_panel.rs +++ b/crates/imaging/src/ui/adjust/levels_panel.rs @@ -1,5 +1,5 @@ -//! [`LevelsPanel`]: the Levels adjustment around the [`LevelsEditor`]: the Channel select, Auto, -//! the editor over the shown channel's histogram and the point pickers. +//! [`LevelsPanel`]: the Levels adjustment around the [`LevelsEditor`]: the point pickers, the +//! Channel select, Auto and the editor over the shown channel's histogram. #[cfg(feature = "screen-testing")] mod stories; @@ -78,20 +78,19 @@ impl Outcome for LevelsPanelOutput { /// The Levels adjustment: Image › Adjustments › Levels and a Levels layer's Properties panel /// (the same call with [`AdjustContext::properties`]). /// -/// Top to bottom (PhotoCraft's and Photoshop's order): -/// 1. The Channel select ([`ToneChannels`]; an isolated channel is the only entry, named as given) +/// Top to bottom (PhotoCraft's order): +/// 1. With [`pickers`](Self::pickers), the [`TonePickerRow`]: Set Black, Neutral Gray, White Point. +/// 2. The Channel select ([`ToneChannels`]; an isolated channel is the only entry, named as given) /// and Auto. Picking a channel shows that channel's levels and histogram; the choice is the /// panel's own state, reported as [`LevelsPanelOutput::channel`]. -/// 2. The [`LevelsEditor`] for the shown channel, over its histogram drawn in the channel's colour; +/// 3. The [`LevelsEditor`] for the shown channel, over its histogram drawn in the channel's colour; /// a [`stale`](Self::stale) histogram shows the stale mark. -/// 3. With [`pickers`](Self::pickers), the [`TonePickerRow`] below: Set Black, Neutral Gray, White -/// Point. /// /// - **Auto** sets the shown channel to [`Levels::auto`] of its histogram as one `Set`; without a /// histogram it is disabled. /// - **Edits**: the editor's events pass through for the shown channel, mapped onto the per-channel /// values. -/// - **Keyboard**: Tab visits the Channel select, Auto, the editor, then the pickers. +/// - **Keyboard**: Tab visits the pickers, the Channel select, Auto, then the editor. #[must_use = "show the panel with `show`"] #[derive(Pattern, Props)] pub struct LevelsPanel<'a> { @@ -105,7 +104,7 @@ pub struct LevelsPanel<'a> { /// The histograms are being recounted. #[prop] stale: bool, - /// The armed point picker; the picker row shows when it is given. + /// The armed point picker; the picker row shows, first, when it is given. #[prop] pickers: Option>>, /// The document canvas the armed picker samples. @@ -178,6 +177,22 @@ impl<'a> LevelsPanel<'a> { // Alt+2…Alt+6 pick the Channel select's entry in a dialog; Properties has no such keys. let stack = if context.is_dialog() { stack.command_scope(ToneChannelCommands::SCOPE) } else { stack }; let group = stack.show(ui, |ui, cx| { + if let Some(armed) = pickers.as_mut() { + let mut row = TonePickerRow::new(armed.reborrowed()); + if pickers_unavailable { + row = row.unavailable(); + } + if let Some(canvas) = canvas { + row = row.canvas(canvas); + } + for each in TonePicker::ALL { + // A grey document has no Neutral Gray point. + let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray())); + row = row.enabled_picker(each, usable); + } + picker = row.show(ui).change; + } + let all: Vec = match levels.reborrow().read(cx) { Some(Mixed::Same(all)) => all, _ => Vec::new(), @@ -232,21 +247,6 @@ impl<'a> LevelsPanel<'a> { } edit = events; - if let Some(armed) = pickers.as_mut() { - let mut row = TonePickerRow::new(armed.reborrowed()); - if pickers_unavailable { - row = row.unavailable(); - } - if let Some(canvas) = canvas { - row = row.canvas(canvas); - } - for each in TonePicker::ALL { - // A grey document has no Neutral Gray point. - let usable = picker_enabled[each as usize] && !(each == TonePicker::Gray && (channels.is_gray() || context.is_gray())); - row = row.enabled_picker(each, usable); - } - picker = row.show(ui).change; - } // An edit belongs to the channel it was drawn for; a switch shows from the next pass. shown = if picked == channel || !edit.is_empty() { channel } else { picked }; write_shown(&mut channel_bind, cx, stored, shown); From 68f7685b8ecac48ced3c8e3d28754c7051e61838 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 16:37:51 +0000 Subject: [PATCH 2/8] A form dialog's buttons go across the foot unless it asks for side buttons; Guide Layout, Layer Style and the Color Picker keep their button column --- crates/color/src/ui/picker_dialog.rs | 1 + crates/imaging/src/ui/adjust/hosted.rs | 4 +-- crates/imaging/src/ui/layer_style/hosted.rs | 1 + .../src/patterns/form_dialogs/form.rs | 31 +++++++++++++------ .../src/patterns/form_dialogs/guides.rs | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/crates/color/src/ui/picker_dialog.rs b/crates/color/src/ui/picker_dialog.rs index a30222f41..134ba3c1d 100644 --- a/crates/color/src/ui/picker_dialog.rs +++ b/crates/color/src/ui/picker_dialog.rs @@ -454,6 +454,7 @@ impl StackDialog for ColorPickerDialog { let shown = Dialog::new(title.clone()) .opened(Bind::bound(open)) .buttons(buttons) + .side_buttons(true) .close_on_enter(true) .initial_focus(Initial::Keep) .roomy(true) diff --git a/crates/imaging/src/ui/adjust/hosted.rs b/crates/imaging/src/ui/adjust/hosted.rs index 9f4e55536..6117a1c2c 100644 --- a/crates/imaging/src/ui/adjust/hosted.rs +++ b/crates/imaging/src/ui/adjust/hosted.rs @@ -87,8 +87,8 @@ type Editor = dyn for<'b> Fn(&mut Ui, &mut V, &mut AdjustDialogCx<'b>) -> type JsonForm = dyn Fn(&V, bool) -> serde_json::Map + Send; /// An Image › Adjustments dialog the [`DialogHost`](craft_ui::dialog::DialogHost) owns: an adjustment editor over a -/// value `V` the host keeps, in a form dialog with OK and Cancel beside the editor (Alt turns Cancel into Reset, which -/// restores the value the dialog opened with) and the Preview box under them. The editor runs in its dialog form +/// value `V` the host keeps, in a form dialog with the Preview box at the start of the footer and OK and Cancel at its +/// end (Alt turns Cancel into Reset, which restores the value the dialog opened with). The editor runs in its dialog form /// ([`AdjustContext::dialog`]). What the editor asks of the app (Levels' Auto, Black & White's Auto) is an `E` that /// waits in [`take_asks`](Self::take_asks). It answers with the value at OK. /// diff --git a/crates/imaging/src/ui/layer_style/hosted.rs b/crates/imaging/src/ui/layer_style/hosted.rs index 9c6a5e17e..2d5464cde 100644 --- a/crates/imaging/src/ui/layer_style/hosted.rs +++ b/crates/imaging/src/ui/layer_style/hosted.rs @@ -363,6 +363,7 @@ impl StackDialog for HostedLayerStyle { let shown = FormDialog::new(label.clone(), Bind::bound(&mut *draft)) .opened(Bind::bound(open)) .preview(Some(Bind::bound(&mut preview))) + .side_buttons(true) .extra_buttons([FooterButton::new(new_style, DialogRole::Other)]) .footer_extra(|ui| { if let (Some(paint), Some(draft)) = (preview_thumb.as_deref(), snapshot.as_ref()) { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/form.rs b/crates/ui-patterns/src/patterns/form_dialogs/form.rs index 8b0fa5e7c..b41cd4dbb 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/form.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/form.rs @@ -158,8 +158,9 @@ type ResetWithFn<'a, V> = Box V + 'a>; /// - The body returns whether the value can be accepted; OK is enabled while it can and `ok_enabled` is true. /// - With [`history`](FormDialog::history), Cmd/Ctrl+Z and Shift+Cmd/Ctrl+Z step the dialog's own value; a drag or a /// typing run is one step. -/// - With [`preview`](FormDialog::preview), the buttons stand in a column beside the body, with the Preview check box -/// and the footer controls under them. +/// - The footer goes across the foot, the Preview check box and the footer controls at its start edge; with +/// [`side_buttons`](FormDialog::side_buttons) the buttons stand in a column beside the body, with the Preview check +/// box and the footer controls under them. #[must_use = "show the dialog with `show`"] #[derive(crate::contract::Pattern)] #[pattern(probe(FormDialog<'static, bool>))] @@ -179,6 +180,7 @@ pub struct FormDialog<'a, V: Value + Default> { closable: bool, accept_stays_open: bool, enter_confirms: bool, + side_buttons: bool, footer_extra: Option>, /// The Preview check box when shown, over its owner's bind or (`None`) the footer's memory. preview: Option>>, @@ -210,6 +212,7 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { closable: true, accept_stays_open: false, enter_confirms: true, + side_buttons: false, footer_extra: None, preview: None, extra_buttons: Vec::new(), @@ -308,15 +311,21 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { self } - /// The Preview check box, first under the buttons, which stand beside the body: the host previews the value while - /// it is on, and the unfiltered picture while it is held ([`FormOutput::comparing`]). With `on`, the box reads and - /// writes that bind (a kept bind starts on). Without it, every open starts with the box on, and the dialog keeps - /// it off while it stays open. + /// The Preview check box, first in the footer: the host previews the value while it is on, and the unfiltered + /// picture while it is held ([`FormOutput::comparing`]). With `on`, the box reads and writes that bind (a kept + /// bind starts on). Without it, every open starts with the box on, and the dialog keeps it off while it stays open. pub fn preview(mut self, on: Option>) -> Self { self.preview = Some(on); self } + /// Whether the buttons stand in a column beside the body, with the Preview check box and the footer controls under + /// them (`Dialog::side_buttons`), instead of across the foot: Photoshop's button-column dialogs. + pub fn side_buttons(mut self, on: bool) -> Self { + self.side_buttons = on; + self + } + /// Footer buttons after OK and Cancel, which keep the dialog open: the caller acts on /// [`FormOutput::picked`]. pub fn extra_buttons(mut self, buttons: impl IntoIterator) -> Self { @@ -375,6 +384,7 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { closable, accept_stays_open, enter_confirms, + side_buttons, footer_extra, preview, extra_buttons, @@ -413,7 +423,11 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { } } }; - let mut dialog = Dialog::new(title).closable(closable).close_on_enter(ok_enabled && enter_confirms).outer_gesture(outer_gesture); + let mut dialog = Dialog::new(title) + .closable(closable) + .close_on_enter(ok_enabled && enter_confirms) + .outer_gesture(outer_gesture) + .side_buttons(side_buttons); dialog = reset.install(dialog, accept, restore); if let Some(open) = open { dialog = dialog.opened(open); @@ -423,9 +437,6 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { } let changed = RefCell::new(None::); let (preview_on, comparing) = (Rc::new(Cell::new(false)), Rc::new(Cell::new(false))); - if preview.is_some() { - dialog = dialog.side_buttons(true); - } if footer_extra.is_some() || preview.is_some() { let (on, held, label) = (Rc::clone(&preview_on), Rc::clone(&comparing), env.words::().preview.clone()); let (mut extra, mut preview) = (footer_extra, preview); diff --git a/crates/ui-patterns/src/patterns/form_dialogs/guides.rs b/crates/ui-patterns/src/patterns/form_dialogs/guides.rs index 3bc28b93e..5e2dfdb1b 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/guides.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/guides.rs @@ -331,7 +331,7 @@ impl<'a> GuideLayoutDialog<'a> { let env = Env::of(ui); let words = env.words::(); let number_units = env.units(); - let mut dialog = FormDialog::new(words.layout_title.clone(), values).outer_gesture(true).answers(answers).preview(preview); + let mut dialog = FormDialog::new(words.layout_title.clone(), values).outer_gesture(true).answers(answers).preview(preview).side_buttons(true); if let Some(open) = open { dialog = dialog.opened(open); } From 592a757d302133d8fbd55f5cc25808c3afd93713 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 16:37:58 +0000 Subject: [PATCH 3/8] ParamLayout::Stacked: stacked slider rows, the zoom row under the preview pane and the buttons across the foot, with its story --- .../src/patterns/form_dialogs/dialog.rs | 64 +++++++++++++++---- .../patterns/form_dialogs/dialog/stories.rs | 12 +++- .../src/patterns/form_dialogs/rows.rs | 47 ++++++++++++-- 3 files changed, 101 insertions(+), 22 deletions(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index 9106347b7..fb0d69635 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs @@ -17,6 +17,7 @@ use crate::contract::{Bind, BodyCx, CanvasGesture, NoValue, Outcome, Remember as use crate::dialog::{Alert, Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, FooterHooks, HeldAnswer, HeldOk, StackDialog, dialog_id}; use crate::display::{Shade, Text}; +use crate::form::SliderFieldLayout; use crate::layout_components::{Row, Stack}; use crate::notices::{Notice, NoticeLayout}; @@ -47,15 +48,37 @@ craft_ui::words! { } } -/// Where the preview pane sits. +/// How a parameter dialog arranges its rows, its preview pane and its buttons. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[non_exhaustive] pub enum ParamLayout { - /// The preview pane to the right of the rows, under the zoom row. + /// The preview pane to the right of the rows, under the zoom row. A dialog that previews has its buttons in a + /// column beside the body, with the Preview check box under them. #[default] Beside, - /// The preview pane under the rows. + /// The preview pane under the rows, under the zoom row. A dialog that previews has its buttons in a column beside + /// the body, with the Preview check box under them: Photoshop's filter dialogs. Below, + /// One column: each slider row stacked (the label and the number field with its unit on one line, a full-width + /// slider under them), then the preview pane with the zoom row under it, and the buttons across the foot with the + /// Preview check box at their start: PhotoCraft's filter dialogs. The other rows keep the form's label and control + /// columns. + Stacked, +} + +impl ParamLayout { + /// Whether a dialog that previews stands its buttons in a column beside the body. + fn side_buttons(self) -> bool { + !matches!(self, ParamLayout::Stacked) + } + + /// How the range rows arrange their slider and number field. + fn sliders(self) -> SliderFieldLayout { + match self { + ParamLayout::Stacked => SliderFieldLayout::Stacked, + ParamLayout::Beside | ParamLayout::Below => SliderFieldLayout::Inline, + } + } } /// What a parameter dialog answers with at OK. @@ -139,8 +162,8 @@ impl Outcome for ParamDialogOutput { /// fills the parameters' defaults and, with `remember`, the values saved by [`ParamResult::remember`]. /// - Preview: a dialog that `previews` has the Preview check box; the host renders from the reported values while /// `preview_on` (on the canvas, or as the picture it hands to `preview`), the unfiltered picture while `comparing` -/// (the Preview check box held down). Drag pans the picture, the zoom buttons scale it. A dialog that previews has -/// its buttons in a column beside the body, with the Preview check box and the footer note under them. +/// (the Preview check box held down). Drag pans the picture, the zoom buttons scale it. The +/// [`layout`](ParamDialog::layout) places the pane and the buttons. /// - Footer: [`extra_buttons`](ParamDialog::extra_buttons) keep the dialog open and come back as /// `ParamDialogOutput::footer_action`; [`footer_note`](ParamDialog::footer_note) is a muted line at the start edge. /// - A command form is a dialog with no preview and no remember key. @@ -191,7 +214,7 @@ pub struct ParamDialog<'a> { /// keys added since the open go. #[prop] reset_to: Option, - /// Where the preview pane sits. + /// How the rows, the preview pane and the buttons are arranged. #[prop] layout: ParamLayout, /// Whether the title row has a close action. @@ -459,7 +482,7 @@ impl<'a> ParamDialog<'a> { form = form.opened(open); } if previews { - form = form.preview(preview_on); + form = form.preview(preview_on).side_buttons(layout.side_buttons()); } // The pane shows only in a dialog that previews. let preview = preview.filter(|_| previews); @@ -523,7 +546,10 @@ impl<'a> ParamDialog<'a> { live.view = live.view.centred_on(point, texture.size); } let mut show_rows = |ui: &mut Ui, values: &mut DialogFields| { - let mut shown = ParamRows::new(title.clone(), ¶ms, Bind::bound(values)).patterns(&patterns).preview_colors(&preview_colors); + let mut shown = ParamRows::new(title.clone(), ¶ms, Bind::bound(values)) + .patterns(&patterns) + .preview_colors(&preview_colors) + .sliders(layout.sliders()); if let Some(canvas) = canvas { shown = shown.canvas(canvas); } @@ -533,13 +559,15 @@ impl<'a> ParamDialog<'a> { (Some(texture), ParamLayout::Beside) => { Row::new().show(ui, |ui, _| { show_rows(ui, values); - Stack::new().show(ui, |ui, _| shown_preview = show_preview(ui, &preview_label, texture, click_centres, &mut live)); + Stack::new() + .show(ui, |ui, _| shown_preview = show_preview(ui, &preview_label, texture, click_centres, ZoomRow::Above, &mut live)); }); } - (Some(texture), ParamLayout::Below) => { + (Some(texture), layout) => { + let zoom = if layout == ParamLayout::Stacked { ZoomRow::Below } else { ZoomRow::Above }; Stack::new().show(ui, |ui, _| { show_rows(ui, values); - shown_preview = show_preview(ui, &preview_label, texture, click_centres, &mut live); + shown_preview = show_preview(ui, &preview_label, texture, click_centres, zoom, &mut live); }); } (None, _) => show_rows(ui, values), @@ -722,12 +750,20 @@ struct ShownPreview { centre: Option, } +/// Where the zoom row stands: over the preview pane or under it. +#[derive(Clone, Copy, PartialEq, Eq)] +enum ZoomRow { + Above, + Below, +} + /// The zoom row and the pane. -fn show_preview(ui: &mut Ui, label: &Label, texture: &SizedTexture, click_centres: bool, live: &mut Live) -> ShownPreview { - let zoom = PreviewZoom::new(&live.view).show(ui); +fn show_preview(ui: &mut Ui, label: &Label, texture: &SizedTexture, click_centres: bool, zoom_row: ZoomRow, live: &mut Live) -> ShownPreview { + let above = (zoom_row == ZoomRow::Above).then(|| PreviewZoom::new(&live.view).show(ui)); let pane = PreviewPane::new(label.clone(), *texture, &live.view).click_centres(click_centres).show(ui); + let below = (zoom_row == ZoomRow::Below).then(|| PreviewZoom::new(&live.view).show(ui)); let centre = pane.shown.centre(texture.size); - live.view = zoom.view.or(pane.view).unwrap_or(pane.shown); + live.view = above.or(below).and_then(|zoom| zoom.view).or(pane.view).unwrap_or(pane.shown); ShownPreview { clicked: pane.clicked, centre: Some(centre) } } diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog/stories.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog/stories.rs index ef90768a1..c444e9a44 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog/stories.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog/stories.rs @@ -27,15 +27,15 @@ fn picture(ui: &Ui, unfiltered: bool) -> SizedTexture { SizedTexture::new(id, Vec2::new(PICTURE[0] as f32, PICTURE[1] as f32)) } -const LAYOUTS: [(&str, ParamLayout); 2] = [("Beside", ParamLayout::Beside), ("Below", ParamLayout::Below)]; +const LAYOUTS: [(&str, ParamLayout); 3] = [("Beside", ParamLayout::Beside), ("Below", ParamLayout::Below), ("Stacked", ParamLayout::Stacked)]; /// A blur dialog with the `preview` and `layout` values of the story. fn blur_story(ui: &mut Ui, data: &mut StoryData, preview: bool, layout: ParamLayout) -> StoryOutput { let preview = *data.value("preview", preview); let layout = *data.choice("layout", layout, &LAYOUTS); let comparing = *data.value("comparing", false); - let dialog = ParamDialog::new("blur", "Blur", Param::parse_list(SPEC)).opened(Bind::bound(data.value("open", true))).history(true); - let dialog = if preview { dialog.previews(true).preview(picture(ui, comparing)).layout(layout) } else { dialog }; + let dialog = ParamDialog::new("blur", "Blur", Param::parse_list(SPEC)).opened(Bind::bound(data.value("open", true))).history(true).layout(layout); + let dialog = if preview { dialog.previews(true).preview(picture(ui, comparing)) } else { dialog }; let shown = dialog.show(ui); *data.value("comparing", false) = shown.comparing; shown.into() @@ -56,6 +56,12 @@ fn param_dialog_with_preview_below(ui: &mut Ui, data: &mut StoryData) -> StoryOu blur_story(ui, data, true, ParamLayout::Below) } +/// PhotoCraft's filter dialogs: stacked slider rows, the pane with the zoom row under it, the buttons across the foot. +#[story(ParamDialog<'static>, covers = [], drive = Drive::Never)] +fn param_dialog_stacked(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + blur_story(ui, data, true, ParamLayout::Stacked) +} + #[story(ParamDialog<'static>, covers = [], drive = Drive::Never)] fn param_dialog_close_without_reset(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { ParamDialog::new("blur", "Blur", Param::parse_list(SPEC)) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index 4b7eb3994..cbf8f328b 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs @@ -91,6 +91,8 @@ impl Outcome for ParamRowsOutput { /// which the pass writes. The host keeps its own history of the values and its own Reset. /// - **Rows.** A row is shown while its `visible_when` holds and takes input while its `enabled_when` holds. A /// [`Param::section`] opens a section whose body is the rows up to the next section. +/// A range row is a slider and its number field beside the row's label, or stacked under the label +/// ([`sliders`](ParamRows::sliders)). /// - **Requests.** A colour press, a Browse press and the eyedropper toggle come back in [`ParamRowsOutput`]. /// - **Random.** The Random button of an int row draws from a sequence seeded by `seed`'s binding; without one the /// sequence starts the same in every run. @@ -107,12 +109,31 @@ pub struct ParamRows<'a> { canvas: Option, patterns: &'a [PresetRow], preview_colors: &'a [(String, Srgba)], + sliders: SliderFieldLayout, } impl<'a> ParamRows<'a> { /// Rows for `params` over `fields`, the group named `label`. pub fn new(label: impl Into