fix manager assignment
This commit is contained in:
@@ -79,7 +79,7 @@ void App::cloud_browse()
|
||||
|
||||
// load thumbnail test
|
||||
auto dialog = std::make_shared<NodeDialogCloud>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, int total /*= 0*/)
|
||||
{
|
||||
auto pb = std::make_shared<NodeProgressBar>();
|
||||
pb->m_manager = &layout;
|
||||
pb->set_manager(&layout);
|
||||
pb->init();
|
||||
pb->create();
|
||||
pb->loaded();
|
||||
@@ -32,7 +32,7 @@ std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, in
|
||||
std::shared_ptr<NodeMessageBox> App::message_box(const std::string &title, const std::string& text, bool cancel_button)
|
||||
{
|
||||
auto m = std::make_shared<NodeMessageBox>();
|
||||
m->m_manager = &layout;
|
||||
m->set_manager(&layout);
|
||||
m->init();
|
||||
m->create();
|
||||
m->loaded();
|
||||
@@ -49,7 +49,7 @@ std::shared_ptr<NodeInputBox> App::input_box(const std::string& title,
|
||||
const std::string& field_name, const std::string& ok_caption /*= "Ok"*/)
|
||||
{
|
||||
auto m = std::make_shared<NodeInputBox>();
|
||||
m->m_manager = &layout;
|
||||
m->set_manager(&layout);
|
||||
m->init();
|
||||
m->create();
|
||||
m->loaded();
|
||||
@@ -63,7 +63,7 @@ std::shared_ptr<NodeInputBox> App::input_box(const std::string& title,
|
||||
void App::dialog_usermanual()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeUserManual>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -74,7 +74,7 @@ void App::dialog_usermanual()
|
||||
void App::dialog_changelog()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeChangelog>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -85,7 +85,7 @@ void App::dialog_changelog()
|
||||
void App::dialog_about()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeAbout>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -97,7 +97,7 @@ void App::dialog_newdoc()
|
||||
{
|
||||
auto show_dialog = [this] {
|
||||
auto dialog = std::make_shared<NodeDialogNewDoc>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -146,7 +146,7 @@ void App::dialog_newdoc()
|
||||
{
|
||||
// ask confirm is file already exist
|
||||
auto msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = &layout;
|
||||
msgbox->set_manager(&layout);
|
||||
msgbox->init();
|
||||
msgbox->m_title->set_text("Warning");
|
||||
msgbox->m_message->set_text("A document with this name already exists, continue?");
|
||||
@@ -205,7 +205,7 @@ void App::dialog_open()
|
||||
auto show_dialog = [this] {
|
||||
// load thumbnail test
|
||||
auto dialog = std::make_shared<NodeDialogOpen>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -265,7 +265,7 @@ void App::dialog_browse()
|
||||
auto show_dialog = [this] {
|
||||
// load thumbnail test
|
||||
auto dialog = std::make_shared<NodeDialogBrowse>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
#ifdef __IOS__
|
||||
dialog->search_paths = {work_path, data_path + "/Inbox"};
|
||||
#else
|
||||
@@ -365,7 +365,7 @@ void App::dialog_save()
|
||||
if (canvas)
|
||||
{
|
||||
auto dialog = std::make_shared<NodeDialogSave>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -398,7 +398,7 @@ void App::dialog_save()
|
||||
{
|
||||
// ask confirm is file already exist
|
||||
auto msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = &layout;
|
||||
msgbox->set_manager(&layout);
|
||||
msgbox->init();
|
||||
msgbox->m_title->set_text("Warning");
|
||||
msgbox->m_message->set_text(("Are you sure you want to overwrite " + name + "?").c_str());
|
||||
@@ -505,7 +505,7 @@ void App::dialog_export_depth()
|
||||
void App::dialog_resize()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeDialogResize>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
@@ -542,7 +542,7 @@ void App::dialog_export_cube_faces()
|
||||
void App::dialog_layer_rename()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeDialogLayerRename>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->set_manager(&layout);
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
|
||||
@@ -73,7 +73,7 @@ void App::init_toolbar_main()
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = &layout;
|
||||
msgbox->set_manager(&layout);
|
||||
msgbox->init();
|
||||
layout[main_id]->add_child(msgbox);
|
||||
};
|
||||
@@ -82,7 +82,7 @@ void App::init_toolbar_main()
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
settings = new NodeSettings();
|
||||
settings->m_manager = &layout;
|
||||
settings->set_manager(&layout);
|
||||
settings->init();
|
||||
layout[main_id]->add_child(settings);
|
||||
};
|
||||
@@ -93,7 +93,7 @@ template <class T> std::shared_ptr<T> create_panel(LayoutManager& manager)
|
||||
{
|
||||
std::shared_ptr<T> ret;
|
||||
ret = std::make_shared<T>();
|
||||
ret->m_manager = &manager;
|
||||
ret->set_manager(&manager);
|
||||
ret->init();
|
||||
ret->create();
|
||||
ret->loaded();
|
||||
@@ -1405,13 +1405,12 @@ void App::initLayout()
|
||||
layout.load("data/layout.xml");
|
||||
LOG("initializing layout completed");
|
||||
|
||||
//LOG("initializing layout designer xml");
|
||||
//layout_designer.on_loaded = [&](bool reloaded) {
|
||||
// if (!reloaded)
|
||||
// layout_designer.create();
|
||||
// layout_designer[main_id]->add_child(layout_designer.instantiate("changelog"));
|
||||
//};
|
||||
//layout_designer.load("data/dialogs/changelog.xml");
|
||||
LOG("initializing layout designer xml");
|
||||
layout_designer.on_loaded = [&](bool reloaded) {
|
||||
layout_designer.create();
|
||||
layout_designer[main_id]->add_child(layout_designer.instantiate("usermanual"));
|
||||
};
|
||||
//layout_designer.load("data/dialogs/usermanual.xml");
|
||||
}
|
||||
|
||||
void App::set_ui_scale(float scale)
|
||||
|
||||
@@ -2222,7 +2222,7 @@ bool Canvas::project_open_thread(std::string file_path)
|
||||
if (App::I->layout.m_loaded)
|
||||
{
|
||||
pb = std::make_shared<NodeProgressBar>();
|
||||
pb->m_manager = &App::I->layout;
|
||||
pb->set_manager(&App::I->layout);
|
||||
pb->init();
|
||||
pb->create();
|
||||
pb->loaded();
|
||||
|
||||
@@ -90,7 +90,7 @@ bool LayoutManager::load(const char* path)
|
||||
node.reset(new Node());
|
||||
break;
|
||||
}
|
||||
node->m_manager = this;
|
||||
node->set_manager(this);
|
||||
// try to copy the old size values
|
||||
if (old.count(id))
|
||||
{
|
||||
|
||||
14
src/node.cpp
14
src/node.cpp
@@ -340,21 +340,22 @@ void Node::removed(Node* parent)
|
||||
|
||||
const Node* Node::init_template(const char* id)
|
||||
{
|
||||
Node* m_template = nullptr;
|
||||
Node* t = nullptr;
|
||||
App::I->ui_task([&]
|
||||
{
|
||||
auto hid = const_hash(id);
|
||||
Node* top = m_manager->get(hid);
|
||||
m_template = static_cast<Node*>(top->m_children[0].get());
|
||||
for (auto& c : m_template->m_children)
|
||||
t = static_cast<Node*>(top->m_children[0].get());
|
||||
t->set_manager(m_manager);
|
||||
for (auto& c : t->m_children)
|
||||
{
|
||||
auto node = c->clone();
|
||||
add_child(node);
|
||||
}
|
||||
YGNodeCopyStyle(y_node, m_template->y_node);
|
||||
m_template->clone_copy(this);
|
||||
YGNodeCopyStyle(y_node, t->y_node);
|
||||
t->clone_copy(this);
|
||||
});
|
||||
return m_template;
|
||||
return t;
|
||||
}
|
||||
|
||||
bool Node::init_template_file(const std::string& path, const std::string& id)
|
||||
@@ -366,6 +367,7 @@ bool Node::init_template_file(const std::string& path, const std::string& id)
|
||||
if (m.load(path.c_str()))
|
||||
{
|
||||
auto t = m.get_ref(id.c_str())->m_children[0];
|
||||
t->set_manager(m_manager);
|
||||
for (auto& c : t->m_children)
|
||||
add_child(c->clone());
|
||||
YGNodeCopyStyle(y_node, t->y_node);
|
||||
|
||||
@@ -103,8 +103,8 @@ class Node : public std::enable_shared_from_this<Node>
|
||||
public:
|
||||
Node* m_parent{ nullptr };
|
||||
YGNodeRef y_node{ nullptr };
|
||||
class LayoutManager* m_manager;
|
||||
uint16_t m_nodeID;
|
||||
class LayoutManager* m_manager = nullptr;
|
||||
uint16_t m_nodeID = 0;
|
||||
std::string m_nodeID_s;
|
||||
std::vector<std::shared_ptr<Node>> m_children;
|
||||
std::shared_ptr<Node> current_mouse_capture = nullptr;
|
||||
|
||||
@@ -38,7 +38,7 @@ void NodeDialogBrowse::init_controls()
|
||||
return;
|
||||
|
||||
auto msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = m_manager;
|
||||
msgbox->set_manager(m_manager);
|
||||
msgbox->init();
|
||||
msgbox->m_title->set_text("Delete Project");
|
||||
msgbox->m_message->set_text(("Are you sure you want to delete " + current->m_file_name + "?").c_str());
|
||||
@@ -134,7 +134,7 @@ void NodeDialogBrowse::init_list()
|
||||
continue;
|
||||
|
||||
auto node = new NodeDialogBrowseItem;
|
||||
node->m_manager = m_manager;
|
||||
node->set_manager(m_manager);
|
||||
node->init();
|
||||
node->m_text->set_text(f_name.substr(0, f_name.length() - strlen(".ppi")).c_str());
|
||||
node->m_path = f_path;
|
||||
|
||||
@@ -88,7 +88,7 @@ void NodeDialogCloud::load_thumbs_thread()
|
||||
for (const auto& n : names)
|
||||
{
|
||||
auto node = new NodeDialogCloudItem;
|
||||
node->m_manager = m_manager;
|
||||
node->set_manager(m_manager);
|
||||
node->init();
|
||||
node->m_text->set_text(n.c_str());
|
||||
node->m_path = App::I->work_path + "/" + n;
|
||||
|
||||
@@ -40,7 +40,7 @@ void NodeDialogOpen::init_controls()
|
||||
return;
|
||||
|
||||
auto msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = m_manager;
|
||||
msgbox->set_manager(m_manager);
|
||||
msgbox->init();
|
||||
msgbox->m_title->set_text("Delete Project");
|
||||
msgbox->m_message->set_text(("Are you sure you want to delete " + current->m_file_name + "?").c_str());
|
||||
@@ -73,7 +73,7 @@ void NodeDialogOpen::init_controls()
|
||||
for (const auto& n : names)
|
||||
{
|
||||
auto node = new NodeDialogOpenItem;
|
||||
node->m_manager = m_manager;
|
||||
node->set_manager(m_manager);
|
||||
node->init();
|
||||
node->m_text->set_text(n.c_str());
|
||||
node->m_path = App::I->work_path + "/" + n;
|
||||
|
||||
@@ -108,7 +108,7 @@ void NodePanelQuick::reset_state(bool fire_event /*= false*/)
|
||||
void NodePanelQuick::init_controls()
|
||||
{
|
||||
m_picker = std::make_shared<NodeColorPicker>();
|
||||
m_picker->m_manager = m_manager;
|
||||
m_picker->set_manager(m_manager);
|
||||
m_picker->init();
|
||||
m_picker->create();
|
||||
m_picker->loaded();
|
||||
|
||||
@@ -121,7 +121,7 @@ void NodePanelStroke::init_fold(const std::string& name)
|
||||
void NodePanelStroke::init_controls()
|
||||
{
|
||||
m_brush_popup = std::make_shared<NodePanelBrush>();
|
||||
m_brush_popup->m_manager = m_manager;
|
||||
m_brush_popup->set_manager(m_manager);
|
||||
m_brush_popup->m_dir_name = "brushes";
|
||||
m_brush_popup->init();
|
||||
m_brush_popup->create();
|
||||
@@ -133,7 +133,7 @@ void NodePanelStroke::init_controls()
|
||||
m_brush_popup->m_capture_children = false;
|
||||
|
||||
m_pattern_popup = std::make_shared<NodePanelBrush>();
|
||||
m_pattern_popup->m_manager = m_manager;
|
||||
m_pattern_popup->set_manager(m_manager);
|
||||
m_pattern_popup->m_dir_name = "patterns";
|
||||
m_pattern_popup->init();
|
||||
m_pattern_popup->create();
|
||||
|
||||
Reference in New Issue
Block a user