aboutsummaryrefslogtreecommitdiff
path: root/source/EditorUtils.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-05-23 22:36:46 -0700
committerrtk0c <[email protected]>2022-05-23 22:36:46 -0700
commite3e848ac4da1c2ae59d93e62da8ef6f87b3452cd (patch)
treef70d86d4ae80f1fedc0afb1ba3b923e3651f0475 /source/EditorUtils.hpp
parent123f741e3f5374b93ac39887b62bfa0d66762ae2 (diff)
Changeset: 37 Branch comment: [] Add infrastructure for rendering wireframe (rendering broken) including saving and loading config files
Diffstat (limited to 'source/EditorUtils.hpp')
-rw-r--r--source/EditorUtils.hpp19
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