PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Guide Layout: the disabled Rows field no longer turns Rows on (#5625) (#5626)
David Mann64efae47c85a
diff --git a/crates/ui-egui/src/guide_layout_ui.rs b/crates/ui-egui/src/guide_layout_ui.rsindex 8d47e628c..894535e68 100644--- a/crates/ui-egui/src/guide_layout_ui.rs+++ b/crates/ui-egui/src/guide_layout_ui.rs@@ -194,6 +194,9 @@ fn number(ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, count: bool)let mut value = f.get(key).and_then(Value::as_f64).unwrap_or(0.0) as f32;if widgets::value_field(ui, &mut value, (if count { 1.0 } else { 0.0 })..=if count { 1000.0 } else { 300_000.0 }, if count { "" } else { "px" }, 68.0).changed()+ // A disabled field still clamps its value into range (a zero count to 1); writing that+ // back would switch the axis on through its `positive` fallback (#5625).+ && ui.is_enabled(){f.insert(key.into(), if count { json!(value.round() as u64) } else { json!(value) });}diff --git a/crates/ui-egui/src/guide_layout_ui/tests.rs b/crates/ui-egui/src/guide_layout_ui/tests.rsindex 299b3fb83..673f1663b 100644--- a/crates/ui-egui/src/guide_layout_ui/tests.rs+++ b/crates/ui-egui/src/guide_layout_ui/tests.rs@@ -104,6 +104,32 @@ fn tab_skips_disabled_rows_and_margins() {assert_eq!(f["gutter"], 4.0);}+/// The disabled Number field must not clamp a zero count to 1 and so switch its axis on (#5625).+#[test]+fn disabled_number_fields_do_not_turn_their_axis_on() {+ let mut app = app();+ let id = open(&mut app);+ let mut h = harness(app);+ h.run_steps(3);+ let f = &h.state().ui.dialogs.first().unwrap().fields;+ assert_eq!(f["rows"], 0, "the default layout has no rows");+ assert!(!on(f, "__rowsEnabled", positive(f, "rows")), "Rows stays off");+ let mut app = h.into_state();+ crate::dialogs::confirm(&mut app, id).unwrap();+ let guides = &app.session.active().unwrap().doc.guides;+ assert!(!guides.vertical.is_empty(), "the columns were created");+ assert!(guides.horizontal.is_empty(), "no row guides at the top and bottom");++ let mut app = self::app();+ let id = open(&mut app);+ app.ui.dialog_mut(id).unwrap().fields.insert("columns".into(), json!(0));+ let mut h = harness(app);+ h.run_steps(3);+ let f = &h.state().ui.dialogs.first().unwrap().fields;+ assert_eq!(f["columns"], 0);+ assert!(!on(f, "__columnsEnabled", positive(f, "columns")), "Columns stays off");+}+/// New Guide Layout offers New Guide's colours, by value, and keeps another one as Custom.#[test]fn color_list_is_new_guides() {