-
Notifications
You must be signed in to change notification settings - Fork 142
/
LVGLStyle.h
88 lines (67 loc) · 1.7 KB
/
LVGLStyle.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
#ifndef LVGLSTYLE_H
#define LVGLSTYLE_H
#include <QString>
#include <QList>
#include <QVariant>
#include <lvgl/lvgl.h>
namespace LVGL {
enum StylePart {
None = 0x00,
BodyBorder = 0x01,
BodyShadow = 0x02,
BodyPadding = 0x04,
Body = BodyBorder | BodyShadow | BodyPadding,
Text = 0x08,
Image = 0x10,
Line = 0x20,
All = Body | Text | Image | Line
};
Q_DECLARE_FLAGS(StyleParts, StylePart)
}
Q_DECLARE_OPERATORS_FOR_FLAGS(LVGL::StyleParts)
class LVGLStyleItem {
public:
enum Type {
Color,
Coord,
Opacity,
BorderPart,
ShadowType,
Font,
Property
};
LVGLStyleItem(QString name, LVGL::StylePart stylePart, LVGLStyleItem *parent = nullptr);
LVGLStyleItem(QString name, Type type, size_t offset, LVGL::StylePart stylePart, LVGLStyleItem *parent = nullptr);
~LVGLStyleItem();
QString name() const;
const LVGLStyleItem *parent() const;
int count() const;
const LVGLStyleItem *child(int index) const;
int row() const;
int indexOf(const LVGLStyleItem *item) const;
void addChild(LVGLStyleItem *child);
Type type() const;
size_t offset() const;
LVGL::StylePart stylePart() const;
protected:
QString m_name;
LVGLStyleItem *m_parent;
Type m_type;
size_t m_offset;
QList<LVGLStyleItem*> m_childs;
LVGL::StylePart m_stylePart;
};
class LVGLStyle : public LVGLStyleItem
{
public:
LVGLStyle();
QVariant get(const LVGLStyleItem *item) const;
lv_border_part_t getBorderPart(const LVGLStyleItem *item) const;
void set(const LVGLStyleItem *item, QVariant value);
lv_style_t *style() const;
void setStyle(lv_style_t *style);
static bool hasStyleChanged(const lv_style_t *style, const lv_style_t *base, LVGL::StyleParts parts = LVGL::All);
private:
lv_style_t *m_style;
};
#endif // LVGLSTYLE_H