Line data Source code
1 : #include "filesystem_panel.hpp"
2 :
3 : namespace editor {
4 :
5 0 : void render_filesystem_panel(const editor::Context& ctx) {
6 0 : ImGui::Begin("Filesystem");
7 :
8 0 : ImGui::Text("Project root: %s", ctx.project_path.c_str());
9 :
10 0 : for (const auto& file :
11 0 : std::filesystem::directory_iterator(ctx.project_path)) {
12 0 : const auto f = std::filesystem::relative(file, ctx.project_path);
13 :
14 0 : int flags = ImGuiTreeNodeFlags_SpanAvailWidth;
15 0 : if (!file.is_directory()) flags |= ImGuiTreeNodeFlags_Leaf;
16 :
17 0 : if (ImGui::TreeNodeEx(f.c_str(), flags)) {
18 : // Get children
19 :
20 0 : ImGui::TreePop();
21 0 : }
22 :
23 0 : auto filename = f.string();
24 :
25 0 : if (ImGui::BeginDragDropSource()) {
26 0 : ImGui::SetTooltip("%s", filename.c_str());
27 0 : ImGui::SetDragDropPayload("FILESYSTEM_BROWSER", filename.c_str(),
28 0 : filename.size() + 1, ImGuiCond_Once);
29 0 : ImGui::EndDragDropSource();
30 0 : }
31 0 : }
32 :
33 0 : ImGui::End();
34 0 : }
35 :
36 : } // namespace editor
|