fix combobox issue, pad scissor by 1px

This commit is contained in:
2019-08-17 10:20:05 +02:00
parent a8e9e92d96
commit c1bd377ee8
7 changed files with 53 additions and 42 deletions

View File

@@ -58,13 +58,13 @@ void Node::watch(std::function<bool(Node*)> observer)
void Node::destroy()
{
auto children_copy = m_children;
for (auto c : children_copy)
c->destroy();
mouse_release();
key_release();
remove_from_parent();
app_redraw();
App::I->ui_task([&]
{
mouse_release();
key_release();
remove_all_children();
remove_from_parent();
});
}
Node* Node::root()
@@ -79,11 +79,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)
@@ -112,7 +112,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;
@@ -131,7 +131,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)
@@ -144,7 +144,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;
@@ -398,7 +398,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;
});
}
@@ -539,7 +539,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)
@@ -567,7 +568,7 @@ void Node::mouse_capture()
}
// make current
c = this;
c = shared_from_this();
m_mouse_captured = true;
}
@@ -579,8 +580,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())
{
@@ -601,7 +603,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;
}