[jasper/world/studio/worldeditor] Add file drag/drop support
This commit is contained in:
parent
7dfbfc834b
commit
92a549ad38
@ -8,9 +8,9 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
ObjectExplorerModel::ObjectExplorerModel(ox::StringView name, ObjectExplorerModel *parent) noexcept:
|
||||
ObjectExplorerModel::ObjectExplorerModel(ox::StringParam name, ObjectExplorerModel *parent) noexcept:
|
||||
m_parent(parent),
|
||||
m_name(name),
|
||||
m_name(std::move(name)),
|
||||
m_fullPath(m_parent ? (m_parent->m_fullPath + "/" + m_name) : ox::String{}) {
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ class ObjectExplorerModel {
|
||||
ox::String m_fullPath;
|
||||
ox::Vector<ox::UPtr<ObjectExplorerModel>> m_children;
|
||||
public:
|
||||
explicit ObjectExplorerModel(ox::StringView name, ObjectExplorerModel *parent = {}) noexcept;
|
||||
explicit ObjectExplorerModel(ox::StringParam name, ObjectExplorerModel *parent = {}) noexcept;
|
||||
void draw(turbine::Context &ctx) const noexcept;
|
||||
private:
|
||||
};
|
||||
|
@ -201,6 +201,12 @@ void WorldEditorImGui::drawObjSetSelector() noexcept {
|
||||
}
|
||||
return setName;
|
||||
}, m_doc.objSets.size(), m_palMgr.selectedIdx);
|
||||
if (ig::DragDropTarget const d; d) {
|
||||
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
|
||||
if (!err && endsWith(fr.path, FileExt_jwob)) {
|
||||
std::ignore = addObjSet(fr.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldEditorImGui::drawObjSelector() noexcept {
|
||||
@ -386,7 +392,7 @@ ox::Error WorldEditorImGui::handleDrop(float const fbPaneScale) noexcept {
|
||||
ox::Error WorldEditorImGui::addObjSet(ox::StringViewCR path) noexcept {
|
||||
OX_REQUIRE(uuid, getUuid(keelCtx(m_sctx), path));
|
||||
std::ignore = pushCommand<AddObjectSet>(m_doc, uuid);
|
||||
return {};
|
||||
return loadObjectSets();
|
||||
}
|
||||
|
||||
void WorldEditorImGui::rmObjSet() noexcept {
|
||||
|
Loading…
x
Reference in New Issue
Block a user