Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Fix #4542: Edit › Color Settings… and Assign Profile… show the Separations Preview panel

bflatastic5438ed12d39b
diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs
index 206242768..53a5a6ad6 100644
--- a/crates/ui-egui/src/menus/run.rs
+++ b/crates/ui-egui/src/menus/run.rs
@@ -175,11 +175,11 @@ fn run_ui_part2(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
crate::prefs_dialog::open(app, s("category").as_deref());
Ok(Value::Null)
}
- // Edit → Color Settings… / Assign Profile… (no params): show the colour-management panel.
+ // Edit → Color Settings… / Assign Profile… (no params): show the colour-management panel
+ // wherever it is, as Window › Separations Preview does (it isn't in an icon column, so a
+ // flyout for it never opened: #4542).
"edit.colorSettings" | "edit.assignProfile" if p.as_object().is_none_or(|o| o.is_empty()) => {
- app.ui.open_panel = Some("separations".into());
- app.ui.dock = true;
- app.session.execute(id, p).map_err(|e| e.to_string())
+ crate::panel_docking::reveal_panel(app, "separations").and_then(|_| app.session.execute(id, p).map_err(|e| e.to_string()))
}
"view.outline" => flag(&mut app.ui.view.outline),
_ => return None,
diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs
index 35f711c39..7a23026d2 100644
--- a/crates/ui-egui/src/menus/tests.rs
+++ b/crates/ui-egui/src/menus/tests.rs
@@ -283,6 +283,20 @@ fn panel_ids_are_case_insensitive_and_labels_work() {
app.ui.dock_collapsed = false;
}
+/// #4542: Edit › Color Settings… and Assign Profile… show the Separations Preview panel, which
+/// isn't in an icon column, and leave it showing when it already does.
+#[test]
+fn color_settings_and_assign_profile_show_the_separations_panel() {
+ let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let shown = |app: &VectorcraftApp| checked(app, "window.panel", &json!({"panel": "separations"})).unwrap();
+ assert!(!shown(&app));
+ for id in ["edit.colorSettings", "edit.colorSettings", "edit.assignProfile"] {
+ app.run(id, json!({})).unwrap();
+ assert!(shown(&app), "{id} shows the panel");
+ }
+}
+
#[test]
fn saved_views_store_and_restore_the_view() {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs
index eba97d88f..dfedad31d 100644
--- a/crates/ui-egui/src/panel_docking.rs
+++ b/crates/ui-egui/src/panel_docking.rs
@@ -345,6 +345,16 @@ fn show_panel(app: &mut VectorcraftApp, params: &Value) -> Result<Value, String>
})
}
+/// Show `panel` as `window.panel` does, but leave it be when it already shows ([`showing`]): a
+/// command that opens a panel to work in (Edit › Color Settings…) never puts it away.
+pub(crate) fn reveal_panel(app: &mut VectorcraftApp, panel: &str) -> Result<Value, String> {
+ if showing(&app.ui, panel) {
+ app.ui.dock = true;
+ return Ok(json!({"open": panel}));
+ }
+ show_panel(app, &json!({ "panel": panel }))
+}
+
/// `window.collapseDock {collapsed?}`: collapse every dock column to icons, or expand the outer
/// one; without `collapsed` it toggles the outer column.
pub(crate) fn collapse_dock(app: &mut VectorcraftApp, collapsed: Option<bool>) -> Result<Value, String> {