Support default editor panel layout and locked panels #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The editor has docking enabled but no defined layout. On first launch every panel is a free-floating window, and the user has to arrange them by hand. There is also no way to mark a panel as fixed (unmovable, undockable, unclosable), which editors usually want for things like a toolbar or status bar.
Background
engine/src/imgui_renderer.cpp, which callsDockSpaceOverViewport(...)each frame. Nothing is assigned to the dockspace, so it starts empty.imgui.inionce the user rearranges windows, but nothing seeds the initial layout.Panel(engine/include/sophia/ui/panel.hpp) only hasvisible. It has no way to express window flags or lock behaviour.ImGui::Begin("...")andEnd()itself, so the base class can't apply per-panel window settings.editor/panels/and are registered inEditor::onCreate()ineditor/main.cpp.Proposal
1. Panel owns
Begin/End, configured viaPanel::ConfigPanel::Configstruct, passed to thePanelconstructor and used with designated initializers, likeApplication::Config. Example:Panel{{.name = "Toolbar", .locked = true, .size = {300, 0}}}.name,locked,closable, andsize(initial size). More can be added later.PanelRegistry::updatecalls a non-virtualPanel::draw(), which doesBegin(name, &open, flags), calls the virtualonUpdate, thenEnd(). Subclasses drop their ownBegin/End.Configinto ImGui window flags in one place, and handles the close button.setVisible). If something needs to change dynamically, such as locking during play mode, add a singlesetLockedalongside the config rather than a full set of setters.2. Locked panels
NoMove | NoResize | NoDocking | NoCollapse(and optionallyNoTitleBar) and is drawn outside the dockspace, for example a fixed top toolbar.setVisible(), or must always be shown.3. Default layout
DockBuilderAPI (imgui_internal.h):DockBuilderSplitNode()to carve the dockspace into regions, thenDockBuilderDockWindow(name, nodeId)to assign each panel.imgui.ini, or the dockspace node has no children). After that, normal ini persistence takes over.ImGuiRenderer::beginFrame()should expose a hook for it.Suggested order
Begin/EndintoPanel::draw()and addPanel::Config. Migrate the existing panels (Console, Frame Stats, PanelRegistry, ECS Inspector, and the three editor panels).lockedandclosable.Acceptance criteria
ImGui::Begin/Enddirectly.lockedcannot be moved, resized, docked, collapsed or closed.imgui.iniand launching the editor produces the default docked layout.Risks / open questions
DockBuilderlives inimgui_internal.hand upstream marks it as subject to change. It is still the standard way to seed a layout, but we should isolate its usage in one place.Begin/Endinto the base class touches every existing panel, so it should land as its own change before the layout work.