| 1059 | } |
| 1060 | |
| 1061 | void FileDialog::m_renderTree(FileTreeNode* node) |
| 1062 | { |
| 1063 | // directory |
| 1064 | std::error_code ec; |
| 1065 | ImGui::PushID(node); |
| 1066 | bool isClicked = false; |
| 1067 | std::string displayName = node->Path.stem().u8string(); |
| 1068 | if (displayName.size() == 0) |
| 1069 | displayName = node->Path.u8string(); |
| 1070 | if (FolderNode(displayName.c_str(), (ImTextureID)m_getIcon(node->Path), isClicked)) { |
| 1071 | if (!node->Read) { |
| 1072 | // cache children if it's not already cached |
| 1073 | if (std::filesystem::exists(node->Path, ec)) |
| 1074 | for (const auto& entry : std::filesystem::directory_iterator(node->Path, ec)) { |
| 1075 | if (std::filesystem::is_directory(entry, ec)) |
| 1076 | node->Children.push_back(new FileTreeNode(entry.path().u8string())); |
| 1077 | } |
| 1078 | node->Read = true; |
| 1079 | } |
| 1080 | |
| 1081 | // display children |
| 1082 | for (auto c : node->Children) |
| 1083 | m_renderTree(c); |
| 1084 | |
| 1085 | ImGui::TreePop(); |
| 1086 | } |
| 1087 | if (isClicked) |
| 1088 | m_setDirectory(node->Path); |
| 1089 | ImGui::PopID(); |
| 1090 | } |
| 1091 | void FileDialog::m_renderContent() |
| 1092 | { |
| 1093 | if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) |
nothing calls this directly
no test coverage detected