-
Notifications
You must be signed in to change notification settings - Fork 1
/
theme.h
205 lines (177 loc) · 4.53 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* Copyright 2021 Johannes Marbach
*
* This file is part of furios-terminal, 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 UL_THEME_H
#define UL_THEME_H
#include "lvgl/lvgl.h"
#include <stdbool.h>
#include <stdint.h>
#define UL_WIDGET_HEADER LV_OBJ_FLAG_USER_1
/**
* Theming structs
*/
/* Window theme */
typedef struct {
uint32_t bg_color;
} ul_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;
} ul_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;
} ul_theme_key_state;
/* Key theme for one specific key type and all states */
typedef struct {
ul_theme_key_state normal;
ul_theme_key_state pressed;
} ul_theme_key;
/* Key theme */
typedef struct {
lv_coord_t border_width;
lv_coord_t corner_radius;
ul_theme_key key_char;
ul_theme_key key_non_char;
ul_theme_key key_mod_act;
ul_theme_key key_mod_inact;
} ul_theme_keys;
/* Keyboard theme */
typedef struct {
uint32_t bg_color;
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t pad;
lv_coord_t gap;
ul_theme_keys keys;
} ul_theme_keyboard;
/* Button theme for one specific button state */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
uint32_t border_color;
} ul_theme_button_state;
/* Button theme */
typedef struct {
lv_coord_t border_width;
lv_coord_t corner_radius;
lv_coord_t pad;
ul_theme_button_state normal;
ul_theme_button_state pressed;
} ul_theme_button;
/* Text area cursor theme */
typedef struct {
lv_coord_t width;
uint32_t color;
int period;
} ul_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;
ul_theme_textarea_cursor cursor;
} ul_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;
} ul_theme_dropdown_list;
/* Dropdown theme */
typedef struct {
ul_theme_button button;
ul_theme_dropdown_list list;
} ul_theme_dropdown;
/* Label */
typedef struct {
uint32_t fg_color;
} ul_theme_label;
/* Message box buttons theme */
typedef struct {
lv_coord_t gap;
} ul_theme_msgbox_buttons;
/* Message box dimming theme */
typedef struct {
uint32_t color;
short opacity;
} ul_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;
ul_theme_msgbox_buttons buttons;
ul_theme_msgbox_dimming dimming;
} ul_theme_msgbox;
/* Progress bar indicator theme */
typedef struct {
uint32_t bg_color;
} ul_theme_bar_indicator;
/* Progress bar theme */
typedef struct {
lv_coord_t border_width;
uint32_t border_color;
lv_coord_t corner_radius;
ul_theme_bar_indicator indicator;
} ul_theme_bar;
/* Full theme */
typedef struct {
char *name;
ul_theme_window window;
ul_theme_header header;
ul_theme_keyboard keyboard;
ul_theme_button button;
ul_theme_textarea textarea;
ul_theme_dropdown dropdown;
ul_theme_label label;
ul_theme_msgbox msgbox;
ul_theme_bar bar;
} ul_theme;
/**
* Prepare a keyboard widget to be themed with a theme.
*
* @param keyboard keyboard widget
*/
void ul_theme_prepare_keyboard(lv_obj_t *keyboard);
/**
* Apply a UI theme.
*
* @param theme the theme to apply
*/
void ul_theme_apply(const ul_theme *theme);
#endif /* UL_THEME_H */