refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
#include "ProductEditorHostCommandBridge.h"
|
||||
#include "EditorHostCommandBridge.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
void ProductEditorHostCommandBridge::BindSession(ProductEditorSession& session) {
|
||||
void EditorHostCommandBridge::BindSession(EditorSession& session) {
|
||||
m_session = &session;
|
||||
}
|
||||
|
||||
void ProductEditorHostCommandBridge::SetExitRequestHandler(std::function<void()> handler) {
|
||||
void EditorHostCommandBridge::SetExitRequestHandler(std::function<void()> handler) {
|
||||
m_requestExit = std::move(handler);
|
||||
}
|
||||
|
||||
UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateHostCommand(
|
||||
UIEditorHostCommandEvaluationResult EditorHostCommandBridge::EvaluateHostCommand(
|
||||
std::string_view commandId) const {
|
||||
UIEditorHostCommandEvaluationResult result = {};
|
||||
|
||||
@@ -48,7 +48,7 @@ UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateHost
|
||||
return BuildDisabledResult("Host command is not attached yet.");
|
||||
}
|
||||
|
||||
UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchHostCommand(
|
||||
UIEditorHostCommandDispatchResult EditorHostCommandBridge::DispatchHostCommand(
|
||||
std::string_view commandId) {
|
||||
UIEditorHostCommandDispatchResult result = {};
|
||||
|
||||
@@ -75,7 +75,7 @@ UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchHostCo
|
||||
return result;
|
||||
}
|
||||
|
||||
UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::BuildDisabledResult(
|
||||
UIEditorHostCommandEvaluationResult EditorHostCommandBridge::BuildDisabledResult(
|
||||
std::string_view message) const {
|
||||
UIEditorHostCommandEvaluationResult result = {};
|
||||
result.executable = false;
|
||||
@@ -83,14 +83,14 @@ UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::BuildDisable
|
||||
return result;
|
||||
}
|
||||
|
||||
UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateEditCommand(
|
||||
UIEditorHostCommandEvaluationResult EditorHostCommandBridge::EvaluateEditCommand(
|
||||
std::string_view commandId) const {
|
||||
if (m_session == nullptr) {
|
||||
return BuildDisabledResult("Editor session is not attached yet.");
|
||||
}
|
||||
|
||||
switch (m_session->activeRoute) {
|
||||
case ProductEditorActionRoute::Hierarchy:
|
||||
case EditorActionRoute::Hierarchy:
|
||||
if (SupportsHierarchyEditCommands(commandId)) {
|
||||
return UIEditorHostCommandEvaluationResult{
|
||||
true,
|
||||
@@ -98,7 +98,7 @@ UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateEdit
|
||||
};
|
||||
}
|
||||
return BuildDisabledResult("Current hierarchy route does not expose this command yet.");
|
||||
case ProductEditorActionRoute::Project:
|
||||
case EditorActionRoute::Project:
|
||||
if (SupportsProjectEditCommands(commandId)) {
|
||||
return UIEditorHostCommandEvaluationResult{
|
||||
true,
|
||||
@@ -106,14 +106,14 @@ UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateEdit
|
||||
};
|
||||
}
|
||||
return BuildDisabledResult("Current project route does not expose this command yet.");
|
||||
case ProductEditorActionRoute::None:
|
||||
case EditorActionRoute::None:
|
||||
return BuildDisabledResult("No active edit route.");
|
||||
default:
|
||||
return BuildDisabledResult("Current panel does not expose edit commands yet.");
|
||||
}
|
||||
}
|
||||
|
||||
UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchEditCommand(
|
||||
UIEditorHostCommandDispatchResult EditorHostCommandBridge::DispatchEditCommand(
|
||||
std::string_view commandId) {
|
||||
UIEditorHostCommandDispatchResult result = {};
|
||||
const UIEditorHostCommandEvaluationResult evaluation = EvaluateEditCommand(commandId);
|
||||
@@ -123,11 +123,11 @@ UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchEditCo
|
||||
}
|
||||
|
||||
result.commandExecuted = true;
|
||||
switch (m_session != nullptr ? m_session->activeRoute : ProductEditorActionRoute::None) {
|
||||
case ProductEditorActionRoute::Hierarchy:
|
||||
switch (m_session != nullptr ? m_session->activeRoute : EditorActionRoute::None) {
|
||||
case EditorActionRoute::Hierarchy:
|
||||
result.message = "Hierarchy edit command route reached.";
|
||||
break;
|
||||
case ProductEditorActionRoute::Project:
|
||||
case EditorActionRoute::Project:
|
||||
result.message = "Project edit command route reached.";
|
||||
break;
|
||||
default:
|
||||
@@ -137,7 +137,7 @@ UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchEditCo
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ProductEditorHostCommandBridge::SupportsHierarchyEditCommands(
|
||||
bool EditorHostCommandBridge::SupportsHierarchyEditCommands(
|
||||
std::string_view commandId) const {
|
||||
return commandId == "edit.cut" ||
|
||||
commandId == "edit.copy" ||
|
||||
@@ -147,10 +147,11 @@ bool ProductEditorHostCommandBridge::SupportsHierarchyEditCommands(
|
||||
commandId == "edit.rename";
|
||||
}
|
||||
|
||||
bool ProductEditorHostCommandBridge::SupportsProjectEditCommands(
|
||||
bool EditorHostCommandBridge::SupportsProjectEditCommands(
|
||||
std::string_view commandId) const {
|
||||
return commandId == "edit.delete" ||
|
||||
commandId == "edit.rename";
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
|
||||
Reference in New Issue
Block a user