[studio] Add ability to drag files between directories
All checks were successful
Build / build (push) Successful in 3m29s

This commit is contained in:
2025-01-26 02:03:54 -06:00
parent a24bf7ffb9
commit 109e1898cc
6 changed files with 39 additions and 1 deletions

View File

@@ -45,6 +45,8 @@ class FileExplorer: public ox::SignalHandler {
virtual void fileDeleted(ox::StringViewCR path) const noexcept;
virtual void fileMoved(ox::StringViewCR src, ox::StringViewCR dst) const noexcept;
void drawFileContextMenu(ox::CStringViewCR path) const noexcept;
void drawDirContextMenu(ox::CStringViewCR path) const noexcept;

View File

@@ -41,6 +41,8 @@ void FileExplorer::fileOpened(ox::StringViewCR) const noexcept {}
void FileExplorer::fileDeleted(ox::StringViewCR) const noexcept {}
void FileExplorer::fileMoved(ox::StringViewCR, ox::StringViewCR) const noexcept {}
void FileExplorer::drawFileContextMenu(ox::CStringViewCR path) const noexcept {
ig::IDStackItem const idStackItem{path};
fileContextMenu(path);
@@ -91,6 +93,13 @@ void FileTreeModel::draw(turbine::Context &tctx) const noexcept {
}
ig::IDStackItem const idStackItem{m_name};
m_explorer.drawDirContextMenu(m_fullPath);
if (ig::DragDropTarget const dragDropTarget; dragDropTarget) {
auto const [ref, err] = ig::getDragDropPayload<FileRef>("FileRef");
if (!err) {
auto const name = substr(ref.path, find(ref.path.rbegin(), ref.path.rend(), '/').offset() + 1);
m_explorer.fileMoved(ref.path, sfmt("{}/{}", m_fullPath, name));
}
}
if (nodeOpen) {
for (auto const&child : m_children) {
child->draw(tctx);