载入中...
搜索中...
未找到
WorkspaceLayoutShellBindings.cpp
浏览该文件的文档.
2
4#include "ui/UI.h"
5#include "ui/UIHost.h"
8
9#include <simplesquirrel/simplesquirrel.hpp>
10
11namespace eve::ui_editor {
12namespace {
13
14bool mountWorkspaceShell(ui::UI* uiModule, editor::EditorWorkspace* workspace,
15 const std::string& hostName) {
16 if (!uiModule || !workspace) return false;
17 WorkspaceShellOptions options;
18 options.windowId = "root";
19 auto toolbar = ui::toolbar(
20 {ui::text(workspace->getTitle(), "shell-title"), ui::spacer("shell-fill"),
21 ui::badge(workspace->getMode(), "shell-mode")},
22 "shell-toolbar");
23 auto status = ui::statusBar(
24 {ui::text("panels=" + std::to_string(workspace->getPanelCount()), "shell-panels"),
25 ui::spacer("shell-status-fill"),
26 ui::text(workspace->getActivePanel().empty() ? "no active panel"
27 : ("active=" + workspace->getActivePanel()),
28 "shell-active")},
29 "shell-status");
30 options.toolbar = std::move(toolbar);
31 options.statusBar = std::move(status);
32 ui::WidgetDesc root = WorkspaceLayoutShell::buildWindow(*workspace, {}, std::move(options));
33 const auto handle = uiModule->mountAs(hostName.empty() ? "workspace-shell" : hostName,
34 std::move(root));
35 if (auto host = ui::UIHost::resolve(handle)) {
36 // Lock chrome: fixed IDE layout, not freely draggable panels.
37 auto meta = host->get().meta();
38 meta->hasPos = true;
39 meta->posX = 0.f;
40 meta->posY = 0.f;
41 meta->lockPos = true;
42 meta->hasSize = true;
43 meta->lockSize = true;
44 meta->percentW = 1.f;
45 meta->percentH = 1.f;
46 return true;
47 }
48 return false;
49}
50
51} // namespace
52
53void exposeWorkspaceLayoutShellBindings(ssq::Table& table, ssq::Class& moduleClass) {
54 (void)table;
55 moduleClass.addFunc("mountWorkspaceShell",
56 [](UiEditorModule*, ui::UI* uiModule, editor::EditorWorkspace* workspace,
57 const std::string& hostName) {
58 return mountWorkspaceShell(uiModule, workspace, hostName);
59 });
60 moduleClass.addFunc("panelsInRegion",
61 [](UiEditorModule*, editor::EditorWorkspace* workspace, const std::string& region) {
62 if (!workspace) return 0;
63 return int(WorkspaceLayoutShell::panelsInRegion(*workspace, region).size());
64 });
65}
66
67} // namespace eve::ui_editor
int root
Definition AnimSmr.cpp:119
ScriptFieldRegion region
wgpu::PopErrorScopeStatus status
PrimitiveHandle handle
const SquirrelValueOptions & options
float size
Definition TreeMesh.cpp:158
UIHostHandle host
Squirrel adapters for WorkspaceLayoutShell.
Composition model shared by project-specific developer and runtime editors.
static eve::OptionalRef< UIHost > resolve(UIHostHandle handle) noexcept
Resolves a UI host handle with ECS generation checking.
Definition UIHost.cpp:62
Declarative UI module (eve.UI).
Definition UI.h:41
Composition adapter that exposes the script-owned UiThemeEditor factory.
static std::vector< editor::WorkspacePanelDescriptor > panelsInRegion(const editor::EditorWorkspace &workspace, std::string_view region)
Collect visible panels for one region in deterministic order.
static ui::WidgetDesc buildWindow(const editor::EditorWorkspace &workspace, ContentBuilder content={}, WorkspaceShellOptions options={})
Compose a full Window tree for the workspace.
void exposeWorkspaceLayoutShellBindings(ssq::Table &table, ssq::Class &moduleClass)
Expose WorkspaceLayoutShell helpers on UiEditorModule.
WidgetDesc badge(std::string label, std::string id)
Compact status/category pill. Tint controls its background color.
Definition Widget.cpp:581
WidgetDesc statusBar(std::vector< WidgetDesc > children, std::string id)
Compact horizontal status strip; Spacer children absorb free width.
Definition Widget.cpp:688
WidgetDesc spacer(std::string id, float grow)
Flexible empty space; default flexGrow=1 so it absorbs free space in a Flex parent.
Definition Widget.cpp:888
WidgetDesc toolbar(std::vector< WidgetDesc > children, std::string id)
Horizontal editor command strip; Spacer children absorb free width.
Definition Widget.cpp:655
WidgetDesc text(std::string content, std::string id)
Static text label.
Definition Widget.cpp:336