diff --git a/Platformio/OmoteUI/core/UIElement.cpp b/Platformio/OmoteUI/core/UIElement.cpp index e79b966..6ba472a 100644 --- a/Platformio/OmoteUI/core/UIElement.cpp +++ b/Platformio/OmoteUI/core/UIElement.cpp @@ -217,6 +217,9 @@ void UIElement::SetBgColor(lv_color_t aColor, lv_style_selector_t aStyle) { }; void UIElement::Show() { + if (IsVisible()) { + return; + } { auto lock = LvglResourceManger::GetInstance().scopeLock(); lv_obj_clear_flag(mLvglSelf, LV_OBJ_FLAG_HIDDEN); @@ -225,7 +228,9 @@ void UIElement::Show() { } void UIElement::Hide() { - + if (!IsVisible()) { + return; + } { auto lock = LvglResourceManger::GetInstance().scopeLock(); lv_obj_add_flag(mLvglSelf, LV_OBJ_FLAG_HIDDEN); diff --git a/Platformio/OmoteUI/core/page/PageBase.cpp b/Platformio/OmoteUI/core/page/PageBase.cpp index d7dec5e..49693e5 100644 --- a/Platformio/OmoteUI/core/page/PageBase.cpp +++ b/Platformio/OmoteUI/core/page/PageBase.cpp @@ -44,4 +44,20 @@ bool Base::KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { return false; }; -bool Base::OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { return false; }; \ No newline at end of file +bool Base::OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { return false; }; + +void Base::OnShow() { + for (auto &widget : mWidgets) { + if (widget->IsVisible()) { + widget->OnShow(); + } + } +}; + +void Base::OnHide() { + for (auto &widget : mWidgets) { + if (widget->IsVisible()) { + widget->OnHide(); + } + } +}; \ No newline at end of file diff --git a/Platformio/OmoteUI/core/page/PageBase.hpp b/Platformio/OmoteUI/core/page/PageBase.hpp index ad86d7d..aab10f2 100644 --- a/Platformio/OmoteUI/core/page/PageBase.hpp +++ b/Platformio/OmoteUI/core/page/PageBase.hpp @@ -11,6 +11,7 @@ namespace UI::Page { class Tab; class TabView; class Base : public UIElement { + // Classes that Own Pages friend Tab; // Allow Tab to Forward all Key Events to its page friend TabView; // Allow Tab view to call OnShow and OnHide Since it can show // and Hide pages by swiping @@ -34,8 +35,11 @@ public: virtual std::string GetTitle() { return ""; }; protected: - void OnShow() override{}; - void OnHide() override{}; + /// @brief Forward To widgets that are visible + void OnShow() override; + + /// @brief Forward To widgets that are visible + void OnHide() override; bool KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override; bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override; diff --git a/Platformio/OmoteUI/core/screen/PopUpScreen.cpp b/Platformio/OmoteUI/core/screen/PopUpScreen.cpp index ff0b94d..6e108d2 100644 --- a/Platformio/OmoteUI/core/screen/PopUpScreen.cpp +++ b/Platformio/OmoteUI/core/screen/PopUpScreen.cpp @@ -33,5 +33,13 @@ bool PopUpScreen::OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { return mContentPage->OnKeyEvent(aKeyEvent); } -void PopUpScreen::OnShow() { mContentPage->OnShow(); }; -void PopUpScreen::OnHide() { mContentPage->OnHide(); }; \ No newline at end of file +void PopUpScreen::OnShow() { + mContentPage->OnShow(); + mExitButton->OnShow(); + mTitle->OnShow(); +}; +void PopUpScreen::OnHide() { + mContentPage->OnHide(); + mExitButton->OnHide(); + mTitle->OnHide(); +}; \ No newline at end of file diff --git a/Platformio/OmoteUI/core/widget/WidgetBase.hpp b/Platformio/OmoteUI/core/widget/WidgetBase.hpp index a7eeb8d..4b0e988 100644 --- a/Platformio/OmoteUI/core/widget/WidgetBase.hpp +++ b/Platformio/OmoteUI/core/widget/WidgetBase.hpp @@ -3,15 +3,21 @@ #include "UIElement.hpp" #include -namespace UI::Page { +namespace UI { +namespace Page { class Base; } +namespace Screen { +class PopUpScreen; +} +} // namespace UI namespace UI::Widget { class Base : public UIElement { - + // Classes that Own Widgets friend class UI::Page::Base; + friend class UI::Screen::PopUpScreen; public: typedef std::unique_ptr Ptr;