implement file picker in iOS with .ext to UTI filtering

This commit is contained in:
2019-09-09 15:31:47 +02:00
parent 4b3b1749d6
commit 096930b02e
5 changed files with 83 additions and 46 deletions

View File

@@ -525,36 +525,19 @@ void App::init_menu_file()
};
if (auto b = popup->find<NodeButtonCustom>("file-import"))
b->on_click = [this, popup](Node*) {
pick_file({ "JPG", "PNG", "ABR" }, [this](std::string path){
std::string name, base, ext;
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return;
base = m[1].str();
name = m[2].str();
ext = m[3].str();
if (str_iequals(ext, "abr"))
pick_image([this](std::string path){
Image img;
img.load_file(path);
if (img.width == img.height / 6 || img.width == img.height * 2)
{
std::thread([this,path] { presets->import_abr(path); }).detach();
Canvas::I->import_equirectangular(path);
}
else
{
Image img;
img.load_file(path);
if (img.width == img.height / 6 || img.width == img.height * 2)
{
Canvas::I->import_equirectangular(path);
}
else
{
auto m = static_cast<CanvasModeTransform*>(canvas->m_canvas->modes[(int)kCanvasMode::Import][0]);
m->m_action = CanvasModeTransform::ActionType::Import;
m->m_source_image = std::move(img);
Canvas::set_mode(kCanvasMode::Import);
}
async_redraw();
auto m = static_cast<CanvasModeTransform*>(canvas->m_canvas->modes[(int)kCanvasMode::Import][0]);
m->m_action = CanvasModeTransform::ActionType::Import;
m->m_source_image = std::move(img);
Canvas::set_mode(kCanvasMode::Import);
}
});
popup->mouse_release();