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
|
/**
* Copyright 2021 Johannes Marbach
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef BBX_THEME_H
#define BBX_THEME_H
#include "lvgl/lvgl.h"
#include <stdbool.h>
#include <stdint.h>
#define BBX_WIDGET_HEADER LV_OBJ_FLAG_USER_1
/**
* Theming structs
*/
/* Window theme */
typedef struct {
uint32_t bg_color;
} bbx_theme_window;
/* Header theme */
typedef struct {
uint32_t bg_color;
int32_t border_width;
uint32_t border_color;
int32_t pad;
int32_t gap;
} bbx_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;
} bbx_theme_key_state;
/* Key theme for one specific key type and all states */
typedef struct {
bbx_theme_key_state normal;
bbx_theme_key_state pressed;
} bbx_theme_key;
/* Key theme */
typedef struct {
int32_t border_width;
int32_t corner_radius;
bbx_theme_key key_char;
bbx_theme_key key_non_char;
bbx_theme_key key_mod_act;
bbx_theme_key key_mod_inact;
} bbx_theme_keys;
/* Keyboard theme */
typedef struct {
uint32_t bg_color;
int32_t border_width;
uint32_t border_color;
int32_t pad;
int32_t gap;
bbx_theme_keys keys;
} bbx_theme_keyboard;
/* Button theme for one specific button state */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
uint32_t border_color;
} bbx_theme_button_state;
/* Button theme */
typedef struct {
int32_t border_width;
int32_t corner_radius;
int32_t pad;
bbx_theme_button_state normal;
bbx_theme_button_state pressed;
} bbx_theme_button;
/* Text area cursor theme */
typedef struct {
int32_t width;
uint32_t color;
int period;
} bbx_theme_textarea_cursor;
/* Text area theme */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
int32_t border_width;
uint32_t border_color;
int32_t corner_radius;
int32_t pad;
uint32_t placeholder_color;
bbx_theme_textarea_cursor cursor;
} bbx_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;
int32_t border_width;
uint32_t border_color;
int32_t corner_radius;
int32_t pad;
} bbx_theme_dropdown_list;
/* Dropdown theme */
typedef struct {
bbx_theme_button button;
bbx_theme_dropdown_list list;
} bbx_theme_dropdown;
/* Label */
typedef struct {
uint32_t fg_color;
} bbx_theme_label;
/* Message box dimming theme */
typedef struct {
uint32_t color;
short opacity;
} bbx_theme_msgbox_dimming;
/* Message box theme */
typedef struct {
uint32_t fg_color;
uint32_t bg_color;
int32_t border_width;
uint32_t border_color;
int32_t corner_radius;
int32_t pad;
int32_t gap;
bbx_theme_msgbox_dimming dimming;
} bbx_theme_msgbox;
/* Progress bar indicator theme */
typedef struct {
uint32_t bg_color;
} bbx_theme_bar_indicator;
/* Progress bar theme */
typedef struct {
int32_t border_width;
uint32_t border_color;
int32_t corner_radius;
bbx_theme_bar_indicator indicator;
} bbx_theme_bar;
/* Full theme */
typedef struct {
char *name;
bbx_theme_window window;
bbx_theme_header header;
bbx_theme_keyboard keyboard;
bbx_theme_button button;
bbx_theme_textarea textarea;
bbx_theme_dropdown dropdown;
bbx_theme_label label;
bbx_theme_msgbox msgbox;
bbx_theme_bar bar;
} bbx_theme;
/**
* Prepare a keyboard widget to be themed with a theme.
*
* @param keyboard keyboard widget
*/
void bbx_theme_prepare_keyboard(lv_obj_t *keyboard);
/**
* Apply a UI theme.
*
* @param theme the theme to apply
*/
void bbx_theme_apply(const bbx_theme *theme);
#endif /* BBX_THEME_H */
|