From a959117beb252816c0ee30e1a60c93002a5a1af5 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 12:36:19 +0100 Subject: [PATCH 1/3] New Document: Advanced Options holds Color Profile and Pixel Aspect Ratio; the depth reads 32 bit The details pane puts Color Profile and Pixel Aspect Ratio in an Advanced Options disclosure under Background Contents, open by default; folding it keeps their values. The float depth entry reads "32 bit" (storytold/photocraft#14035). Co-Authored-By: Claude Opus 5.5 --- .../src/patterns/form_dialogs/new_document.rs | 11 +++--- .../form_dialogs/new_document/details.rs | 32 +++++++++-------- .../tests/it/form_dialogs/new_document.rs | 34 ++++++++++++++++++- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs b/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs index 8c256f5b1c..72cd2425ed 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs @@ -88,6 +88,8 @@ craft_ui::words! { /// The Color Profile entry of [`NewDocumentDialog::unmanaged_profile`]: no profile is embedded. dont_color_manage: "newDocument.dontColorManage" = "Don't Color Manage"; background: "newDocument.background" = "Background Contents"; + /// The disclosure under Background Contents that holds Color Profile and Pixel Aspect Ratio. + advanced_options: "newDocument.advancedOptions" = "Advanced Options"; white: "newDocument.white" = "White"; black: "newDocument.black" = "Black"; background_color: "newDocument.backgroundColor" = "Background Color"; @@ -111,7 +113,7 @@ craft_ui::words! { depth_1: "newDocument.depth1" = "1 bit"; depth_8: "newDocument.depth8" = "8 bit"; depth_16: "newDocument.depth16" = "16 bit"; - depth_32: "newDocument.depth32" = "32 bit (float)"; + depth_32: "newDocument.depth32" = "32 bit"; orientation: "newDocument.orientation" = "Orientation"; pixel_aspect: "newDocument.pixelAspect" = "Pixel Aspect Ratio"; square_pixels: "newDocument.pixelAspectSquare" = "Square Pixels"; @@ -468,9 +470,10 @@ fn body(ui: &mut Ui, form: &mut FormCx<'_, '_>, values: &mu /// the orientation control. Saved and recent cards restore every setting but the name. A Web or Mobile card turns /// Artboards on; a card of another category turns it off again only when such a card turned it on. /// - Details: Name with the Save Document Preset icon, Width and Height with their units, Orientation, Artboards, -/// Resolution, Color Mode, Depth, Color Profile, Pixel Aspect Ratio (the built-in ratios, then the app's -/// [`custom_pixel_aspects`](NewDocumentDialog::custom_pixel_aspects)) and Background Contents. Bitmap takes only 1 -/// bit and offers no Transparent background ([`DocumentOptions::fitted`]). +/// Resolution, Color Mode, Depth, Background Contents, then an Advanced Options disclosure (open by default) +/// holding Color Profile and Pixel Aspect Ratio (the built-in ratios, then the app's +/// [`custom_pixel_aspects`](NewDocumentDialog::custom_pixel_aspects)). Bitmap takes only 1 bit and offers no +/// Transparent background ([`DocumentOptions::fitted`]). /// - Save Document Preset: the icon opens a pane in place of the details with the first free `Saved N` selected; /// Save Preset or Enter saves the preset and does not create the document, Cancel goes back. The name is checked by /// the preset library (not blank, different from the saved names ignoring case), and at most 256 presets are kept. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/new_document/details.rs b/crates/ui-patterns/src/patterns/form_dialogs/new_document/details.rs index 2490ac4d1b..e2c655c68d 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/new_document/details.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/new_document/details.rs @@ -19,6 +19,7 @@ use crate::runtime::env::{Env, Label, Message, UnitKind, Units}; use crate::runtime::focus::{self, FocusTarget}; use crate::runtime::requests::{ColorRequest, HostAnswer}; use crate::runtime::words::CommonWords; +use crate::sections::{HeaderStrength, Section}; use crate::style::TypeRole; use crate::text::{NumberField, TextField}; use craft_behavior::{ColumnWidth, EditEvent, EditEvents, IconId, NumberCodec, PixelSize}; @@ -312,20 +313,23 @@ fn raster_rows(ui: &mut Ui, values: &mut DocumentOptions, memory: &mut RasterMem } }); }); - Field::new(words.profile.clone()).layout(FieldLayout::Above).id_salt("profile").show(ui, |ui, _| { - let current = values.profile.clone().filter(|profile| others.contains(&profile) || Some(profile) == unmanaged); - let shown = Select::new(words.profile.clone(), Bind::given(current), &profiles).sizing(Sizing::FillWidth).show(ui); - if let Some(profile) = shown.value().cloned() { - values.profile = profile; - } - }); - Field::new(words.pixel_aspect.clone()).layout(FieldLayout::Above).id_salt("pixel-aspect").show(ui, |ui, _| { - let listed = pixel_aspects.iter().any(|entry| entry.value() == Some(&values.pixel_aspect)); - let current = if listed { values.pixel_aspect.clone() } else { SQUARE_PIXELS.to_owned() }; - let shown = Select::new(words.pixel_aspect.clone(), Bind::given(current), &pixel_aspects).sizing(Sizing::FillWidth).show(ui); - if let Some(id) = shown.value().cloned() { - values.pixel_aspect = id; - } + // Color Profile and Pixel Aspect Ratio stand under Advanced Options, open by default; collapsing it keeps their values. + Section::new(words.advanced_options.clone()).strength(HeaderStrength::Subheading).id_salt("advanced").show(ui, |ui, _| { + Field::new(words.profile.clone()).layout(FieldLayout::Above).id_salt("profile").show(ui, |ui, _| { + let current = values.profile.clone().filter(|profile| others.contains(&profile) || Some(profile) == unmanaged); + let shown = Select::new(words.profile.clone(), Bind::given(current), &profiles).sizing(Sizing::FillWidth).show(ui); + if let Some(profile) = shown.value().cloned() { + values.profile = profile; + } + }); + Field::new(words.pixel_aspect.clone()).layout(FieldLayout::Above).id_salt("pixel-aspect").show(ui, |ui, _| { + let listed = pixel_aspects.iter().any(|entry| entry.value() == Some(&values.pixel_aspect)); + let current = if listed { values.pixel_aspect.clone() } else { SQUARE_PIXELS.to_owned() }; + let shown = Select::new(words.pixel_aspect.clone(), Bind::given(current), &pixel_aspects).sizing(Sizing::FillWidth).show(ui); + if let Some(id) = shown.value().cloned() { + values.pixel_aspect = id; + } + }); }); if ask_color { diff --git a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs index 5d415b8ece..176e7c15b6 100644 --- a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs +++ b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs @@ -3,7 +3,7 @@ use craft_behavior::MotionMode; use craft_ui::buttons::Button; -use craft_ui::contract::{Bind, SaveKey, Show as _, clicked}; +use craft_ui::contract::{Bind, Role, SaveKey, Show as _, clicked}; use craft_ui::dialog::DialogHost; use craft_ui::display::Text; use craft_ui::patterns::form_dialogs::{ @@ -737,6 +737,38 @@ fn without_unmanaged_profile_there_is_no_dont_color_manage() { assert!(!shows(&fixture, "Don't Color Manage")); } +/// Advanced Options starts open under Background Contents; folding it hides Color Profile and Pixel Aspect Ratio and keeps +/// the profile picked under it, and unfolding shows them again. +#[trial] +fn advanced_options_folds_color_profile_and_pixel_aspect_and_keeps_the_profile() { + let mut picked = DocumentOptions::default(); + picked.profile = Some("display-p3".to_owned()); + let held = Rc::new(RefCell::new(picked)); + let shared = held.clone(); + let mut fixture = Fixture::new(move |ui| { + let mut options = shared.borrow().clone(); + let _ = NewDocumentDialog::new(Bind::bound(&mut options)).profiles(two_mode_profiles()).show(ui); + *shared.borrow_mut() = options; + }); + fixture.room(Vec2::new(1400.0, 1000.0)).idle(30); + let background = fixture.by_label("Background Contents").expect("the Background Contents field").rect; + let tree = fixture.tree(); + let advanced = + fixture.by_role(Role::BUTTON).into_iter().find(|button| tree.name_of(button.node) == Some("Advanced Options")).expect("the disclosure"); + assert_eq!(tree.expanded_of(advanced.node), Some(true), "Advanced Options starts open"); + assert!(background.bottom() <= advanced.rect.top(), "Advanced Options follows Background Contents"); + assert!(fixture.by_label("Color Profile").is_some() && fixture.by_label("Pixel Aspect Ratio").is_some(), "open, it shows its fields"); + + fixture.click(&advanced).settle(); + assert_eq!(fixture.tree().expanded_of(advanced.node), Some(false), "a click folds it"); + assert!(fixture.by_label("Color Profile").is_none() && fixture.by_label("Pixel Aspect Ratio").is_none(), "folded, its fields are hidden"); + assert_eq!(held.borrow().profile.as_deref(), Some("display-p3"), "folding keeps the profile"); + + fixture.click(&advanced).settle(); + assert!(fixture.by_label("Color Profile").is_some(), "unfolded, Color Profile shows again"); + assert!(shows(&fixture, "display-p3"), "with the profile still picked"); +} + /// The names of the standard category `id`, in card order. fn standard_names(id: &str) -> Vec<&'static str> { let categories = craft_ui::patterns::form_dialogs::PresetCategory::standard(); From 8d09ceca38a8b78ddfaa698f7493b31ff4a51162 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 13:00:39 +0100 Subject: [PATCH 2/3] New Document test: fold Advanced Options without motion, so the check runs after the fold ends Co-Authored-By: Claude Opus 5.5 --- crates/ui-patterns/tests/it/form_dialogs/new_document.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs index 176e7c15b6..ad2ca7d835 100644 --- a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs +++ b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs @@ -750,7 +750,8 @@ fn advanced_options_folds_color_profile_and_pixel_aspect_and_keeps_the_profile() let _ = NewDocumentDialog::new(Bind::bound(&mut options)).profiles(two_mode_profiles()).show(ui); *shared.borrow_mut() = options; }); - fixture.room(Vec2::new(1400.0, 1000.0)).idle(30); + // Without motion the fold finishes at once, rather than mid-animation when the assertions run. + fixture.motion(MotionMode::Off).room(Vec2::new(1400.0, 1000.0)).settle(); let background = fixture.by_label("Background Contents").expect("the Background Contents field").rect; let tree = fixture.tree(); let advanced = From cb477ef88ecfbca600a0cee5162623f1dc667d32 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 13:25:50 +0100 Subject: [PATCH 3/3] New Document test: unfold Advanced Options past the double-click time, with the header found again Co-Authored-By: Claude Opus 5.5 --- crates/ui-patterns/tests/it/form_dialogs/new_document.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs index ad2ca7d835..110adea98c 100644 --- a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs +++ b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs @@ -765,7 +765,14 @@ fn advanced_options_folds_color_profile_and_pixel_aspect_and_keeps_the_profile() assert!(fixture.by_label("Color Profile").is_none() && fixture.by_label("Pixel Aspect Ratio").is_none(), "folded, its fields are hidden"); assert_eq!(held.borrow().profile.as_deref(), Some("display-p3"), "folding keeps the profile"); + // Past the double-click time, so the second click is a click of its own; the header is found again in case the fold + // moved it. + fixture.advance(1.0).frame(Vec::new()); + let tree = fixture.tree(); + let advanced = + fixture.by_role(Role::BUTTON).into_iter().find(|button| tree.name_of(button.node) == Some("Advanced Options")).expect("the disclosure"); fixture.click(&advanced).settle(); + assert_eq!(fixture.tree().expanded_of(advanced.node), Some(true), "a second click unfolds it"); assert!(fixture.by_label("Color Profile").is_some(), "unfolded, Color Profile shows again"); assert!(shows(&fixture, "display-p3"), "with the profile still picked"); }