Add themes and fbdev force-refresh quirk via config
This commit is contained in:
parent
a4a4734317
commit
2987305546
29 changed files with 636 additions and 287 deletions
|
|
@ -92,7 +92,7 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) {
|
|||
|
||||
int opt, index = 0;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "c:C:g:d:hvV", long_opts, &index)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "C:g:d:hvV", long_opts, &index)) != -1) {
|
||||
switch (opt) {
|
||||
case 'C':
|
||||
opts->config_files = realloc(opts->config_files, (opts->num_config_files + 1) * sizeof(char *));
|
||||
|
|
|
|||
|
|
@ -189,14 +189,14 @@ static int parsing_handler(void* user_data, const char* section, const char* key
|
|||
}
|
||||
} else if (strcmp(section, "theme") == 0) {
|
||||
if (strcmp(key, "default") == 0) {
|
||||
ul_themes_theme_id_t id = ul_themes_find_theme_with_name(value);
|
||||
if (id != UL_THEMES_THEME_NONE) {
|
||||
bb_themes_theme_id_t id = bb_themes_find_theme_with_name(value);
|
||||
if (id != BB_THEMES_THEME_NONE) {
|
||||
opts->theme.default_id = id;
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(key, "alternate") == 0) {
|
||||
ul_themes_theme_id_t id = ul_themes_find_theme_with_name(value);
|
||||
if (id != UL_THEMES_THEME_NONE) {
|
||||
bb_themes_theme_id_t id = bb_themes_find_theme_with_name(value);
|
||||
if (id != BB_THEMES_THEME_NONE) {
|
||||
opts->theme.alternate_id = id;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -263,8 +263,8 @@ void ul_config_init_opts(ul_config_opts *opts) {
|
|||
opts->keyboard.popovers = true;
|
||||
opts->textarea.obscured = true;
|
||||
opts->textarea.bullet = LV_SYMBOL_BULLET;
|
||||
opts->theme.default_id = UL_THEMES_THEME_BREEZY_DARK;
|
||||
opts->theme.alternate_id = UL_THEMES_THEME_BREEZY_LIGHT;
|
||||
opts->theme.default_id = BB_THEMES_THEME_BREEZY_DARK;
|
||||
opts->theme.alternate_id = BB_THEMES_THEME_BREEZY_LIGHT;
|
||||
opts->input.keyboard = true;
|
||||
opts->input.pointer = true;
|
||||
opts->input.touchscreen = true;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "backends.h"
|
||||
|
||||
#include "themes.h"
|
||||
#include "../shared/themes.h"
|
||||
|
||||
#include "sq2lv_layouts.h"
|
||||
|
||||
|
|
@ -55,9 +55,9 @@ typedef struct {
|
|||
*/
|
||||
typedef struct {
|
||||
/* Default theme */
|
||||
ul_themes_theme_id_t default_id;
|
||||
bb_themes_theme_id_t default_id;
|
||||
/* Alternate theme */
|
||||
ul_themes_theme_id_t alternate_id;
|
||||
bb_themes_theme_id_t alternate_id;
|
||||
} ul_config_opts_theme;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
#include "config.h"
|
||||
#include "unl0kr.h"
|
||||
#include "terminal.h"
|
||||
#include "theme.h"
|
||||
#include "themes.h"
|
||||
|
||||
#include "../shared/indev.h"
|
||||
#include "../shared/log.h"
|
||||
#include "../shared/theme.h"
|
||||
#include "../shared/themes.h"
|
||||
#include "../squeek2lvgl/sq2lv.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
|
@ -220,11 +220,11 @@ static void toggle_theme(void) {
|
|||
}
|
||||
|
||||
static void set_theme(bool is_alternate) {
|
||||
ul_theme_apply(get_theme(is_alternate));
|
||||
bb_theme_apply(get_theme(is_alternate));
|
||||
}
|
||||
|
||||
static const ul_theme * get_theme(bool is_alternate) {
|
||||
return ul_themes_themes[is_alternate ? conf_opts.theme.alternate_id : conf_opts.theme.default_id];
|
||||
return bb_themes_themes[is_alternate ? conf_opts.theme.alternate_id : conf_opts.theme.default_id];
|
||||
}
|
||||
|
||||
static void toggle_pw_btn_clicked_cb(lv_event_t *event) {
|
||||
|
|
@ -462,7 +462,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
/* Header flexbox */
|
||||
lv_obj_t *header = lv_obj_create(container);
|
||||
lv_obj_add_flag(header, UL_WIDGET_HEADER);
|
||||
lv_obj_add_flag(header, BB_WIDGET_HEADER);
|
||||
lv_theme_apply(header); /* Force re-apply theme after setting flag so that the widget can be identified */
|
||||
lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(header, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
|
@ -561,7 +561,7 @@ int main(int argc, char *argv[]) {
|
|||
lv_obj_add_event_cb(keyboard, keyboard_ready_cb, LV_EVENT_READY, NULL);
|
||||
lv_obj_set_pos(keyboard, 0, is_keyboard_hidden ? keyboard_height : 0);
|
||||
lv_obj_set_size(keyboard, hor_res, keyboard_height);
|
||||
ul_theme_prepare_keyboard(keyboard);
|
||||
bb_theme_prepare_keyboard(keyboard);
|
||||
|
||||
/* Apply textarea options */
|
||||
set_password_obscured(conf_opts.textarea.obscured);
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ unl0kr_sources = [
|
|||
'main.c',
|
||||
'sq2lv_layouts.c',
|
||||
'terminal.c',
|
||||
'theme.c',
|
||||
'themes.c',
|
||||
]
|
||||
|
||||
shared_sources = [
|
||||
'../shared/cursor/cursor.c',
|
||||
'../shared/indev.c',
|
||||
'../shared/log.c',
|
||||
'../shared/theme.c',
|
||||
'../shared/themes.c',
|
||||
]
|
||||
|
||||
squeek2lvgl_sources = [
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
**/
|
||||
|
||||
#include "sq2lv_layouts.h"
|
||||
#include "../squeek2lvgl/sq2lv.h"
|
||||
|
||||
#define SQ2LV_SYMBOL_SHIFT "\xef\x8d\x9b"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@
|
|||
|
||||
#define SQ2LV_SCANCODES_ENABLED 0
|
||||
|
||||
/* Key attributes */
|
||||
#define SQ2LV_CTRL_NON_CHAR (LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_CHECKED)
|
||||
#define SQ2LV_CTRL_MOD_ACTIVE (LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_CHECKABLE)
|
||||
#define SQ2LV_CTRL_MOD_INACTIVE (LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_CHECKABLE | LV_BUTTONMATRIX_CTRL_CHECKED)
|
||||
|
||||
/* Layout IDs, values can be used as indexes into the sq2lv_layouts array */
|
||||
typedef enum {
|
||||
SQ2LV_LAYOUT_NONE = -1,
|
||||
|
|
|
|||
392
unl0kr/theme.c
392
unl0kr/theme.c
|
|
@ -1,392 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Johannes Marbach
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#include "theme.h"
|
||||
|
||||
#include "sq2lv_layouts.h"
|
||||
#include "unl0kr.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
|
||||
/**
|
||||
* Static variables
|
||||
*/
|
||||
|
||||
static ul_theme current_theme;
|
||||
static lv_theme_t lv_theme;
|
||||
|
||||
static struct {
|
||||
lv_style_t widget;
|
||||
lv_style_t window;
|
||||
lv_style_t header;
|
||||
lv_style_t keyboard;
|
||||
lv_style_t key;
|
||||
lv_style_t button;
|
||||
lv_style_t button_pressed;
|
||||
lv_style_t textarea;
|
||||
lv_style_t textarea_placeholder;
|
||||
lv_style_t textarea_cursor;
|
||||
lv_style_t dropdown;
|
||||
lv_style_t dropdown_pressed;
|
||||
lv_style_t dropdown_list;
|
||||
lv_style_t dropdown_list_selected;
|
||||
lv_style_t label;
|
||||
lv_style_t msgbox;
|
||||
lv_style_t msgbox_label;
|
||||
lv_style_t msgbox_btnmatrix;
|
||||
lv_style_t msgbox_background;
|
||||
lv_style_t bar;
|
||||
lv_style_t bar_indicator;
|
||||
} styles;
|
||||
|
||||
static bool are_styles_initialised = false;
|
||||
|
||||
|
||||
/**
|
||||
* Static prototypes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set up the static styles for a specific theme.
|
||||
*
|
||||
* @param theme theme to derive the styles from
|
||||
*/
|
||||
static void init_styles(const ul_theme *theme);
|
||||
|
||||
/**
|
||||
* Initialise or reset a style.
|
||||
*
|
||||
* @param style style to reset
|
||||
*/
|
||||
static void reset_style(lv_style_t *style);
|
||||
|
||||
/**
|
||||
* Apply a theme to an object.
|
||||
*
|
||||
* @param theme theme to apply
|
||||
* @param obj object to style
|
||||
*/
|
||||
static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj);
|
||||
|
||||
/**
|
||||
* Handle LV_EVENT_DRAW_TASK_ADDED events from the keyboard widget.
|
||||
*
|
||||
* @param event the event object
|
||||
*/
|
||||
static void keyboard_draw_task_added_cb(lv_event_t *event);
|
||||
|
||||
|
||||
/**
|
||||
* Static functions
|
||||
*/
|
||||
|
||||
static void init_styles(const ul_theme *theme) {
|
||||
reset_style(&(styles.widget));
|
||||
lv_style_set_text_font(&(styles.widget), &font_32);
|
||||
|
||||
reset_style(&(styles.window));
|
||||
lv_style_set_bg_opa(&(styles.window), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.window), lv_color_hex(theme->window.bg_color));
|
||||
|
||||
reset_style(&(styles.header));
|
||||
lv_style_set_bg_opa(&(styles.header), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.header), lv_color_hex(theme->header.bg_color));
|
||||
lv_style_set_border_side(&(styles.header), LV_BORDER_SIDE_BOTTOM);
|
||||
lv_style_set_border_width(&(styles.header), lv_dpx(theme->header.border_width));
|
||||
lv_style_set_border_color(&(styles.header), lv_color_hex(theme->header.border_color));
|
||||
lv_style_set_pad_all(&(styles.header), lv_dpx(theme->header.pad));
|
||||
lv_style_set_pad_gap(&(styles.header), lv_dpx(theme->header.gap));
|
||||
|
||||
reset_style(&(styles.keyboard));
|
||||
lv_style_set_bg_opa(&(styles.keyboard), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.keyboard), lv_color_hex(theme->keyboard.bg_color));
|
||||
lv_style_set_border_side(&(styles.keyboard), LV_BORDER_SIDE_TOP);
|
||||
lv_style_set_border_width(&(styles.keyboard), lv_dpx(theme->keyboard.border_width));
|
||||
lv_style_set_border_color(&(styles.keyboard), lv_color_hex(theme->keyboard.border_color));
|
||||
lv_style_set_pad_all(&(styles.keyboard), lv_dpx(theme->keyboard.pad));
|
||||
lv_style_set_pad_gap(&(styles.keyboard), lv_dpx(theme->keyboard.gap));
|
||||
|
||||
reset_style(&(styles.key));
|
||||
lv_style_set_bg_opa(&(styles.key), LV_OPA_COVER);
|
||||
lv_style_set_border_side(&(styles.key), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.key), lv_dpx(theme->keyboard.keys.border_width));
|
||||
lv_style_set_radius(&(styles.key), lv_dpx(theme->keyboard.keys.corner_radius));
|
||||
|
||||
reset_style(&(styles.button));
|
||||
lv_style_set_text_color(&(styles.button), lv_color_hex(theme->button.normal.fg_color));
|
||||
lv_style_set_bg_opa(&(styles.button), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.button), lv_color_hex(theme->button.normal.bg_color));
|
||||
lv_style_set_border_side(&(styles.button), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.button), lv_dpx(theme->button.border_width));
|
||||
lv_style_set_border_color(&(styles.button), lv_color_hex(theme->button.normal.border_color));
|
||||
lv_style_set_radius(&(styles.button), lv_dpx(theme->button.corner_radius));
|
||||
lv_style_set_pad_all(&(styles.button), lv_dpx(theme->button.pad));
|
||||
|
||||
reset_style(&(styles.button_pressed));
|
||||
lv_style_set_text_color(&(styles.button_pressed), lv_color_hex(theme->button.pressed.fg_color));
|
||||
lv_style_set_bg_color(&(styles.button_pressed), lv_color_hex(theme->button.pressed.bg_color));
|
||||
lv_style_set_border_color(&(styles.button_pressed), lv_color_hex(theme->button.pressed.border_color));
|
||||
|
||||
reset_style(&(styles.textarea));
|
||||
lv_style_set_text_color(&(styles.textarea), lv_color_hex(theme->textarea.fg_color));
|
||||
lv_style_set_bg_opa(&(styles.textarea), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.textarea), lv_color_hex(theme->textarea.bg_color));
|
||||
lv_style_set_border_side(&(styles.textarea), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.textarea), lv_dpx(theme->textarea.border_width));
|
||||
lv_style_set_border_color(&(styles.textarea), lv_color_hex(theme->textarea.border_color));
|
||||
lv_style_set_radius(&(styles.textarea), lv_dpx(theme->textarea.corner_radius));
|
||||
lv_style_set_pad_all(&(styles.textarea), lv_dpx(theme->textarea.pad));
|
||||
|
||||
reset_style(&(styles.textarea_placeholder));
|
||||
lv_style_set_text_color(&(styles.textarea_placeholder), lv_color_hex(theme->textarea.placeholder_color));
|
||||
|
||||
reset_style(&(styles.textarea_cursor));
|
||||
lv_style_set_border_side(&(styles.textarea_cursor), LV_BORDER_SIDE_LEFT);
|
||||
lv_style_set_border_width(&(styles.textarea_cursor), lv_dpx(theme->textarea.cursor.width));
|
||||
lv_style_set_border_color(&(styles.textarea_cursor), lv_color_hex(theme->textarea.cursor.color));
|
||||
lv_style_set_anim_time(&(styles.textarea_cursor), theme->textarea.cursor.period);
|
||||
|
||||
reset_style(&(styles.dropdown));
|
||||
lv_style_set_text_color(&(styles.dropdown), lv_color_hex(theme->dropdown.button.normal.fg_color));
|
||||
lv_style_set_bg_opa(&(styles.dropdown), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.dropdown), lv_color_hex(theme->dropdown.button.normal.bg_color));
|
||||
lv_style_set_border_side(&(styles.dropdown), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.dropdown), lv_dpx(theme->dropdown.button.border_width));
|
||||
lv_style_set_border_color(&(styles.dropdown), lv_color_hex(theme->dropdown.button.normal.border_color));
|
||||
lv_style_set_radius(&(styles.dropdown), lv_dpx(theme->dropdown.button.corner_radius));
|
||||
lv_style_set_pad_all(&(styles.dropdown), lv_dpx(theme->dropdown.button.pad));
|
||||
|
||||
reset_style(&(styles.dropdown_pressed));
|
||||
lv_style_set_text_color(&(styles.dropdown_pressed), lv_color_hex(theme->dropdown.button.pressed.fg_color));
|
||||
lv_style_set_bg_color(&(styles.dropdown_pressed), lv_color_hex(theme->dropdown.button.pressed.bg_color));
|
||||
lv_style_set_border_color(&(styles.dropdown_pressed), lv_color_hex(theme->dropdown.button.pressed.border_color));
|
||||
|
||||
reset_style(&(styles.dropdown_list));
|
||||
lv_style_set_text_color(&(styles.dropdown_list), lv_color_hex(theme->dropdown.list.fg_color));
|
||||
lv_style_set_bg_opa(&(styles.dropdown_list), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.dropdown_list), lv_color_hex(theme->dropdown.list.bg_color));
|
||||
lv_style_set_border_side(&(styles.dropdown_list), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.dropdown_list), lv_dpx(theme->dropdown.list.border_width));
|
||||
lv_style_set_border_color(&(styles.dropdown_list), lv_color_hex(theme->dropdown.list.border_color));
|
||||
lv_style_set_radius(&(styles.dropdown_list), lv_dpx(theme->dropdown.list.corner_radius));
|
||||
lv_style_set_pad_all(&(styles.dropdown_list), lv_dpx(theme->dropdown.list.pad));
|
||||
|
||||
reset_style(&(styles.dropdown_list_selected));
|
||||
lv_style_set_text_color(&(styles.dropdown_list_selected), lv_color_hex(theme->dropdown.list.selection_fg_color));
|
||||
lv_style_set_bg_opa(&(styles.dropdown_list_selected), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.dropdown_list_selected), lv_color_hex(theme->dropdown.list.selection_bg_color));
|
||||
|
||||
reset_style(&(styles.label));
|
||||
lv_style_set_text_color(&(styles.label), lv_color_hex(theme->label.fg_color));
|
||||
|
||||
reset_style(&(styles.msgbox));
|
||||
lv_style_set_text_color(&(styles.msgbox), lv_color_hex(theme->msgbox.fg_color));
|
||||
lv_style_set_bg_opa(&(styles.msgbox), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.msgbox), lv_color_hex(theme->msgbox.bg_color));
|
||||
lv_style_set_border_side(&(styles.msgbox), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.msgbox), lv_dpx(theme->msgbox.border_width));
|
||||
lv_style_set_border_color(&(styles.msgbox), lv_color_hex(theme->msgbox.border_color));
|
||||
lv_style_set_radius(&(styles.msgbox), lv_dpx(theme->msgbox.corner_radius));
|
||||
lv_style_set_pad_all(&(styles.msgbox), lv_dpx(theme->msgbox.pad));
|
||||
|
||||
reset_style(&(styles.msgbox_label));
|
||||
lv_style_set_text_align(&(styles.msgbox_label), LV_TEXT_ALIGN_CENTER);
|
||||
lv_style_set_pad_bottom(&(styles.msgbox_label), lv_dpx(theme->msgbox.gap));
|
||||
|
||||
reset_style(&(styles.msgbox_btnmatrix));
|
||||
lv_style_set_pad_gap(&(styles.msgbox_btnmatrix), lv_dpx(theme->msgbox.buttons.gap));
|
||||
lv_style_set_min_width(&(styles.msgbox_btnmatrix), LV_PCT(100));
|
||||
|
||||
reset_style(&(styles.msgbox_background));
|
||||
lv_style_set_bg_color(&(styles.msgbox_background), lv_color_hex(theme->msgbox.dimming.color));
|
||||
lv_style_set_bg_opa(&(styles.msgbox_background), theme->msgbox.dimming.opacity);
|
||||
|
||||
reset_style(&(styles.bar));
|
||||
lv_style_set_border_side(&(styles.bar), LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_border_width(&(styles.bar), lv_dpx(theme->bar.border_width));
|
||||
lv_style_set_border_color(&(styles.bar), lv_color_hex(theme->bar.border_color));
|
||||
lv_style_set_radius(&(styles.bar), lv_dpx(theme->bar.corner_radius));
|
||||
|
||||
reset_style(&(styles.bar_indicator));
|
||||
lv_style_set_bg_opa(&(styles.bar_indicator), LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&(styles.bar_indicator), lv_color_hex(theme->bar.indicator.bg_color));
|
||||
|
||||
are_styles_initialised = true;
|
||||
}
|
||||
|
||||
static void reset_style(lv_style_t *style) {
|
||||
if (are_styles_initialised) {
|
||||
lv_style_reset(style);
|
||||
} else {
|
||||
lv_style_init(style);
|
||||
}
|
||||
}
|
||||
|
||||
static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj) {
|
||||
LV_UNUSED(theme);
|
||||
|
||||
lv_obj_add_style(obj, &(styles.widget), 0);
|
||||
|
||||
if (lv_obj_get_parent(obj) == NULL) {
|
||||
lv_obj_add_style(obj, &(styles.window), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_has_flag(obj, UL_WIDGET_HEADER)) {
|
||||
lv_obj_add_style(obj, &(styles.header), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_keyboard_class)) {
|
||||
lv_obj_add_style(obj, &(styles.keyboard), 0);
|
||||
lv_obj_add_style(obj, &(styles.key), LV_PART_ITEMS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_button_class)) {
|
||||
lv_obj_add_style(obj, &(styles.button), 0);
|
||||
lv_obj_add_style(obj, &(styles.button_pressed), LV_STATE_PRESSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_label_class) && lv_obj_check_type(lv_obj_get_parent(obj), &lv_button_class)) {
|
||||
return; /* Inherit styling from button */
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_textarea_class)) {
|
||||
lv_obj_add_style(obj, &(styles.textarea), 0);
|
||||
lv_obj_add_style(obj, &(styles.textarea_placeholder), LV_PART_TEXTAREA_PLACEHOLDER);
|
||||
lv_obj_add_style(obj, &(styles.textarea_cursor), LV_PART_CURSOR | LV_STATE_FOCUSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_label_class) && lv_obj_check_type(lv_obj_get_parent(obj), &lv_textarea_class)) {
|
||||
return; /* Inherit styling from textarea */
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_dropdown_class)) {
|
||||
lv_obj_add_style(obj, &(styles.dropdown), 0);
|
||||
lv_obj_add_style(obj, &(styles.dropdown_pressed), LV_STATE_PRESSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_dropdownlist_class)) {
|
||||
lv_obj_add_style(obj, &(styles.dropdown_list), 0);
|
||||
lv_obj_add_style(obj, &(styles.dropdown_list_selected), LV_PART_SELECTED | LV_STATE_CHECKED);
|
||||
lv_obj_add_style(obj, &(styles.dropdown_list_selected), LV_PART_SELECTED | LV_STATE_PRESSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_label_class) && lv_obj_check_type(lv_obj_get_parent(obj), &lv_dropdownlist_class)) {
|
||||
return; /* Inherit styling from dropdown list */
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_msgbox_class)) {
|
||||
lv_obj_add_style(obj, &(styles.msgbox), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_label_class) && (lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class) || lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_content_class))) {
|
||||
lv_obj_add_style(obj, &(styles.msgbox_label), 0);
|
||||
return; /* Inherit styling from message box */
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_buttonmatrix_class) && lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
|
||||
lv_obj_add_style(obj, &(styles.msgbox_btnmatrix), 0);
|
||||
lv_obj_add_style(obj, &(styles.button), LV_PART_ITEMS);
|
||||
lv_obj_add_style(obj, &(styles.button_pressed), LV_PART_ITEMS | LV_STATE_PRESSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_msgbox_backdrop_class)) {
|
||||
lv_obj_add_style(obj, &(styles.msgbox_background), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_label_class) || lv_obj_check_type(obj, &lv_spangroup_class)) {
|
||||
lv_obj_add_style(obj, &(styles.label), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_bar_class)) {
|
||||
lv_obj_add_style(obj, &(styles.bar), 0);
|
||||
lv_obj_add_style(obj, &(styles.bar_indicator), LV_PART_INDICATOR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void keyboard_draw_task_added_cb(lv_event_t *event) {
|
||||
lv_obj_t *obj = lv_event_get_target(event);
|
||||
lv_buttonmatrix_t *btnm = (lv_buttonmatrix_t *)obj;
|
||||
lv_draw_task_t *draw_task = lv_event_get_draw_task(event);
|
||||
lv_draw_dsc_base_t *dsc = draw_task->draw_dsc;
|
||||
|
||||
if (dsc->part != LV_PART_ITEMS) {
|
||||
return;
|
||||
}
|
||||
|
||||
ul_theme_key *key = NULL;
|
||||
|
||||
if ((btnm->ctrl_bits[dsc->id1] & SQ2LV_CTRL_MOD_INACTIVE) == SQ2LV_CTRL_MOD_INACTIVE) {
|
||||
key = &(current_theme.keyboard.keys.key_mod_inact);
|
||||
} else if ((btnm->ctrl_bits[dsc->id1] & SQ2LV_CTRL_MOD_ACTIVE) == SQ2LV_CTRL_MOD_ACTIVE) {
|
||||
key = &(current_theme.keyboard.keys.key_mod_act);
|
||||
} else if ((btnm->ctrl_bits[dsc->id1] & SQ2LV_CTRL_NON_CHAR) == SQ2LV_CTRL_NON_CHAR) {
|
||||
key = &(current_theme.keyboard.keys.key_non_char);
|
||||
} else {
|
||||
key = &(current_theme.keyboard.keys.key_char);
|
||||
}
|
||||
|
||||
bool pressed = lv_btnmatrix_get_selected_btn(obj) == dsc->id1 && lv_obj_has_state(obj, LV_STATE_PRESSED);
|
||||
|
||||
lv_draw_label_dsc_t *label_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if (label_dsc) {
|
||||
label_dsc->color = lv_color_hex((pressed ? key->pressed : key->normal).fg_color);
|
||||
}
|
||||
|
||||
lv_draw_fill_dsc_t *fill_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if (fill_dsc) {
|
||||
fill_dsc->color = lv_color_hex((pressed ? key->pressed : key->normal).bg_color);
|
||||
}
|
||||
|
||||
lv_draw_border_dsc_t *border_dsc = lv_draw_task_get_border_dsc(draw_task);
|
||||
if (border_dsc) {
|
||||
border_dsc->color = lv_color_hex((pressed ? key->pressed : key->normal).border_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
void ul_theme_prepare_keyboard(lv_obj_t *keyboard) {
|
||||
lv_obj_add_event_cb(keyboard, keyboard_draw_task_added_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
|
||||
lv_obj_add_flag(keyboard, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
|
||||
}
|
||||
|
||||
void ul_theme_apply(const ul_theme *theme) {
|
||||
if (!theme) {
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Could not apply theme from NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_theme.disp = NULL;
|
||||
lv_theme.font_small = &font_32;
|
||||
lv_theme.font_normal = &font_32;
|
||||
lv_theme.font_large = &font_32;
|
||||
lv_theme.apply_cb = apply_theme_cb;
|
||||
|
||||
current_theme = *theme;
|
||||
init_styles(theme);
|
||||
|
||||
lv_obj_report_style_change(NULL);
|
||||
lv_disp_set_theme(NULL, &lv_theme);
|
||||
lv_theme_apply(lv_scr_act());
|
||||
}
|
||||
191
unl0kr/theme.h
191
unl0kr/theme.h
|
|
@ -1,191 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Johannes Marbach
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#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 */
|
||||
668
unl0kr/themes.c
668
unl0kr/themes.c
|
|
@ -1,668 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Johannes Marbach
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#include "themes.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/**
|
||||
* Static variables
|
||||
*/
|
||||
|
||||
/* Breezy light (based on KDE Breeze color palette, see https://develop.kde.org/hig/style/color/default/) */
|
||||
static const ul_theme ul_themes_breezy_light = {
|
||||
.name = "breezy-light",
|
||||
.window = {
|
||||
.bg_color = 0xeff0f1
|
||||
},
|
||||
.header = {
|
||||
.bg_color = 0xfcfcfc,
|
||||
.border_width = 1,
|
||||
.border_color = 0xbdc3c7,
|
||||
.pad = 10,
|
||||
.gap = 10
|
||||
},
|
||||
.keyboard = {
|
||||
.bg_color = 0xfcfcfc,
|
||||
.border_width = 1,
|
||||
.border_color = 0xbdc3c7,
|
||||
.pad = 10,
|
||||
.gap = 10,
|
||||
.keys = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 5,
|
||||
.key_char = {
|
||||
.normal = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xeff0f1,
|
||||
.border_color = 0xbdc3c7
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.key_non_char = {
|
||||
.normal = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xbdc3c7,
|
||||
.border_color = 0x7f8c8d
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.key_mod_act = {
|
||||
.normal = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.key_mod_inact = {
|
||||
.normal = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xbdc3c7,
|
||||
.border_color = 0x7f8c8d
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 5,
|
||||
.pad = 5,
|
||||
.normal = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xeff0f1,
|
||||
.border_color = 0xbdc3c7
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.textarea = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xfcfcfc,
|
||||
.border_width = 1,
|
||||
.border_color = 0xbdc3c7,
|
||||
.corner_radius = 5,
|
||||
.pad = 5,
|
||||
.placeholder_color = 0x7f8c8d,
|
||||
.cursor = {
|
||||
.width = 1,
|
||||
.color = 0x232629,
|
||||
.period = 700
|
||||
}
|
||||
},
|
||||
.dropdown = {
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 5,
|
||||
.pad = 5,
|
||||
.normal = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xeff0f1,
|
||||
.border_color = 0xbdc3c7
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.list = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xfcfcfc,
|
||||
.selection_fg_color = 0x232629,
|
||||
.selection_bg_color = 0x3daee9,
|
||||
.border_width = 1,
|
||||
.border_color = 0xbdc3c7,
|
||||
.corner_radius = 0,
|
||||
.pad = 0
|
||||
}
|
||||
},
|
||||
.label = {
|
||||
.fg_color = 0x232629
|
||||
},
|
||||
.msgbox = {
|
||||
.fg_color = 0x232629,
|
||||
.bg_color = 0xeff0f1,
|
||||
.border_width = 1,
|
||||
.border_color = 0xbdc3c7,
|
||||
.corner_radius = 0,
|
||||
.pad = 20,
|
||||
.gap = 20,
|
||||
.buttons = {
|
||||
.gap = 5
|
||||
},
|
||||
.dimming = {
|
||||
.color = 0x232629,
|
||||
.opacity = 178
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x3daee9,
|
||||
.corner_radius = 5,
|
||||
.indicator = {
|
||||
.bg_color = 0x3daee9
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Breezy dark (based on KDE Breeze Dark color palette, see https://develop.kde.org/hig/style/color/dark/) */
|
||||
static const ul_theme ul_themes_breezy_dark = {
|
||||
.name = "breezy-dark",
|
||||
.window = {
|
||||
.bg_color = 0x31363b
|
||||
},
|
||||
.header = {
|
||||
.bg_color = 0x232629,
|
||||
.border_width = 1,
|
||||
.border_color = 0x7f8c8d,
|
||||
.pad = 10,
|
||||
.gap = 10
|
||||
},
|
||||
.keyboard = {
|
||||
.bg_color = 0x232629,
|
||||
.border_width = 1,
|
||||
.border_color = 0x7f8c8d,
|
||||
.pad = 10,
|
||||
.gap = 10,
|
||||
.keys = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 5,
|
||||
.key_char = {
|
||||
.normal = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x31363b,
|
||||
.border_color = 0xbdc3c7
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.key_non_char = {
|
||||
.normal = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x232629,
|
||||
.border_color = 0x7f8c8d
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.key_mod_act = {
|
||||
.normal = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.key_mod_inact = {
|
||||
.normal = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x232629,
|
||||
.border_color = 0x7f8c8d
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 5,
|
||||
.pad = 5,
|
||||
.normal = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x31363b,
|
||||
.border_color = 0xbdc3c7
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.textarea = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x232629,
|
||||
.border_width = 1,
|
||||
.border_color = 0x7f8c8d,
|
||||
.corner_radius = 5,
|
||||
.pad = 5,
|
||||
.placeholder_color = 0x7f8c8d,
|
||||
.cursor = {
|
||||
.width = 1,
|
||||
.color = 0xeff0f1,
|
||||
.period = 700
|
||||
}
|
||||
},
|
||||
.dropdown = {
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 5,
|
||||
.pad = 5,
|
||||
.normal = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x31363b,
|
||||
.border_color = 0xbdc3c7
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x3daee9,
|
||||
.border_color = 0x2980b9
|
||||
}
|
||||
},
|
||||
.list = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x232629,
|
||||
.selection_fg_color = 0x232629,
|
||||
.selection_bg_color = 0x3daee9,
|
||||
.border_width = 1,
|
||||
.border_color = 0x7f8c8d,
|
||||
.corner_radius = 0,
|
||||
.pad = 0
|
||||
}
|
||||
},
|
||||
.label = {
|
||||
.fg_color = 0xeff0f1
|
||||
},
|
||||
.msgbox = {
|
||||
.fg_color = 0xeff0f1,
|
||||
.bg_color = 0x31363b,
|
||||
.border_width = 1,
|
||||
.border_color = 0x3b4045,
|
||||
.corner_radius = 0,
|
||||
.pad = 20,
|
||||
.gap = 20,
|
||||
.buttons = {
|
||||
.gap = 5
|
||||
},
|
||||
.dimming = {
|
||||
.color = 0x232629,
|
||||
.opacity = 178
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x3daee9,
|
||||
.corner_radius = 5,
|
||||
.indicator = {
|
||||
.bg_color = 0x3daee9
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* pmOS light (based on palette https://coolors.co/009900-395e66-db504a-e3b505-ebf5ee) */
|
||||
static const ul_theme ul_themes_pmos_light = {
|
||||
.name = "pmos-light",
|
||||
.window = {
|
||||
.bg_color = 0xf2f7f8,
|
||||
},
|
||||
.header = {
|
||||
.bg_color = 0xf2f7f8,
|
||||
.border_width = 0,
|
||||
.border_color = 0xf2f7f8,
|
||||
.pad = 20,
|
||||
.gap = 10
|
||||
},
|
||||
.keyboard = {
|
||||
.bg_color = 0xd8e6e9,
|
||||
.border_width = 2,
|
||||
.border_color = 0x97bcc4,
|
||||
.pad = 20,
|
||||
.gap = 10,
|
||||
.keys = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 3,
|
||||
.key_char = {
|
||||
.normal = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xd8e6e9,
|
||||
.border_color = 0x97bcc4
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.key_non_char = {
|
||||
.normal = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xbed5da,
|
||||
.border_color = 0xb1cdd3
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.key_mod_act = {
|
||||
.normal = {
|
||||
.fg_color = 0x009900,
|
||||
.bg_color = 0xbed5da,
|
||||
.border_color = 0x009900
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.key_mod_inact = {
|
||||
.normal = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xbed5da,
|
||||
.border_color = 0xb1cdd3
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 3,
|
||||
.pad = 8,
|
||||
.normal = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xbed5da,
|
||||
.border_color = 0xb1cdd3
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.textarea = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xebffeb,
|
||||
.border_width = 1,
|
||||
.border_color = 0x009900,
|
||||
.corner_radius = 3,
|
||||
.pad = 8,
|
||||
.placeholder_color = 0x009900,
|
||||
.cursor = {
|
||||
.width = 2,
|
||||
.color = 0x009900,
|
||||
.period = 700
|
||||
}
|
||||
},
|
||||
.dropdown = {
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 3,
|
||||
.pad = 8,
|
||||
.normal = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xbed5da,
|
||||
.border_color = 0xb1cdd3
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.list = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xd8e6e9,
|
||||
.selection_fg_color = 0xf2f7f8,
|
||||
.selection_bg_color = 0x009900,
|
||||
.border_width = 1,
|
||||
.border_color = 0x97bcc4,
|
||||
.corner_radius = 0,
|
||||
.pad = 8
|
||||
}
|
||||
},
|
||||
.label = {
|
||||
.fg_color = 0x070c0d
|
||||
},
|
||||
.msgbox = {
|
||||
.fg_color = 0x070c0d,
|
||||
.bg_color = 0xd8e6e9,
|
||||
.border_width = 1,
|
||||
.border_color = 0x97bcc4,
|
||||
.corner_radius = 3,
|
||||
.pad = 20,
|
||||
.gap = 20,
|
||||
.buttons = {
|
||||
.gap = 10
|
||||
},
|
||||
.dimming = {
|
||||
.color = 0x070c0d,
|
||||
.opacity = 225
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x009900,
|
||||
.corner_radius = 3,
|
||||
.indicator = {
|
||||
.bg_color = 0x009900
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* pmOS dark (based on palette https://coolors.co/009900-395e66-db504a-e3b505-ebf5ee) */
|
||||
static const ul_theme ul_themes_pmos_dark = {
|
||||
.name = "pmos-dark",
|
||||
.window = {
|
||||
.bg_color = 0x070c0d
|
||||
},
|
||||
.header = {
|
||||
.bg_color = 0x070c0d,
|
||||
.border_width = 0,
|
||||
.border_color = 0x070c0d,
|
||||
.pad = 20,
|
||||
.gap = 10
|
||||
},
|
||||
.keyboard = {
|
||||
.bg_color = 0x162427,
|
||||
.border_width = 2,
|
||||
.border_color = 0x395e66,
|
||||
.pad = 20,
|
||||
.gap = 10,
|
||||
.keys = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 3,
|
||||
.key_char = {
|
||||
.normal = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x162427,
|
||||
.border_color = 0x395e66
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.key_non_char = {
|
||||
.normal = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x253c41,
|
||||
.border_color = 0x2c484e
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.key_mod_act = {
|
||||
.normal = {
|
||||
.fg_color = 0x009900,
|
||||
.bg_color = 0x253c41,
|
||||
.border_color = 0x009900
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.key_mod_inact = {
|
||||
.normal = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x253c41,
|
||||
.border_color = 0x2c484e
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 3,
|
||||
.pad = 8,
|
||||
.normal = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x253c41,
|
||||
.border_color = 0x2c484e
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.textarea = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x002900,
|
||||
.border_width = 1,
|
||||
.border_color = 0x009900,
|
||||
.corner_radius = 3,
|
||||
.pad = 8,
|
||||
.placeholder_color = 0x009900,
|
||||
.cursor = {
|
||||
.width = 2,
|
||||
.color = 0x009900,
|
||||
.period = 700
|
||||
}
|
||||
},
|
||||
.dropdown = {
|
||||
.button = {
|
||||
.border_width = 1,
|
||||
.corner_radius = 3,
|
||||
.pad = 8,
|
||||
.normal = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x253c41,
|
||||
.border_color = 0x2c484e
|
||||
},
|
||||
.pressed = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x009900,
|
||||
.border_color = 0x009900
|
||||
}
|
||||
},
|
||||
.list = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x162427,
|
||||
.selection_fg_color = 0xf2f7f8,
|
||||
.selection_bg_color = 0x009900,
|
||||
.border_width = 1,
|
||||
.border_color = 0x395e66,
|
||||
.corner_radius = 0,
|
||||
.pad = 8
|
||||
}
|
||||
},
|
||||
.label = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
},
|
||||
.msgbox = {
|
||||
.fg_color = 0xf2f7f8,
|
||||
.bg_color = 0x162427,
|
||||
.border_width = 1,
|
||||
.border_color = 0x395e66,
|
||||
.corner_radius = 3,
|
||||
.pad = 20,
|
||||
.gap = 20,
|
||||
.buttons = {
|
||||
.gap = 10
|
||||
},
|
||||
.dimming = {
|
||||
.color = 0x070c0d,
|
||||
.opacity = 225
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x009900,
|
||||
.corner_radius = 3,
|
||||
.indicator = {
|
||||
.bg_color = 0x009900
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Public interface
|
||||
*/
|
||||
|
||||
const int ul_themes_num_themes = 4;
|
||||
const ul_theme *ul_themes_themes[] = {
|
||||
&ul_themes_breezy_light,
|
||||
&ul_themes_breezy_dark,
|
||||
&ul_themes_pmos_light,
|
||||
&ul_themes_pmos_dark
|
||||
};
|
||||
|
||||
ul_themes_theme_id_t ul_themes_find_theme_with_name(const char *name) {
|
||||
for (int i = 0; i < ul_themes_num_themes; ++i) {
|
||||
if (strcmp(ul_themes_themes[i]->name, name) == 0) {
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Found theme: %s\n", name);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Theme %s not found\n", name);
|
||||
return UL_THEMES_THEME_NONE;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Johannes Marbach
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UL_THEMES_H
|
||||
#define UL_THEMES_H
|
||||
|
||||
#include "theme.h"
|
||||
|
||||
/* Theme IDs, values can be used as indexes into the ul_themes_themes array */
|
||||
typedef enum {
|
||||
UL_THEMES_THEME_NONE = -1,
|
||||
UL_THEMES_THEME_BREEZY_LIGHT = 0,
|
||||
UL_THEMES_THEME_BREEZY_DARK = 1,
|
||||
UL_THEMES_THEME_PMOS_LIGHT = 2,
|
||||
UL_THEMES_THEME_PMOS_DARK = 3
|
||||
} ul_themes_theme_id_t;
|
||||
|
||||
/* Themes */
|
||||
extern const int ul_themes_num_themes;
|
||||
extern const ul_theme *ul_themes_themes[];
|
||||
|
||||
/**
|
||||
* Find the first theme with a given name.
|
||||
*
|
||||
* @param name theme name
|
||||
* @return ID of the first matching theme or UL_THEMES_THEME_NONE if no theme matched
|
||||
*/
|
||||
ul_themes_theme_id_t ul_themes_find_theme_with_name(const char *name);
|
||||
|
||||
#endif /* UL_THEMES_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue