Skip to content

Commit

Permalink
move lvgl demo out of main class into tests
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed May 5, 2024
1 parent 08508dc commit fa01e2e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
10 changes: 0 additions & 10 deletions opengl/LVGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "../distrho/extra/Sleep.hpp"
#include "../distrho/extra/Time.hpp"

#include "demos/lv_demos.h"

START_NAMESPACE_DGL

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -530,14 +528,6 @@ void LVGLWidget::onResize(const Widget::ResizeEvent& event)
lv_global = lvglData->global;
lv_display_set_resolution(lvglData->display, width, height);
lv_refr_now(lvglData->display);

// TESTING
static bool testing = true;
if (testing)
{
testing = false;
lv_demo_widgets();
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/lvgl/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@
*https://fonts.google.com/specimen/Montserrat*/
#define LV_FONT_MONTSERRAT_8 0
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_12 0
#define LV_FONT_MONTSERRAT_12 1
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_18 1
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 1
#define LV_FONT_MONTSERRAT_24 1
Expand Down
27 changes: 23 additions & 4 deletions tests/lvgl/lvgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
#include "../../generic/ResizeHandle.hpp"
#include "../../opengl/LVGL.hpp"

#include "demos/lv_demos.h"

class LVGLDemo : public LVGLWidget
{
public:
LVGLDemo(Window& window)
: LVGLWidget(window) {}

// delay setup after window size has been set
void setup()
{
lv_demo_widgets();
}
};

class DemoWindow : public StandaloneWindow
{
static const uint kMarginBase = 8;
Expand All @@ -13,14 +28,16 @@ class DemoWindow : public StandaloneWindow
static const uint kMinWindowWidth = 1000;
static const uint kMinWindowHeight = 600;

// ResizeHandle resizeHandle;
LVGLWidget lvgl;
LVGLDemo lvgl;
ResizeHandle resizeHandle;

bool widgetsDone = false;

public:
DemoWindow(Application& app)
: StandaloneWindow(app),
// resizeHandle(this),
lvgl(this)
lvgl((Window&)*this),
resizeHandle(this)
{
const double scaleFactor = getScaleFactor();
const uint margin = kMarginContent * scaleFactor;
Expand All @@ -29,6 +46,8 @@ class DemoWindow : public StandaloneWindow
setSize(kMinWindowWidth * scaleFactor, kMinWindowHeight * scaleFactor);
setResizable(true);
setTitle("LVGL Widgets Demo");

lvgl.setup();
}

protected:
Expand Down

0 comments on commit fa01e2e

Please sign in to comment.