mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-27 03:28:22 -06:00
D1: tests for never-placed panels and native window places; Move Panel to New Window stays in the panel menu
A panel never laid out opens at EffectCraft's default place for it; a closed panel reopens at its recorded place. The panel menu keeps Move Panel to New Window, which records the window's place.
This commit is contained in:
@@ -234,8 +234,16 @@ pub fn panel_menu_popup(app: &mut EffectcraftApp, ui: &mut egui::Ui) {
|
||||
let _ = app.dock_command(ui.ctx(), craft_ui::docking::Action::Float { panel, rect: r });
|
||||
close = true;
|
||||
}
|
||||
// D2: Move Panel to New Window / Main Window returns here once craft-ui's native
|
||||
// windows draw the window (`window.panelWindow` records the place meanwhile).
|
||||
// Multiple monitors: a native window of its own, which can go on another screen.
|
||||
// D2: craft-ui's native windows draw it; until then the place is recorded and the
|
||||
// panel floats in the main window.
|
||||
if !ui.ctx().embed_viewports() {
|
||||
let windowed = app.in_panel_window(panel);
|
||||
if ui.button(if windowed { tr("Move Panel to Main Window") } else { tr("Move Panel to New Window") }).clicked() {
|
||||
let _ = crate::menus::invoke(app, &ui.ctx().clone(), "window.panelWindow", serde_json::json!({"panel": panel, "window": !windowed}));
|
||||
close = true;
|
||||
}
|
||||
}
|
||||
if !floating && ui.button(if app.ui.maximized == Some(panel) { tr("Restore Panel Size") } else { tr("Maximize Panel") }).clicked() {
|
||||
app.toggle_maximize(panel);
|
||||
close = true;
|
||||
|
||||
@@ -361,12 +361,12 @@ mod tests {
|
||||
let config = MemoryConfig::default();
|
||||
let mut ui = UiState::default();
|
||||
let mut store = WorkspaceStore::load(Some(&config), &mut ui);
|
||||
ui.dock.apply(Action::Float { panel: PanelKind::Info, rect: [10.0, 10.0, 300.0, 200.0] }, crate::dock::permissions).unwrap();
|
||||
ui.dock.apply(Action::SetNative { panel: PanelKind::Info, rect: Some([90_000.0, -90_000.0, 1.0e5, 0.5]) }, crate::dock::permissions).unwrap();
|
||||
ui.dock.apply(Action::Float { panel: PanelKind::Project, rect: [10.0, 10.0, 300.0, 200.0] }, crate::dock::permissions).unwrap();
|
||||
ui.dock.apply(Action::SetNative { panel: PanelKind::Project, rect: Some([90_000.0, -90_000.0, 1.0e5, 0.5]) }, crate::dock::permissions).unwrap();
|
||||
assert!(store.save(Some(&config), &ui).unwrap());
|
||||
let mut restored = UiState::default();
|
||||
WorkspaceStore::load(Some(&config), &mut restored);
|
||||
let native = restored.dock.layout.floating.iter().find(|w| w.contains(&PanelKind::Info)).and_then(|w| w.native).unwrap();
|
||||
let native = restored.dock.layout.floating.iter().find(|w| w.contains(&PanelKind::Project)).and_then(|w| w.native).unwrap();
|
||||
assert_eq!(native, crate::dock_ui::sanitized_window_rect(native));
|
||||
assert!(native[2] <= crate::dock_ui::PANEL_WINDOW_MAX && native[3] >= crate::dock_ui::PANEL_WINDOW_MIN[1]);
|
||||
}
|
||||
|
||||
@@ -331,3 +331,21 @@ fn failed_close_preserves_viewer_lifecycle_and_maximize_state() {
|
||||
assert_eq!(app.ui.active_viewer, before.active_viewer);
|
||||
assert_eq!(app.ui.locked_tabs, before.locked_tabs);
|
||||
}
|
||||
|
||||
/// A panel never laid out opens at EffectCraft's default place for it (History beside the
|
||||
/// Project panel, Render Queue with the Timeline), not where craft-ui's fallback puts it; a panel
|
||||
/// the user closed comes back where it was.
|
||||
#[test]
|
||||
fn never_placed_panels_open_at_their_default_place() {
|
||||
let mut app = EffectcraftApp::new(Session::default());
|
||||
assert!(!app.ui.dock.is_open(PanelKind::History));
|
||||
invoke(&mut app, "window.panel", json!({"panel": "History"})).unwrap();
|
||||
assert!(app.ui.dock.group_of(PanelKind::History).contains(&PanelKind::Project), "{:?}", app.ui.dock.group_of(PanelKind::History));
|
||||
invoke(&mut app, "window.panel.activate", json!({"panel": "Tracker"})).unwrap();
|
||||
assert!(app.ui.dock.group_of(PanelKind::Tracker).contains(&PanelKind::EffectsPresets) || app.ui.dock.is_open(PanelKind::Tracker));
|
||||
// Closed by the user, it reopens at its recorded place.
|
||||
invoke(&mut app, "window.dockPanel", json!({"panel": "History", "anchor": "Timeline"})).unwrap();
|
||||
invoke(&mut app, "window.closePanel", json!({"panel": "History"})).unwrap();
|
||||
invoke(&mut app, "window.panel", json!({"panel": "History"})).unwrap();
|
||||
assert!(app.ui.dock.group_of(PanelKind::History).contains(&PanelKind::Timeline));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user