diff --git a/PanoPainter.vcxproj b/PanoPainter.vcxproj
index d16925e..ace9142 100644
--- a/PanoPainter.vcxproj
+++ b/PanoPainter.vcxproj
@@ -527,6 +527,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Designer
diff --git a/PanoPainter.vcxproj.filters b/PanoPainter.vcxproj.filters
index bab1563..95a1f20 100644
--- a/PanoPainter.vcxproj.filters
+++ b/PanoPainter.vcxproj.filters
@@ -61,6 +61,9 @@
{ca37521b-213f-4bcf-acfd-eda1483a30b2}
+
+ {5ecb54ed-7c3d-46fd-9b5d-227abdbc5954}
+
@@ -635,6 +638,75 @@
extras
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
+
+ extras\dialogs
+
diff --git a/data/dialogs/about.xml b/data/dialogs/about.xml
new file mode 100644
index 0000000..0fea3a1
--- /dev/null
+++ b/data/dialogs/about.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/brush-export.xml b/data/dialogs/brush-export.xml
new file mode 100644
index 0000000..e26c12e
--- /dev/null
+++ b/data/dialogs/brush-export.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/changelog.xml b/data/dialogs/changelog.xml
new file mode 100644
index 0000000..4186806
--- /dev/null
+++ b/data/dialogs/changelog.xml
@@ -0,0 +1,161 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/cloud-browse.xml b/data/dialogs/cloud-browse.xml
new file mode 100644
index 0000000..13d06df
--- /dev/null
+++ b/data/dialogs/cloud-browse.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/color-picker.xml b/data/dialogs/color-picker.xml
new file mode 100644
index 0000000..844caa8
--- /dev/null
+++ b/data/dialogs/color-picker.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/doc-browse.xml b/data/dialogs/doc-browse.xml
new file mode 100644
index 0000000..705aecd
--- /dev/null
+++ b/data/dialogs/doc-browse.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/doc-new.xml b/data/dialogs/doc-new.xml
new file mode 100644
index 0000000..ed79e1f
--- /dev/null
+++ b/data/dialogs/doc-new.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/doc-open.xml b/data/dialogs/doc-open.xml
new file mode 100644
index 0000000..08577f1
--- /dev/null
+++ b/data/dialogs/doc-open.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/doc-resize.xml b/data/dialogs/doc-resize.xml
new file mode 100644
index 0000000..5c74689
--- /dev/null
+++ b/data/dialogs/doc-resize.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/doc-save.xml b/data/dialogs/doc-save.xml
new file mode 100644
index 0000000..723299c
--- /dev/null
+++ b/data/dialogs/doc-save.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/input-box.xml b/data/dialogs/input-box.xml
new file mode 100644
index 0000000..ca35b76
--- /dev/null
+++ b/data/dialogs/input-box.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/layer-rename.xml b/data/dialogs/layer-rename.xml
new file mode 100644
index 0000000..2a0d892
--- /dev/null
+++ b/data/dialogs/layer-rename.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/message-box.xml b/data/dialogs/message-box.xml
new file mode 100644
index 0000000..c3a7fcf
--- /dev/null
+++ b/data/dialogs/message-box.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-brushes.xml b/data/dialogs/panel-brushes.xml
new file mode 100644
index 0000000..6ae85a7
--- /dev/null
+++ b/data/dialogs/panel-brushes.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-floating.xml b/data/dialogs/panel-floating.xml
new file mode 100644
index 0000000..997fa62
--- /dev/null
+++ b/data/dialogs/panel-floating.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-grid.xml b/data/dialogs/panel-grid.xml
new file mode 100644
index 0000000..697c90d
--- /dev/null
+++ b/data/dialogs/panel-grid.xml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-layers.xml b/data/dialogs/panel-layers.xml
new file mode 100644
index 0000000..02f832c
--- /dev/null
+++ b/data/dialogs/panel-layers.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-presets.xml b/data/dialogs/panel-presets.xml
new file mode 100644
index 0000000..dba946b
--- /dev/null
+++ b/data/dialogs/panel-presets.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-quick.xml b/data/dialogs/panel-quick.xml
new file mode 100644
index 0000000..a154a17
--- /dev/null
+++ b/data/dialogs/panel-quick.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/panel-stroke.xml b/data/dialogs/panel-stroke.xml
new file mode 100644
index 0000000..e4acc59
--- /dev/null
+++ b/data/dialogs/panel-stroke.xml
@@ -0,0 +1,513 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/progress-bar.xml b/data/dialogs/progress-bar.xml
new file mode 100644
index 0000000..3ab1d28
--- /dev/null
+++ b/data/dialogs/progress-bar.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/settings.xml b/data/dialogs/settings.xml
new file mode 100644
index 0000000..6f91456
--- /dev/null
+++ b/data/dialogs/settings.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/dialogs/template.xml b/data/dialogs/template.xml
new file mode 100644
index 0000000..9f5c254
--- /dev/null
+++ b/data/dialogs/template.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/data/dialogs/usermanual.xml b/data/dialogs/usermanual.xml
new file mode 100644
index 0000000..4d53188
--- /dev/null
+++ b/data/dialogs/usermanual.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/layout.xml b/data/layout.xml
index 5b4796a..ba2b2f2 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -3,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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/node.cpp b/src/node.cpp
index e5b82d5..86c7735 100644
--- a/src/node.cpp
+++ b/src/node.cpp
@@ -89,6 +89,13 @@ Node* Node::root()
return ret;
}
+void Node::set_manager(LayoutManager* manager)
+{
+ m_manager = manager;
+ for (auto& c : m_children)
+ c->set_manager(manager);
+}
+
kEventResult Node::on_event(Event* e)
{
kEventResult ret = kEventResult::Available;
@@ -346,6 +353,35 @@ const Node* Node::init_template(const char* id)
return m_template;
}
+bool Node::init_template_file(const std::string& path, const std::string& id)
+{
+ bool ret = false;
+ App::I->ui_task([&]
+ {
+ LayoutManager m;
+ if (m.load(path.c_str()))
+ {
+ auto t = m.get_ref(id.c_str())->m_children[0];
+ for (auto& c : t->m_children)
+ add_child(c->clone());
+ YGNodeCopyStyle(y_node, t->y_node);
+ t->clone_copy(this);
+ ret = true;
+ }
+ });
+ return ret;
+}
+
+std::shared_ptr Node::load_template(const std::string& filename, const std::string& name) const
+{
+ LayoutManager m;
+ std::shared_ptr ret;
+ if (m.load(filename.c_str()))
+ ret = std::dynamic_pointer_cast(std::move(m.get_ref(name.c_str())->m_children[0]));
+ m.unload();
+ return ret;
+}
+
void Node::add_child(Node* n)
{
App::I->ui_task([&]
@@ -354,7 +390,7 @@ void Node::add_child(Node* n)
n->m_parent->remove_child(n);
m_children.emplace_back(n);
n->m_parent = this;
- n->m_manager = m_manager;
+ n->set_manager(m_manager);
n->m_destroyed = false;
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
n->added(this);
@@ -370,7 +406,7 @@ void Node::add_child(Node* n, int index)
n->m_parent->remove_child(n);
m_children.emplace_back(n);
n->m_parent = this;
- n->m_manager = m_manager;
+ n->set_manager(m_manager);
n->m_destroyed = false;
YGNodeInsertChild(y_node, n->y_node, index);
n->added(this);
@@ -380,13 +416,13 @@ void Node::add_child(Node* n, int index)
void Node::add_child(std::shared_ptr n)
{
- App::I->ui_task([&]
+ App::I->ui_task([this,n]
{
if (n->m_parent)
n->m_parent->remove_child(n.get());
m_children.push_back(n);
n->m_parent = this;
- n->m_manager = m_manager;
+ n->set_manager(m_manager);
n->m_destroyed = false;
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
n->added(this);
@@ -402,7 +438,7 @@ void Node::add_child(std::shared_ptr n, int index)
n->m_parent->remove_child(n.get());
m_children.insert(m_children.begin() + index, n);
n->m_parent = this;
- n->m_manager = m_manager;
+ n->set_manager(m_manager);
n->m_destroyed = false;
YGNodeInsertChild(y_node, n->y_node, index);
n->added(this);
@@ -673,8 +709,6 @@ Node::Node(Node&& o)
m_name = std::move(o.m_name);
m_nodeID_s = std::move(o.m_nodeID_s);
m_children = std::move(o.m_children);
- for (auto& c : m_children)
- c->m_parent = this;
m_nodeID = o.m_nodeID;
m_display = o.m_display;
m_parent = o.m_parent;
@@ -687,7 +721,10 @@ Node::Node(Node&& o)
o.y_node = nullptr;
o.m_parent = nullptr;
- m_manager = o.m_manager;
+ set_manager(o.m_manager);
+ for (auto& c : m_children)
+ c->m_parent = this;
+
current_mouse_capture = o.current_mouse_capture;
current_key_capture = o.current_key_capture;
m_mouse_captured = o.m_mouse_captured;
@@ -1380,7 +1417,7 @@ Node* Node::clone_instantiate() const
void Node::clone_copy(Node* dest) const
{
YGNodeCopyStyle(dest->y_node, y_node);
- dest->m_manager = m_manager;
+ dest->set_manager(m_manager);
dest->m_name = m_name;
dest->m_nodeID_s = m_nodeID_s;
@@ -1392,7 +1429,6 @@ void Node::clone_copy(Node* dest) const
dest->m_flood_events = m_flood_events;
dest->m_force_mouse_capture = m_force_mouse_capture;
- dest->m_manager = m_manager;
dest->current_mouse_capture = current_mouse_capture;
dest->current_key_capture = current_key_capture;
dest->m_mouse_captured = m_mouse_captured;
@@ -1416,7 +1452,7 @@ void Node::clone_children(Node* dest) const
std::shared_ptr cn = c->clone();
dest->m_children.push_back(cn);
cn->m_parent = dest;
- cn->m_manager = dest->m_manager;
+ cn->set_manager(dest->m_manager);
cn->loaded();
YGNodeInsertChild(dest->y_node, cn->y_node, YGNodeGetChildCount(dest->y_node));
}
diff --git a/src/node.h b/src/node.h
index 22001d6..fb6a861 100644
--- a/src/node.h
+++ b/src/node.h
@@ -206,7 +206,7 @@ public:
void watch(std::function observer);
virtual void destroy();
Node* root();
-
+ void set_manager(LayoutManager* manager);
template std::shared_ptr clone()
{
@@ -242,7 +242,7 @@ public:
template T* add_child()
{
auto* n = new T;
- n->m_manager = m_manager;
+ n->set_manager(m_manager);
n->m_parent = m_parent;
n->init();
n->create();
@@ -253,7 +253,7 @@ public:
template std::shared_ptr add_child_ref()
{
auto n = std::make_shared();
- n->m_manager = m_manager;
+ n->set_manager(m_manager);
n->m_parent = m_parent;
n->init();
n->create();
@@ -261,6 +261,15 @@ public:
add_child(n);
return n;
}
+ template std::shared_ptr add_child_file(const std::string& filename, const std::string& name)
+ {
+ if (auto t = load_template(filename, name))
+ {
+ add_child(t);
+ return std::dynamic_pointer_cast(t);
+ }
+ return nullptr;
+ }
virtual void on_tick(float dt) { };
virtual kEventResult on_event(Event* e);
@@ -276,6 +285,8 @@ public:
virtual void on_child_added(Node* child) { };
virtual void on_child_removed(Node* child) { };
const Node* init_template(const char* id);
+ bool init_template_file(const std::string& path, const std::string& id);
+ std::shared_ptr load_template(const std::string& filename, const std::string& name) const;
void tick(float dt);
void app_redraw();
void add_child(Node* n);
diff --git a/src/node_about.cpp b/src/node_about.cpp
index ae4e875..0d7faca 100644
--- a/src/node_about.cpp
+++ b/src/node_about.cpp
@@ -14,9 +14,8 @@ void NodeAbout::init()
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
- auto m_template = (*m_manager)[const_hash("about")]->m_children[0]->clone();
- add_child(m_template);
- btn_ok = m_template->find("btn-ok");
+ add_child_file("data/dialogs/about.xml", "about");
+ btn_ok = find("btn-ok");
btn_ok->on_click = [&](Node*) { destroy(); };
}
diff --git a/src/node_changelog.cpp b/src/node_changelog.cpp
index 0d41c85..1b9bbdf 100644
--- a/src/node_changelog.cpp
+++ b/src/node_changelog.cpp
@@ -14,9 +14,8 @@ void NodeChangelog::init()
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
- auto m_template = (*m_manager)[const_hash("changelog")]->m_children[0]->clone();
- add_child(m_template);
- btn_ok = m_template->find("btn-ok");
+ add_child_file("data/dialogs/changelog.xml", "changelog");
+ btn_ok = find("btn-ok");
btn_ok->on_click = [&](Node*) { destroy(); };
}
diff --git a/src/node_dialog_browse.cpp b/src/node_dialog_browse.cpp
index 7c216fe..4f43ee1 100644
--- a/src/node_dialog_browse.cpp
+++ b/src/node_dialog_browse.cpp
@@ -21,10 +21,7 @@ void NodeDialogBrowse::clone_finalize(Node* dest) const
void NodeDialogBrowse::init()
{
- auto tpl = static_cast(init_template("dialog-browse"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;;
- m_thinkness = tpl->m_thinkness;;
+ init_template_file("data/dialogs/doc-browse.xml", "dialog-browse");
init_controls();
}
@@ -186,10 +183,7 @@ void NodeDialogBrowseItem::clone_finalize(Node* dest) const
}
void NodeDialogBrowseItem::init()
{
- auto tpl = static_cast(init_template("dialog-browse-item"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;
- m_thinkness = tpl->m_thinkness;
+ init_template_file("data/dialogs/doc-browse.xml", "dialog-browse-item");
init_controls();
}
void NodeDialogBrowseItem::init_controls()
diff --git a/src/node_dialog_cloud.cpp b/src/node_dialog_cloud.cpp
index 93d2d80..ab48657 100644
--- a/src/node_dialog_cloud.cpp
+++ b/src/node_dialog_cloud.cpp
@@ -21,10 +21,7 @@ void NodeDialogCloud::clone_finalize(Node* dest) const
void NodeDialogCloud::init()
{
- auto tpl = static_cast(init_template("dialog-cloud"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;;
- m_thinkness = tpl->m_thinkness;;
+ init_template_file("data/dialogs/cloud-browse.xml", "dialog-cloud");
init_controls();
}
@@ -162,10 +159,7 @@ void NodeDialogCloudItem::clone_finalize(Node* dest) const
}
void NodeDialogCloudItem::init()
{
- auto tpl = static_cast(init_template("dialog-cloud-item"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;
- m_thinkness = tpl->m_thinkness;
+ init_template_file("data/dialogs/cloud-browse.xml", "dialog-cloud-item");
init_controls();
}
void NodeDialogCloudItem::init_controls()
diff --git a/src/node_dialog_export_ppbr.cpp b/src/node_dialog_export_ppbr.cpp
index ada7440..ee23523 100644
--- a/src/node_dialog_export_ppbr.cpp
+++ b/src/node_dialog_export_ppbr.cpp
@@ -17,10 +17,7 @@ void NodeDialogExportPPBR::clone_finalize(Node* dest) const
void NodeDialogExportPPBR::init()
{
- auto tpl = static_cast(init_template("dialog-brush-upload"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;;
- m_thinkness = tpl->m_thinkness;;
+ init_template_file("data/dialogs/brush-export.xml", "dialog-brush-upload");
init_controls();
m_capture_children = false; // don't capture children events on mouse_capture
}
diff --git a/src/node_dialog_layer_rename.cpp b/src/node_dialog_layer_rename.cpp
index 07cd302..604ae27 100644
--- a/src/node_dialog_layer_rename.cpp
+++ b/src/node_dialog_layer_rename.cpp
@@ -17,10 +17,7 @@ void NodeDialogLayerRename::clone_finalize(Node* dest) const
void NodeDialogLayerRename::init()
{
- auto tpl = static_cast(init_template("dialog-layer-rename"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;;
- m_thinkness = tpl->m_thinkness;;
+ init_template_file("data/dialogs/layer-rename.xml", "dialog-layer-rename");
init_controls();
}
diff --git a/src/node_dialog_open.cpp b/src/node_dialog_open.cpp
index 7cef7b8..ff98b88 100644
--- a/src/node_dialog_open.cpp
+++ b/src/node_dialog_open.cpp
@@ -119,10 +119,7 @@ void NodeDialogOpenItem::clone_finalize(Node* dest) const
}
void NodeDialogOpenItem::init()
{
- auto tpl = static_cast(init_template("dialog-open-item"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;
- m_thinkness = tpl->m_thinkness;
+ init_template_file("data/dialogs/doc-open.xml", "dialog-open-item");
init_controls();
}
void NodeDialogOpenItem::init_controls()
@@ -176,10 +173,7 @@ void NodeDialogSave::clone_finalize(Node* dest) const
}
void NodeDialogSave::init()
{
- auto tpl = static_cast(init_template("dialog-save"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;
- m_thinkness = tpl->m_thinkness;
+ init_template_file("data/dialogs/doc-save.xml", "dialog-save");
init_controls();
}
void NodeDialogSave::init_controls()
@@ -236,10 +230,7 @@ void NodeDialogNewDoc::clone_finalize(Node* dest) const
}
void NodeDialogNewDoc::init()
{
- auto tpl = static_cast(init_template("dialog-newdoc"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;
- m_thinkness = tpl->m_thinkness;
+ init_template_file("data/dialogs/doc-new.xml", "dialog-newdoc");
init_controls();
}
void NodeDialogNewDoc::init_controls()
diff --git a/src/node_dialog_picker.cpp b/src/node_dialog_picker.cpp
index e96d34e..129dd81 100644
--- a/src/node_dialog_picker.cpp
+++ b/src/node_dialog_picker.cpp
@@ -19,8 +19,7 @@ void NodeColorPicker::clone_finalize(Node* dest) const
void NodeColorPicker::init()
{
- auto n = (NodeColorPicker*)init_template("color-picker");
- n->clone_copy(this);
+ init_template_file("data/dialogs/color-picker.xml", "color-picker");
init_controls();
}
diff --git a/src/node_dialog_resize.cpp b/src/node_dialog_resize.cpp
index 251f430..8791fd2 100644
--- a/src/node_dialog_resize.cpp
+++ b/src/node_dialog_resize.cpp
@@ -19,10 +19,7 @@ void NodeDialogResize::clone_finalize(Node* dest) const
void NodeDialogResize::init()
{
- auto tpl = static_cast(init_template("dialog-resize"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;;
- m_thinkness = tpl->m_thinkness;;
+ init_template_file("data/dialogs/doc-resize.xml", "dialog-resize");
init_controls();
}
diff --git a/src/node_input_box.cpp b/src/node_input_box.cpp
index 3090bdc..b0c6cfb 100644
--- a/src/node_input_box.cpp
+++ b/src/node_input_box.cpp
@@ -14,17 +14,16 @@ void NodeInputBox::init()
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
- auto m_template = (*m_manager)[const_hash("input-box")]->m_children[0]->clone();
- add_child(m_template);
- m_title = m_template->find("title");
- m_field_name = m_template->find("field-name");
- m_field_text = m_template->find("field-text");
- btn_ok = m_template->find("btn-ok");
+ add_child_file("data/dialogs/input-box.xml", "input-box");
+ m_title = find("title");
+ m_field_name = find("field-name");
+ m_field_text = find("field-text");
+ btn_ok = find("btn-ok");
btn_ok->on_click = [&](Node*) {
if (on_submit)
on_submit(this, m_field_text->m_text);
};
- btn_cancel = m_template->find("btn-cancel");
+ btn_cancel = find("btn-cancel");
btn_cancel->on_click = [&](Node*) { destroy(); };
m_capture_children = false; // don't capture children events on mouse_capture
}
diff --git a/src/node_message_box.cpp b/src/node_message_box.cpp
index 42bf4ad..6203b03 100644
--- a/src/node_message_box.cpp
+++ b/src/node_message_box.cpp
@@ -14,16 +14,15 @@ void NodeMessageBox::init()
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
- auto m_template = (*m_manager)[const_hash("message-box")]->m_children[0]->clone();
- add_child(m_template);
- m_title = m_template->find("title");
- m_message = m_template->find("message");
- btn_ok = m_template->find("btn-ok");
+ add_child_file("data/dialogs/message-box.xml", "message-box");
+ m_title = find("title");
+ m_message = find("message");
+ btn_ok = find("btn-ok");
btn_ok->on_click = [&](Node*) {
if (on_submit)
on_submit(this);
};
- btn_cancel = m_template->find("btn-cancel");
+ btn_cancel = find("btn-cancel");
on_submit = btn_cancel->on_click = [&](Node*) { destroy(); };
m_capture_children = false; // don't capture children events on mouse_capture
}
diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp
index 478bf6c..607ee9e 100644
--- a/src/node_panel_brush.cpp
+++ b/src/node_panel_brush.cpp
@@ -18,7 +18,7 @@ Node* NodeButtonBrush::clone_instantiate() const
void NodeButtonBrush::init()
{
- init_template("tpl-brush-icon");
+ init_template_file("data/dialogs/panel-brushes.xml", "tpl-brush-icon");
color_hover = glm::vec4(.7, .7, .7, 1);
color_normal = glm::vec4(.3, .3, .3, 1);
m_color = color_normal;
@@ -74,7 +74,7 @@ Node* NodePanelBrush::clone_instantiate() const
void NodePanelBrush::init()
{
- init_template("tpl-panel-brushes");
+ init_template_file("data/dialogs/panel-brushes.xml", "tpl-panel-brushes");
m_btn_add = find("btn-add");
m_btn_add->on_click = [this](Node*) {
@@ -379,7 +379,7 @@ Node* NodeBrushPresetItem::clone_instantiate() const
void NodeBrushPresetItem::init()
{
- init_template("tpl-brush-preset");
+ init_template_file("data/dialogs/panel-brushes.xml", "tpl-brush-preset");
color_hover = glm::vec4(.7, .7, .7, 1);
color_normal = glm::vec4(.3, .3, .3, 1);
m_color = color_normal;
@@ -415,7 +415,7 @@ Node* NodePanelBrushPreset::clone_instantiate() const
void NodePanelBrushPreset::init()
{
- init_template("tpl-panel-brush-preset");
+ init_template_file("data/dialogs/panel-brushes.xml", "tpl-panel-brush-preset");
m_container = find("brushes");
m_btn_add = find("btn-add");
m_btn_add->on_click = [this] (Node*) {
diff --git a/src/node_panel_color.cpp b/src/node_panel_color.cpp
index 058e286..2eb1327 100644
--- a/src/node_panel_color.cpp
+++ b/src/node_panel_color.cpp
@@ -16,7 +16,7 @@ void NodePanelColor::clone_finalize(Node* dest) const
void NodePanelColor::init()
{
- init_template("tpl-panel-color");
+ init_template_file("data/dialogs/color-picker.xml", "tpl-panel-color");
init_controls();
}
diff --git a/src/node_panel_floating.cpp b/src/node_panel_floating.cpp
index f8a8791..c3116cd 100644
--- a/src/node_panel_floating.cpp
+++ b/src/node_panel_floating.cpp
@@ -17,7 +17,7 @@ void NodePanelFloating::clone_finalize(Node* dest) const
void NodePanelFloating::init()
{
parent::init();
- init_template("tpl-panel-floating");
+ init_template_file("data/dialogs/panel-floating.xml", "tpl-panel-floating");
init_controls();
}
diff --git a/src/node_panel_grid.cpp b/src/node_panel_grid.cpp
index 69e3dd1..a8d6586 100644
--- a/src/node_panel_grid.cpp
+++ b/src/node_panel_grid.cpp
@@ -19,7 +19,7 @@ void NodePanelGrid::clone_finalize(Node* dest) const
void NodePanelGrid::init()
{
- init_template("tpl-panel-grid");
+ init_template_file("data/dialogs/panel-grid.xml", "tpl-panel-grid");
init_controls();
}
diff --git a/src/node_panel_layer.cpp b/src/node_panel_layer.cpp
index 8f9850e..18a5123 100644
--- a/src/node_panel_layer.cpp
+++ b/src/node_panel_layer.cpp
@@ -28,10 +28,7 @@ void NodeLayer::clone_copy(Node* dest) const
void NodeLayer::init()
{
- const auto& m_template = (NodeBorder*)init_template("tpl-layer");
- m_color = m_template->m_color;
- m_border_color = m_template->m_border_color;
- m_thinkness = m_template->m_thinkness;
+ init_template_file("data/dialogs/panel-layers.xml", "tpl-layer");
m_label = find("label");
m_visibility = find("cb");
}
@@ -111,7 +108,7 @@ Node* NodePanelLayer::clone_instantiate() const
void NodePanelLayer::init()
{
- init_template("tpl-panel-layers");
+ init_template_file("data/dialogs/panel-layers.xml", "tpl-panel-layers");
m_layers_container = find("layers-container");
btn_add = find("btn-add");
btn_remove = find("btn-remove");
diff --git a/src/node_panel_quick.cpp b/src/node_panel_quick.cpp
index 2cc15ae..78df7a8 100644
--- a/src/node_panel_quick.cpp
+++ b/src/node_panel_quick.cpp
@@ -19,7 +19,7 @@ void NodePanelQuick::clone_finalize(Node* dest) const
void NodePanelQuick::init()
{
parent::init();
- init_template("tpl-panel-quick");
+ init_template_file("data/dialogs/panel-quick.xml", "tpl-panel-quick");
init_controls();
}
diff --git a/src/node_panel_stroke.cpp b/src/node_panel_stroke.cpp
index a571e79..6c61dfc 100644
--- a/src/node_panel_stroke.cpp
+++ b/src/node_panel_stroke.cpp
@@ -19,7 +19,7 @@ void NodePanelStroke::clone_finalize(Node* dest) const
void NodePanelStroke::init()
{
- init_template("tpl-panel-stroke");
+ init_template_file("data/dialogs/panel-stroke.xml", "tpl-panel-stroke");
init_controls();
}
diff --git a/src/node_popup_menu.cpp b/src/node_popup_menu.cpp
index 141276d..682264c 100644
--- a/src/node_popup_menu.cpp
+++ b/src/node_popup_menu.cpp
@@ -2,6 +2,7 @@
#include "log.h"
#include "node_popup_menu.h"
#include "node_button_custom.h"
+#include "app.h"
Node* NodePopupMenu::clone_instantiate() const
{
@@ -54,7 +55,8 @@ kEventResult NodePopupMenu::handle_event(Event* e)
void NodePopupMenu::added(Node* parent)
{
- mouse_capture();
+ if (root() == App::I->layout.get(App::I->main_id))
+ mouse_capture();
m_mouse_ignore = false;
m_flood_events = true;
m_capture_children = false;
diff --git a/src/node_progress_bar.cpp b/src/node_progress_bar.cpp
index 00744a9..3e49ced 100644
--- a/src/node_progress_bar.cpp
+++ b/src/node_progress_bar.cpp
@@ -10,15 +10,12 @@ Node* NodeProgressBar::clone_instantiate() const
void NodeProgressBar::init()
{
- auto tpl = static_cast(init_template("progress-bar"));
- m_color = tpl->m_color;
- m_border_color = tpl->m_border_color;
- m_thinkness = tpl->m_thinkness;
+ init_template_file("data/dialogs/progress-bar.xml", "progress-bar");
m_capture_children = false; // don't capture children events on mouse_capture
m_title = find("title");
btn_cancel = find("btn-cancel");
- btn_cancel->on_click = [&](Node*) { destroy(); };
+ //btn_cancel->on_click = [&](Node*) { destroy(); };
m_progress = find("progress");
m_body = find("body");
diff --git a/src/node_settings.cpp b/src/node_settings.cpp
index 82bca93..898921d 100644
--- a/src/node_settings.cpp
+++ b/src/node_settings.cpp
@@ -14,9 +14,8 @@ void NodeSettings::init()
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
- auto m_template = (*m_manager)[const_hash("settings")]->m_children[0]->clone();
- add_child(m_template);
- btnOk = m_template->find("btn-ok");
+ add_child_file("data/dialogs/settings.xml", "settings");
+ btnOk = find("btn-ok");
btnOk->on_click = [&](Node*) { destroy(); };
}
diff --git a/src/node_usermanual.cpp b/src/node_usermanual.cpp
index fc87760..be18af5 100644
--- a/src/node_usermanual.cpp
+++ b/src/node_usermanual.cpp
@@ -14,9 +14,8 @@ void NodeUserManual::init()
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
- auto m_template = (*m_manager)[const_hash("usermanual")]->m_children[0]->clone();
- add_child(m_template);
- btn_ok = m_template->find("btn-ok");
+ add_child_file("data/dialogs/usermanual.xml", "usermanual");
+ btn_ok = find("btn-ok");
btn_ok->on_click = [&](Node*) { destroy(); };
}