Refine editor viewport and interaction workflow

This commit is contained in:
2026-03-29 15:12:38 +08:00
parent b0427b7091
commit 2651bad080
42 changed files with 3888 additions and 570 deletions

View File

@@ -111,11 +111,20 @@ void HierarchyPanel::Render() {
RenderEntity(gameObject);
}
Actions::HandleHierarchyBackgroundPrimaryClick(*m_context, m_renameState);
Actions::RequestHierarchyBackgroundContextPopup(m_backgroundContextMenu);
Actions::DrawHierarchyBackgroundInteraction(*m_context, m_renameState);
Actions::DrawHierarchyEntityContextPopup(*m_context, m_itemContextMenu);
Actions::DrawHierarchyBackgroundContextPopup(*m_context, m_backgroundContextMenu);
Actions::DrawHierarchyRootDropTarget(*m_context);
static bool s_backgroundContextOpen = false;
if (UI::BeginContextMenuForLastItem("##HierarchyBackgroundContext")) {
if (!s_backgroundContextOpen) {
Actions::TraceHierarchyPopup("Hierarchy background popup opened via background surface");
s_backgroundContextOpen = true;
}
Actions::DrawHierarchyCreateActions(*m_context, nullptr);
UI::EndContextMenu();
} else if (s_backgroundContextOpen) {
Actions::TraceHierarchyPopup("Hierarchy background popup closed");
s_backgroundContextOpen = false;
}
}
ImGui::PopStyleColor(2);
}
@@ -126,22 +135,16 @@ void HierarchyPanel::RenderEntity(::XCEngine::Components::GameObject* gameObject
ImGui::PushID(static_cast<int>(gameObject->GetID()));
if (m_renameState.IsEditing(gameObject->GetID())) {
if (m_renameState.ConsumeFocusRequest()) {
ImGui::SetKeyboardFocusHere();
}
ImGui::SetNextItemWidth(-1);
if (ImGui::InputText(
"##Rename",
m_renameState.Buffer(),
m_renameState.BufferSize(),
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)) {
CommitRename();
}
const UI::InlineRenameFieldResult renameField = UI::DrawInlineRenameField(
"##Rename",
m_renameState.Buffer(),
m_renameState.BufferSize(),
-1.0f,
m_renameState.ConsumeFocusRequest());
if (ImGui::IsItemActive() && ImGui::IsKeyPressed(ImGuiKey_Escape)) {
if (renameField.cancelRequested) {
CancelRename();
} else if (!ImGui::IsItemActive() && ImGui::IsMouseClicked(0)) {
} else if (renameField.submitted || renameField.deactivated) {
CommitRename();
}
} else {
@@ -161,10 +164,6 @@ void HierarchyPanel::RenderEntity(::XCEngine::Components::GameObject* gameObject
if (node.secondaryClicked) {
Actions::HandleHierarchyItemContextRequest(*m_context, gameObject, m_itemContextMenu);
}
if (node.doubleClicked) {
BeginRename(gameObject);
}
};
nodeDefinition.callbacks.onRenderExtras = [this, gameObject]() {
Actions::BeginHierarchyEntityDrag(gameObject);