Add background color setter in UIElement
Use main to spawn refacoredBasic UI Start using new screen manager and screen concepts
This commit is contained in:
parent
6a4aa9a35c
commit
52cb2e7ce2
12 changed files with 55 additions and 15 deletions
11
Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.cpp
Normal file
11
Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "BasicUI.hpp"
|
||||
#include "HomeScreen.hpp"
|
||||
#include "ScreenManager.hpp"
|
||||
|
||||
using namespace UI;
|
||||
|
||||
BasicUI::BasicUI(std::shared_ptr<HardwareAbstract> aHardware)
|
||||
: UIBase(aHardware) {
|
||||
Screen::Manager::getInstance().pushScreen(
|
||||
std::make_unique<Screen::HomeScreen>());
|
||||
}
|
11
Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.hpp
Normal file
11
Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.hpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
#include "UIBase.hpp"
|
||||
|
||||
namespace UI {
|
||||
|
||||
class BasicUI : public UIBase {
|
||||
public:
|
||||
BasicUI(std::shared_ptr<HardwareAbstract> aHardware);
|
||||
};
|
||||
|
||||
} // namespace UI
|
|
@ -3,4 +3,9 @@
|
|||
using namespace UI;
|
||||
|
||||
UIBase::UIBase(std::shared_ptr<HardwareAbstract> aHardware)
|
||||
: mHardware(aHardware) {}
|
||||
: mHardware(aHardware) {}
|
||||
|
||||
void UIBase::loopHandler() {
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
}
|
|
@ -11,6 +11,8 @@ class UIBase {
|
|||
public:
|
||||
UIBase(std::shared_ptr<HardwareAbstract> aHardware);
|
||||
|
||||
void loopHandler();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<HardwareAbstract> mHardware;
|
||||
};
|
||||
|
|
|
@ -6,4 +6,8 @@ UIElement::UIElement(lv_obj_t *aLvglSelf, ID aId)
|
|||
mLvglSelf->user_data = this;
|
||||
}
|
||||
|
||||
UIElement::SetBgColor(lv_color_t aColor, lv_style_selector_t aStyle) {
|
||||
lv_obj_set_style_bg_color(mLvglSelf, aColor, aStyle);
|
||||
};
|
||||
|
||||
} // namespace UI
|
||||
|
|
|
@ -10,6 +10,8 @@ class UIElement {
|
|||
public:
|
||||
UIElement(lv_obj_t *aLvglSelf, const ID aId = ID());
|
||||
|
||||
SetBgColor(lv_color_t value, lv_style_selector_t selector = LV_PART_MAIN);
|
||||
|
||||
protected:
|
||||
lv_obj_t *mLvglSelf;
|
||||
const ID mId;
|
||||
|
|
|
@ -2,4 +2,7 @@
|
|||
|
||||
using namespace UI::Screen;
|
||||
|
||||
HomeScreen::HomeScreen() : Base(UI::ID::Screens::Home) {}
|
||||
HomeScreen::HomeScreen() : Base(UI::ID::Screens::Home) {
|
||||
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
namespace UI::Screen {
|
||||
|
||||
class HomeScreen : public Base {
|
||||
public:
|
||||
HomeScreen();
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using namespace UI::Screen;
|
||||
|
||||
Base::Base(ID aId) : UIElement(mScreen, aId), mScreen(lv_obj_create(NULL)) {}
|
||||
Base::Base(ID aId) : UIElement(lv_obj_create(NULL), aId) {}
|
||||
|
||||
void Base::AddWidget(Widget::Base::Ptr aWidget) {
|
||||
mWidgets.push_back(std::move(aWidget));
|
||||
|
|
|
@ -17,7 +17,6 @@ public:
|
|||
void AddWidget(Widget::Base::Ptr aWidget);
|
||||
|
||||
private:
|
||||
lv_obj_t *mScreen;
|
||||
std::vector<Widget::Base::Ptr> mWidgets;
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ build_flags =
|
|||
-I OmoteUI/core/widget
|
||||
-I OmoteUI/UIs
|
||||
-I OmoteUI/UIs/Basic
|
||||
-I OmoteUI/UIs/BasicRefactored
|
||||
-I HAL
|
||||
-I HAL/HardwareModules
|
||||
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#include "HardwareSimulator.hpp"
|
||||
#include "omoteconfig.h"
|
||||
#include "BasicUI.hpp"
|
||||
#include "HardwareSimulator.hpp"
|
||||
#include "OmoteUI.hpp"
|
||||
#include <memory>
|
||||
#include "omoteconfig.h"
|
||||
#include <memory>
|
||||
|
||||
int main(){
|
||||
auto hwSim = std::make_shared<HardwareSimulator>();
|
||||
hwSim->init();
|
||||
int main() {
|
||||
auto hwSim = std::make_shared<HardwareSimulator>();
|
||||
hwSim->init();
|
||||
|
||||
auto ui = UI::Basic::OmoteUI::getInstance(hwSim);
|
||||
ui->layout_UI();
|
||||
auto ui = UI::BasicUI(hwSim);
|
||||
// ui->layout_UI();
|
||||
|
||||
while (true){
|
||||
ui->loopHandler();
|
||||
}
|
||||
while (true) {
|
||||
ui.loopHandler();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue