push Display settings page on a tem button press

This commit is contained in:
MatthewColvin 2023-10-07 19:54:05 -05:00
parent 235d8e043f
commit f9dd87fbe7
7 changed files with 44 additions and 2 deletions

View file

@ -1,4 +1,5 @@
#include "ScreenManager.hpp"
#include "PopUpScreen.hpp"
using namespace UI::Screen;
@ -19,6 +20,12 @@ void Manager::pushScreen(Screen::Base::Ptr aScreen) {
mScreens.top()->Show();
}
void Manager::pushPopUp(Page::Base::Ptr aPopUpPage,
lv_scr_load_anim_t aPushAnimation) {
pushScreen(std::make_unique<PopUpScreen>(std::move(aPopUpPage)),
aPushAnimation);
}
bool Manager::distributeKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) {
// Send Key Even to top Screen for handling
return mScreens.top()->KeyEvent(aKeyEvent);

View file

@ -1,5 +1,6 @@
#pragma once
#include "PageBase.hpp"
#include "ScreenBase.hpp"
#include <memory>
#include <stack>
@ -11,7 +12,12 @@ public:
static Manager &getInstance();
void pushScreen(Screen::Base::Ptr aScreen);
void pushScreen(Screen::Base::Ptr aScreen, lv_scr_load_anim_t aPushAnimation);
void pushScreen(Screen::Base::Ptr aScreen,
lv_scr_load_anim_t aPushAnimationOverride);
void
pushPopUp(UI::Page::Base::Ptr aPopUpPage,
lv_scr_load_anim_t aPushAnimation = LV_SCR_LOAD_ANIM_OVER_LEFT);
bool distributeKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent);

View file

@ -20,6 +20,7 @@ public:
enum class Pages {
Settings = static_cast<int>(Widgets::INVALID_WIDGET_ID) + 1,
DisplaySettings,
INVALID_PAGE_ID
};

View file

@ -0,0 +1,6 @@
#include "DisplaySettings.hpp"
using namespace UI::Page;
DisplaySettings::DisplaySettings(std::shared_ptr<DisplayAbstract> aDisplay)
: Base(UI::ID::Pages::DisplaySettings), mDisplay(aDisplay) {}

View file

@ -0,0 +1,13 @@
#pragma once
#include "DisplayAbstract.h"
#include "PageBase.hpp"
namespace UI::Page {
class DisplaySettings : public Base {
public:
DisplaySettings(std::shared_ptr<DisplayAbstract> aDisplay);
private:
std::shared_ptr<DisplayAbstract> mDisplay;
};
} // namespace UI::Page

View file

@ -1,13 +1,16 @@
#include "SettingsPage.hpp"
#include "BackgroundScreen.hpp"
#include "Button.hpp"
#include "DisplaySettings.hpp"
#include "PopUpScreen.hpp"
#include "ScreenManager.hpp"
using namespace UI::Page;
SettingsPage::SettingsPage(std::shared_ptr<HardwareAbstract> aHardware)
: Base(ID::Pages::Settings), mHardware(aHardware) {
SetBgColor(lv_color_make(255, 0, 0));
auto button = std::make_unique<UI::Widget::Button>([this] { AddSlider(); });
auto button = std::make_unique<UI::Widget::Button>([this] { PushDisplaySettings(); });
button->SetY(0);
button->SetHeight(lv_pct(10));
button->SetWidth(lv_pct(10));
@ -17,6 +20,11 @@ SettingsPage::SettingsPage(std::shared_ptr<HardwareAbstract> aHardware)
void SettingsPage::OnShow() {}
void SettingsPage::PushDisplaySettings() {
UI::Screen::Manager::getInstance().pushPopUp(
std::make_unique<DisplaySettings>(mHardware->display()));
}
void SettingsPage::AddSlider() {
auto fakeSlider = std::make_unique<UI::Widget::Base>(
lv_slider_create(UI::Screen::BackgroundScreen::getLvInstance()));

View file

@ -9,6 +9,7 @@ public:
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override;
void AddSlider();
void PushDisplaySettings();
protected:
void OnShow() override;