Window: saved workspaces are listed in Window ▸ Workspace (#191)
Save as New Workspace stored the layout and `window.workspace` could switch to it, but the Workspace submenu was a fixed list of the built-in workspaces, so a saved one never appeared and could not be chosen from the menu. The submenu now has a `savedWorkspaces` dynamic node after the built-ins (DynCtx carries the saved names), in the in-window and native menus, with a check mark on the current one as the built-ins have. The in-window submenu was also too short to show it. egui lays out a new submenu in a default 400 pt area, and the scroll area inside took that height and kept it, so Window ▸ Workspace (514 pt) opened with its last rows (Undocked Panels and below, where saved workspaces go) scrolled out of view. Submenus now open at their full height and scroll only when taller than the window. Tests: saved_workspace_is_listed_in_the_workspace_menu (picks it from the menu bar), saved_workspaces_are_in_the_native_workspace_menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,8 @@ pub enum MenuNode {
|
||||
pub struct DynCtx<'a> {
|
||||
/// The current workspace (Window ▸ Assign Shortcut to "…" Workspace).
|
||||
pub workspace: Option<&'a str>,
|
||||
/// Workspaces the user saved (Save as New Workspace), listed in Window ▸ Workspace.
|
||||
pub saved_workspaces: &'a [String],
|
||||
}
|
||||
|
||||
fn file_name(p: &str) -> String {
|
||||
@@ -70,8 +72,9 @@ fn holder_of(s: &Session, keys: &str) -> Option<String> {
|
||||
|
||||
/// The entries of a `@dynamic:<name>` node, and the disabled placeholder shown when there are
|
||||
/// none: `recentProjects`, `recentFootage`, `recentPresets`, `history` (undo steps, newest
|
||||
/// first), `view3dShortcuts`, `workspaceShortcuts` and `openViewers` (open compositions other
|
||||
/// than the active one), `scripts` (File ▸ Scripts) and `scriptPanels` (ScriptUI panels).
|
||||
/// first), `view3dShortcuts`, `workspaceShortcuts`, `savedWorkspaces` (Window ▸ Workspace) and
|
||||
/// `openViewers` (open compositions other than the active one), `scripts` (File ▸ Scripts) and
|
||||
/// `scriptPanels` (ScriptUI panels).
|
||||
pub fn dynamic(s: &Session, name: &str, cx: &DynCtx) -> (Vec<MenuEntry>, Option<&'static str>) {
|
||||
use serde_json::json;
|
||||
let indexed = |list: &[String], cmd: &str, stem: bool| -> Vec<MenuEntry> {
|
||||
@@ -122,6 +125,7 @@ pub fn dynamic(s: &Session, name: &str, cx: &DynCtx) -> (Vec<MenuEntry>, Option<
|
||||
.collect(),
|
||||
None,
|
||||
),
|
||||
"savedWorkspaces" => (cx.saved_workspaces.iter().map(|w| dyn_entry(w.clone(), "window.workspace", json!({"name": w}))).collect(), None),
|
||||
"openViewers" => (
|
||||
s.state
|
||||
.open_comps
|
||||
@@ -1151,6 +1155,7 @@ Window
|
||||
Paint | window.workspace {"name":"Paint"}
|
||||
Text | window.workspace {"name":"Text"}
|
||||
Undocked Panels | window.workspace {"name":"Undocked Panels"}
|
||||
@dynamic:savedWorkspaces
|
||||
---
|
||||
Reset to Saved Layout | window.resetWorkspace
|
||||
Save Changes to this Workspace | window.saveWorkspace
|
||||
|
||||
Reference in New Issue
Block a user