* 'master' of https://bitbucket.org/omigamedev/new_engine:
  add text input popup
This commit is contained in:
2019-09-12 15:18:22 +02:00
12 changed files with 186 additions and 12 deletions

View File

@@ -192,14 +192,32 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
#endif
}
#if __IOS__
void App::pick_file_save(const std::string& type, std::function<void(std::string)> writer)
{
redraw = true;
std::thread([=]{
auto mb = input_box("Insert", "File name");
std::string placeholder = "name." + type;
mb->m_field_text->set_text(placeholder.c_str());
mb->on_submit = [this, writer, type] (Node* target, std::string name) {
std::string ext = "." + type;
std::string path = data_path + "/" + name;
if (name.find(ext) == std::string::npos)
path += ext;
writer(path);
dispatch_async(dispatch_get_main_queue(), ^{
[ios_view pick_file_save:path];
});
target->destroy();
};
}).detach();
}
#else
void App::pick_file_save(std::vector<std::string> types, std::function<void (std::string)> callback)
{
redraw = true;
#ifdef __IOS__
// dispatch_async(dispatch_get_main_queue(), ^{
// [ios_view pick_file_save:callback];
// });
#elif __OSX__
#if __OSX__
dispatch_async(dispatch_get_main_queue(), ^{
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];
NSMutableArray<NSString*>* fileTypes = [NSMutableArray arrayWithCapacity:types.size()];
@@ -233,6 +251,7 @@ void App::pick_file_save(std::vector<std::string> types, std::function<void (std
callback(path);
#endif
}
#endif
void App::pick_dir(std::function<void(std::string path)> callback)
{