refactor(new_editor): unify panel input and rename primitives

This commit is contained in:
2026-04-19 03:23:16 +08:00
parent c59cd83c38
commit 78bcd2e9ca
17 changed files with 652 additions and 338 deletions

View File

@@ -2,6 +2,7 @@
#include "Composition/EditorPanelIds.h"
#include <XCEditor/Fields/UIEditorFieldStyle.h>
#include <XCEditor/Foundation/UIEditorPanelInputFilter.h>
#include <XCEditor/Foundation/UIEditorTheme.h>
#include "Features/Inspector/Components/IInspectorComponentEditor.h"
@@ -18,7 +19,6 @@ namespace {
using ::XCEngine::UI::UIColor;
using ::XCEngine::UI::UIDrawList;
using ::XCEngine::UI::UIInputEvent;
using ::XCEngine::UI::UIInputEventType;
using ::XCEngine::UI::UIPoint;
using ::XCEngine::UI::UIRect;
@@ -32,63 +32,11 @@ constexpr UIColor kTitleColor(0.930f, 0.930f, 0.930f, 1.0f);
constexpr UIColor kSubtitleColor(0.660f, 0.660f, 0.660f, 1.0f);
constexpr UIColor kSurfaceColor(0.10f, 0.10f, 0.10f, 1.0f);
bool ContainsPoint(const UIRect& rect, const UIPoint& point) {
return point.x >= rect.x &&
point.x <= rect.x + rect.width &&
point.y >= rect.y &&
point.y <= rect.y + rect.height;
}
float ResolveTextTop(float rectY, float rectHeight, float fontSize) {
const float lineHeight = fontSize * 1.6f;
return rectY + std::floor((rectHeight - lineHeight) * 0.5f);
}
std::vector<UIInputEvent> FilterInspectorInputEvents(
const UIRect& bounds,
const std::vector<UIInputEvent>& inputEvents,
bool allowInteraction,
bool panelActive) {
if (!allowInteraction && !panelActive) {
return {};
}
std::vector<UIInputEvent> filteredEvents = {};
filteredEvents.reserve(inputEvents.size());
for (const UIInputEvent& event : inputEvents) {
switch (event.type) {
case UIInputEventType::PointerMove:
case UIInputEventType::PointerButtonDown:
case UIInputEventType::PointerButtonUp:
case UIInputEventType::PointerWheel:
if (allowInteraction && ContainsPoint(bounds, event.position)) {
filteredEvents.push_back(event);
}
break;
case UIInputEventType::PointerLeave:
filteredEvents.push_back(event);
break;
case UIInputEventType::FocusGained:
case UIInputEventType::FocusLost:
if (panelActive) {
filteredEvents.push_back(event);
}
break;
case UIInputEventType::KeyDown:
case UIInputEventType::KeyUp:
case UIInputEventType::Character:
if (panelActive) {
filteredEvents.push_back(event);
}
break;
default:
break;
}
}
return filteredEvents;
}
UIEditorHostCommandEvaluationResult BuildEvaluationResult(
bool executable,
std::string message) {
@@ -317,11 +265,16 @@ void InspectorPanel::Update(
}
const std::vector<UIInputEvent> filteredEvents =
FilterInspectorInputEvents(
FilterUIEditorPanelInputEvents(
m_bounds,
inputEvents,
allowInteraction,
panelActive);
UIEditorPanelInputFilterOptions{
.allowPointerInBounds = allowInteraction,
.allowPointerWhileCaptured = false,
.allowKeyboardInput = panelActive,
.allowFocusEvents = panelActive,
.includePointerLeave = allowInteraction || panelActive
});
m_gridFrame = UpdateUIEditorPropertyGridInteraction(
m_interactionState,
m_fieldSelection,