-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththeme.h
187 lines (161 loc) · 4.01 KB
/
theme.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**
* Copyright 2021 Johannes Marbach
*
* This file is part of furios-recovery, hereafter referred to as the program.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef THEME_H
#define THEME_H
#include "lvgl/lvgl.h"
#include <stdbool.h>
#include <stdint.h>
#define WIDGET_HEADER LV_OBJ_FLAG_USER_1
/**
* Theming structs
*/
/* Window theme */
typedef struct {
uint32_t bg_color;
} theme_window;
/* Header theme */
typedef struct {
uint32_t bg_color;
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t pad;
lv_coord_t gap;
} theme_header;
/* Key theme for one specific key type and state */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
uint32_t border_color;
} theme_key_state;
/* Key theme for one specific key type and all states */
typedef struct {
theme_key_state normal;
theme_key_state pressed;
} theme_key;
/* Key theme */
typedef struct {
lv_coord_t border_width;
lv_coord_t corner_radius;
theme_key key_char;
theme_key key_non_char;
theme_key key_mod_act;
theme_key key_mod_inact;
} theme_keys;
/* Button theme for one specific button state */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
uint32_t border_color;
} theme_button_state;
/* Button theme */
typedef struct {
lv_coord_t border_width;
lv_coord_t corner_radius;
lv_coord_t pad;
theme_button_state normal;
theme_button_state pressed;
} theme_button;
/* Text area cursor theme */
typedef struct {
lv_coord_t width;
uint32_t color;
int period;
} theme_textarea_cursor;
/* Text area theme */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t corner_radius;
lv_coord_t pad;
uint32_t placeholder_color;
theme_textarea_cursor cursor;
} theme_textarea;
/* Dropdown list theme */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
uint32_t selection_fg_color;
uint32_t selection_bg_color;
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t corner_radius;
lv_coord_t pad;
} theme_dropdown_list;
/* Dropdown theme */
typedef struct {
theme_button button;
theme_dropdown_list list;
} theme_dropdown;
/* Label */
typedef struct {
uint32_t fg_color;
} theme_label;
/* Message box buttons theme */
typedef struct {
lv_coord_t gap;
} theme_msgbox_buttons;
/* Message box dimming theme */
typedef struct {
uint32_t color;
short opacity;
} theme_msgbox_dimming;
/* Message box theme */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t corner_radius;
lv_coord_t pad;
lv_coord_t gap;
theme_msgbox_buttons buttons;
theme_msgbox_dimming dimming;
} theme_msgbox;
/* Progress bar indicator theme */
typedef struct {
uint32_t bg_color;
} theme_bar_indicator;
/* Progress bar theme */
typedef struct {
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t corner_radius;
theme_bar_indicator indicator;
} theme_bar;
/* Full theme */
typedef struct {
char *name;
theme_window window;
theme_header header;
theme_button button;
theme_textarea textarea;
theme_dropdown dropdown;
theme_label label;
theme_msgbox msgbox;
theme_bar bar;
} theme;
/**
* Apply a UI theme.
*
* @param theme the theme to apply
*/
void theme_apply(const theme *theme);
#endif /* THEME_H */