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;
|
using namespace UI;
|
||||||
|
|
||||||
UIBase::UIBase(std::shared_ptr<HardwareAbstract> aHardware)
|
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:
|
public:
|
||||||
UIBase(std::shared_ptr<HardwareAbstract> aHardware);
|
UIBase(std::shared_ptr<HardwareAbstract> aHardware);
|
||||||
|
|
||||||
|
void loopHandler();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<HardwareAbstract> mHardware;
|
std::shared_ptr<HardwareAbstract> mHardware;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,4 +6,8 @@ UIElement::UIElement(lv_obj_t *aLvglSelf, ID aId)
|
||||||
mLvglSelf->user_data = this;
|
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
|
} // namespace UI
|
||||||
|
|
|
@ -10,6 +10,8 @@ class UIElement {
|
||||||
public:
|
public:
|
||||||
UIElement(lv_obj_t *aLvglSelf, const ID aId = ID());
|
UIElement(lv_obj_t *aLvglSelf, const ID aId = ID());
|
||||||
|
|
||||||
|
SetBgColor(lv_color_t value, lv_style_selector_t selector = LV_PART_MAIN);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
lv_obj_t *mLvglSelf;
|
lv_obj_t *mLvglSelf;
|
||||||
const ID mId;
|
const ID mId;
|
||||||
|
|
|
@ -2,4 +2,7 @@
|
||||||
|
|
||||||
using namespace UI::Screen;
|
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 {
|
namespace UI::Screen {
|
||||||
|
|
||||||
class HomeScreen : public Base {
|
class HomeScreen : public Base {
|
||||||
|
public:
|
||||||
HomeScreen();
|
HomeScreen();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using namespace UI::Screen;
|
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) {
|
void Base::AddWidget(Widget::Base::Ptr aWidget) {
|
||||||
mWidgets.push_back(std::move(aWidget));
|
mWidgets.push_back(std::move(aWidget));
|
||||||
|
|
|
@ -17,7 +17,6 @@ public:
|
||||||
void AddWidget(Widget::Base::Ptr aWidget);
|
void AddWidget(Widget::Base::Ptr aWidget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lv_obj_t *mScreen;
|
|
||||||
std::vector<Widget::Base::Ptr> mWidgets;
|
std::vector<Widget::Base::Ptr> mWidgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ build_flags =
|
||||||
-I OmoteUI/core/widget
|
-I OmoteUI/core/widget
|
||||||
-I OmoteUI/UIs
|
-I OmoteUI/UIs
|
||||||
-I OmoteUI/UIs/Basic
|
-I OmoteUI/UIs/Basic
|
||||||
|
-I OmoteUI/UIs/BasicRefactored
|
||||||
-I HAL
|
-I HAL
|
||||||
-I HAL/HardwareModules
|
-I HAL/HardwareModules
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
#include "HardwareSimulator.hpp"
|
#include "BasicUI.hpp"
|
||||||
#include "omoteconfig.h"
|
#include "HardwareSimulator.hpp"
|
||||||
#include "OmoteUI.hpp"
|
#include "OmoteUI.hpp"
|
||||||
#include <memory>
|
#include "omoteconfig.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
auto hwSim = std::make_shared<HardwareSimulator>();
|
auto hwSim = std::make_shared<HardwareSimulator>();
|
||||||
hwSim->init();
|
hwSim->init();
|
||||||
|
|
||||||
auto ui = UI::Basic::OmoteUI::getInstance(hwSim);
|
auto ui = UI::BasicUI(hwSim);
|
||||||
ui->layout_UI();
|
// ui->layout_UI();
|
||||||
|
|
||||||
while (true){
|
while (true) {
|
||||||
ui->loopHandler();
|
ui.loopHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue