mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 19:36:16 +00:00
Merge pull request #9360 from dotCooCoo/fix/control-bar-paragraph-link-fit
Control bar: the Paragraph: link stays after its Align buttons leave
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -2600,6 +2600,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]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -751,7 +751,6 @@ fn bar_names(app: &mut VectorcraftApp) -> Vec<String> {
|
||||
/// #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());
|
||||
|
||||
Reference in New Issue
Block a user