Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Docking: a Properties panel link keeps that panel's open flyout

aionggaa442c9495fc
diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs
index 21d6df50b..40f4f766e 100644
--- a/crates/ui-egui/src/panels/properties.rs
+++ b/crates/ui-egui/src/panels/properties.rs
@@ -16,9 +16,12 @@ use crate::widgets::{
};
use crate::{DesignApp, icons};
-/// A link to another panel: `window.panel` shows it in the docking layout.
+/// A link to another panel: `window.panel` shows it in the docking layout. An open flyout of
+/// that panel stays: `window.panel` would close it.
fn show_panel(app: &mut DesignApp, panel: &str) {
- let _ = app.run("window.panel", json!({"panel": panel}));
+ if app.ui.docking_flyout.as_deref() != Some(panel) {
+ let _ = app.run("window.panel", json!({"panel": panel}));
+ }
}
fn units(app: &DesignApp) -> Unit {
@@ -3169,6 +3172,16 @@ mod tests {
use super::*;
+ /// A link to a panel whose flyout is open leaves the flyout open.
+ #[test]
+ fn a_panel_link_keeps_its_open_flyout() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ show_panel(&mut app, "stroke");
+ assert_eq!(app.ui.docking_flyout.as_deref(), Some("stroke"));
+ show_panel(&mut app, "stroke");
+ assert!(crate::panel_docking::showing(&app, "stroke"));
+ }
+
fn language(app: &mut DesignApp) -> Value {
text_attrs(app).unwrap()["chars"]["language"].clone()
}