Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Workspaces: leaving Learn closes its tutorials (#272)

bflatastic02c75fcaf116
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 53bf34ace..d35630b82 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -383,16 +383,21 @@ impl EffectcraftApp {
}
pub fn set_workspace(&mut self, name: &str) {
- self.ui.workspace = name.to_string();
- self.ui.dock = self.ui.saved_workspaces.get(name).cloned().unwrap_or_else(|| dock::workspace(name));
- self.ui.floating = self.ui.saved_floating.get(name).cloned().unwrap_or_else(|| dock::workspace_floating(name));
- self.ui.maximized = None;
- // Learn: the Home screen's Learn tab (tutorials) in the Composition panel.
+ // Learn: the Home screen's Learn tab (tutorials) in the Composition panel. Leaving it for
+ // another workspace closes the Home screen again: it stayed over every workspace until a
+ // project was created (#272).
if name == "Learn" {
self.ui.start_screen = true;
self.ui.home_learn = true;
self.ui.home_templates = false;
+ } else if self.ui.workspace == "Learn" {
+ self.ui.start_screen = false;
+ self.ui.home_learn = false;
}
+ self.ui.workspace = name.to_string();
+ self.ui.dock = self.ui.saved_workspaces.get(name).cloned().unwrap_or_else(|| dock::workspace(name));
+ self.ui.floating = self.ui.saved_floating.get(name).cloned().unwrap_or_else(|| dock::workspace_floating(name));
+ self.ui.maximized = None;
}
/// Built-in workspaces followed by the saved ones (Window ▸ Workspace ▸ Save as New Workspace).
diff --git a/crates/ui-egui/tests/ui_panels.rs b/crates/ui-egui/tests/ui_panels.rs
index 471e47bfb..6b8bd4a57 100644
--- a/crates/ui-egui/tests/ui_panels.rs
+++ b/crates/ui-egui/tests/ui_panels.rs
@@ -153,6 +153,20 @@ fn saved_workspace_is_listed_in_the_workspace_menu() {
assert_eq!(h.state().ui.dock, saved, "its layout came back");
}
+/// Learn opens the Home screen's tutorials; clicking another workspace tab closes them again,
+/// however quickly the tabs are clicked (they stayed over every workspace, #272).
+#[test]
+fn leaving_the_learn_workspace_closes_its_tutorials() {
+ let mut h = harness();
+ for name in ["Learn", "Default", "Learn", "Review", "Learn", "Learn", "Small Screen", "Standard", "Learn", "Default"] {
+ click(&mut h, &format!("header.workspace.{name}"));
+ assert_eq!(h.state().ui.workspace, name);
+ let learn = name == "Learn";
+ assert_eq!(h.state().ui.start_screen, learn, "{name}: the Home screen shows only for Learn");
+ assert_eq!(!h.state().auto.query("home.learn.").is_empty(), learn, "{name}: the tutorials show only for Learn");
+ }
+}
+
/// Headless look at the panels (wgpu offscreen; needs a GPU adapter). Run with
/// `PANELS_SNAPSHOT=/abs/dir cargo test -p effectcraft-ui-egui --test ui_panels -- --ignored`.
#[test]