Last active
May 17, 2021 04:21
-
-
Save nariakiiwatani/dabf4cd2d04ad015bb6fabdedef7b2aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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