allow Node/Ref to accept drag&drop

This commit is contained in:
2022-06-16 10:29:35 +09:00
parent 9ff6339fe4
commit 6eaab065aa
8 changed files with 177 additions and 46 deletions

View File

@@ -7,6 +7,8 @@
#include "nf7.hh"
#include "common/gui_dnd.hh"
namespace nf7::gui {
@@ -128,4 +130,18 @@ struct FileCreatePopup final {
std::string type_filter_;
};
} // namespace nf7
inline bool InputFilePath(const char* id, std::string* path) noexcept {
bool ret = ImGui::InputText(id, path, ImGuiInputTextFlags_EnterReturnsTrue);
if (ImGui::BeginDragDropTarget()) {
if (auto str = gui::dnd::Accept<std::string>(gui::dnd::kFilePath)) {
*path = *str;
ret = true;
}
ImGui::EndDragDropTarget();
}
return ret;
}
} // namespace nf7::gui