add panels docking
This commit is contained in:
59
src/node.cpp
59
src/node.cpp
@@ -62,7 +62,10 @@ void Node::watch(std::function<bool(Node*)> observer)
|
||||
if (cont)
|
||||
{
|
||||
for (auto& c : m_children)
|
||||
c->watch(observer);
|
||||
{
|
||||
if (!glm::any(glm::lessThanEqual(zw(c->m_clip), { 0, 0 })))
|
||||
c->watch(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +122,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
|
||||
|
||||
if (!m_display)
|
||||
if (!m_display || glm::any(glm::lessThanEqual(zw(m_clip), { 0, 0 })))
|
||||
return kEventResult::Available;
|
||||
|
||||
if (!skip_children)
|
||||
@@ -257,6 +260,11 @@ void Node::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
||||
|
||||
}
|
||||
|
||||
void Node::handle_parent_resize(glm::vec2 old_size, glm::vec2 new_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Node::create()
|
||||
{
|
||||
|
||||
@@ -354,6 +362,7 @@ void Node::remove_child(Node* n)
|
||||
if (i != m_children.end())
|
||||
{
|
||||
n->removed(this);
|
||||
n->m_parent = nullptr;
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
on_child_removed(n);
|
||||
m_children.erase(i);
|
||||
@@ -367,6 +376,7 @@ void Node::remove_all_children()
|
||||
for (auto& n : m_children)
|
||||
{
|
||||
n->removed(this);
|
||||
n->m_parent = nullptr;
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
on_child_removed(n.get());
|
||||
}
|
||||
@@ -385,6 +395,12 @@ void Node::move_child(Node* n, int index)
|
||||
m_children.insert(m_children.begin() + index, tmp);
|
||||
}
|
||||
|
||||
void Node::move_child_front(Node* n)
|
||||
{
|
||||
int count = YGNodeGetChildCount(y_node);
|
||||
move_child(n, count - 1);
|
||||
}
|
||||
|
||||
void Node::move_child_offset(Node* n, int offset)
|
||||
{
|
||||
int count = YGNodeGetChildCount(y_node);
|
||||
@@ -437,6 +453,21 @@ glm::vec4 Node::get_children_rect() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Node>> Node::get_children_at_point(glm::vec2 point) const
|
||||
{
|
||||
std::vector<std::shared_ptr<Node>> ret;
|
||||
for (const auto& c : m_children)
|
||||
{
|
||||
if (point_in_rect(point, c->m_clip))
|
||||
{
|
||||
ret.push_back(c);
|
||||
auto c_ret = c->get_children_at_point(point);
|
||||
ret.insert(ret.end(), c_ret.begin(), c_ret.end());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Node::is_child_recursive(Node* o) const
|
||||
{
|
||||
for (const auto& c : m_children)
|
||||
@@ -651,6 +682,26 @@ void Node::SetMaxHeightP(float value)
|
||||
YGNodeStyleSetMaxHeightPercent(y_node, value);
|
||||
}
|
||||
|
||||
void Node::SetMinWidth(float value)
|
||||
{
|
||||
YGNodeStyleSetMinWidth(y_node, value);
|
||||
}
|
||||
|
||||
void Node::SetMinWidthP(float value)
|
||||
{
|
||||
YGNodeStyleSetMinWidthPercent(y_node, value);
|
||||
}
|
||||
|
||||
void Node::SetMinHeight(float value)
|
||||
{
|
||||
YGNodeStyleSetMinHeight(y_node, value);
|
||||
}
|
||||
|
||||
void Node::SetMinHeightP(float value)
|
||||
{
|
||||
YGNodeStyleSetMinHeightPercent(y_node, value);
|
||||
}
|
||||
|
||||
void Node::SetPadding(float t, float r, float b, float l)
|
||||
{
|
||||
YGNodeStyleSetPadding(y_node, YGEdgeTop, t);
|
||||
@@ -887,7 +938,11 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj)
|
||||
}
|
||||
|
||||
if (m_size != old_size)
|
||||
{
|
||||
handle_resize(old_size, m_size);
|
||||
for (auto& c : m_children)
|
||||
c->handle_parent_resize(old_size, m_size);
|
||||
}
|
||||
|
||||
for (auto& c : m_children)
|
||||
c->update_internal(m_pos, proj);
|
||||
|
||||
Reference in New Issue
Block a user