editor: remove shared panel services bag
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "InspectorPanel.h"
|
||||
|
||||
#include "Panels/EditorPanelServices.h"
|
||||
#include "UtilityWindows/EditorUtilityWindowRuntime.h"
|
||||
#include "State/EditorColorPickerToolState.h"
|
||||
#include "Inspector/InspectorFieldValueApplier.h"
|
||||
@@ -450,36 +449,36 @@ Widgets::UIEditorPropertyGridField* InspectorPanel::FindMutableField(
|
||||
}
|
||||
|
||||
void InspectorPanel::CapturePresentationStamps(
|
||||
const EditorPanelServices& services) {
|
||||
m_lastSceneSelectionStamp = services.sceneRuntime.GetSelectionStamp();
|
||||
m_lastProjectSelectionStamp = services.projectRuntime.GetSelectionStamp();
|
||||
m_lastSceneInspectorRevision = services.sceneRuntime.GetInspectorRevision();
|
||||
const InspectorPanelContext& context) {
|
||||
m_lastSceneSelectionStamp = context.sceneRuntime.GetSelectionStamp();
|
||||
m_lastProjectSelectionStamp = context.projectRuntime.GetSelectionStamp();
|
||||
m_lastSceneInspectorRevision = context.sceneRuntime.GetInspectorRevision();
|
||||
}
|
||||
|
||||
void InspectorPanel::RebuildPresentation(
|
||||
EditorPanelServices& services,
|
||||
InspectorPanelContext& context,
|
||||
bool subjectChanged) {
|
||||
m_presentation = BuildInspectorPresentationModel(
|
||||
m_subject,
|
||||
services.sceneRuntime,
|
||||
context.sceneRuntime,
|
||||
InspectorComponentEditorRegistry::Get());
|
||||
CapturePresentationStamps(services);
|
||||
CapturePresentationStamps(context);
|
||||
SyncExpansionState(subjectChanged);
|
||||
SyncSelectionState();
|
||||
}
|
||||
|
||||
void InspectorPanel::ForceResyncPresentation(EditorPanelServices& services) {
|
||||
void InspectorPanel::ForceResyncPresentation(InspectorPanelContext& context) {
|
||||
if (m_subject.kind != InspectorSubjectKind::SceneObject) {
|
||||
RebuildPresentation(services, false);
|
||||
RebuildPresentation(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string structureSignature = BuildInspectorStructureSignature(
|
||||
m_subject,
|
||||
services.sceneRuntime,
|
||||
context.sceneRuntime,
|
||||
InspectorComponentEditorRegistry::Get());
|
||||
if (structureSignature != m_presentation.structureSignature) {
|
||||
RebuildPresentation(services, false);
|
||||
RebuildPresentation(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -487,38 +486,38 @@ void InspectorPanel::ForceResyncPresentation(EditorPanelServices& services) {
|
||||
SyncInspectorPresentationModelValues(
|
||||
m_presentation,
|
||||
m_subject,
|
||||
services.sceneRuntime,
|
||||
context.sceneRuntime,
|
||||
InspectorComponentEditorRegistry::Get());
|
||||
if (!syncResult.success) {
|
||||
RebuildPresentation(services, false);
|
||||
RebuildPresentation(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_presentation.structureSignature = structureSignature;
|
||||
CapturePresentationStamps(services);
|
||||
CapturePresentationStamps(context);
|
||||
SyncSelectionState();
|
||||
}
|
||||
|
||||
void InspectorPanel::RefreshPresentation(
|
||||
EditorPanelServices& services,
|
||||
InspectorPanelContext& context,
|
||||
bool subjectChanged) {
|
||||
if (subjectChanged) {
|
||||
RebuildPresentation(services, true);
|
||||
RebuildPresentation(context, true);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m_subject.kind) {
|
||||
case InspectorSubjectKind::ProjectAsset:
|
||||
if (m_lastProjectSelectionStamp !=
|
||||
services.projectRuntime.GetSelectionStamp()) {
|
||||
RebuildPresentation(services, false);
|
||||
context.projectRuntime.GetSelectionStamp()) {
|
||||
RebuildPresentation(context, false);
|
||||
}
|
||||
return;
|
||||
|
||||
case InspectorSubjectKind::SceneObject: {
|
||||
const EditorSceneRuntime& sceneRuntime = services.sceneRuntime;
|
||||
const EditorSceneRuntime& sceneRuntime = context.sceneRuntime;
|
||||
if (m_lastSceneSelectionStamp != sceneRuntime.GetSelectionStamp()) {
|
||||
RebuildPresentation(services, false);
|
||||
RebuildPresentation(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -531,7 +530,7 @@ void InspectorPanel::RefreshPresentation(
|
||||
sceneRuntime,
|
||||
InspectorComponentEditorRegistry::Get());
|
||||
if (structureSignature != m_presentation.structureSignature) {
|
||||
RebuildPresentation(services, false);
|
||||
RebuildPresentation(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -542,12 +541,12 @@ void InspectorPanel::RefreshPresentation(
|
||||
sceneRuntime,
|
||||
InspectorComponentEditorRegistry::Get());
|
||||
if (!syncResult.success) {
|
||||
RebuildPresentation(services, false);
|
||||
RebuildPresentation(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_presentation.structureSignature = structureSignature;
|
||||
CapturePresentationStamps(services);
|
||||
CapturePresentationStamps(context);
|
||||
SyncSelectionState();
|
||||
return;
|
||||
}
|
||||
@@ -558,8 +557,8 @@ void InspectorPanel::RefreshPresentation(
|
||||
}
|
||||
}
|
||||
|
||||
bool InspectorPanel::ApplyColorPickerToolValue(EditorPanelServices& services) {
|
||||
EditorColorPickerToolState& toolState = services.colorPickerToolState;
|
||||
bool InspectorPanel::ApplyColorPickerToolValue(InspectorPanelContext& context) {
|
||||
EditorColorPickerToolState& toolState = context.colorPickerToolState;
|
||||
if (m_sceneRuntime == nullptr ||
|
||||
!toolState.active ||
|
||||
toolState.revision == m_lastAppliedColorPickerRevision ||
|
||||
@@ -585,16 +584,16 @@ bool InspectorPanel::ApplyColorPickerToolValue(EditorPanelServices& services) {
|
||||
const bool applied = ApplyChangedField(field->fieldId);
|
||||
m_lastAppliedColorPickerRevision = toolState.revision;
|
||||
if (!applied) {
|
||||
ForceResyncPresentation(services);
|
||||
ForceResyncPresentation(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
RefreshPresentation(services, false);
|
||||
RefreshPresentation(context, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void InspectorPanel::RequestColorPicker(
|
||||
EditorPanelServices& services,
|
||||
InspectorPanelContext& context,
|
||||
std::string_view fieldId) {
|
||||
const Widgets::UIEditorPropertyGridField* field = FindField(fieldId);
|
||||
if (field == nullptr ||
|
||||
@@ -604,12 +603,12 @@ void InspectorPanel::RequestColorPicker(
|
||||
}
|
||||
|
||||
OpenEditorColorPickerToolForInspectorField(
|
||||
services.colorPickerToolState,
|
||||
context.colorPickerToolState,
|
||||
m_subjectKey,
|
||||
field->fieldId,
|
||||
field->colorValue.value,
|
||||
field->colorValue.showAlpha);
|
||||
services.RequestOpenUtilityWindow(EditorUtilityWindowKind::ColorPicker);
|
||||
context.RequestOpenUtilityWindow(EditorUtilityWindowKind::ColorPicker);
|
||||
}
|
||||
|
||||
void InspectorPanel::ResetAddComponentButtonState() {
|
||||
@@ -618,7 +617,7 @@ void InspectorPanel::ResetAddComponentButtonState() {
|
||||
}
|
||||
|
||||
void InspectorPanel::UpdateAddComponentButton(
|
||||
EditorPanelServices& services,
|
||||
InspectorPanelContext& context,
|
||||
const std::vector<UIInputEvent>& inputEvents) {
|
||||
if (!ShouldShowAddComponentButton()) {
|
||||
ResetAddComponentButtonState();
|
||||
@@ -659,7 +658,7 @@ void InspectorPanel::UpdateAddComponentButton(
|
||||
|
||||
if (m_addComponentButtonPressed &&
|
||||
ContainsPoint(buttonRect, event.position)) {
|
||||
services.RequestOpenUtilityWindow(EditorUtilityWindowKind::AddComponent);
|
||||
context.RequestOpenUtilityWindow(EditorUtilityWindowKind::AddComponent);
|
||||
}
|
||||
|
||||
m_addComponentButtonHovered = ContainsPoint(buttonRect, event.position);
|
||||
@@ -711,7 +710,7 @@ bool InspectorPanel::ApplyChangedField(std::string_view fieldId) {
|
||||
}
|
||||
|
||||
void InspectorPanel::Update(
|
||||
EditorPanelServices& services,
|
||||
InspectorPanelContext& context,
|
||||
const UIEditorHostedPanelDispatchEntry& dispatchEntry,
|
||||
const std::vector<UIInputEvent>& inputEvents) {
|
||||
if (!dispatchEntry.mounted) {
|
||||
@@ -721,9 +720,9 @@ void InspectorPanel::Update(
|
||||
|
||||
m_visible = true;
|
||||
m_bounds = dispatchEntry.bounds;
|
||||
m_sceneRuntime = &services.sceneRuntime;
|
||||
m_textMeasurer = services.textMeasurer;
|
||||
m_subject = BuildInspectorSubject(services.session, services.sceneRuntime);
|
||||
m_sceneRuntime = &context.sceneRuntime;
|
||||
m_textMeasurer = context.textMeasurer;
|
||||
m_subject = BuildInspectorSubject(context.session, context.sceneRuntime);
|
||||
|
||||
const std::string nextSubjectKey = BuildSubjectKey();
|
||||
const bool subjectChanged = m_subjectKey != nextSubjectKey;
|
||||
@@ -732,8 +731,8 @@ void InspectorPanel::Update(
|
||||
ResetInteractionState();
|
||||
}
|
||||
|
||||
RefreshPresentation(services, subjectChanged);
|
||||
ApplyColorPickerToolValue(services);
|
||||
RefreshPresentation(context, subjectChanged);
|
||||
ApplyColorPickerToolValue(context);
|
||||
|
||||
const std::vector<UIInputEvent> filteredEvents =
|
||||
BuildUIEditorPanelInputEvents(
|
||||
@@ -802,21 +801,21 @@ void InspectorPanel::Update(
|
||||
m_gridFrame.result = interactionFrame.result;
|
||||
if (interactionFrame.result.pickerRequested &&
|
||||
!interactionFrame.result.requestedFieldId.empty()) {
|
||||
RequestColorPicker(services, interactionFrame.result.requestedFieldId);
|
||||
RequestColorPicker(context, interactionFrame.result.requestedFieldId);
|
||||
}
|
||||
|
||||
if (interactionFrame.result.fieldValueChanged &&
|
||||
!interactionFrame.result.changedFieldId.empty()) {
|
||||
if (ApplyChangedField(interactionFrame.result.changedFieldId)) {
|
||||
RefreshPresentation(services, false);
|
||||
RefreshPresentation(context, false);
|
||||
} else {
|
||||
ForceResyncPresentation(services);
|
||||
ForceResyncPresentation(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RebuildScrollableLayout();
|
||||
UpdateAddComponentButton(services, filteredEvents);
|
||||
UpdateAddComponentButton(context, filteredEvents);
|
||||
}
|
||||
|
||||
void InspectorPanel::Append(UIDrawList& drawList) const {
|
||||
|
||||
Reference in New Issue
Block a user