Skip to content

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

#1311: Dock Panel in a floating panel's menu

aionggc75ff9d32c97
diff --git a/ROADMAP.md b/ROADMAP.md
index df49a8906..221fcb679 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -163,7 +163,7 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope
- Pathfinder (Object › Pathfinder and a Pathfinder panel): Add, Subtract, Intersect, Exclude Overlap, Minus Back; curves stay curves (flo_curves); `object.pathfinder`.
- Make / Release Compound Path (⌘8; nested paths become holes), Create Outlines (⇧⌘O; one path per text colour), Scissors tool (C) with `path.split`.
- Transform Again / Individually / Sequence Again (⌥⌘3; a moved copy repeats like Step and Repeat), Clear Transformations; Layers: Merge, Delete Unused, Hide/Lock Others, Show/Unlock All; Break Link to Style (paragraph and character).
-- Floating panels: drag a panel's tab, or a group by its drag bar, off the dock (or choose Float Panel) into a movable, resizable floating window; Dock Panel puts it back where it was; positions persist; `window.panel.float` / `window.panel.dock` (aliases `window.floatPanel` / `window.dockPanel`).
+- Floating panels: drag a panel's tab, or a group by its drag bar, off the dock (or choose Float Panel) into a movable floating window that resizes from every edge; Dock Panel (in its tab menu and ≡ menu) puts it back where it was; positions persist; `window.panel.float` / `window.panel.dock` (aliases `window.floatPanel` / `window.dockPanel`).
- Place SVG (vector in PDF export via krilla-svg, resvg on screen, text in the bundled fonts), Photoshop (.psd/.psb composite in its colour mode — Bitmap, Grayscale, Duotone, Indexed, RGB, CMYK, Lab, 8/16-bit — with merged transparency; extra alpha and spot channels don't change the image), BMP, and Illustrator files saved with PDF compatibility (.ai). New `designcraft-images` crate (L2) for sniffing, sizes and decoding. EPS is still missing.
- View › Display Performance: Fast (grey boxes, no effects, ⌥⇧⌘Z), Typical (72 ppi proxies, ⌥⌘Z), High Quality (⌥⌘H, our default — the renderer is fast enough).
- OpenType menu (Character panel): discretionary ligatures, fractions, ordinal, swash, titling, contextual alternates, slashed zero, the four figure styles and stylistic sets 1–20; `type.openType`; mapped to IDML's OTF attributes.
diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs
index b7439f29c..8d811230a 100644
--- a/crates/ui-egui/src/panel_docking.rs
+++ b/crates/ui-egui/src/panel_docking.rs
@@ -972,6 +972,7 @@ pub(crate) fn panel_menu(app: &mut DesignApp, ui: &mut egui::Ui, panel: &str) {
}
ui.close();
}
+ dock_panel_item(app, ui, panel);
ui.menu_button(crate::rtl::widget(ui, crate::i18n::tr(&language, "Group with")), |ui| {
egui::ScrollArea::vertical().max_height(360.0).show(ui, |ui| {
for (anchor, label, _) in crate::dock::DOCK_TABS.iter().chain(crate::dock::ICON_PANELS) {
@@ -990,6 +991,20 @@ pub(crate) fn panel_menu(app: &mut DesignApp, ui: &mut egui::Ui, panel: &str) {
});
}
+/// Dock Panel, for a floating panel: back to where it floated from (`Transaction::dock_back`),
+/// else into the dock.
+fn dock_panel_item(app: &mut DesignApp, ui: &mut egui::Ui, panel: &str) {
+ if !layout_of(app).floating.iter().any(|w| w.contains(&panel.to_owned())) {
+ return;
+ }
+ if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Dock Panel"))).clicked() {
+ if let Err(error) = app.run("window.panel.dock", json!({"panel": panel})) {
+ app.status(error);
+ }
+ ui.close();
+ }
+}
+
/// The size a panel floats at (tab strip included), whatever the size of the dock it left.
fn floating_size(panel: &str) -> egui::Vec2 {
match panel {
@@ -1051,6 +1066,11 @@ impl craft_ui::docking::DockContent<String> for PanelContent<'_> {
fn bare(&self, id: &String) -> bool {
id == CANVAS
}
+ fn panel_menu(&mut self, ui: &mut egui::Ui, id: &String) {
+ if let Some(panel) = normalize(id) {
+ dock_panel_item(self.app, ui, panel);
+ }
+ }
fn group_header_width(&self, _: &[String], _: &String, _: bool, _: f32) -> f32 {
24.0
}
diff --git a/crates/ui-egui/src/panel_docking_tests.rs b/crates/ui-egui/src/panel_docking_tests.rs
index b4031201d..4638c8320 100644
--- a/crates/ui-egui/src/panel_docking_tests.rs
+++ b/crates/ui-egui/src/panel_docking_tests.rs
@@ -619,11 +619,35 @@ fn a_tabs_context_menu_lists_indesigns_tab_commands_and_close_works() {
assert!(h.query_all_by_label(item).next().is_some(), "{item}");
}
assert_eq!(h.query_all_by_label("Minimize").count(), 1, "the tab menu lists Minimize once");
+ assert!(h.query_all_by_label("Dock Panel").next().is_none(), "a docked panel has no Dock Panel");
h.get_by_label("Close").click();
h.run_steps(2);
assert!(!h.state().ui.docking.as_ref().unwrap().contains(&"layers".to_string()));
}
+/// A floating panel's tab menu and three-line menu have Dock Panel, which puts it back where it
+/// floated from.
+#[test]
+fn dock_panel_in_a_floating_panels_menus_returns_it_to_the_dock() {
+ let mut app = app();
+ app.run("window.panel.activate", json!({"panel":"layers"})).unwrap();
+ let docked = app.ui.docking.clone().unwrap();
+ app.run("window.panel.float", json!({"panel":"layers","x":200,"y":150})).unwrap();
+ let mut h = harness(app, vec2(1280.0, 800.0));
+ let tab = h.ctx.read_response(tab_id("layers")).unwrap().rect;
+ click(&mut h, tab.center(), PointerButton::Secondary);
+ h.get_by_label("Dock Panel").click();
+ h.run_steps(3);
+ assert_eq!(h.state().ui.docking.as_ref(), Some(&docked), "the tab menu docks it back in its group");
+ let mut app = h.into_state();
+ app.run("window.panel.float", json!({"panel":"layers","x":200,"y":150})).unwrap();
+ let mut menu = Harness::builder().with_size(vec2(300.0, 400.0)).build_ui_state(|ui, app: &mut DesignApp| panel_menu(app, ui, "layers"), app);
+ menu.run_steps(1);
+ menu.get_by_label("Dock Panel").click();
+ menu.run_steps(2);
+ assert_eq!(menu.state().ui.docking.as_ref(), Some(&docked), "so does the three-line menu");
+}
+
/// Window › Styles › Paragraph Styles opens InDesign's floating Character Styles | Paragraph Styles
/// group, which stays open while other panels open (Learn Skills Daily's InDesign course, 7:55).
#[test]
diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md
index afea8666e..036c434a6 100644
--- a/docs/target-app-parity.md
+++ b/docs/target-app-parity.md
@@ -431,7 +431,7 @@ It is evidence of breadth: each item exists. It is not a claim of InDesign-level
- Pathfinder panel as InDesign's: Paths (Join Path `path.join`, Open/Close Path, Reverse Path), Pathfinder, Convert Shape, Convert Point (`path.convertPoints`: plain, corner, smooth, symmetrical).
- Make / Release Compound Path (⌘8; nested paths become holes), Create Outlines (⇧⌘O; one path per text colour), Scissors tool (C) with `path.split`.
- Transform Again / Individually / Sequence Again (⌥⌘3; a moved copy repeats like Step and Repeat), Clear Transformations; Layers: Merge, Delete Unused, Hide/Lock Others, Show/Unlock All; Break Link to Style (paragraph and character).
-- Floating panels: drag a panel's tab, or a group by its drag bar, off the dock (or choose Float Panel) into a movable, resizable floating window; Dock Panel puts it back where it was; positions persist; `window.panel.float` / `window.panel.dock` (aliases `window.floatPanel` / `window.dockPanel`).
+- Floating panels: drag a panel's tab, or a group by its drag bar, off the dock (or choose Float Panel) into a movable floating window that resizes from every edge; Dock Panel (in its tab menu and ≡ menu) puts it back where it was; positions persist; `window.panel.float` / `window.panel.dock` (aliases `window.floatPanel` / `window.dockPanel`).
- Place SVG (vector in PDF export via krilla-svg, resvg on screen, text in the bundled fonts), Photoshop (.psd/.psb composite in its colour mode — Bitmap, Grayscale, Duotone, Indexed, RGB, CMYK, Lab, 8/16-bit — with merged transparency; extra alpha and spot channels don't change the image), BMP, and Illustrator files saved with PDF compatibility (.ai). A swatch on a placed greyscale or bitmap image (IDML `<Image FillColor>`) colours it on screen and in PDF. New `designcraft-images` crate (L2) for sniffing, sizes and decoding. EPS is still missing.
- View › Display Performance: Fast (grey boxes, no effects, ⌥⇧⌘Z), Typical (72 ppi proxies, ⌥⌘Z), High Quality (⌥⌘H, our default — the renderer is fast enough).
- OpenType menu (Character panel): discretionary ligatures, fractions, ordinal, swash, titling, contextual alternates, slashed zero, the four figure styles and stylistic sets 1–20; `type.openType`; mapped to IDML's OTF attributes.