Advance app runtime ownership and modernization docs

This commit is contained in:
2026-06-16 06:35:59 +02:00
parent c3d757f4a4
commit a76560e3df
24 changed files with 6675 additions and 9009 deletions

View File

@@ -4,6 +4,7 @@
#include "node_popup_menu.h"
#include "node_button_custom.h"
#include "app.h"
#include <memory>
Node* NodePopupMenu::clone_instantiate() const
{
@@ -33,19 +34,22 @@ kEventResult NodePopupMenu::handle_event(Event* e)
case kEventType::MouseDownL:
break;
case kEventType::MouseUpL:
if (m_mouse_inside)
{
for (int i = 0; i < m_children.size(); i++)
auto self = std::static_pointer_cast<NodePopupMenu>(shared_from_this());
if (m_mouse_inside)
{
if (m_children[i]->m_mouse_inside)
for (int i = 0; i < m_children.size(); i++)
{
if (on_select)
on_select(this, i);
break;
if (m_children[i]->m_mouse_inside)
{
if (on_select)
on_select(self.get(), i);
break;
}
}
}
close_popup();
}
close_popup();
break;
default:
return kEventResult::Available;
@@ -61,13 +65,19 @@ void NodePopupMenu::added(Node* parent)
m_mouse_ignore = false;
m_flood_events = true;
m_capture_children = false;
auto self = std::static_pointer_cast<NodePopupMenu>(shared_from_this());
for (int i = 0; i < m_children.size(); i++)
{
if (auto b = std::dynamic_pointer_cast<NodeButtonCustom>(m_children[i]))
{
b->on_click = [this, i](Node* target) {
if (on_select)
on_select(this, i);
std::weak_ptr<NodePopupMenu> weak_self = self;
b->on_click = [weak_self, i](Node* target) {
auto self = weak_self.lock();
if (!self) {
return;
}
if (self->on_select)
self->on_select(self.get(), i);
};
}
}