This commit is contained in:
2018-10-08 12:45:06 +02:00
7 changed files with 89 additions and 22 deletions

View File

@@ -5,7 +5,8 @@
void displayKeyboard(android_app* mApplication, bool pShow);
void pick_file(android_app* mApplication, std::function<void(std::string)> callback);
#elif _WIN32
std::string win32_open_file();
std::string win32_open_file(const char* filter);
std::string win32_open_dir();
#endif
@@ -64,7 +65,7 @@ void App::pick_image(std::function<void(std::string path)> callback)
#elif __ANDROID__
pick_file(and_app, callback);
#elif _WIN32
std::string path = win32_open_file();
std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
if (!path.empty())
callback(path);
#endif
@@ -89,7 +90,21 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
#elif __ANDROID__
pick_file(and_app, callback);
#elif _WIN32
std::string path = win32_open_file();
std::string filter = "Image Files (";
bool first_type = true;
for (auto& t : types)
{
filter += std::string(first_type ? "" : " ,") + "*." + t;
first_type = false;
}
filter += ")\0";
first_type = true;
for (auto& t : types)
{
filter += std::string(first_type ? "" : ";") + "*." + t;
first_type = false;
}
std::string path = win32_open_file(filter.c_str());
if (!path.empty())
callback(path);
#endif
@@ -110,9 +125,9 @@ void App::pick_dir(std::function<void(std::string path)> callback)
// NOT IMPLEMENTED
#elif _WIN32
// TODO: to be implemented
// std::string path = win32_open_file();
// if (!path.empty())
// callback(path);
std::string path = win32_open_dir();
if (!path.empty())
callback(path);
#endif
}