Add base UIElement class and extend widget and screen
This commit is contained in:
parent
5cb4c1408d
commit
f5ba2e9b84
6 changed files with 44 additions and 15 deletions
12
Platformio/OmoteUI/core/UIElement.cpp
Normal file
12
Platformio/OmoteUI/core/UIElement.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "UIElement.hpp"
|
||||
|
||||
namespace UI
|
||||
{
|
||||
UIElement::UIElement(lv_obj_t* aLvglSelf, uint16_t aId):
|
||||
mLvglSelf(aLvglSelf),
|
||||
mId(aId)
|
||||
{
|
||||
mLvglSelf->user_data = this;
|
||||
}
|
||||
|
||||
} // namespace UI
|
16
Platformio/OmoteUI/core/UIElement.hpp
Normal file
16
Platformio/OmoteUI/core/UIElement.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace UI{
|
||||
|
||||
class UIElement{
|
||||
|
||||
public:
|
||||
UIElement(lv_obj_t* aLvglSelf, uint16_t aId = 0);
|
||||
|
||||
protected:
|
||||
lv_obj_t* mLvglSelf;
|
||||
uint16_t mId;
|
||||
};
|
||||
}
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
using namespace UI::Screen;
|
||||
|
||||
Base::Base(){
|
||||
|
||||
Base::Base(uint16_t aId) : UIElement(mScreen, aId),
|
||||
mScreen(lv_obj_create(NULL))
|
||||
{
|
||||
}
|
||||
|
||||
void Base::AddWidget(Widget::Base::Ptr aWidget){
|
||||
void Base::AddWidget(Widget::Base::Ptr aWidget)
|
||||
{
|
||||
mWidgets.push_back(std::move(aWidget));
|
||||
}
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#include "UIElement.hpp"
|
||||
#include "WidgetBase.hpp"
|
||||
|
||||
#include <vector>
|
||||
namespace UI::Screen{
|
||||
|
||||
class Base {
|
||||
class Base : UIElement {
|
||||
public:
|
||||
typedef std::unique_ptr<Base> Ptr;
|
||||
|
||||
Base();
|
||||
Base(uint16_t aId = 0);
|
||||
|
||||
void AddWidget(Widget::Base::Ptr aWidget);
|
||||
|
||||
private:
|
||||
lv_obj_t *mScreen;
|
||||
std::vector<Widget::Base::Ptr> mWidgets;
|
||||
lv_obj_t *mScreen = lv_obj_create(NULL);
|
||||
};
|
||||
|
||||
}
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
namespace UI::Widget{
|
||||
|
||||
Base::Base(lv_obj_t* aLvglSelf):
|
||||
mLvglSelf(aLvglSelf)
|
||||
{
|
||||
mLvglSelf->user_data = this;
|
||||
}
|
||||
Base::Base(lv_obj_t* aLvglSelf) : UIElement(aLvglSelf){}
|
||||
|
||||
|
||||
}
|
|
@ -1,18 +1,17 @@
|
|||
#include "lvgl.h"
|
||||
#pragma once
|
||||
|
||||
#include "UIElement.hpp"
|
||||
#include <memory>
|
||||
namespace UI::Widget{
|
||||
|
||||
class Base{
|
||||
class Base : public UIElement{
|
||||
public:
|
||||
typedef std::unique_ptr<Base> Ptr;
|
||||
|
||||
Base(lv_obj_t* aLvglSelf);
|
||||
|
||||
private:
|
||||
lv_obj_t* mLvglSelf;
|
||||
|
||||
uint16_t mId;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue