forked from staunchheart/LVGLBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLVGLCore.h
123 lines (97 loc) · 3.53 KB
/
LVGLCore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef LVGLCORE_HPP
#define LVGLCORE_HPP
#include <lvgl/lvgl.h>
#include "LVGLImageData.h"
#include "widgets/LVGLWidget.h"
#include <QTimer>
#include <QElapsedTimer>
#include <QObject>
#include <QPixmap>
#include <QList>
#include <QHash>
class LVGLObject;
class LVGLFontData;
class QLVGL : public QObject
{
Q_OBJECT
public:
QLVGL(QObject *parent = nullptr);
~QLVGL();
void init(int width, int height);
QPixmap framebuffer() const;
QPixmap grab(const QRect ®ion) const;
int width() const;
int height() const;
QSize size() const;
LVGLImageData *addImage(QImage image, QString name);
LVGLImageData *addImage(QString fileName, QString name = QString());
void addImage(LVGLImageData *image);
QStringList imageNames() const;
QList<LVGLImageData *> images() const;
lv_img_dsc_t *image(QString name);
lv_img_dsc_t *defaultImage() const;
QString nameByImage(const lv_img_dsc_t *img_dsc) const;
LVGLImageData *imageByDesc(const lv_img_dsc_t *img_dsc) const;
bool removeImage(LVGLImageData *img);
void removeAllImages();
QStringList symbolNames() const;
const char *symbol(const QString &name) const;
void poll();
void send_mouse_event(int x, int y, bool pressed);
QList<lv_obj_t *> get_objects_under_coords(int x, int y, lv_obj_t *parent = lv_scr_act()) const;
QList<lv_obj_t *> get_object_children(const lv_obj_t *obj, bool recursive) const;
QList<lv_obj_t *> get_objects_by_type(QString type, lv_obj_t *parent = lv_scr_act()) const;
int get_object_child_index(const lv_obj_t *obj) const;
QPoint get_absolute_position(const lv_obj_t *lv_obj) const;
QSize get_object_size(const lv_obj_t *lv_obj) const;
QRect get_object_rect(const lv_obj_t *lv_obj) const;
QString get_object_class(lv_obj_t *lv_obj) const;
void set_object_position(lv_obj_t *lv_obj, const QPoint &pos);
void set_object_geometry(lv_obj_t *lv_obj, const QRect &geometry);
void addObject(LVGLObject *object);
void removeObject(LVGLObject *object);
void removeAllObjects();
QList<LVGLObject *> allObjects() const;
QList<LVGLObject *> topLevelObjects() const;
QList<LVGLObject *> objectsByType(QString className) const;
LVGLObject *object(QString name) const;
LVGLObject *object(lv_obj_t *obj) const;
QColor toColor(lv_color_t c) const;
lv_color_t fromColor(QColor c) const;
lv_color_t fromColor(QVariant v) const;
LVGLFontData *addFont(const QString &fileName, uint8_t size);
void addFont(LVGLFontData *font);
bool removeFont(LVGLFontData *font);
QStringList fontNames() const;
QStringList fontCodeNames() const;
const lv_font_t *font(int index) const;
const lv_font_t *font(const QString &name, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int indexOfFont(const lv_font_t *font) const;
QString fontName(const lv_font_t *font) const;
QString fontCodeName(const lv_font_t *font) const;
QList<const LVGLFontData *> customFonts() const;
void removeCustomFonts();
QString baseStyleName(const lv_style_t *style) const;
void setScreenColor(QColor color);
QColor screenColor() const;
bool screenColorChanged() const;
QList<const LVGLWidget *> widgets() const;
const LVGLWidget *widget(const QString &name) const;
private slots:
void tick();
private:
void addWidget(const LVGLWidget *w);
QTimer m_timer;
QElapsedTimer m_time;
QHash<QString,LVGLImageData*> m_images;
QHash<QString,const LVGLWidget *> m_widgets;
LVGLImageData *m_default;
QList<LVGLObject*> m_objects;
QList<LVGLFontData *> m_fonts;
lv_style_t m_screen_style;
const LVGLFontData *m_defaultFont;
struct FT_LibraryRec_ *m_ft;
friend class LVGLFontData;
};
extern QLVGL lvgl;
#endif // LVGLCORE_HPP