split layout.xml into multiple files loaded on demand, update changelog
This commit is contained in:
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);
|
||||
|
||||
Reference in New Issue
Block a user