add preset popup menu

This commit is contained in:
2019-08-30 15:32:01 +02:00
parent 462c4a52e1
commit 56bba88c14
7 changed files with 43 additions and 34 deletions

View File

@@ -34,10 +34,16 @@ public:
auto i = m_layouts.find(id);
return i == m_layouts.end() ? nullptr : i->second.get();
}
class std::shared_ptr<Node> get_ref(const char* name)
template<class T = Node> std::shared_ptr<T> get_ref(const char* name)
{
auto i = m_layouts.find(const_hash(name));
return i == m_layouts.end() ? nullptr : i->second;
return i == m_layouts.end() ? nullptr : std::dynamic_pointer_cast<T>(i->second);
}
template<class T = Node> std::shared_ptr<T> instantiate(const char* name)
{
if (auto layout = get_ref(name))
return layout->m_children[0]->clone<T>();
return nullptr;
}
void restore_context();
void clear_context();