mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-30 18:13:53 +01:00
Resetting the layout cancels a panel drag in progress again
As before the move to the craft-ui dock, a tab held while the layout resets is not dropped into the reset layout. The reset replaces the workspace, so its generation changes; ordinary edits keep theirs.
This commit is contained in:
1 parent
54053124b7
commit
266a94ea86
2 files changed
+19
-1
No files matched your search
@@ -213,6 +213,12 @@ impl Dock {
|
||||
self.workspace.layout().panel_state(&p) == PanelState::Front
|
||||
}
|
||||
|
||||
/// Puts the default layout back. It replaces the workspace instead of editing it, which ends a drag in progress.
|
||||
pub fn reset(&mut self) {
|
||||
self.workspace.replace(default_workspace());
|
||||
self.raise = None;
|
||||
}
|
||||
|
||||
/// Hide a visible panel, otherwise bring it up.
|
||||
pub fn toggle(&mut self, p: Panel) {
|
||||
if self.is_visible(p) { self.close(p) } else { self.focus(p) }
|
||||
@@ -438,6 +444,18 @@ mod tests {
|
||||
assert_eq!(back, dock);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_a_reset_replaces_the_workspace() {
|
||||
let mut dock = Dock::default();
|
||||
let start = dock.workspace().generation();
|
||||
dock.focus(Panel::Console);
|
||||
dock.close(Panel::Library);
|
||||
assert_eq!(dock.workspace().generation(), start);
|
||||
dock.reset();
|
||||
assert_ne!(dock.workspace().generation(), start);
|
||||
assert_eq!(dock, Dock::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_graph_stays_put_and_panels_come_back() {
|
||||
let mut dock = Dock::default();
|
||||
|
||||
@@ -251,7 +251,7 @@ pub fn invoke(app: &mut MaterialCraftApp, ctx: &egui::Context, id: &str) {
|
||||
"ui.quit" => ctx.send_viewport_cmd(egui::ViewportCommand::Close),
|
||||
"ui.preferences" => app.ui.windows.preferences = true,
|
||||
"ui.view.graph" => {}
|
||||
"ui.resetLayout" => app.ui.dock = crate::docking::Dock::default(),
|
||||
"ui.resetLayout" => app.ui.dock.reset(),
|
||||
"ui.closeAll" => crate::unsaved::guard(app, crate::unsaved::Guarded::Menu { id: id.to_string() }),
|
||||
"file.newPackage" => {
|
||||
app.run("file.newPackage", serde_json::json!({}));
|
||||
|
||||
Reference in new issue
Block a user