boiler plate code for Pop up Screen to UI to allow for quick way to launch pages.
This will be huge for RAM saving as the page will de alloc when closed.
This commit is contained in:
parent
6343a48be1
commit
a11b78c540
4 changed files with 39 additions and 0 deletions
|
@ -9,6 +9,7 @@ public:
|
|||
enum class Screens {
|
||||
Background = static_cast<int>(INVALID) + 1,
|
||||
Home,
|
||||
PopUp,
|
||||
INVALID_SCREEN_ID
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
#include "WidgetBase.hpp"
|
||||
|
||||
#include <vector>
|
||||
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<Base> Ptr;
|
||||
|
||||
|
|
14
Platformio/OmoteUI/core/screen/PopUpScreen.cpp
Normal file
14
Platformio/OmoteUI/core/screen/PopUpScreen.cpp
Normal file
|
@ -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);
|
||||
}
|
18
Platformio/OmoteUI/core/screen/PopUpScreen.hpp
Normal file
18
Platformio/OmoteUI/core/screen/PopUpScreen.hpp
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue