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