From 99fccade635c89b7d6617eefbddf6c9ba138de2d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 15:20:13 -0800 Subject: [PATCH 1/2] Control bar: with type selected, Opacity and Recolor Artwork stay while the type groups leave The Character and Paragraph groups were drawn without a rank, and a member without a rank never leaves the bar. When type's controls did not fit, every ranked member ahead of them left instead: Snapping, the width profile, Recolor Artwork and then Opacity. - A new `rank::TYPE`, below the other ranks, ranks the Character group, the Paragraph group and area type's vertical alignment buttons, so they leave before the members ahead of them. - With type groups shown, the Align buttons after them take the same rank and, coming last, leave first. - `text_style` is looked up only when the Character or Paragraph group is on. The new test narrows the bar step by step with a text object selected and checks that Opacity, Recolor Artwork and the Style picker show at every width that shows the Character group. --- crates/ui-egui/src/chrome/control_bar.rs | 33 +++++++++++++++++------- crates/ui-egui/src/chrome/tests.rs | 23 +++++++++++++++++ 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/chrome/control_bar.rs b/crates/ui-egui/src/chrome/control_bar.rs index 2088bfa1b4..7cecd2414d 100644 --- a/crates/ui-egui/src/chrome/control_bar.rs +++ b/crates/ui-egui/src/chrome/control_bar.rs @@ -23,14 +23,18 @@ pub(crate) mod rank { pub const SELECT_SIMILAR: u8 = 1; /// The inline X/Y/W/H fields and the Snapping menu. pub const FIELDS: u8 = 2; + /// The type groups (Character, Paragraph and area type's vertical alignment) and the Align buttons after them: + /// they leave before the members ahead of them, so Opacity, the Style picker and Recolor Artwork show while type + /// is selected. + pub const TYPE: u8 = 3; /// The parts of a group that its other members work without: the width profile, Recolor Artwork, Global Edit /// Options, Document Setup, an image's Edit Original. - pub const DETAIL: u8 = 3; + pub const DETAIL: u8 = 4; /// The Opacity link and field: they leave before the groups, so the narrower Style link and picker after them /// can show without them. - pub const OPACITY: u8 = 4; + pub const OPACITY: u8 = 5; /// Every other member of the bar. - pub const GROUP: u8 = 5; + pub const GROUP: u8 = 6; } /// An anchor button: icon, tooltip, command and the convert command's `to`. @@ -597,14 +601,21 @@ fn members(app: &mut VectorcraftApp, ui: &mut Ui) { if group_on(app, "graphicStyle") && count > 0 { style_group(app, ui); } - if group_on(app, "character") { - crate::panels::character::control_bar(app, ui); + let (character, paragraph) = (group_on(app, "character"), group_on(app, "paragraph")); + let typed = (character || paragraph) && crate::panels::character::text_style(app).is_some(); + if typed && character { + ranked(ui, rank::TYPE, |ui| { + crate::panels::character::control_bar(app, ui); + }); } - if group_on(app, "paragraph") { - crate::panels::paragraph::control_bar(app, ui); + if typed && paragraph { + ranked(ui, rank::TYPE, |ui| { + crate::panels::paragraph::control_bar(app, ui); + }); } - if group_on(app, "verticalAlignment") && crate::panels::properties::vertical_align::shown(app).is_some() { - group(ui, rank::GROUP, |ui| { + let vertical = group_on(app, "verticalAlignment") && crate::panels::properties::vertical_align::shown(app).is_some(); + if vertical { + group(ui, rank::TYPE, |ui| { crate::panels::properties::vertical_align::buttons(app, ui); }); } @@ -615,7 +626,9 @@ fn members(app: &mut VectorcraftApp, ui: &mut Ui) { return; } if group_on(app, "alignDistribute") { - group(ui, rank::GROUP, |ui| crate::panels::align::control_bar_strip(app, ui)); + // After the type groups, the Align buttons take their rank and, coming last, leave first. + let rank = if typed || vertical { rank::TYPE } else { rank::GROUP }; + group(ui, rank, |ui| crate::panels::align::control_bar_strip(app, ui)); } if transform { // The Transform link opens the whole Transform panel in a popover; X/Y/W/H follow inline while the diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index acc0ecf522..75dbc0754d 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -2431,6 +2431,29 @@ fn the_control_bar_leaves_members_out_in_its_priority_order() { assert!(seen.iter().any(|s| s[0] && !s[1]), "some width shows the Align buttons without the fields"); } +/// With type selected, the Character and Paragraph groups leave the Control bar before the members ahead of them: at +/// every width that shows the Character group, Opacity, Recolor Artwork and the Style picker show too, the Paragraph +/// group leaves before the Character group, the Align buttons leave before the Paragraph group, and some width shows +/// Opacity without them. +#[test] +fn the_type_groups_leave_the_control_bar_before_opacity_and_style() { + crate::i18n::set_current(crate::i18n::Lang::EN); + let mut app = crate::VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 200})).unwrap(); + let text = app.run("text.create", json!({"x": 10, "y": 100, "text": "Hi"})).unwrap()["id"].clone(); + app.run("select.set", json!({ "ids": [text] })).unwrap(); + let mut bar = control_shown(app); + let names = ["Character:", "Paragraph:", "Opacity:", "Recolor Artwork", "Style:", "Horizontal Align Left"]; + let seen = control_bar_widths(&mut bar, &names); + assert!(seen.iter().any(|s| s.iter().all(|shown| *shown)), "a wide bar shows {names:?}"); + for s in &seen { + assert!(!s[0] || s[2..5].iter().all(|shown| *shown), "the Character group shows only with {:?}: {s:?}", &names[2..5]); + assert!(!s[1] || s[0], "the Paragraph group shows only with the Character group: {s:?}"); + assert!(!s[5] || s[1], "the Align buttons show only with the Paragraph group: {s:?}"); + } + assert!(seen.iter().any(|s| s[2] && !s[0]), "some width shows Opacity without the Character group"); +} + /// The names of the bar's X, Y, W and H fields, in their order. const BAR_FIELDS: [&str; 4] = ["X position", "Y position", "Width", "Height"]; From 51cad798675808d4f16725e4b26488544600a4a6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 18:06:52 -0800 Subject: [PATCH 2/2] Control bar: test area type's vertical alignment rank with type selected - New test: with area type selected, the vertical alignment buttons leave the bar before Opacity, Recolor Artwork and the Style picker, and the Align buttons after them leave first. It runs with the Character and Paragraph groups shown and with both turned off, so it covers the vertical alignment group's rank and the Align strip's rank when only vertical alignment shows. - The `rank::TYPE` doc comment now says where the rank sits: type groups leave after Select Similar, Snapping and the X/Y/W/H fields, and before every other member. --- crates/ui-egui/src/chrome/control_bar.rs | 4 +-- crates/ui-egui/src/chrome/tests.rs | 31 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/chrome/control_bar.rs b/crates/ui-egui/src/chrome/control_bar.rs index 7cecd2414d..ab90d71dc2 100644 --- a/crates/ui-egui/src/chrome/control_bar.rs +++ b/crates/ui-egui/src/chrome/control_bar.rs @@ -24,8 +24,8 @@ pub(crate) mod rank { /// The inline X/Y/W/H fields and the Snapping menu. pub const FIELDS: u8 = 2; /// The type groups (Character, Paragraph and area type's vertical alignment) and the Align buttons after them: - /// they leave before the members ahead of them, so Opacity, the Style picker and Recolor Artwork show while type - /// is selected. + /// they leave after Select Similar, Snapping and the X/Y/W/H fields and before every other member, so Opacity, + /// the Style picker and Recolor Artwork show while type is selected. pub const TYPE: u8 = 3; /// The parts of a group that its other members work without: the width profile, Recolor Artwork, Global Edit /// Options, Document Setup, an image's Edit Original. diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 75dbc0754d..5b91533f58 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -2431,7 +2431,7 @@ fn the_control_bar_leaves_members_out_in_its_priority_order() { assert!(seen.iter().any(|s| s[0] && !s[1]), "some width shows the Align buttons without the fields"); } -/// With type selected, the Character and Paragraph groups leave the Control bar before the members ahead of them: at +/// With type selected, the Character and Paragraph groups leave the Control bar before Opacity and the Style group: at /// every width that shows the Character group, Opacity, Recolor Artwork and the Style picker show too, the Paragraph /// group leaves before the Character group, the Align buttons leave before the Paragraph group, and some width shows /// Opacity without them. @@ -2454,6 +2454,35 @@ fn the_type_groups_leave_the_control_bar_before_opacity_and_style() { assert!(seen.iter().any(|s| s[2] && !s[0]), "some width shows Opacity without the Character group"); } +/// With area type selected, its vertical alignment buttons leave the Control bar before Opacity and the Style group, +/// and after the Align buttons that follow them, with the Character and Paragraph groups shown and with both off. +#[test] +fn the_vertical_alignment_buttons_leave_the_control_bar_before_opacity_and_style() { + crate::i18n::set_current(crate::i18n::Lang::EN); + let mut app = crate::VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 200})).unwrap(); + let area = json!({"x": 10, "y": 10, "text": "Hi", "area": {"width": 100, "height": 120}}); + let text = app.run("text.create", area).unwrap()["id"].clone(); + app.run("select.set", json!({ "ids": [text] })).unwrap(); + let mut bar = control_shown(app); + let names = ["Align Top", "Opacity:", "Recolor Artwork", "Style:", "Horizontal Align Left", "Paragraph:"]; + for type_groups in [true, false] { + for group in ["character", "paragraph"] { + bar.app().run("window.control.options", json!({ "group": group, "visible": type_groups })).unwrap(); + } + let case = if type_groups { "with the type groups" } else { "without the type groups" }; + let seen = control_bar_widths(&mut bar, &names); + assert!(seen.iter().any(|s| s[..5].iter().all(|shown| *shown)), "{case}: a wide bar shows {:?}", &names[..5]); + for s in &seen { + assert!(!s[0] || s[1..4].iter().all(|shown| *shown), "{case}: Align Top shows only with {:?}: {s:?}", &names[1..4]); + assert!(!s[4] || s[0], "{case}: the Align buttons show only with Align Top: {s:?}"); + assert!(type_groups || !s[5], "{case}: the Paragraph group is off: {s:?}"); + assert!(!type_groups || !s[0] || s[5], "{case}: Align Top shows only with the Paragraph group: {s:?}"); + } + assert!(seen.iter().any(|s| s[1] && !s[0]), "{case}: some width shows Opacity without Align Top"); + } +} + /// The names of the bar's X, Y, W and H fields, in their order. const BAR_FIELDS: [&str; 4] = ["X position", "Y position", "Width", "Height"];