fix layout designer
This commit is contained in:
@@ -67,6 +67,8 @@ void App::crash_test()
|
||||
|
||||
void App::tick(float dt)
|
||||
{
|
||||
if (auto* main = layout_designer[main_id])
|
||||
main->tick(dt);
|
||||
if (auto* main = layout[main_id])
|
||||
main->tick(dt);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ void LayoutManager::unload()
|
||||
void LayoutManager::create()
|
||||
{
|
||||
m_layouts[const_hash("main")] = std::make_unique<Node>();
|
||||
m_layouts[const_hash("main")]->m_manager = this;
|
||||
}
|
||||
|
||||
bool LayoutManager::load(const char* path)
|
||||
|
||||
14
src/node.cpp
14
src/node.cpp
@@ -96,6 +96,12 @@ void Node::set_manager(LayoutManager* manager)
|
||||
c->set_manager(manager);
|
||||
}
|
||||
|
||||
bool Node::added_to_root()
|
||||
{
|
||||
auto r = root();
|
||||
return r == m_manager->get(App::I->main_id);
|
||||
}
|
||||
|
||||
kEventResult Node::on_event(Event* e)
|
||||
{
|
||||
kEventResult ret = kEventResult::Available;
|
||||
@@ -599,7 +605,7 @@ bool Node::is_child(Node* o) const
|
||||
|
||||
void Node::mouse_capture()
|
||||
{
|
||||
auto root = App::I->layout.get_ref("main");
|
||||
auto root = m_manager->get_ref("main");
|
||||
if (!root) return;
|
||||
|
||||
auto& c = root->current_mouse_capture;
|
||||
@@ -644,7 +650,7 @@ void Node::mouse_release()
|
||||
if (!m_parent)
|
||||
return;
|
||||
|
||||
auto root = App::I->layout.get_ref("main");
|
||||
auto root = m_manager->get_ref("main");
|
||||
if (!root) return;
|
||||
|
||||
auto& c = root->current_mouse_capture;
|
||||
@@ -673,7 +679,7 @@ void Node::key_capture()
|
||||
if (!m_parent)
|
||||
return;
|
||||
|
||||
auto root = App::I->layout.get_ref("main");
|
||||
auto root = m_manager->get_ref("main");
|
||||
if (!root) return;
|
||||
|
||||
root->current_key_capture = shared_from_this();
|
||||
@@ -682,7 +688,7 @@ void Node::key_capture()
|
||||
|
||||
void Node::key_release()
|
||||
{
|
||||
auto root = App::I->layout.get_ref("main");
|
||||
auto root = m_manager->get_ref("main");
|
||||
if (!root) return;
|
||||
|
||||
if (root->current_key_capture.get() == this)
|
||||
|
||||
@@ -208,6 +208,7 @@ public:
|
||||
virtual void destroy();
|
||||
Node* root();
|
||||
void set_manager(LayoutManager* manager);
|
||||
bool added_to_root();
|
||||
|
||||
template<class T = Node> std::shared_ptr<T> clone()
|
||||
{
|
||||
|
||||
@@ -82,5 +82,6 @@ void NodeDialogExportPPBR::open_header()
|
||||
void NodeDialogExportPPBR::added(Node* parent)
|
||||
{
|
||||
NodeBorder::added(parent);
|
||||
mouse_capture();
|
||||
if (added_to_root())
|
||||
mouse_capture();
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ void NodeImage::load_url(const std::string& url)
|
||||
m_remote_texture->create_mipmaps();
|
||||
delete rgba;
|
||||
if (m_autosize)
|
||||
SetAspectRatio(w / h);
|
||||
SetAspectRatio((float)w / (float)h);
|
||||
}
|
||||
m_remote_asset.reset();
|
||||
}
|
||||
@@ -162,6 +162,6 @@ void NodeImage::load_url(const std::string& url)
|
||||
void NodeImage::added(Node* parent)
|
||||
{
|
||||
Node::added(parent);
|
||||
if (!m_url.empty() && root() == App::I->layout.get(App::I->main_id))
|
||||
if (!m_url.empty() && added_to_root())
|
||||
load_url(m_url);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ kEventResult NodeInputBox::handle_event(Event* e)
|
||||
void NodeInputBox::added(Node* parent)
|
||||
{
|
||||
Node::added(parent);
|
||||
mouse_capture();
|
||||
m_field_text->key_capture();
|
||||
if (added_to_root())
|
||||
{
|
||||
mouse_capture();
|
||||
m_field_text->key_capture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,5 +51,6 @@ kEventResult NodeMessageBox::handle_event(Event* e)
|
||||
void NodeMessageBox::added(Node* parent)
|
||||
{
|
||||
Node::added(parent);
|
||||
mouse_capture();
|
||||
if (added_to_root())
|
||||
mouse_capture();
|
||||
}
|
||||
|
||||
@@ -37,5 +37,6 @@ void NodeProgressBar::set_progress(float p) noexcept
|
||||
void NodeProgressBar::added(Node* parent)
|
||||
{
|
||||
NodeBorder::added(parent);
|
||||
mouse_capture();
|
||||
if (added_to_root())
|
||||
mouse_capture();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user