diff --git a/Platformio/OmoteUI/core/page/PageBase.cpp b/Platformio/OmoteUI/core/page/PageBase.cpp index b9bf568..d7dec5e 100644 --- a/Platformio/OmoteUI/core/page/PageBase.cpp +++ b/Platformio/OmoteUI/core/page/PageBase.cpp @@ -9,7 +9,7 @@ Base::Base(ID aID) Base::Base(lv_obj_t *aLvglSelf, ID aID) : UIElement(aLvglSelf, aID) { SetHeight(lv_pct(100)); SetWidth(lv_pct(100)); - lv_obj_set_align(aLvglSelf, LV_ALIGN_CENTER); + SetPadding(Padding()); // Set Padding to default } // Return non owning refrence to widget UI::Widget::Base *Base::AddWidget(Widget::Base::Ptr aWidget) { diff --git a/Platformio/OmoteUI/core/page/TabView.cpp b/Platformio/OmoteUI/core/page/TabView.cpp index 417410f..6a7a5e3 100644 --- a/Platformio/OmoteUI/core/page/TabView.cpp +++ b/Platformio/OmoteUI/core/page/TabView.cpp @@ -29,10 +29,7 @@ void Tab::OnHide() { mContent->OnHide(); }; TabView::TabView(ID aId) : Base(lv_tabview_create(Screen::BackgroundScreen::getLvInstance(), LV_DIR_TOP, 0), - aId) { - lv_obj_add_event_cb(LvglSelf(), HandleTabChangeImpl, LV_EVENT_VALUE_CHANGED, - nullptr); -} + aId) {} void TabView::AddTab(Page::Base::Ptr aPage, std::string aTitle) { auto tab = std::make_unique( @@ -64,17 +61,15 @@ void TabView::HandleTabChange() { } } -void TabView::HandleTabChangeImpl(lv_event_t *aTabChangeEvent) { - auto self = - UIElement::GetElement(lv_event_get_target(aTabChangeEvent)); - if (self) { - self->HandleTabChange(); - } -} - bool TabView::KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) { if (OnKeyEvent(aKeyEvent)) { return true; } return mTabs[GetCurrentTabIdx()]->KeyEvent(aKeyEvent); }; + +void TabView::OnLvglEvent(lv_event_t *anEvent) { + if (anEvent->code == LV_EVENT_VALUE_CHANGED) { + HandleTabChange(); + } +} \ No newline at end of file diff --git a/Platformio/OmoteUI/core/page/TabView.hpp b/Platformio/OmoteUI/core/page/TabView.hpp index 28adb4a..0c54ccd 100644 --- a/Platformio/OmoteUI/core/page/TabView.hpp +++ b/Platformio/OmoteUI/core/page/TabView.hpp @@ -37,12 +37,12 @@ public: bool KeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override; protected: - void OnShow() {} - void OnHide() {} + void OnLvglEvent(lv_event_t *anEvent) override; + void OnShow() override {} + void OnHide() override {} private: void HandleTabChange(); - static void HandleTabChangeImpl(lv_event_t *aTabChangeEvent); std::vector mTabs; };