Refactor editor panel services boundary

This commit is contained in:
2026-04-27 16:22:46 +08:00
parent 048ca7b362
commit 9f299ab6e3
17 changed files with 228 additions and 123 deletions

View File

@@ -1,6 +1,6 @@
#include "Features/Inspector/AddComponentPanel.h"
#include "Composition/EditorContext.h"
#include "Core/Panels/EditorPanelServices.h"
#include "Features/Inspector/Components/IInspectorComponentEditor.h"
#include "Features/Inspector/Components/InspectorComponentEditorRegistry.h"
@@ -122,7 +122,7 @@ void AddComponentPanel::RebuildEntries(
}
bool AddComponentPanel::TryActivateEntry(
EditorContext& context,
EditorPanelServices& services,
std::size_t entryIndex) {
if (entryIndex >= m_entries.size()) {
return false;
@@ -133,13 +133,13 @@ bool AddComponentPanel::TryActivateEntry(
return false;
}
if (!context.GetSceneRuntime().AddComponentToSelectedGameObject(entry.componentTypeName)) {
if (!services.sceneRuntime.AddComponentToSelectedGameObject(entry.componentTypeName)) {
return false;
}
m_hasTarget = context.GetSceneRuntime().GetSelectedGameObject() != nullptr;
m_targetDisplayName = context.GetSceneRuntime().GetSelectedDisplayName();
RebuildEntries(context.GetSceneRuntime().GetSelectedGameObject());
m_hasTarget = services.sceneRuntime.GetSelectedGameObject() != nullptr;
m_targetDisplayName = services.sceneRuntime.GetSelectedDisplayName();
RebuildEntries(services.sceneRuntime.GetSelectedGameObject());
return true;
}
@@ -154,7 +154,7 @@ std::size_t AddComponentPanel::HitTestEntry(const UIPoint& point) const {
}
void AddComponentPanel::Update(
EditorContext& context,
EditorPanelServices& services,
const EditorUtilityWindowHostContext& hostContext,
const std::vector<UIInputEvent>& inputEvents) {
if (!hostContext.mounted) {
@@ -164,9 +164,9 @@ void AddComponentPanel::Update(
m_visible = true;
m_bounds = hostContext.bounds;
m_hasTarget = context.GetSceneRuntime().GetSelectedGameObject() != nullptr;
m_targetDisplayName = context.GetSceneRuntime().GetSelectedDisplayName();
RebuildEntries(context.GetSceneRuntime().GetSelectedGameObject());
m_hasTarget = services.sceneRuntime.GetSelectedGameObject() != nullptr;
m_targetDisplayName = services.sceneRuntime.GetSelectedDisplayName();
RebuildEntries(services.sceneRuntime.GetSelectedGameObject());
if (hostContext.focusLost) {
ResetInteractionState();
@@ -204,7 +204,7 @@ void AddComponentPanel::Update(
m_hoveredEntryIndex = HitTestEntry(event.position);
if (m_pressedEntryIndex != kInvalidEntryIndex &&
m_pressedEntryIndex == m_hoveredEntryIndex) {
TryActivateEntry(context, m_pressedEntryIndex);
TryActivateEntry(services, m_pressedEntryIndex);
}
m_pressedEntryIndex = kInvalidEntryIndex;
break;