-
Notifications
You must be signed in to change notification settings - Fork 142
/
LVGLObject.h
100 lines (73 loc) · 2.22 KB
/
LVGLObject.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
#ifndef LVGLOBJECT_H
#define LVGLOBJECT_H
#include <QObject>
#include <QJsonObject>
#include <lvgl/lvgl.h>
#include "widgets/LVGLWidget.h"
class LVGLObject : public QObject
{
Q_OBJECT
public:
LVGLObject(const LVGLWidget *widgetClass, QString name, LVGLObject *parent);
LVGLObject(const LVGLWidget *widgetClass, QString name, lv_obj_t *parent);
LVGLObject(const LVGLWidget *widgetClass, LVGLObject *parent, lv_obj_t *parentObj);
LVGLObject(lv_obj_t *obj, const LVGLWidget *widgetClass, LVGLObject *parent, bool movable = true, int index = -1);
~LVGLObject();
lv_obj_t *obj() const;
QString name() const;
void setName(const QString &name);
QString codeName() const;
bool isLocked() const;
void setLocked(bool locked);
bool isMovable() const;
const LVGLWidget *widgetClass() const;
LVGLWidget::Type widgetType() const;
QPoint absolutePosition() const;
QPoint position() const;
int x() const;
int y() const;
void setPosition(const QPoint &pos);
void setX(int x);
void setY(int y);
QSize size() const;
QRect geometry() const;
void setGeometry(QRect geometry);
int width() const;
int height() const;
void setWidth(int width);
void setHeight(int height);
QJsonObject toJson();
QJsonArray jsonStyles() const;
QStringList codeStyle(QString styleVar, int type) const;
void parseStyles(const QJsonArray &styles);
LVGLObject *parent() const;
operator lv_obj_t *() noexcept;
operator const lv_obj_t *() const noexcept;
bool hasCustomStyle(int type) const;
lv_style_t *style(int type);
QString styleCodeName(int type) const;
QList<LVGLObject *> childs() const;
void removeChild(LVGLObject *child);
bool isAccessible() const;
void setAccessible(bool accessible);
bool doesNameExists() const;
static bool doesNameExists(const QString &name, LVGLObject *except = nullptr);
void generateName();
static LVGLObject *parse(QJsonObject object, LVGLObject *parent);
int index() const;
LVGLObject *findChildByIndex(int index) const;
signals:
void positionChanged();
private:
lv_obj_t *m_obj;
const LVGLWidget *m_widgetClass;
QString m_name;
bool m_locked;
bool m_accessible;
bool m_movable;
int m_index;
LVGLObject *m_parent;
QList<LVGLObject*> m_childs;
QHash<int,lv_style_t> m_styles;
};
#endif // LVGLOBJECT_H