Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moebiussurfing/da88f1124a6a59e8d81dc75701086c8e to your computer and use it in GitHub Desktop.
Save moebiussurfing/da88f1124a6a59e8d81dc75701086c8e to your computer and use it in GitHub Desktop.
namespace ImGui
{
static bool SelectFile(const std::string &path, std::string &selected, const std::vector<std::string> &ext={}) {
bool ret = false;
if(ofFile(path).isDirectory()) {
if(TreeNode(ofFilePath::getBaseName(path).c_str())) {
ofDirectory dir;
if(!ext.empty()) {
dir.allowExt("");
for(auto &&e : ext) {
dir.allowExt(e);
}
}
dir.listDir(path);
for(auto &f : dir) {
ret |= SelectFile(f.path(), selected, ext);
}
TreePop();
}
}
else if(Button(ofFilePath::getFileName(path).c_str())) {
selected = path;
ret = true;
}
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment