载入中...
搜索中...
未找到
EditorSelectionRouter.cpp
浏览该文件的文档.
2
3#include "editor/EditorHost.h"
4
5namespace eve::editor {
6
8
9const std::string& EditorSelectionRouter::channel() const { return host_->selectionChannel(); }
10
12 if (!host_)
13 return eve::editing::failed<std::string>(EditorStatus::Failed, RuleId("editor.selection.no-host"),
14 "SelectionRouter has no host");
15 EditorWorkspace& workspace = host_->workspace();
16 auto selected = workspace.selectItem(channel(), item, additive);
17 if (!selected.ok())
18 return eve::editing::failed<std::string>(selected.code(), RuleId("editor.selection.apply-failed"),
19 "Could not apply host selection");
20
21 std::string activated;
22 const int count = workspace.getPanelCount();
23 for (int index = 0; index < count; ++index) {
24 if (workspace.getPanelContext(index) != "inspector") continue;
25 if (!workspace.getPanelVisible(index)) continue;
26 const std::string capability = workspace.getPanelCapability(index);
27 if (!capability.empty() && !item.type.empty() && capability.find(item.type) == std::string::npos) {
28 // Prefer panels whose capability mentions the selection type; fall back to first inspector.
29 if (activated.empty()) activated = workspace.getPanelId(index);
30 continue;
31 }
32 activated = workspace.getPanelId(index);
33 break;
34 }
35 if (activated.empty()) {
36 for (int index = 0; index < count; ++index) {
37 if (workspace.getPanelContext(index) != "inspector" || !workspace.getPanelVisible(index)) continue;
38 activated = workspace.getPanelId(index);
39 break;
40 }
41 }
42 if (!activated.empty()) (void)workspace.activatePanel(activated);
43 return eve::editing::applied<std::string>(std::move(activated));
44}
45
47 if (!host_)
48 return eve::editing::failed<void>(EditorStatus::Failed, RuleId("editor.selection.no-host"),
49 "SelectionRouter has no host");
51 return eve::editing::applied<void>();
52}
53
54} // namespace eve::editor
std::string selected
int count
UIHostHandle host
uint32_t index
Move-only operation result carrying either a value or Status.
Definition Result.h:176
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
Composition runtime that discovers EditorPackage providers and installs them.
Definition EditorHost.h:53
const std::string & selectionChannel() const
Host selection channel used by SelectionRouter.
Definition EditorHost.h:94
EditorWorkspace & workspace()
Workspace receiving merged panels.
Definition EditorHost.h:89
Result< std::string > select(const SelectionItem &item, bool additive=false)
Apply a selection and activate a matching inspector panel.
const std::string & channel() const
Host selection channel.
Result< void > clear()
Clear the host channel selection.
Composition model shared by project-specific developer and runtime editors.
std::string getPanelCapability(int index) const
Panel capability requirement by deterministic index.
std::string getPanelContext(int index) const
Panel input context by deterministic index.
Result< SelectionSnapshot > selectItem(std::string channel, SelectionItem item, bool additive)
Select one already typed item without string domain parsing.
Result< WorkspacePanelDescriptor > activatePanel(const StableId &id)
Activate a visible panel with structured not-found/rejected results.
int getPanelCount() const
Number of registered panels in deterministic region/order/id order.
bool getPanelVisible(int index) const
Panel visibility by deterministic index.
std::string getPanelId(int index) const
Panel id by deterministic index.
bool clearSelection(const std::string &channel)
Clear one semantic selection channel.
eve::editing::RuleId RuleId
Definition EditorIds.h:32
SelectionItem public API.