Remove optimization from debugging because it was causing breakpoints not to hit.

Rework tab and tabView given the new AddElement API
This commit is contained in:
Matthew Colvin 2023-10-11 12:10:57 -05:00
parent 02b664b893
commit 8a34d0220c
4 changed files with 17 additions and 37 deletions

View file

@ -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<Page::Base>(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<Base>(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<Tab>(
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));
}

View file

@ -10,25 +10,19 @@ class Tab : public Base {
public:
typedef std::unique_ptr<Tab> 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,

View file

@ -5,18 +5,17 @@
using namespace UI::Screen;
HomeScreen::HomeScreen(std::shared_ptr<HardwareAbstract> aHardware)
: Base(UI::ID::Screens::Home), mHardware(aHardware) {
mTabView = AddElement<Page::TabView>(std::make_unique<Page::TabView>(
ID(ID::Pages::INVALID_PAGE_ID))); // Adds Tabview to Homescreen
: Base(UI::ID::Screens::Home),
mTabView( AddElement<Page::TabView>(std::make_unique<Page::TabView>(
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<Page::SettingsPage>(aHardware), "Settings");
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware),
"Settings1");
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware));
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware));
}
void HomeScreen::SetBgColor(lv_color_t value, lv_style_selector_t selector) {

View file

@ -146,6 +146,7 @@ build_flags =
debug_build_flags =
-g ;Allow debugging in vscode
-O0 ;No Optomizations
lib_deps =
${env.lib_deps}