split layout.xml into multiple files loaded on demand, update changelog
This commit is contained in:
58
src/node.cpp
58
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> Node::load_template(const std::string& filename, const std::string& name) const
|
||||
{
|
||||
LayoutManager m;
|
||||
std::shared_ptr<Node> ret;
|
||||
if (m.load(filename.c_str()))
|
||||
ret = std::dynamic_pointer_cast<Node>(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<Node> 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<Node> 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<Node> 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));
|
||||
}
|
||||
|
||||
17
src/node.h
17
src/node.h
@@ -206,7 +206,7 @@ public:
|
||||
void watch(std::function<bool(Node*)> observer);
|
||||
virtual void destroy();
|
||||
Node* root();
|
||||
|
||||
void set_manager(LayoutManager* manager);
|
||||
|
||||
template<class T = Node> std::shared_ptr<T> clone()
|
||||
{
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
template<class T> 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<class T> std::shared_ptr<T> add_child_ref()
|
||||
{
|
||||
auto n = std::make_shared<T>();
|
||||
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<class T = Node> std::shared_ptr<T> 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>(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<Node> load_template(const std::string& filename, const std::string& name) const;
|
||||
void tick(float dt);
|
||||
void app_redraw();
|
||||
void add_child(Node* n);
|
||||
|
||||
@@ -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<NodeButton>("btn-ok");
|
||||
add_child_file("data/dialogs/about.xml", "about");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
}
|
||||
|
||||
|
||||
@@ -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<NodeButton>("btn-ok");
|
||||
add_child_file("data/dialogs/changelog.xml", "changelog");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ void NodeDialogBrowse::clone_finalize(Node* dest) const
|
||||
|
||||
void NodeDialogBrowse::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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<const NodeBorder*>(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()
|
||||
|
||||
@@ -21,10 +21,7 @@ void NodeDialogCloud::clone_finalize(Node* dest) const
|
||||
|
||||
void NodeDialogCloud::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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<const NodeBorder*>(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()
|
||||
|
||||
@@ -17,10 +17,7 @@ void NodeDialogExportPPBR::clone_finalize(Node* dest) const
|
||||
|
||||
void NodeDialogExportPPBR::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ void NodeDialogLayerRename::clone_finalize(Node* dest) const
|
||||
|
||||
void NodeDialogLayerRename::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +119,7 @@ void NodeDialogOpenItem::clone_finalize(Node* dest) const
|
||||
}
|
||||
void NodeDialogOpenItem::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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<const NodeBorder*>(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<const NodeBorder*>(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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,7 @@ void NodeDialogResize::clone_finalize(Node* dest) const
|
||||
|
||||
void NodeDialogResize::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<NodeText>("title");
|
||||
m_field_name = m_template->find<NodeText>("field-name");
|
||||
m_field_text = m_template->find<NodeTextInput>("field-text");
|
||||
btn_ok = m_template->find<NodeButton>("btn-ok");
|
||||
add_child_file("data/dialogs/input-box.xml", "input-box");
|
||||
m_title = find<NodeText>("title");
|
||||
m_field_name = find<NodeText>("field-name");
|
||||
m_field_text = find<NodeTextInput>("field-text");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) {
|
||||
if (on_submit)
|
||||
on_submit(this, m_field_text->m_text);
|
||||
};
|
||||
btn_cancel = m_template->find<NodeButton>("btn-cancel");
|
||||
btn_cancel = find<NodeButton>("btn-cancel");
|
||||
btn_cancel->on_click = [&](Node*) { destroy(); };
|
||||
m_capture_children = false; // don't capture children events on mouse_capture
|
||||
}
|
||||
|
||||
@@ -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<NodeText>("title");
|
||||
m_message = m_template->find<NodeText>("message");
|
||||
btn_ok = m_template->find<NodeButton>("btn-ok");
|
||||
add_child_file("data/dialogs/message-box.xml", "message-box");
|
||||
m_title = find<NodeText>("title");
|
||||
m_message = find<NodeText>("message");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) {
|
||||
if (on_submit)
|
||||
on_submit(this);
|
||||
};
|
||||
btn_cancel = m_template->find<NodeButton>("btn-cancel");
|
||||
btn_cancel = find<NodeButton>("btn-cancel");
|
||||
on_submit = btn_cancel->on_click = [&](Node*) { destroy(); };
|
||||
m_capture_children = false; // don't capture children events on mouse_capture
|
||||
}
|
||||
|
||||
@@ -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<NodeButtonCustom>("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<Node>("brushes");
|
||||
m_btn_add = find<NodeButtonCustom>("btn-add");
|
||||
m_btn_add->on_click = [this] (Node*) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<NodeText>("label");
|
||||
m_visibility = find<NodeCheckBox>("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<NodeScroll>("layers-container");
|
||||
btn_add = find<NodeButtonCustom>("btn-add");
|
||||
btn_remove = find<NodeButtonCustom>("btn-remove");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -10,15 +10,12 @@ Node* NodeProgressBar::clone_instantiate() const
|
||||
|
||||
void NodeProgressBar::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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<NodeText>("title");
|
||||
btn_cancel = find<NodeButton>("btn-cancel");
|
||||
btn_cancel->on_click = [&](Node*) { destroy(); };
|
||||
//btn_cancel->on_click = [&](Node*) { destroy(); };
|
||||
m_progress = find<NodeBorder>("progress");
|
||||
m_body = find<NodeBorder>("body");
|
||||
|
||||
|
||||
@@ -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<NodeButton>("btn-ok");
|
||||
add_child_file("data/dialogs/settings.xml", "settings");
|
||||
btnOk = find<NodeButton>("btn-ok");
|
||||
btnOk->on_click = [&](Node*) { destroy(); };
|
||||
}
|
||||
|
||||
|
||||
@@ -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<NodeButton>("btn-ok");
|
||||
add_child_file("data/dialogs/usermanual.xml", "usermanual");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user