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:
parent
02b664b893
commit
8a34d0220c
4 changed files with 17 additions and 37 deletions
|
@ -4,22 +4,9 @@
|
||||||
|
|
||||||
using namespace UI::Page;
|
using namespace UI::Page;
|
||||||
|
|
||||||
Tab::Tab(lv_obj_t *aTab, ID aId) : Base(aTab, aId) {}
|
Tab::Tab(lv_obj_t *aTab, Base::Ptr aContent) :
|
||||||
|
Base(aTab, aContent->GetID()),
|
||||||
void Tab::GiveContent(Page::Base::Ptr aContent) {
|
mContent(AddElement<Base>(std::move(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(); };
|
|
||||||
|
|
||||||
/////////////////////TabView/////////////////////////////////////
|
/////////////////////TabView/////////////////////////////////////
|
||||||
|
|
||||||
|
@ -28,11 +15,10 @@ TabView::TabView(ID aId)
|
||||||
LV_DIR_TOP, 0),
|
LV_DIR_TOP, 0),
|
||||||
aId) {}
|
aId) {}
|
||||||
|
|
||||||
void TabView::AddTab(Page::Base::Ptr aPage, std::string aTitle) {
|
void TabView::AddTab(Page::Base::Ptr aPage) {
|
||||||
auto tab = std::make_unique<Tab>(
|
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));
|
mTabs.push_back(std::move(tab));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,25 +10,19 @@ class Tab : public Base {
|
||||||
public:
|
public:
|
||||||
typedef std::unique_ptr<Tab> Ptr;
|
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);
|
void OnShow() override{mContent->OnShow();};
|
||||||
[[nodiscard]] Base::Ptr TakeContent();
|
void OnHide() override{mContent->OnHide();};
|
||||||
|
|
||||||
bool KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override;
|
|
||||||
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override;
|
|
||||||
|
|
||||||
void OnShow() override;
|
|
||||||
void OnHide() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base *mContent;
|
Base* mContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TabView : public Base {
|
class TabView : public Base {
|
||||||
public:
|
public:
|
||||||
TabView(ID aId);
|
TabView(ID aId);
|
||||||
void AddTab(Page::Base::Ptr aPage, std::string aTitle);
|
void AddTab(Page::Base::Ptr aPage);
|
||||||
|
|
||||||
uint16_t GetCurrentTabIdx();
|
uint16_t GetCurrentTabIdx();
|
||||||
void SetCurrentTabIdx(uint16_t aTabToSetActive,
|
void SetCurrentTabIdx(uint16_t aTabToSetActive,
|
||||||
|
|
|
@ -5,18 +5,17 @@
|
||||||
using namespace UI::Screen;
|
using namespace UI::Screen;
|
||||||
|
|
||||||
HomeScreen::HomeScreen(std::shared_ptr<HardwareAbstract> aHardware)
|
HomeScreen::HomeScreen(std::shared_ptr<HardwareAbstract> aHardware)
|
||||||
: Base(UI::ID::Screens::Home), mHardware(aHardware) {
|
: Base(UI::ID::Screens::Home),
|
||||||
|
mTabView( AddElement<Page::TabView>(std::make_unique<Page::TabView>(
|
||||||
mTabView = AddElement<Page::TabView>(std::make_unique<Page::TabView>(
|
ID(ID::Pages::INVALID_PAGE_ID)))),
|
||||||
ID(ID::Pages::INVALID_PAGE_ID))); // Adds Tabview to Homescreen
|
mHardware(aHardware) {
|
||||||
|
|
||||||
SetBgColor(UI::Color::BLACK);
|
SetBgColor(UI::Color::BLACK);
|
||||||
SetPushAnimation(LV_SCR_LOAD_ANIM_FADE_IN);
|
SetPushAnimation(LV_SCR_LOAD_ANIM_FADE_IN);
|
||||||
|
|
||||||
// Adds pages to the Tab view
|
// Adds pages to the Tab view
|
||||||
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware), "Settings");
|
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware));
|
||||||
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware),
|
mTabView->AddTab(std::make_unique<Page::SettingsPage>(aHardware));
|
||||||
"Settings1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomeScreen::SetBgColor(lv_color_t value, lv_style_selector_t selector) {
|
void HomeScreen::SetBgColor(lv_color_t value, lv_style_selector_t selector) {
|
||||||
|
|
|
@ -146,6 +146,7 @@ build_flags =
|
||||||
|
|
||||||
debug_build_flags =
|
debug_build_flags =
|
||||||
-g ;Allow debugging in vscode
|
-g ;Allow debugging in vscode
|
||||||
|
-O0 ;No Optomizations
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
|
Loading…
Add table
Reference in a new issue