Simplify reshaping logic
This commit is contained in:
parent
dd87dadd2f
commit
1af6f26e80
1 changed files with 16 additions and 12 deletions
|
|
@ -13,9 +13,6 @@ namespace psemek::ui
|
||||||
{
|
{
|
||||||
assert(!parent_ || !parent);
|
assert(!parent_ || !parent);
|
||||||
|
|
||||||
if (parent && reshape_posted_)
|
|
||||||
parent->post_reshape();
|
|
||||||
|
|
||||||
parent_ = parent;
|
parent_ = parent;
|
||||||
if (loop())
|
if (loop())
|
||||||
post_delayed_callbacks();
|
post_delayed_callbacks();
|
||||||
|
|
@ -189,19 +186,26 @@ namespace psemek::ui
|
||||||
|
|
||||||
void element::post_reshape()
|
void element::post_reshape()
|
||||||
{
|
{
|
||||||
auto r = root();
|
if (auto p = parent())
|
||||||
|
{
|
||||||
|
p->post_reshape();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (r->reshape_posted_)
|
if (reshape_posted_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r->reshape_posted_ = true;
|
if (!loop_)
|
||||||
auto weak_root = r->weak_from_this();
|
return;
|
||||||
post([weak_root]{
|
|
||||||
if (auto root = weak_root.lock())
|
auto weak_self = weak_from_this();
|
||||||
|
|
||||||
|
post([weak_self]{
|
||||||
|
if (auto self = weak_self.lock())
|
||||||
{
|
{
|
||||||
root->reshape_posted_ = false;
|
self->reshape_posted_ = false;
|
||||||
if (!root->parent())
|
if (!self->parent())
|
||||||
root->reshape();
|
self->reshape();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue