From 8e5154fd83e42583558f0804e0ec067ed0692d91 Mon Sep 17 00:00:00 2001 From: MatthewColvin Date: Thu, 19 Oct 2023 12:21:30 -0500 Subject: [PATCH] Fix bug in which OnShow was not being called when pages were pushed or when elements were added to existing page --- Platformio/OmoteUI/core/UIElement.cpp | 5 ++++- Platformio/OmoteUI/core/screen/ScreenBase.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Platformio/OmoteUI/core/UIElement.cpp b/Platformio/OmoteUI/core/UIElement.cpp index b94b5c6..8d9a30d 100644 --- a/Platformio/OmoteUI/core/UIElement.cpp +++ b/Platformio/OmoteUI/core/UIElement.cpp @@ -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(); } } diff --git a/Platformio/OmoteUI/core/screen/ScreenBase.cpp b/Platformio/OmoteUI/core/screen/ScreenBase.cpp index 9ba00c3..ca12cf9 100644 --- a/Platformio/OmoteUI/core/screen/ScreenBase.cpp +++ b/Platformio/OmoteUI/core/screen/ScreenBase.cpp @@ -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) {