mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 11:51:05 +01:00
Merge pull request #9253 from dotCooCoo/fix/control-bar-ranked-rows
Control bar: with type selected, Opacity and Recolor Artwork stay while the type groups leave
This commit is contained in:
2 files changed
+75
-10
No files matched your search
@@ -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 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.
|
||||
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
|
||||
|
||||
@@ -2443,6 +2443,58 @@ 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 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.
|
||||
#[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");
|
||||
}
|
||||
|
||||
/// 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"];
|
||||
|
||||
|
||||
Reference in new issue
Block a user