switching computers so just commiting
This commit is contained in:
parent
f5b7b7bc5f
commit
7fd53ef2f8
12 changed files with 111 additions and 12 deletions
|
@ -6,6 +6,10 @@ UIElement::UIElement(lv_obj_t *aLvglSelf, ID aId)
|
|||
mLvglSelf->user_data = this;
|
||||
}
|
||||
|
||||
void UIElement::AddElement(UIElement *anUIElement) {
|
||||
lv_obj_set_parent(anUIElement->mLvglSelf, mLvglSelf);
|
||||
}
|
||||
|
||||
bool UIElement::IsVisible() { return lv_obj_is_visible(mLvglSelf); }
|
||||
|
||||
void UIElement::SetVisiblity(bool aVisible) {
|
||||
|
|
|
@ -10,13 +10,15 @@ class UIElement {
|
|||
public:
|
||||
UIElement(lv_obj_t *aLvglSelf, const ID aId = ID());
|
||||
|
||||
void SetBgColor(lv_color_t value,
|
||||
virtual void SetBgColor(lv_color_t value,
|
||||
lv_style_selector_t selector = LV_PART_MAIN);
|
||||
|
||||
void SetVisiblity(bool aVisibility);
|
||||
bool IsVisible();
|
||||
|
||||
lv_obj_t *operator()() { return mLvglSelf; }
|
||||
virtual void AddElement(UIElement *anElement);
|
||||
|
||||
ID GetID() { return mId; };
|
||||
|
||||
protected:
|
||||
/// @brief get Lvgl object refernce to use in LVGL APIs
|
||||
|
|
|
@ -16,9 +16,15 @@ public:
|
|||
INVALID_WIDGET_ID
|
||||
};
|
||||
|
||||
enum class Pages {
|
||||
Settings = static_cast<int>(Widgets::INVALID_WIDGET_ID) + 1,
|
||||
INVALID_PAGE_ID
|
||||
};
|
||||
|
||||
ID() : mId(INVALID){};
|
||||
ID(ID::Screens aScreenId) : mId(static_cast<int>(aScreenId)){};
|
||||
ID(ID::Widgets aWidgetId) : mId(static_cast<int>(aWidgetId)){};
|
||||
ID(ID::Pages aPageId) : mId(static_cast<int>(aPageId)){};
|
||||
|
||||
private:
|
||||
const int mId;
|
||||
|
|
11
Platformio/OmoteUI/core/page/PageBase.cpp
Normal file
11
Platformio/OmoteUI/core/page/PageBase.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "PageBase.hpp"
|
||||
|
||||
using namespace UI::Page;
|
||||
|
||||
Base::Base(ID aID) : UIElement(lv_obj_create(nullptr), aID) {}
|
||||
|
||||
Base::Base(lv_obj_t *aLvglSelf, ID aID) : UIElement(aLvglSelf, aID) {}
|
||||
|
||||
void Base::AddWidget(Widget::Base::Ptr aWidget) {
|
||||
mWidgets.push_back(std::move(aWidget));
|
||||
}
|
24
Platformio/OmoteUI/core/page/PageBase.hpp
Normal file
24
Platformio/OmoteUI/core/page/PageBase.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#include "UIElement.hpp"
|
||||
#include "WidgetBase.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace UI::Page {
|
||||
class Base : public UIElement {
|
||||
public:
|
||||
typedef std::unique_ptr<Base> Ptr;
|
||||
|
||||
Base(ID aID);
|
||||
Base(lv_obj_t *aLvglSelf, ID aID);
|
||||
|
||||
void AddWidget(Widget::Base::Ptr aWidget);
|
||||
|
||||
protected:
|
||||
void OnShow() override{};
|
||||
void OnHide() override{};
|
||||
|
||||
private:
|
||||
std::vector<Widget::Base::Ptr> mWidgets;
|
||||
};
|
||||
} // namespace UI::Page
|
13
Platformio/OmoteUI/core/page/TabView.cpp
Normal file
13
Platformio/OmoteUI/core/page/TabView.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "TabView.hpp"
|
||||
|
||||
using namespace UI::Page;
|
||||
|
||||
TabView::TabView(ID aId)
|
||||
: Base(lv_tabview_create(nullptr, LV_DIR_TOP, 0), aId) {}
|
||||
|
||||
void TabView::AddTab(Page::Base::Ptr aPage) {
|
||||
auto tab = std::make_unique<Base>(lv_tabview_add_tab(LvglSelf(), "fake"),
|
||||
aPage->GetID());
|
||||
tab->AddElement(aPage.get());
|
||||
mTabs.push_back(std::move(tab));
|
||||
}
|
18
Platformio/OmoteUI/core/page/TabView.hpp
Normal file
18
Platformio/OmoteUI/core/page/TabView.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "PageBase.hpp"
|
||||
|
||||
namespace UI::Page {
|
||||
|
||||
class TabView : public Base {
|
||||
public:
|
||||
TabView(ID aId);
|
||||
void AddTab(Page::Base::Ptr aPage);
|
||||
|
||||
protected:
|
||||
void OnShow() {}
|
||||
void OnHide() {}
|
||||
|
||||
private:
|
||||
std::vector<Page::Base::Ptr> mTabs;
|
||||
};
|
||||
|
||||
} // namespace UI::Page
|
|
@ -2,7 +2,21 @@
|
|||
|
||||
using namespace UI::Screen;
|
||||
|
||||
HomeScreen::HomeScreen() : Base(UI::ID::Screens::Home) {
|
||||
HomeScreen::HomeScreen()
|
||||
: Base(UI::ID::Screens::Home), mMyTabView(ID(ID::Pages::INVALID_PAGE_ID)),
|
||||
mTabView(nullptr) {
|
||||
AddElement(&mMyTabView);
|
||||
mMyTabView.SetBgColor(lv_color_black());
|
||||
SetBgColor(lv_color_white());
|
||||
SetPushAnimation(LV_SCR_LOAD_ANIM_FADE_IN);
|
||||
}
|
||||
|
||||
// void HomeScreen::SetBgColor(lv_color_t value, lv_style_selector_t selector) {
|
||||
// mTabView.SetBgColor(value, selector);
|
||||
// UI::UIElement::SetBgColor(value, selector);
|
||||
// }
|
||||
|
||||
void HomeScreen::AddPage(Page::Base::Ptr aPage) {
|
||||
// mTabView.AddElement(aPage.get());
|
||||
mPages.push_back(std::move(aPage));
|
||||
}
|
|
@ -1,11 +1,22 @@
|
|||
#pragma once
|
||||
#include "PageBase.hpp"
|
||||
#include "ScreenBase.hpp"
|
||||
|
||||
#include "TabView.hpp"
|
||||
namespace UI::Screen {
|
||||
|
||||
class HomeScreen : public Base {
|
||||
public:
|
||||
HomeScreen();
|
||||
|
||||
// void SetBgColor(lv_color_t value,
|
||||
// lv_style_selector_t selector = LV_PART_MAIN) override;
|
||||
|
||||
void AddPage(Page::Base::Ptr aPage);
|
||||
|
||||
private:
|
||||
Page::TabView mMyTabView;
|
||||
lv_obj_t *mTabView;
|
||||
std::vector<Page::Base::Ptr> mPages;
|
||||
};
|
||||
|
||||
} // namespace UI::Screen
|
|
@ -4,9 +4,6 @@ using namespace UI::Screen;
|
|||
|
||||
Base::Base(ID aId) : UIElement(lv_obj_create(NULL), aId) {}
|
||||
|
||||
void Base::AddWidget(Widget::Base::Ptr aWidget) {
|
||||
mWidgets.push_back(std::move(aWidget));
|
||||
}
|
||||
|
||||
void Base::Show() {
|
||||
lv_scr_load_anim(LvglSelf(), mPushAnimation, 1000, 1000, false);
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "lvgl.h"
|
||||
|
||||
#include "UIElement.hpp"
|
||||
#include "WidgetBase.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace UI::Screen {
|
||||
class Manager;
|
||||
|
||||
|
@ -17,7 +17,6 @@ public:
|
|||
|
||||
Base(ID aId);
|
||||
|
||||
void AddWidget(Widget::Base::Ptr aWidget);
|
||||
void SetPushAnimation(lv_scr_load_anim_t aPushAnimation);
|
||||
|
||||
protected:
|
||||
|
@ -26,7 +25,6 @@ protected:
|
|||
void OnHide() override{};
|
||||
|
||||
private:
|
||||
std::vector<Widget::Base::Ptr> mWidgets;
|
||||
lv_scr_load_anim_t mPushAnimation = LV_SCR_LOAD_ANIM_NONE;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ build_flags =
|
|||
-I OmoteUI/core/interfaces
|
||||
-I OmoteUI/core/screen
|
||||
-I OmoteUI/core/widget
|
||||
-I OmoteUI/core/page
|
||||
-I OmoteUI/UIs
|
||||
-I OmoteUI/UIs/Basic
|
||||
-I OmoteUI/UIs/BasicRefactored
|
||||
|
|
Loading…
Add table
Reference in a new issue