[studio] Complete drag/drop support for files
This commit is contained in:
parent
500b93562c
commit
1cbc576286
@ -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 {};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 {};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
22
src/olympic/studio/modlib/include/studio/dragdrop.hpp
Normal file
22
src/olympic/studio/modlib/include/studio/dragdrop.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
namespace studio {
|
||||
|
||||
struct FileRef {
|
||||
static constexpr auto TypeName = "net.drinkingtea.studio.FileRef";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
ox::String path;
|
||||
};
|
||||
|
||||
OX_MODEL_BEGIN(FileRef)
|
||||
OX_MODEL_FIELD(path)
|
||||
OX_MODEL_END()
|
||||
|
||||
}
|
@ -63,6 +63,7 @@ auto dragDropSource(auto const&cb) noexcept {
|
||||
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
}
|
||||
return ox::Error{};
|
||||
} else {
|
||||
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||
cb();
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <studio/configio.hpp>
|
||||
#include <studio/context.hpp>
|
||||
#include <studio/dragdrop.hpp>
|
||||
#include <studio/editor.hpp>
|
||||
#include <studio/filedialog.hpp>
|
||||
#include <studio/imguiutil.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user