diff options
Diffstat (limited to 'source/EditorUtils.hpp')
-rw-r--r-- | source/EditorUtils.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/EditorUtils.hpp b/source/EditorUtils.hpp index 99c522b..4fd4811 100644 --- a/source/EditorUtils.hpp +++ b/source/EditorUtils.hpp @@ -1,7 +1,9 @@ #pragma once #include "Color.hpp" +#include "EditorCore.hpp" #include "EditorGuizmo.hpp" +#include "Ires.hpp" #include <imgui.h> #include <string> @@ -60,4 +62,21 @@ float CalcImageHeight(glm::vec2 original, int targetWidth); float CalcImageWidth(glm::vec2 original, float targetHeight); ImVec2 FitImage(glm::vec2 original); +// TODO get kind from T +template <class T> +T* SimpleIresReceptor(T* existing, IEditor& editor, IresObject::Kind kind) { + if (existing) { + existing->ShowReference(editor); + } else { + IresObject::ShowReferenceNull(editor); + } + if (ImGui::BeginDragDropTarget()) { + if (auto payload = ImGui::AcceptDragDropPayload(IresObject::ToString(kind).data())) { + return *static_cast<T* const*>(payload->Data); + } + ImGui::EndDragDropTarget(); + } + return nullptr; +} + } // namespace Utils |