Fix bug in which OnShow was not being called when pages were pushed or when elements were added to existing page

This commit is contained in:
MatthewColvin 2023-10-19 12:21:30 -05:00
parent 5a383629db
commit 8e5154fd83
2 changed files with 5 additions and 2 deletions

View file

@ -38,6 +38,9 @@ UIElement *UIElement::AddElement(UIElement::Ptr anUIElement) {
auto lock = LvglResourceManager::GetInstance().scopeLock();
lv_obj_set_parent(anUIElement->mLvglSelf, mLvglSelf);
anUIElement->OnAdded(this);
if (IsVisible() && anUIElement->IsSetVisible()) {
anUIElement->OnShow();
}
mContainedElements.push_back(std::move(anUIElement));
return mContainedElements[mContainedElements.size() - 1].get();
}
@ -314,7 +317,7 @@ void UIElement::OnHide() {
void UIElement::OnShow() {
for (auto &elem : mContainedElements) {
if (!lv_obj_has_flag(mLvglSelf, LV_OBJ_FLAG_HIDDEN)) {
if (IsSetVisible()) {
elem->OnShow();
}
}

View file

@ -7,7 +7,7 @@ Base::Base(ID aId) : UIElement(lv_obj_create(NULL), aId) {}
void Base::Show() {
lv_scr_load_anim(LvglSelf(), mPushAnimation, mTransitionAnimationTime,
mTransitionDelayTime, false);
UIElement::Show();
UIElement::OnShow();
}
void Base::SetPushAnimation(lv_scr_load_anim_t aShowAnimation) {