Merge branch 'master'
This commit is contained in:
28
src/node.cpp
28
src/node.cpp
@@ -40,7 +40,7 @@
|
||||
void Node::app_redraw()
|
||||
{
|
||||
App::I->redraw = true;
|
||||
App::I->ui_cv.notify_all();
|
||||
App::I->render_cv.notify_all();
|
||||
}
|
||||
|
||||
void Node::watch(std::function<bool(Node*)> observer)
|
||||
@@ -82,11 +82,11 @@ kEventResult Node::on_event(Event* e)
|
||||
{
|
||||
kEventResult ret = kEventResult::Available;
|
||||
|
||||
if (current_mouse_capture && current_mouse_capture != this)
|
||||
if (current_mouse_capture && current_mouse_capture.get() != this)
|
||||
{
|
||||
if (e->m_cat == kEventCategory::MouseEvent &&
|
||||
child_mouse_focus != current_mouse_capture &&
|
||||
is_child(current_mouse_capture))
|
||||
is_child(current_mouse_capture.get()))
|
||||
{
|
||||
MouseEvent* me = static_cast<MouseEvent*>(e);
|
||||
if (child_mouse_focus)
|
||||
@@ -115,7 +115,7 @@ kEventResult Node::on_event(Event* e)
|
||||
}
|
||||
|
||||
skip_children |= (e->m_cat == kEventCategory::MouseEvent || e->m_cat == kEventCategory::GestureEvent) &&
|
||||
(m_mouse_captured) && (root()->current_mouse_capture == this) && m_capture_children; // <-- THIS IS WRONG "!m_capture_children" is correct, but it breaks everything if changed
|
||||
(m_mouse_captured) && (root()->current_mouse_capture.get() == this) && m_capture_children; // <-- THIS IS WRONG "!m_capture_children" is correct, but it breaks everything if changed
|
||||
|
||||
if (!m_display || glm::any(glm::lessThanEqual(zw(m_clip), { 0, 0 })))
|
||||
return kEventResult::Available;
|
||||
@@ -134,7 +134,7 @@ kEventResult Node::on_event(Event* e)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e->m_cat == kEventCategory::MouseEvent && child_mouse_focus != it->get())
|
||||
if (e->m_cat == kEventCategory::MouseEvent && child_mouse_focus.get() != it->get())
|
||||
{
|
||||
MouseEvent* me = static_cast<MouseEvent*>(e);
|
||||
if (child_mouse_focus)
|
||||
@@ -147,7 +147,7 @@ kEventResult Node::on_event(Event* e)
|
||||
MouseEvent e2 = *me;
|
||||
e2.m_type = kEventType::MouseFocus;
|
||||
(*it)->handle_event(&e2);
|
||||
child_mouse_focus = it->get();
|
||||
child_mouse_focus = *it;
|
||||
child_mouse_focus->m_mouse_focus = true;
|
||||
}
|
||||
ret = kEventResult::Consumed;
|
||||
@@ -401,7 +401,7 @@ void Node::remove_child(Node* n)
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
on_child_removed(n);
|
||||
m_children.erase(i);
|
||||
if (child_mouse_focus == n)
|
||||
if (child_mouse_focus.get() == n)
|
||||
child_mouse_focus = nullptr;
|
||||
});
|
||||
}
|
||||
@@ -542,7 +542,8 @@ void Node::mouse_capture()
|
||||
auto& s = root()->m_capture_stack;
|
||||
|
||||
// already owner of capture
|
||||
if (c == this || std::find(s.begin(), s.end(), this) != s.end())
|
||||
if (c.get() == this || std::find_if(s.begin(), s.end(),
|
||||
[this](const auto& a) { return a.get() == this; }) != s.end())
|
||||
return;
|
||||
|
||||
if (c)
|
||||
@@ -570,7 +571,7 @@ void Node::mouse_capture()
|
||||
}
|
||||
|
||||
// make current
|
||||
c = this;
|
||||
c = shared_from_this();
|
||||
m_mouse_captured = true;
|
||||
}
|
||||
|
||||
@@ -582,8 +583,9 @@ void Node::mouse_release()
|
||||
auto& c = root()->current_mouse_capture;
|
||||
auto& s = root()->m_capture_stack;
|
||||
|
||||
s.erase(std::remove(s.begin(), s.end(), this), s.end());
|
||||
if (c == this)
|
||||
s.erase(std::remove_if(s.begin(), s.end(),
|
||||
[this](const auto& a) { return a.get() == this; }), s.end());
|
||||
if (c.get() == this)
|
||||
{
|
||||
if (s.empty())
|
||||
{
|
||||
@@ -604,7 +606,7 @@ void Node::key_capture()
|
||||
if (!m_parent)
|
||||
return;
|
||||
|
||||
root()->current_key_capture = this;
|
||||
root()->current_key_capture = shared_from_this();
|
||||
m_key_captured = true;
|
||||
}
|
||||
|
||||
@@ -1376,8 +1378,6 @@ void Node::clone_copy(Node* dest) const
|
||||
dest->m_pos_offset = m_pos_offset;
|
||||
dest->m_pos_offset_childred = m_pos_offset_childred;
|
||||
dest->m_clip_uncut = m_clip_uncut;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Node::clone_children(Node* dest) const
|
||||
|
||||
Reference in New Issue
Block a user