diff --git a/Platformio/OmoteUI/core/page/TabView.cpp b/Platformio/OmoteUI/core/page/TabView.cpp index a82fc65..26baf4c 100644 --- a/Platformio/OmoteUI/core/page/TabView.cpp +++ b/Platformio/OmoteUI/core/page/TabView.cpp @@ -4,22 +4,9 @@ using namespace UI::Page; -Tab::Tab(lv_obj_t *aTab, ID aId) : Base(aTab, aId) {} - -void Tab::GiveContent(Page::Base::Ptr aContent) { - mContent = AddElement(std::move(aContent)); -} - -bool Tab::OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { - return mContent->OnKeyEvent(aKeyEvent); -} - -bool Tab::KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { - return mContent->KeyEvent(aKeyEvent); -} - -void Tab::OnShow() { mContent->OnShow(); }; -void Tab::OnHide() { mContent->OnHide(); }; +Tab::Tab(lv_obj_t *aTab, Base::Ptr aContent) : + Base(aTab, aContent->GetID()), + mContent(AddElement(std::move(aContent))) {} /////////////////////TabView///////////////////////////////////// @@ -28,11 +15,10 @@ TabView::TabView(ID aId) LV_DIR_TOP, 0), aId) {} -void TabView::AddTab(Page::Base::Ptr aPage, std::string aTitle) { +void TabView::AddTab(Page::Base::Ptr aPage) { auto tab = std::make_unique( - lv_tabview_add_tab(LvglSelf(), aTitle.c_str()), aPage->GetID()); + lv_tabview_add_tab(LvglSelf(), aPage->GetTitle().c_str()), std::move(aPage)); - tab->GiveContent(std::move(aPage)); mTabs.push_back(std::move(tab)); } diff --git a/Platformio/OmoteUI/core/page/TabView.hpp b/Platformio/OmoteUI/core/page/TabView.hpp index c6f103b..3c1d25a 100644 --- a/Platformio/OmoteUI/core/page/TabView.hpp +++ b/Platformio/OmoteUI/core/page/TabView.hpp @@ -10,25 +10,19 @@ class Tab : public Base { public: typedef std::unique_ptr Ptr; - Tab(lv_obj_t *aTab, ID aId); + Tab(lv_obj_t *aTab, Base::Ptr aContent); - void GiveContent(Page::Base::Ptr aContent); - [[nodiscard]] Base::Ptr TakeContent(); - - bool KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override; - bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override; - - void OnShow() override; - void OnHide() override; + void OnShow() override{mContent->OnShow();}; + void OnHide() override{mContent->OnHide();}; private: - Base *mContent; + Base* mContent; }; class TabView : public Base { public: TabView(ID aId); - void AddTab(Page::Base::Ptr aPage, std::string aTitle); + void AddTab(Page::Base::Ptr aPage); uint16_t GetCurrentTabIdx(); void SetCurrentTabIdx(uint16_t aTabToSetActive, diff --git a/Platformio/OmoteUI/core/screen/HomeScreen.cpp b/Platformio/OmoteUI/core/screen/HomeScreen.cpp index d667a76..1098669 100644 --- a/Platformio/OmoteUI/core/screen/HomeScreen.cpp +++ b/Platformio/OmoteUI/core/screen/HomeScreen.cpp @@ -5,18 +5,17 @@ using namespace UI::Screen; HomeScreen::HomeScreen(std::shared_ptr aHardware) - : Base(UI::ID::Screens::Home), mHardware(aHardware) { - - mTabView = AddElement(std::make_unique( - ID(ID::Pages::INVALID_PAGE_ID))); // Adds Tabview to Homescreen + : Base(UI::ID::Screens::Home), + mTabView( AddElement(std::make_unique( + ID(ID::Pages::INVALID_PAGE_ID)))), + mHardware(aHardware) { SetBgColor(UI::Color::BLACK); SetPushAnimation(LV_SCR_LOAD_ANIM_FADE_IN); // Adds pages to the Tab view - mTabView->AddTab(std::make_unique(aHardware), "Settings"); - mTabView->AddTab(std::make_unique(aHardware), - "Settings1"); + mTabView->AddTab(std::make_unique(aHardware)); + mTabView->AddTab(std::make_unique(aHardware)); } void HomeScreen::SetBgColor(lv_color_t value, lv_style_selector_t selector) { diff --git a/Platformio/platformio.ini b/Platformio/platformio.ini index ece393b..a54539d 100644 --- a/Platformio/platformio.ini +++ b/Platformio/platformio.ini @@ -146,6 +146,7 @@ build_flags = debug_build_flags = -g ;Allow debugging in vscode + -O0 ;No Optomizations lib_deps = ${env.lib_deps}