[studio] Complete drag/drop support for files

This commit is contained in:
2025-01-19 11:41:08 -06:00
parent 500b93562c
commit 1cbc576286
5 changed files with 34 additions and 9 deletions

View File

@ -4,6 +4,7 @@
#include <imgui.h>
#include <studio/dragdrop.hpp>
#include <studio/imguiutil.hpp>
#include "projectexplorer.hpp"
@ -54,8 +55,9 @@ void ProjectTreeModel::draw(turbine::Context &tctx) const noexcept {
ImGui::EndPopup();
}
ImGui::TreePop();
ig::dragDropSource([this] {
std::ignore = ig::dragDropSource([this] {
ImGui::Text("%s", m_name.c_str());
return ig::setDragDropPayload("FileRef", FileRef{fullPath<ox::String>()});
});
}
}
@ -80,11 +82,4 @@ void ProjectTreeModel::drawDirContextMenu() const noexcept {
}
}
ox::BasicString<255> ProjectTreeModel::fullPath() const noexcept {
if (m_parent) {
return m_parent->fullPath() + "/" + m_name;
}
return {};
}
}

View File

@ -32,8 +32,14 @@ class ProjectTreeModel {
private:
void drawDirContextMenu() const noexcept;
template<typename Str = ox::BasicString<255>>
[[nodiscard]]
ox::BasicString<255> fullPath() const noexcept;
Str fullPath() const noexcept {
if (m_parent) {
return m_parent->fullPath<Str>() + "/" + m_name;
}
return {};
}
};