From 7c37e6968731d475e13227be7a3f65bb86ef2898 Mon Sep 17 00:00:00 2001 From: Skyler Lehmkuhl Date: Wed, 25 Feb 2026 07:45:39 -0500 Subject: [PATCH] adjust default layouts --- .../lightningbeam-editor/assets/layouts.json | 94 +++---------------- .../lightningbeam-editor/src/main.rs | 6 +- .../lightningbeam-editor/src/menu.rs | 51 ++++++++-- 3 files changed, 63 insertions(+), 88 deletions(-) diff --git a/lightningbeam-ui/lightningbeam-editor/assets/layouts.json b/lightningbeam-ui/lightningbeam-editor/assets/layouts.json index d549ec4..f5f5202 100644 --- a/lightningbeam-ui/lightningbeam-editor/assets/layouts.json +++ b/lightningbeam-ui/lightningbeam-editor/assets/layouts.json @@ -32,7 +32,7 @@ "type": "vertical-grid", "percent": 10, "children": [ - { "type": "pane", "name": "toolbar" }, + { "type": "pane", "name": "infopanel" }, { "type": "vertical-grid", "percent": 65, @@ -42,7 +42,7 @@ "percent": 50, "children": [ { "type": "pane", "name": "stage" }, - { "type": "pane", "name": "infopanel" } + { "type": "pane", "name": "assetLibrary" } ] }, { "type": "pane", "name": "timelineV2" } @@ -53,17 +53,17 @@ }, { "name": "Audio/DAW", - "description": "Audio tracks prominent with mixer, node editor, and preset browser", + "description": "Audio tracks prominent with mixer, virtual piano, and preset browser", "layout": { "type": "horizontal-grid", "percent": 75, "children": [ { "type": "vertical-grid", - "percent": 50, + "percent": 60, "children": [ { "type": "pane", "name": "timelineV2" }, - { "type": "pane", "name": "nodeEditor" } + { "type": "pane", "name": "virtualPiano" } ] }, { "type": "pane", "name": "presetBrowser" } @@ -72,34 +72,20 @@ }, { "name": "Scripting", - "description": "Code editor, object hierarchy, and console", + "description": "Script editor with stage preview and timeline", "layout": { - "type": "vertical-grid", - "percent": 10, + "type": "horizontal-grid", + "percent": 50, "children": [ - { "type": "pane", "name": "toolbar" }, { - "type": "horizontal-grid", - "percent": 70, + "type": "vertical-grid", + "percent": 60, "children": [ - { - "type": "vertical-grid", - "percent": 50, - "children": [ - { "type": "pane", "name": "stage" }, - { "type": "pane", "name": "timelineV2" } - ] - }, - { - "type": "vertical-grid", - "percent": 50, - "children": [ - { "type": "pane", "name": "infopanel" }, - { "type": "pane", "name": "outlineer" } - ] - } + { "type": "pane", "name": "stage" }, + { "type": "pane", "name": "timelineV2" } ] - } + }, + { "type": "pane", "name": "scriptEditor" } ] } }, @@ -129,32 +115,6 @@ ] } }, - { - "name": "3D", - "description": "3D viewport, camera controls, and lighting panel", - "layout": { - "type": "vertical-grid", - "percent": 10, - "children": [ - { "type": "pane", "name": "toolbar" }, - { - "type": "horizontal-grid", - "percent": 70, - "children": [ - { - "type": "vertical-grid", - "percent": 70, - "children": [ - { "type": "pane", "name": "stage" }, - { "type": "pane", "name": "timelineV2" } - ] - }, - { "type": "pane", "name": "infopanel" } - ] - } - ] - } - }, { "name": "Drawing/Painting", "description": "Minimal UI - just canvas and drawing tools", @@ -180,31 +140,5 @@ } ] } - }, - { - "name": "Shader Editor", - "description": "Split between viewport preview and code editor", - "layout": { - "type": "vertical-grid", - "percent": 10, - "children": [ - { "type": "pane", "name": "toolbar" }, - { - "type": "horizontal-grid", - "percent": 50, - "children": [ - { "type": "pane", "name": "stage" }, - { - "type": "vertical-grid", - "percent": 60, - "children": [ - { "type": "pane", "name": "infopanel" }, - { "type": "pane", "name": "timelineV2" } - ] - } - ] - } - ] - } } ] diff --git a/lightningbeam-ui/lightningbeam-editor/src/main.rs b/lightningbeam-ui/lightningbeam-editor/src/main.rs index 381f29a..8743272 100644 --- a/lightningbeam-ui/lightningbeam-editor/src/main.rs +++ b/lightningbeam-ui/lightningbeam-editor/src/main.rs @@ -4707,7 +4707,11 @@ impl eframe::App for EditorApp { egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| { if let Some(menu_system) = &self.menu_system { let recent_files = self.config.get_recent_files(); - if let Some(action) = menu_system.render_egui_menu_bar(ui, &recent_files, Some(&self.keymap)) { + let layout_names: Vec = self.layouts.iter().map(|l| l.name.clone()).collect(); + if let Some(action) = menu_system.render_egui_menu_bar( + ui, &recent_files, Some(&self.keymap), + &layout_names, self.current_layout_index, + ) { self.handle_menu_action(action); } } diff --git a/lightningbeam-ui/lightningbeam-editor/src/menu.rs b/lightningbeam-ui/lightningbeam-editor/src/menu.rs index fdba78a..ebb8b8d 100644 --- a/lightningbeam-ui/lightningbeam-editor/src/menu.rs +++ b/lightningbeam-ui/lightningbeam-editor/src/menu.rs @@ -766,12 +766,19 @@ impl MenuSystem { } /// Render egui menu bar from the same menu structure (for Linux/Windows) - pub fn render_egui_menu_bar(&self, ui: &mut egui::Ui, recent_files: &[std::path::PathBuf], keymap: Option<&crate::keymap::KeymapManager>) -> Option { + pub fn render_egui_menu_bar( + &self, + ui: &mut egui::Ui, + recent_files: &[std::path::PathBuf], + keymap: Option<&crate::keymap::KeymapManager>, + layout_names: &[String], + current_layout_index: usize, + ) -> Option { let mut action = None; egui::MenuBar::new().ui(ui, |ui| { for menu_def in MenuItemDef::menu_structure() { - if let Some(a) = self.render_menu_def(ui, menu_def, recent_files, keymap) { + if let Some(a) = self.render_menu_def(ui, menu_def, recent_files, keymap, layout_names, current_layout_index) { action = Some(a); } } @@ -781,7 +788,15 @@ impl MenuSystem { } /// Recursively render a MenuDef as egui UI - fn render_menu_def(&self, ui: &mut egui::Ui, def: &MenuDef, recent_files: &[std::path::PathBuf], keymap: Option<&crate::keymap::KeymapManager>) -> Option { + fn render_menu_def( + &self, + ui: &mut egui::Ui, + def: &MenuDef, + recent_files: &[std::path::PathBuf], + keymap: Option<&crate::keymap::KeymapManager>, + layout_names: &[String], + current_layout_index: usize, + ) -> Option { match def { MenuDef::Item(item_def) => { if Self::render_menu_item(ui, item_def, keymap) { @@ -797,9 +812,8 @@ impl MenuSystem { MenuDef::Submenu { label, children } => { let mut action = None; ui.menu_button(*label, |ui| { - // Special handling for "Open Recent" submenu if *label == "Open Recent" { - // Render dynamic recent files + // Special handling for "Open Recent" submenu for (index, path) in recent_files.iter().enumerate() { let display_name = path .file_name() @@ -812,7 +826,6 @@ impl MenuSystem { } } - // Add separator and clear option if we have items if !recent_files.is_empty() { ui.separator(); } @@ -821,10 +834,34 @@ impl MenuSystem { action = Some(MenuAction::ClearRecentFiles); ui.close(); } + } else if *label == "Layout" { + // Render static items first (Next/Previous Layout) + for child in *children { + if let Some(a) = self.render_menu_def(ui, child, recent_files, keymap, layout_names, current_layout_index) { + action = Some(a); + ui.close(); + } + } + + // Dynamic layout list + if !layout_names.is_empty() { + ui.separator(); + for (index, name) in layout_names.iter().enumerate() { + let label = if index == current_layout_index { + format!("* {}", name) + } else { + name.clone() + }; + if ui.button(label).clicked() { + action = Some(MenuAction::SwitchLayout(index)); + ui.close(); + } + } + } } else { // Normal submenu rendering for child in *children { - if let Some(a) = self.render_menu_def(ui, child, recent_files, keymap) { + if let Some(a) = self.render_menu_def(ui, child, recent_files, keymap, layout_names, current_layout_index) { action = Some(a); ui.close(); }