Refine editor action shell and add regression tests
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
#include "EditorActions.h"
|
||||
#include "Commands/ComponentCommands.h"
|
||||
#include "ComponentEditors/ComponentEditorRegistry.h"
|
||||
#include "Core/EditorEvents.h"
|
||||
#include "Core/IEditorContext.h"
|
||||
#include "UI/PopupState.h"
|
||||
#include "UI/UI.h"
|
||||
|
||||
#include <string>
|
||||
@@ -28,6 +30,28 @@ inline std::string BuildAddComponentMenuLabel(const IComponentEditor& editor, ::
|
||||
return label;
|
||||
}
|
||||
|
||||
inline void HandleInspectorSelectionChanged(
|
||||
IEditorContext& context,
|
||||
const SelectionChangedEvent& event,
|
||||
uint64_t& selectedEntityId,
|
||||
UI::DeferredPopupState& addComponentPopup) {
|
||||
if (context.GetUndoManager().HasPendingInteractiveChange()) {
|
||||
context.GetUndoManager().FinalizeInteractiveChange();
|
||||
}
|
||||
|
||||
selectedEntityId = event.primarySelection;
|
||||
addComponentPopup.Clear();
|
||||
}
|
||||
|
||||
inline bool DrawInspectorAddComponentButton(UI::DeferredPopupState& addComponentPopup, bool enabled = true) {
|
||||
if (!DrawInspectorAction(MakeAddComponentButtonAction(enabled))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
addComponentPopup.RequestOpen();
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool DrawInspectorAddComponentMenu(IEditorContext& context, ::XCEngine::Components::GameObject* gameObject) {
|
||||
bool drewAnyEntry = false;
|
||||
|
||||
@@ -49,6 +73,23 @@ inline bool DrawInspectorAddComponentMenu(IEditorContext& context, ::XCEngine::C
|
||||
return drewAnyEntry;
|
||||
}
|
||||
|
||||
inline void DrawInspectorAddComponentPopup(
|
||||
IEditorContext& context,
|
||||
UI::DeferredPopupState& addComponentPopup,
|
||||
::XCEngine::Components::GameObject* gameObject) {
|
||||
addComponentPopup.ConsumeOpenRequest("AddComponent");
|
||||
|
||||
if (!UI::BeginTitledPopup("AddComponent", "Components")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DrawInspectorAddComponentMenu(context, gameObject)) {
|
||||
UI::DrawHintText("No registered component editors");
|
||||
}
|
||||
|
||||
UI::EndTitledPopup();
|
||||
}
|
||||
|
||||
inline bool DrawInspectorComponentMenu(
|
||||
IEditorContext& context,
|
||||
::XCEngine::Components::Component* component,
|
||||
@@ -60,6 +101,12 @@ inline bool DrawInspectorComponentMenu(
|
||||
});
|
||||
}
|
||||
|
||||
inline void FinalizeInspectorInteractiveChangeIfIdle(IEditorContext& context) {
|
||||
if (context.GetUndoManager().HasPendingInteractiveChange() && !ImGui::IsAnyItemActive()) {
|
||||
context.GetUndoManager().FinalizeInteractiveChange();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Actions
|
||||
} // namespace Editor
|
||||
} // namespace XCEngine
|
||||
|
||||
Reference in New Issue
Block a user