From 55ff5e033e2c5d91a48073d59ada09347058f54a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 20:21:57 -0800 Subject: [PATCH] Control bar: the Paragraph: link stays after its Align buttons leave, as production kept it The Paragraph group was one ranked member at its call site, and a narrowing row drops a ranked member whole, so the link left with the Align left, Align center and Align right buttons. `panels/paragraph.rs::control_bar` now shows the link and the buttons as two members of `rank::TYPE`, and within one rank the bar drops the last member first. --- crates/ui-egui/src/chrome/control_bar.rs | 5 ++--- crates/ui-egui/src/chrome/tests.rs | 20 ++++++++++++++++++++ crates/ui-egui/src/panels/paragraph.rs | 8 ++++---- crates/ui-egui/src/panels/paragraph/tests.rs | 1 - 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/chrome/control_bar.rs b/crates/ui-egui/src/chrome/control_bar.rs index ab90d71dc2..a0d69c55c5 100644 --- a/crates/ui-egui/src/chrome/control_bar.rs +++ b/crates/ui-egui/src/chrome/control_bar.rs @@ -609,9 +609,8 @@ fn members(app: &mut VectorcraftApp, ui: &mut Ui) { }); } if typed && paragraph { - ranked(ui, rank::TYPE, |ui| { - crate::panels::paragraph::control_bar(app, ui); - }); + // The Paragraph group ranks its link and its Align buttons as two members, so the buttons leave first. + crate::panels::paragraph::control_bar(app, ui); } let vertical = group_on(app, "verticalAlignment") && crate::panels::properties::vertical_align::shown(app).is_some(); if vertical { diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 2c3b214c69..ce79f1b608 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -2551,6 +2551,26 @@ 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 type selected, the Paragraph group's Align left, Align center and Align right buttons leave the Control bar +/// before its Paragraph: link: some width shows the link without them, and no width shows them without the link. +#[test] +fn the_paragraph_link_stays_on_the_control_bar_after_its_align_buttons_leave() { + 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 = ["Paragraph:", "Align left", "Align center", "Align right"]; + 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[1..].iter().all(|shown| *shown == s[1]), "the three Align buttons show or go together: {s:?}"); + assert!(!s[1] || s[0], "the Align buttons show only with the Paragraph: link: {s:?}"); + } + assert!(seen.iter().any(|s| s[0] && !s[1]), "some width shows the Paragraph: link without the Align buttons"); +} + /// 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] diff --git a/crates/ui-egui/src/panels/paragraph.rs b/crates/ui-egui/src/panels/paragraph.rs index 2dd7f1f39f..26102b5311 100644 --- a/crates/ui-egui/src/panels/paragraph.rs +++ b/crates/ui-egui/src/panels/paragraph.rs @@ -434,19 +434,19 @@ pub(crate) fn alignment_toggles(app: &mut VectorcraftApp, ui: &mut Ui, count: us /// The Control bar's paragraph controls while type is selected or edited (#5372), after its /// Character controls: the Paragraph link, which opens the Paragraph panel in a popover under it, /// and the Align left, Align center and Align right buttons. Always `true`: the bar trims these -/// itself as it narrows. +/// itself as it narrows, the link and the buttons as two members of the type groups' rank, so the +/// buttons leave before the link. pub(crate) fn control_bar(app: &mut VectorcraftApp, ui: &mut Ui) -> bool { if text_style(app).is_none() { return true; } - // PLAN: the members' `Row::fit_rank` (ch.K30: toggles out before the link) belongs to chrome-w16's row. - Row::new().show(ui, |ui, _| { + Row::new().fit_rank(crate::chrome::rank::TYPE).show(ui, |ui, _| { let link = crate::panels::option_link(tl!("Paragraph:")).tooltip(tl!("Paragraph options")).show(ui); Popover::new(tl!("Paragraph"), Bind::kept()) .overlay(|overlay| overlay.opened_by(&link.response, Trigger::Click)) .show(ui, |ui, _| show(app, ui)); - alignment_toggles(app, ui, CONTROL_BAR_ALIGNMENTS); }); + Row::new().fit_rank(crate::chrome::rank::TYPE).show(ui, |ui, _| alignment_toggles(app, ui, CONTROL_BAR_ALIGNMENTS)); true } diff --git a/crates/ui-egui/src/panels/paragraph/tests.rs b/crates/ui-egui/src/panels/paragraph/tests.rs index 48b324ccf4..0d56471f6d 100644 --- a/crates/ui-egui/src/panels/paragraph/tests.rs +++ b/crates/ui-egui/src/panels/paragraph/tests.rs @@ -751,7 +751,6 @@ fn bar_names(app: &mut VectorcraftApp) -> Vec { /// #5372: with type selected the Control bar shows a Paragraph section: the Paragraph: link and the /// Align left, Align center and Align right buttons (the justifying four are in the panel the link /// opens); with no type selected it shows none of them. -// PLAN: the trimming order as the bar narrows (toggles out before the link, ch.K30) is chrome-w16's `Row::fit_rank` and is tested with its fixture. #[test] fn the_control_bar_shows_its_paragraph_section_for_selected_type_only() { let mut app = VectorcraftApp::new(Session::new(), Default::default());