diff --git a/Platformio/OmoteUI/core/UIElementIds.hpp b/Platformio/OmoteUI/core/UIElementIds.hpp index 07045e8..35b935c 100644 --- a/Platformio/OmoteUI/core/UIElementIds.hpp +++ b/Platformio/OmoteUI/core/UIElementIds.hpp @@ -9,6 +9,7 @@ public: enum class Screens { Background = static_cast(INVALID) + 1, Home, + PopUp, INVALID_SCREEN_ID }; diff --git a/Platformio/OmoteUI/core/page/PageBase.hpp b/Platformio/OmoteUI/core/page/PageBase.hpp index fc9ee6e..7167ec3 100644 --- a/Platformio/OmoteUI/core/page/PageBase.hpp +++ b/Platformio/OmoteUI/core/page/PageBase.hpp @@ -3,6 +3,9 @@ #include "WidgetBase.hpp" #include +namespace UI::Screen { +class PopUpScreen; +} namespace UI::Page { class Tab; class TabView; @@ -10,6 +13,9 @@ class Base : public UIElement { 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 + friend UI::Screen::PopUpScreen; // Allow Pop up Screens pass events to the + // page it owns + public: typedef std::unique_ptr Ptr; diff --git a/Platformio/OmoteUI/core/screen/PopUpScreen.cpp b/Platformio/OmoteUI/core/screen/PopUpScreen.cpp new file mode 100644 index 0000000..9f2918b --- /dev/null +++ b/Platformio/OmoteUI/core/screen/PopUpScreen.cpp @@ -0,0 +1,14 @@ +#include "PopUpScreen.hpp" + +using namespace UI; +using namespace UI::Screen; + +PopUpScreen::PopUpScreen(Page::Base::Ptr aPage) + : Screen::Base(UI::ID::Screens::PopUp), mContentPage(std::move(aPage)) { + + AddElement(mContentPage.get()); +} + +bool PopUpScreen::OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { + return mContentPage->OnKeyEvent(aKeyEvent); +} \ No newline at end of file diff --git a/Platformio/OmoteUI/core/screen/PopUpScreen.hpp b/Platformio/OmoteUI/core/screen/PopUpScreen.hpp new file mode 100644 index 0000000..f018bf2 --- /dev/null +++ b/Platformio/OmoteUI/core/screen/PopUpScreen.hpp @@ -0,0 +1,18 @@ +#pragma once +#include "PageBase.hpp" +#include "ScreenBase.hpp" +namespace UI::Screen { + +/// @brief A Screen that allows easy display of a page that +/// can be dismissed easily by an x +class PopUpScreen : public Base { +public: + PopUpScreen(UI::Page::Base::Ptr aPage); + + bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override; + +private: + UI::Page::Base::Ptr mContentPage; +}; + +} // namespace UI::Screen \ No newline at end of file