move abr import to main menu, add progress bar
This commit is contained in:
@@ -404,23 +404,39 @@ void App::init_menu_file()
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-import"))
|
||||
b->on_click = [this, popup](Node*) {
|
||||
App::I.pick_image([this](std::string path){
|
||||
Image img;
|
||||
async_start();
|
||||
img.load_file(path);
|
||||
if (img.width == img.height / 6 || img.width == img.height * 2)
|
||||
App::I.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"))
|
||||
{
|
||||
Canvas::I->import_equirectangular(path);
|
||||
std::thread([this,path] { stroke->import_abr(path); }).detach();
|
||||
}
|
||||
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);
|
||||
Image img;
|
||||
async_start();
|
||||
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();
|
||||
async_end();
|
||||
}
|
||||
async_redraw();
|
||||
async_end();
|
||||
});
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
|
||||
Reference in New Issue
Block a user