[zhoulongyu] 修改部分与LVGL相关的抽象类的名称
This commit is contained in:
parent
c5436c077f
commit
3a9264b31d
|
@ -53,17 +53,17 @@ enum class i_lv_align_t{
|
||||||
|
|
||||||
typedef void (*i_lv_event_cb_t)(i_lv_event_code_t e, void * userData);
|
typedef void (*i_lv_event_cb_t)(i_lv_event_code_t e, void * userData);
|
||||||
|
|
||||||
class Widget
|
class VWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Widget() = default;
|
VWidget() = default;
|
||||||
virtual ~Widget() {}
|
virtual ~VWidget() {}
|
||||||
virtual void ImageSetSrc(const void *src) {}
|
virtual void ImageSetSrc(const void *src) {}
|
||||||
virtual void SetSize(const int16_t width, const int16_t height) {}
|
virtual void SetSize(const int16_t width, const int16_t height) {}
|
||||||
virtual void SetColor(uint32_t color) {}
|
virtual void SetColor(uint32_t color) {}
|
||||||
virtual void Load(void) {}
|
virtual void Load(void) {}
|
||||||
virtual void SetText(const char *text) {}
|
virtual void SetText(const char *text) {}
|
||||||
virtual void AlignTo(std::shared_ptr<Widget> base, i_lv_align_t align, int16_t posX, int16_t posY) {}
|
virtual void AlignTo(std::shared_ptr<VWidget> base, i_lv_align_t align, int16_t posX, int16_t posY) {}
|
||||||
virtual void SetPos(int16_t posX, int16_t posY) {}
|
virtual void SetPos(int16_t posX, int16_t posY) {}
|
||||||
virtual void Center(void) {}
|
virtual void Center(void) {}
|
||||||
virtual void SetEventCb(i_lv_event_cb_t eventCb) {}
|
virtual void SetEventCb(i_lv_event_cb_t eventCb) {}
|
||||||
|
@ -82,23 +82,23 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GuiEngine
|
class VGuiEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiEngine() = default;
|
VGuiEngine() = default;
|
||||||
virtual ~GuiEngine() = default;
|
virtual ~VGuiEngine() = default;
|
||||||
/**
|
/**
|
||||||
* @brief Get the Instance object
|
* @brief Get the Instance object
|
||||||
* Return reference for runing faster. Usage : GuiEngine::GetInstance()->Init();
|
* Return reference for runing faster. Usage : VGuiEngine::GetInstance()->Init();
|
||||||
* Don't use GuiEngine like this:
|
* Don't use VGuiEngine like this:
|
||||||
* std::shared_ptr<GuiEngine> &log = GuiEngine::GetInstance();
|
* std::shared_ptr<VGuiEngine> &log = VGuiEngine::GetInstance();
|
||||||
* or std::shared_ptr<GuiEngine> log = GuiEngine::GetInstance();
|
* or std::shared_ptr<VGuiEngine> log = VGuiEngine::GetInstance();
|
||||||
* @param impl
|
* @param impl
|
||||||
* @return std::shared_ptr<GuiEngine>&
|
* @return std::shared_ptr<VGuiEngine>&
|
||||||
*/
|
*/
|
||||||
static std::shared_ptr<GuiEngine> &GetInstance(std::shared_ptr<GuiEngine> *impl = nullptr)
|
static std::shared_ptr<VGuiEngine> &GetInstance(std::shared_ptr<VGuiEngine> *impl = nullptr)
|
||||||
{
|
{
|
||||||
static auto instance = std::make_shared<GuiEngine>();
|
static auto instance = std::make_shared<VGuiEngine>();
|
||||||
if (impl)
|
if (impl)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -121,13 +121,13 @@ public:
|
||||||
virtual const int16_t GetScreenWidth(void) { return 1;}
|
virtual const int16_t GetScreenWidth(void) { return 1;}
|
||||||
virtual const int16_t GetScreenHeight(void) { return 1;}
|
virtual const int16_t GetScreenHeight(void) { return 1;}
|
||||||
virtual StatusCode CreateFrameParObject(int16_t widht = 100, int16_t height = 100, int16_t posX = 0, int16_t posY = 0) { return CreateStatusCode(STATUS_CODE_OK); } // 这个界面不应该放出来, 在应用层初始化的时候使用
|
virtual StatusCode CreateFrameParObject(int16_t widht = 100, int16_t height = 100, int16_t posX = 0, int16_t posY = 0) { return CreateStatusCode(STATUS_CODE_OK); } // 这个界面不应该放出来, 在应用层初始化的时候使用
|
||||||
virtual std::shared_ptr<Widget> GetFrameParObject(void) { return std::make_shared<Widget>(); }
|
virtual std::shared_ptr<VWidget> GetFrameParObject(void) { return std::make_shared<VWidget>(); }
|
||||||
virtual StatusCode SetNowNode(std::shared_ptr<Widget>) { return CreateStatusCode(STATUS_CODE_OK); } // 这个函数不应该放出来, 在切换界面的时候使用
|
virtual StatusCode SetNowNode(std::shared_ptr<VWidget>) { return CreateStatusCode(STATUS_CODE_OK); } // 这个函数不应该放出来, 在切换界面的时候使用
|
||||||
virtual std::shared_ptr<Widget> GetNowNode(void) { return nullptr; }
|
virtual std::shared_ptr<VWidget> GetNowNode(void) { return nullptr; }
|
||||||
virtual std::shared_ptr<Widget> NewWidget(void) { return std::make_shared<Widget>(); }
|
virtual std::shared_ptr<VWidget> NewWidget(void) { return std::make_shared<VWidget>(); }
|
||||||
virtual std::shared_ptr<Widget> NewPage(void) { return std::make_shared<Widget>(); }
|
virtual std::shared_ptr<VWidget> NewPage(void) { return std::make_shared<VWidget>(); }
|
||||||
virtual std::shared_ptr<Widget> NewImage(void) { return std::make_shared<Widget>(); }
|
virtual std::shared_ptr<VWidget> NewImage(void) { return std::make_shared<VWidget>(); }
|
||||||
virtual std::shared_ptr<Widget> NewButton(void) { return std::make_shared<Widget>(); }
|
virtual std::shared_ptr<VWidget> NewButton(void) { return std::make_shared<VWidget>(); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
bool CreateGuiEngineImpl()
|
bool CreateGuiEngineImpl()
|
||||||
{
|
{
|
||||||
std::shared_ptr<GuiEngine> impl = std::move(std::make_shared<LvglLinuxBoard>());
|
std::shared_ptr<VGuiEngine> impl = std::move(std::make_shared<LvglLinuxBoard>());
|
||||||
GuiEngine::GetInstance(&impl);
|
VGuiEngine::GetInstance(&impl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool LvglLinuxBoard::Init(const unsigned int width, const unsigned int height, void (*appInit)())
|
bool LvglLinuxBoard::Init(const unsigned int width, const unsigned int height, void (*appInit)())
|
||||||
|
|
|
@ -44,9 +44,9 @@ const int16_t GuiLvgl::GetScreenHeight(void)
|
||||||
|
|
||||||
void FrameParObjectCb(i_lv_event_code_t e, void *userData)
|
void FrameParObjectCb(i_lv_event_code_t e, void *userData)
|
||||||
{
|
{
|
||||||
if(GuiEngine::GetInstance()->GetNowNode() != nullptr)
|
if(VGuiEngine::GetInstance()->GetNowNode() != nullptr)
|
||||||
{
|
{
|
||||||
GuiEngine::GetInstance()->GetNowNode()->EventSend(e, userData);
|
VGuiEngine::GetInstance()->GetNowNode()->EventSend(e, userData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,24 +69,24 @@ StatusCode GuiLvgl::CreateFrameParObject(int16_t widht, int16_t height, int16_t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Widget> GuiLvgl::GetFrameParObject(void)
|
std::shared_ptr<VWidget> GuiLvgl::GetFrameParObject(void)
|
||||||
{
|
{
|
||||||
return std::static_pointer_cast<LvglWidget>(_ParWidget);
|
return std::static_pointer_cast<LvglWidget>(_ParWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusCode GuiLvgl::SetNowNode(std::shared_ptr<Widget> widget)
|
StatusCode GuiLvgl::SetNowNode(std::shared_ptr<VWidget> widget)
|
||||||
{
|
{
|
||||||
_NowNode = widget;
|
_NowNode = widget;
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Widget> GuiLvgl::GetNowNode(void)
|
std::shared_ptr<VWidget> GuiLvgl::GetNowNode(void)
|
||||||
{
|
{
|
||||||
return _NowNode;
|
return _NowNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Widget> GuiLvgl::NewWidget(void)
|
std::shared_ptr<VWidget> GuiLvgl::NewWidget(void)
|
||||||
{
|
{
|
||||||
std::shared_ptr<LvglWidget> widget = std::make_shared<LvglWidget>();
|
std::shared_ptr<LvglWidget> widget = std::make_shared<LvglWidget>();
|
||||||
widget->mWidget = lv_obj_create(JudgeParent());
|
widget->mWidget = lv_obj_create(JudgeParent());
|
||||||
|
@ -94,13 +94,13 @@ std::shared_ptr<Widget> GuiLvgl::NewWidget(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Widget> GuiLvgl::NewPage(void)
|
std::shared_ptr<VWidget> GuiLvgl::NewPage(void)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Widget> GuiLvgl::NewImage(void)
|
std::shared_ptr<VWidget> GuiLvgl::NewImage(void)
|
||||||
{
|
{
|
||||||
std::shared_ptr<LvglWidget> widget = std::make_shared<LvglWidget>();
|
std::shared_ptr<LvglWidget> widget = std::make_shared<LvglWidget>();
|
||||||
widget->mWidget = lv_img_create(JudgeParent());
|
widget->mWidget = lv_img_create(JudgeParent());
|
||||||
|
@ -108,7 +108,7 @@ std::shared_ptr<Widget> GuiLvgl::NewImage(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Widget> GuiLvgl::NewButton(void)
|
std::shared_ptr<VWidget> GuiLvgl::NewButton(void)
|
||||||
{
|
{
|
||||||
std::shared_ptr<LvglWidget> widget = std::make_shared<ButtonWidget>();
|
std::shared_ptr<LvglWidget> widget = std::make_shared<ButtonWidget>();
|
||||||
widget->mWidget = lv_btn_create(JudgeParent());
|
widget->mWidget = lv_btn_create(JudgeParent());
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
|
||||||
|
|
||||||
class GuiLvgl : public GuiEngine
|
class GuiLvgl : public VGuiEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiLvgl();
|
GuiLvgl();
|
||||||
|
@ -28,20 +28,20 @@ public:
|
||||||
const int16_t GetScreenWidth(void) override;
|
const int16_t GetScreenWidth(void) override;
|
||||||
const int16_t GetScreenHeight(void) override;
|
const int16_t GetScreenHeight(void) override;
|
||||||
StatusCode CreateFrameParObject(int16_t widht, int16_t height, int16_t posX, int16_t posY) override;
|
StatusCode CreateFrameParObject(int16_t widht, int16_t height, int16_t posX, int16_t posY) override;
|
||||||
std::shared_ptr<Widget> GetFrameParObject(void) override;
|
std::shared_ptr<VWidget> GetFrameParObject(void) override;
|
||||||
StatusCode SetNowNode(std::shared_ptr<Widget>) override;
|
StatusCode SetNowNode(std::shared_ptr<VWidget>) override;
|
||||||
std::shared_ptr<Widget> GetNowNode(void) override;
|
std::shared_ptr<VWidget> GetNowNode(void) override;
|
||||||
std::shared_ptr<Widget> NewWidget(void) override;
|
std::shared_ptr<VWidget> NewWidget(void) override;
|
||||||
std::shared_ptr<Widget> NewPage(void) override;
|
std::shared_ptr<VWidget> NewPage(void) override;
|
||||||
std::shared_ptr<Widget> NewImage(void) override;
|
std::shared_ptr<VWidget> NewImage(void) override;
|
||||||
std::shared_ptr<Widget> NewButton(void) override;
|
std::shared_ptr<VWidget> NewButton(void) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lv_obj_t* JudgeParent(void);
|
lv_obj_t* JudgeParent(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Widget> _LvglParWidget = nullptr;
|
std::shared_ptr<VWidget> _LvglParWidget = nullptr;
|
||||||
std::shared_ptr<Widget> _ParWidget = nullptr;
|
std::shared_ptr<VWidget> _ParWidget = nullptr;
|
||||||
std::shared_ptr<Widget> _NowNode = nullptr;
|
std::shared_ptr<VWidget> _NowNode = nullptr;
|
||||||
};
|
};
|
||||||
#endif // !GUI_LVGL_H
|
#endif // !GUI_LVGL_H
|
||||||
|
|
|
@ -96,7 +96,7 @@ lv_align_t transitionAlignCode_AppMid(i_lv_align_t align)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LvglWidget::AlignTo(std::shared_ptr<Widget> base, i_lv_align_t align, int16_t posX, int16_t posY)
|
void LvglWidget::AlignTo(std::shared_ptr<VWidget> base, i_lv_align_t align, int16_t posX, int16_t posY)
|
||||||
{
|
{
|
||||||
if (mWidget)
|
if (mWidget)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LvglWidget : public Widget
|
class LvglWidget : public VWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LvglWidget()
|
LvglWidget()
|
||||||
|
@ -32,7 +32,7 @@ public:
|
||||||
// void Load(void) override; // 好像挺有用的, 但不知道什么意思
|
// void Load(void) override; // 好像挺有用的, 但不知道什么意思
|
||||||
void Center(void) override;
|
void Center(void) override;
|
||||||
void SetColor(uint32_t color) override;
|
void SetColor(uint32_t color) override;
|
||||||
void AlignTo(std::shared_ptr<Widget> base, i_lv_align_t align, int16_t posX, int16_t posY) override;
|
void AlignTo(std::shared_ptr<VWidget> base, i_lv_align_t align, int16_t posX, int16_t posY) override;
|
||||||
void SetPos(int16_t posX, int16_t posY) override;
|
void SetPos(int16_t posX, int16_t posY) override;
|
||||||
void SetOpa(const uint8_t opaValue) override;
|
void SetOpa(const uint8_t opaValue) override;
|
||||||
void SetEventCb(i_lv_event_cb_t eventCb) override;
|
void SetEventCb(i_lv_event_cb_t eventCb) override;
|
||||||
|
|
|
@ -16,8 +16,8 @@ extern "C"
|
||||||
#endif
|
#endif
|
||||||
bool CreateGuiEngineImpl()
|
bool CreateGuiEngineImpl()
|
||||||
{
|
{
|
||||||
std::shared_ptr<GuiEngine> impl = std::move(std::make_shared<LvglLinuxX86>());
|
std::shared_ptr<VGuiEngine> impl = std::move(std::make_shared<LvglLinuxX86>());
|
||||||
GuiEngine::GetInstance(&impl);
|
VGuiEngine::GetInstance(&impl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool LvglLinuxX86::Init(const unsigned int width, const unsigned int height, void (*appInit)())
|
bool LvglLinuxX86::Init(const unsigned int width, const unsigned int height, void (*appInit)())
|
||||||
|
|
|
@ -84,10 +84,10 @@ TEST_F(GuiInterfaceTest, Demo)
|
||||||
{
|
{
|
||||||
CreateGuiEngineImpl();
|
CreateGuiEngineImpl();
|
||||||
|
|
||||||
GuiEngine::GetInstance()->Init(LV_SCREEN_WIDTH, LV_SCREEN_HEIGHT, GuiTestMainWindow);
|
VGuiEngine::GetInstance()->Init(LV_SCREEN_WIDTH, LV_SCREEN_HEIGHT, GuiTestMainWindow);
|
||||||
|
|
||||||
GuiTest::GetInstance()->GuiTestUninit();
|
GuiTest::GetInstance()->GuiTestUninit();
|
||||||
GuiEngine::GetInstance()->UnInit();
|
VGuiEngine::GetInstance()->UnInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace GuiInterfaceTest
|
}; // namespace GuiInterfaceTest
|
||||||
|
|
|
@ -31,6 +31,8 @@ std::shared_ptr<GuiTest> &GuiTest::GetInstance(std::shared_ptr<GuiTest> *impl)
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 思路: 这里重载 hal_LED 的 修改状态 函数, 接收到然后就 发事件给 Lvgl_led, 让Lvgl的界面做出修改
|
||||||
|
|
||||||
void TestButtonCb(i_lv_event_code_t e, void *userData)
|
void TestButtonCb(i_lv_event_code_t e, void *userData)
|
||||||
{
|
{
|
||||||
if (i_lv_event_code_t::I_LV_EVENT_CLICKED == e) {
|
if (i_lv_event_code_t::I_LV_EVENT_CLICKED == e) {
|
||||||
|
@ -40,13 +42,13 @@ void TestButtonCb(i_lv_event_code_t e, void *userData)
|
||||||
|
|
||||||
const StatusCode GuiTest::GuiTestInit(const unsigned int width, const unsigned int height)
|
const StatusCode GuiTest::GuiTestInit(const unsigned int width, const unsigned int height)
|
||||||
{
|
{
|
||||||
_guiTestPar = GuiEngine::GetInstance()->NewWidget();
|
_guiTestPar = VGuiEngine::GetInstance()->NewWidget();
|
||||||
_guiTestPar->SetSize(width, height);
|
_guiTestPar->SetSize(width, height);
|
||||||
_guiTestPar->SetColor(0x077290);
|
_guiTestPar->SetColor(0x077290);
|
||||||
_guiTestPar->SetOpa(127);
|
_guiTestPar->SetOpa(127);
|
||||||
_guiTestPar->AlignTo(NULL, i_lv_align_t::I_LV_ALIGN_RIGHT_MID, 0, 0);
|
_guiTestPar->AlignTo(NULL, i_lv_align_t::I_LV_ALIGN_RIGHT_MID, 0, 0);
|
||||||
|
|
||||||
_testButton = GuiEngine::GetInstance()->NewButton();
|
_testButton = VGuiEngine::GetInstance()->NewButton();
|
||||||
_testButton->SetSize(50, 50); /*Set its size*/
|
_testButton->SetSize(50, 50); /*Set its size*/
|
||||||
_testButton->SetEventCb(TestButtonCb);
|
_testButton->SetEventCb(TestButtonCb);
|
||||||
_testButton->AlignTo(_guiTestPar, i_lv_align_t::I_LV_ALIGN_CENTER, 0, 0);
|
_testButton->AlignTo(_guiTestPar, i_lv_align_t::I_LV_ALIGN_CENTER, 0, 0);
|
||||||
|
@ -62,6 +64,6 @@ const StatusCode GuiTest::GuiTestUninit(void)
|
||||||
void GuiTestMainWindow(void)
|
void GuiTestMainWindow(void)
|
||||||
{
|
{
|
||||||
// Create a parent window for the application layer
|
// Create a parent window for the application layer
|
||||||
GuiEngine::GetInstance()->CreateFrameParObject(LV_SCREEN_WIDTH, LV_SCREEN_HEIGHT, 0, 0);
|
VGuiEngine::GetInstance()->CreateFrameParObject(LV_SCREEN_WIDTH, LV_SCREEN_HEIGHT, 0, 0);
|
||||||
GuiTest::GetInstance()->GuiTestInit(LV_SCREEN_WIDTH, LV_SCREEN_HEIGHT);
|
GuiTest::GetInstance()->GuiTestInit(LV_SCREEN_WIDTH, LV_SCREEN_HEIGHT);
|
||||||
}
|
}
|
|
@ -28,8 +28,8 @@ public:
|
||||||
static std::shared_ptr<GuiTest> &GetInstance(std::shared_ptr<GuiTest> *impl = nullptr);
|
static std::shared_ptr<GuiTest> &GetInstance(std::shared_ptr<GuiTest> *impl = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Widget> _guiTestPar;
|
std::shared_ptr<VWidget> _guiTestPar;
|
||||||
std::shared_ptr<Widget> _testButton;
|
std::shared_ptr<VWidget> _testButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GuiTestMainWindow(void);
|
void GuiTestMainWindow(void);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user