make popup ptr local on main menu
This commit is contained in:
@@ -379,7 +379,7 @@ void App::init_menu_file()
|
||||
{
|
||||
menu_file->on_click = [=](Node*) {
|
||||
glm::vec2 pos = menu_file->m_pos + glm::vec2(0, menu_file->m_size.y);
|
||||
popup = (NodePopupMenu*)layout[const_hash("file-menu")]->m_children[0]->clone();
|
||||
auto popup = (NodePopupMenu*)layout[const_hash("file-menu")]->m_children[0]->clone();
|
||||
popup->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - popup->m_size.x + menu_file->m_size.x;
|
||||
@@ -393,13 +393,13 @@ void App::init_menu_file()
|
||||
popup->m_capture_children = false;
|
||||
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-newdoc"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_newdoc();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-import"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
App::I.pick_image([this](std::string path){
|
||||
Image img;
|
||||
async_start();
|
||||
@@ -422,7 +422,7 @@ void App::init_menu_file()
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-open"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
//dialog_open();
|
||||
App::I.pick_file({"ppi","PPI"}, [this](std::string path){
|
||||
App::I.open_document(path);
|
||||
@@ -431,13 +431,13 @@ void App::init_menu_file()
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-browse"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_browse();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-save"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
if (Canvas::I->m_newdoc)
|
||||
{
|
||||
dialog_save();
|
||||
@@ -450,27 +450,27 @@ void App::init_menu_file()
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-save-as"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_save();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-save-ver"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
Canvas::I->m_newdoc ? dialog_save() : dialog_save_ver();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-export"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_export(".jpg");
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-export-tick"))
|
||||
b->on_click = [this,b](Node*) {
|
||||
b->on_click = [this, b, popup](Node*) {
|
||||
glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0);
|
||||
subpopup = (NodePopupMenu*)layout[const_hash("file-submenu-export")]->m_children[0]->clone();
|
||||
auto subpopup = (NodePopupMenu*)layout[const_hash("file-submenu-export")]->m_children[0]->clone();
|
||||
subpopup->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - subpopup->m_size.x + b->m_size.x;
|
||||
@@ -482,14 +482,14 @@ void App::init_menu_file()
|
||||
subpopup->m_mouse_ignore = false;
|
||||
subpopup->m_flood_events = true;
|
||||
subpopup->m_capture_children = false;
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-png")->on_click = [this](Node*) {
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-png")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export(".png");
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-layers")->on_click = [this](Node*) {
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-layers")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export_layers();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
@@ -498,31 +498,31 @@ void App::init_menu_file()
|
||||
};
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-share"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
share_file(doc_path);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-resize"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_resize();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-export-cubes"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_export_cubes();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-cloud-upload"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
cloud_upload();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-cloud-browse"))
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
cloud_browse();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
@@ -537,7 +537,7 @@ void App::init_menu_edit()
|
||||
{
|
||||
menu_file->on_click = [=](Node*) {
|
||||
glm::vec2 pos = menu_file->m_pos + glm::vec2(0, menu_file->m_size.y);
|
||||
popup = (NodePopupMenu*)layout[const_hash("edit-menu")]->m_children[0]->clone();
|
||||
auto popup = (NodePopupMenu*)layout[const_hash("edit-menu")]->m_children[0]->clone();
|
||||
popup->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - popup->m_size.x + menu_file->m_size.x;
|
||||
@@ -559,7 +559,7 @@ void App::init_menu_timelapse()
|
||||
{
|
||||
menu_file->on_click = [=](Node*) {
|
||||
glm::vec2 pos = menu_file->m_pos + glm::vec2(0, menu_file->m_size.y);
|
||||
popup = (NodePopupMenu*)layout[const_hash("timelapse-menu")]->m_children[0]->clone();
|
||||
auto popup = (NodePopupMenu*)layout[const_hash("timelapse-menu")]->m_children[0]->clone();
|
||||
popup->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - popup->m_size.x + menu_file->m_size.x;
|
||||
@@ -580,19 +580,19 @@ void App::init_menu_timelapse()
|
||||
}
|
||||
}
|
||||
|
||||
popup->find<NodeButtonCustom>("timelapse-start")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("timelapse-start")->on_click = [this, popup](Node*) {
|
||||
App::I.rec_running ? App::I.rec_stop() : App::I.rec_start();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("timelapse-clear")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("timelapse-clear")->on_click = [this, popup](Node*) {
|
||||
App::I.rec_clear();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("timelapse-export")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("timelapse-export")->on_click = [this, popup](Node*) {
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
App::I.rec_export("");
|
||||
@@ -607,7 +607,7 @@ void App::init_menu_about()
|
||||
{
|
||||
menu_file->on_click = [=](Node*) {
|
||||
glm::vec2 pos = menu_file->m_pos + glm::vec2(0, menu_file->m_size.y);
|
||||
popup = (NodePopupMenu*)layout[const_hash("about-menu")]->m_children[0]->clone();
|
||||
auto popup = (NodePopupMenu*)layout[const_hash("about-menu")]->m_children[0]->clone();
|
||||
popup->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - popup->m_size.x + menu_file->m_size.x;
|
||||
@@ -620,13 +620,13 @@ void App::init_menu_about()
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
|
||||
popup->find<NodeButtonCustom>("about-app")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("about-app")->on_click = [this, popup](Node*) {
|
||||
dialog_about();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("about-doc")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("about-doc")->on_click = [this, popup](Node*) {
|
||||
// auto path = Asset::absolute("data/doc/test.pdf");
|
||||
// display_file(path);
|
||||
dialog_usermanual();
|
||||
@@ -642,7 +642,7 @@ void App::init_menu_about()
|
||||
sprintf(label, "What's new in %d.%d.%d?", g_version_major, g_version_minor, g_version_fix);
|
||||
text->set_text(label);
|
||||
}
|
||||
item->on_click = [this](Node*) {
|
||||
item->on_click = [this, popup](Node*) {
|
||||
dialog_changelog();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
@@ -651,15 +651,17 @@ void App::init_menu_about()
|
||||
|
||||
if (auto b = popup->find<NodeButtonCustom>("about-crash"))
|
||||
{
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
LOG("crashing");
|
||||
App::I.crash_test();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
}
|
||||
|
||||
if (auto b = popup->find<NodeButtonCustom>("about-perf"))
|
||||
{
|
||||
b->on_click = [this](Node*) {
|
||||
b->on_click = [this, popup](Node*) {
|
||||
LOG("perf");
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
Canvas::I->stroke_start({ 0, 0, 0 }, 0.9f, Canvas::I->m_current_brush);
|
||||
@@ -684,6 +686,8 @@ void App::init_menu_about()
|
||||
static char str[256];
|
||||
sprintf(str, "Time %lld ms", ms);
|
||||
App::I.message_box("Performance test", str);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -702,7 +706,7 @@ void App::init_menu_layer()
|
||||
{
|
||||
menu_file->on_click = [=](Node*) {
|
||||
glm::vec2 pos = menu_file->m_pos + glm::vec2(0, menu_file->m_size.y);
|
||||
popup = (NodePopupMenu*)layout[const_hash("layers-menu")]->m_children[0]->clone();
|
||||
auto popup = (NodePopupMenu*)layout[const_hash("layers-menu")]->m_children[0]->clone();
|
||||
popup->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - popup->m_size.x + menu_file->m_size.x;
|
||||
@@ -714,20 +718,20 @@ void App::init_menu_layer()
|
||||
popup->m_mouse_ignore = false;
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
popup->find<NodeButtonCustom>("clear-grids")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup](Node*) {
|
||||
CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];
|
||||
mode->clear();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("camera-reset")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("camera-reset")->on_click = [this, popup](Node*) {
|
||||
canvas->reset_camera();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("layer-clear")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("layer-clear")->on_click = [this, popup](Node*) {
|
||||
canvas->m_canvas->clear();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
@@ -737,8 +741,10 @@ void App::init_menu_layer()
|
||||
find<NodeText>("menu-label")->
|
||||
set_text(("Clear Layer " + layers->m_current_layer->m_label_text).c_str());
|
||||
|
||||
popup->find<NodeButtonCustom>("layer-rename")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("layer-rename")->on_click = [this, popup](Node*) {
|
||||
dialog_layer_rename();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
if (layers->m_current_layer)
|
||||
popup->find<NodeButtonCustom>("layer-rename")->
|
||||
@@ -749,7 +755,7 @@ void App::init_menu_layer()
|
||||
find<NodeText>("menu-label")->
|
||||
set_text("Rename Layer (Select a layer)");
|
||||
|
||||
popup->find<NodeButtonCustom>("layer-merge")->on_click = [this](Node*) {
|
||||
popup->find<NodeButtonCustom>("layer-merge")->on_click = [this, popup](Node*) {
|
||||
const auto& order = canvas->m_canvas->m_order;
|
||||
//layers->get_child_index(layers->)
|
||||
int current_idx_order = std::distance(order.begin(), std::find(order.begin(), order.end(), canvas->m_canvas->m_current_layer_idx));
|
||||
|
||||
Reference in New Issue
Block a user