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);
|
||||
|
||||
if (parent && reshape_posted_)
|
||||
parent->post_reshape();
|
||||
|
||||
parent_ = parent;
|
||||
if (loop())
|
||||
post_delayed_callbacks();
|
||||
|
|
@ -189,19 +186,26 @@ namespace psemek::ui
|
|||
|
||||
void element::post_reshape()
|
||||
{
|
||||
auto r = root();
|
||||
if (auto p = parent())
|
||||
{
|
||||
p->post_reshape();
|
||||
return;
|
||||
}
|
||||
|
||||
if (r->reshape_posted_)
|
||||
if (reshape_posted_)
|
||||
return;
|
||||
|
||||
r->reshape_posted_ = true;
|
||||
auto weak_root = r->weak_from_this();
|
||||
post([weak_root]{
|
||||
if (auto root = weak_root.lock())
|
||||
if (!loop_)
|
||||
return;
|
||||
|
||||
auto weak_self = weak_from_this();
|
||||
|
||||
post([weak_self]{
|
||||
if (auto self = weak_self.lock())
|
||||
{
|
||||
root->reshape_posted_ = false;
|
||||
if (!root->parent())
|
||||
root->reshape();
|
||||
self->reshape_posted_ = false;
|
||||
if (!self->parent())
|
||||
self->reshape();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue