add javascript binding and file picker for web

This commit is contained in:
2019-10-08 23:16:04 +02:00
parent f2a73a905d
commit a669d1313b
7 changed files with 228 additions and 135 deletions

View File

@@ -80,7 +80,7 @@ void NodePanelBrush::init()
m_btn_add->on_click = [this](Node*) {
App::I->pick_file({ "JPG", "PNG" }, [this](std::string path) {
std::string name, base, ext;
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::regex r(R"((.*)[\\/]?([^\\/]+)\.(\w+)$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return;
@@ -546,7 +546,7 @@ void NodePanelBrushPreset::init()
});
};
m_btn_download = find<NodeButton>("download");
m_btn_download->on_click = [] (Node*) {
m_btn_download->on_click = [this] (Node*) {
App::I->dialog_preset_download();
};
m_notification = find("notification");
@@ -701,7 +701,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path_in, const PPBRInf
path += ".ppbr";
LOG("export ppbr to: %s", path.c_str());
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)?$)");
std::regex r(R"((.*)[\\/]?([^\\/]+)\.(\w+)?$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return false;
@@ -965,7 +965,7 @@ bool NodePanelBrushPreset::import_abr(const std::string& path)
LOG("ABR detected");
std::string name, base, ext;
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::regex r(R"((.*)[\\/]?([^\\/]+)\.(\w+)$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return false;
@@ -1035,7 +1035,7 @@ bool NodePanelBrushPreset::import_abr(const std::string& path)
bool NodePanelBrushPreset::import_brush(const std::string& path)
{
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::regex r(R"((.*)[\\/]?([^\\/]+)\.(\w+)$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return false;