docking: hosts seed a FloatSpace with panel sizes

This commit is contained in:
aiongg committed 2026-10-19 13:22:34 +00:00
1 parent 6261d9d39a
commit c715d3f25f
3 files changed
+21 -1

No files matched your search

+11
View File
@@ -359,4 +359,15 @@ fn float_without_a_rect_takes_the_drag_size_inside_the_dock_area() {
let small = FloatSpace::new(egui::Rect::from_min_size(egui::pos2(0.0, 30.0), egui::vec2(200.0, 200.0)));
let applied = parse(json!({"command": "window.panel.float", "panel": "layers", "group": true})).unwrap().to_actions(&workspace(), false, &small);
assert_eq!(applied, Ok(vec![Action::MoveGroup { panel: s("layers"), to: Target::Float { rect: Some([0.0, 30.0, 200.0, 200.0]) } }]));
// A host seeds the size of a panel the area never drew; a recorded size still wins.
let seeded = FloatSpace::new(area).with_panel_size(s("layers"), egui::vec2(180.0, 240.0));
let applied = parse(json!({"command": "window.panel.float", "panel": "layers"})).unwrap().to_actions(&workspace(), false, &seeded);
assert_eq!(applied, Ok(vec![Action::Float { panel: s("layers"), rect: [24.0, 54.0, 180.0, 240.0] }]));
let recorded = space.clone().with_panel_size(s("layers"), egui::vec2(180.0, 240.0));
assert_eq!(float_with(&recorded, "layers"), vec![Action::Float { panel: s("layers"), rect: [24.0, 54.0, 200.0, 150.0] }]);
}
fn float_with(space: &FloatSpace<P>, panel: &str) -> Vec<Action<P>> {
parse(json!({"command": "window.panel.float", "panel": panel})).unwrap().to_actions(&workspace(), false, space).unwrap()
}
+7
View File
@@ -245,6 +245,13 @@ impl<P: PartialEq> FloatSpace<P> {
pub fn new(area: Rect) -> Self {
Self { area, panels: Vec::new(), groups: Vec::new(), columns: Vec::new() }
}
/// Adds the size a command floats `panel` at alone when the area has not drawn it, such as
/// a hidden panel or a headless run. A size the area recorded for the panel takes precedence.
pub fn with_panel_size(mut self, panel: P, size: Vec2) -> Self {
self.panels.push((panel, size));
self
}
}
/// Lookups for `DockCommand`, which needs feature `serde`.
+3 -1
View File
@@ -191,7 +191,9 @@ let closed = command.apply(&mut app.workspace, style.right_to_left, &space, |pan
inside the dock area, 24 points from its top-left corner, so it stays clear of the menu bar.
The area records that geometry in a `FloatSpace` each frame; `float_space(ctx, id)` reads it
and `apply` and `to_actions` take it. Before the area has drawn, `FloatSpace::new(area)` floats
a panel at 260x320 and a group or column at its column width by 320. `x`, `y`, `width` and
a panel at 260x320 and a group or column at its column width by 320.
`FloatSpace::with_panel_size(panel, size)` gives a panel the area has not drawn (a hidden
panel, a headless run) the host's own size; a size the area recorded wins. `x`, `y`, `width` and
`height` replace the matching values, and a group or column that is already a whole floating
window keeps its rect.
- Without a value, `minimized`, `iconic` and `locked` toggle.