Voltray Engine Docs
Loading...
Searching...
No Matches
AssetDragDrop.h
Go to the documentation of this file.
1#pragma once
2#include <imgui.h>
3#include <filesystem>
4#include <string>
5
11namespace Editor
12{
13 namespace Assets
14 {
20 {
21 std::filesystem::path assetPath;
22 std::string assetType;
23 std::string fileName;
25
26 DragDropPayload() = default;
27 DragDropPayload(const std::filesystem::path &path, const std::string &type, bool global)
28 : assetPath(path), assetType(type), fileName(path.filename().string()), isGlobalAsset(global) {}
29 };
30
36 {
37 public:
45 static bool BeginDrag(const std::filesystem::path &assetPath, const std::string &assetType, bool isGlobal);
46
51 static const DragDropPayload *AcceptDrop();
52
58 static bool CanAcceptDrop(const std::string &targetType);
59
64 static const DragDropPayload *GetDragPayload();
65
72 static bool HandleViewportDrop(const DragDropPayload &payload, const ImVec2 &dropPosition);
73
79 static bool HandleSceneDrop(const DragDropPayload &payload);
80
84 static void RenderDragPreview();
85
86 private:
87 static constexpr const char *DRAG_DROP_ID = "ASSET_DRAG_DROP";
88 static DragDropPayload s_currentPayload;
89 static bool s_isDragging;
90
97 static bool CreateSceneObjectFromAsset(const DragDropPayload &payload, const ImVec2 &position);
98
105 static bool LoadModelAsset(const std::filesystem::path &assetPath, const ImVec2 &position);
106
112 static bool ApplyTextureAsset(const std::filesystem::path &assetPath);
113
119 static bool AttachScriptAsset(const std::filesystem::path &assetPath);
120 };
121 }
122}
A panel component responsible for managing and displaying asset resources.
Manages drag and drop operations for assets.
Definition AssetDragDrop.h:36
static bool BeginDrag(const std::filesystem::path &assetPath, const std::string &assetType, bool isGlobal)
Begin a drag operation for an asset.
Definition AssetDragDrop.cpp:21
static void RenderDragPreview()
Render drag preview overlay.
Definition AssetDragDrop.cpp:138
static const DragDropPayload * GetDragPayload()
Get the current drag payload without consuming it.
Definition AssetDragDrop.cpp:89
static bool HandleSceneDrop(const DragDropPayload &payload)
Handle asset drop into scene hierarchy.
Definition AssetDragDrop.cpp:132
static const DragDropPayload * AcceptDrop()
Check if there's an asset being dragged and handle drop.
Definition AssetDragDrop.cpp:42
static bool HandleViewportDrop(const DragDropPayload &payload, const ImVec2 &dropPosition)
Handle asset drop into viewport.
Definition AssetDragDrop.cpp:94
static bool CanAcceptDrop(const std::string &targetType)
Check if we can accept a drop at the current location.
Definition AssetDragDrop.cpp:58
Definition AssetsPanel.cpp:7
Contains information about a dragged asset.
Definition AssetDragDrop.h:20
std::filesystem::path assetPath
Definition AssetDragDrop.h:21
std::string assetType
Definition AssetDragDrop.h:22
std::string fileName
Definition AssetDragDrop.h:23
bool isGlobalAsset
Definition AssetDragDrop.h:24
DragDropPayload(const std::filesystem::path &path, const std::string &type, bool global)
Definition AssetDragDrop.h:27