update scrollbar scroller on tick, fix Transform mode recursive loop

This commit is contained in:
2019-02-02 14:24:50 +01:00
parent 8e5a8eec1b
commit fe7c357bcc
4 changed files with 20 additions and 43 deletions

View File

@@ -24,41 +24,17 @@ void NodeScroll::fix_scroll()
auto rect = get_children_rect();
m_offset = glm::clamp(m_offset, - zw(rect) + zw(m_clip_uncut) - padoff, { 0, 0 });
m_pos_offset_childred = m_offset;
}
void NodeScroll::on_tick(float dt)
{
auto pad = GetPadding();
auto rect = get_children_rect();
// fix scrollbar
float sz = m_size.y - (pad[0] + pad[2]);
if (rect.w == 0 || rect.w <= sz)
{
YGNodeStyleSetPadding(y_node, YGEdgeRight, 5);
return;
}
YGNodeStyleSetPadding(y_node, YGEdgeRight, 35);
}
void NodeScroll::loaded()
{
fix_scroll();
}
void NodeScroll::added(Node* parent)
{
fix_scroll();
}
void NodeScroll::on_child_added(Node* child)
{
fix_scroll();
}
void NodeScroll::on_child_removed(Node* child)
{
fix_scroll();
}
void NodeScroll::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
{
Node::handle_resize(old_size, new_size);
fix_scroll();
float new_pad = rect.w == 0 || rect.w <= sz ? 5 : 35;
if (pad[1] != new_pad)
YGNodeStyleSetPadding(y_node, YGEdgeRight, new_pad);
}
void NodeScroll::draw()