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) {