This commit is contained in:
Johannes Marbach 2022-11-05 21:29:21 +01:00
parent fb83848f53
commit f391269bdd
5 changed files with 190 additions and 156 deletions

41
theme.c
View file

@ -46,6 +46,7 @@ static struct {
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;
@ -164,14 +165,19 @@ static void init_styles(const ul_theme *theme) {
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.box.fg_color));
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.box.bg_color));
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.box.border_width));
lv_style_set_border_color(&(styles.dropdown), lv_color_hex(theme->dropdown.box.border_color));
lv_style_set_radius(&(styles.dropdown), lv_dpx(theme->dropdown.box.corner_radius));
lv_style_set_pad_all(&(styles.dropdown), lv_dpx(theme->dropdown.box.pad));
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));
@ -257,6 +263,10 @@ static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj) {
return;
}
if (lv_obj_check_type(obj, &lv_label_class) && lv_obj_check_type(lv_obj_get_parent(obj), &lv_btn_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);
@ -264,8 +274,13 @@ static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj) {
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;
}
@ -276,9 +291,8 @@ static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj) {
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_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)) {
@ -286,6 +300,15 @@ static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj) {
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))) {
return; /* Inherit styling from message box */
}
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_btnmatrix_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);