Add styling for lv_bar widget
This commit is contained in:
parent
aabaa9aabc
commit
9b9d9bf535
3 changed files with 64 additions and 0 deletions
18
theme.c
18
theme.c
|
|
@ -52,6 +52,8 @@ static struct {
|
|||
lv_style_t msgbox;
|
||||
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;
|
||||
|
|
@ -207,6 +209,16 @@ static void init_styles(const ul_theme *theme) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -285,6 +297,12 @@ static void apply_theme_cb(lv_theme_t *theme, lv_obj_t *obj) {
|
|||
lv_obj_add_style(obj, &(styles.msgbox_background), 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_part_begin_cb(lv_event_t *event) {
|
||||
|
|
|
|||
14
theme.h
14
theme.h
|
|
@ -171,6 +171,19 @@ typedef struct {
|
|||
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;
|
||||
|
|
@ -182,6 +195,7 @@ typedef struct {
|
|||
ul_theme_dropdown dropdown;
|
||||
ul_theme_label label;
|
||||
ul_theme_msgbox msgbox;
|
||||
ul_theme_bar bar;
|
||||
} ul_theme;
|
||||
|
||||
/**
|
||||
|
|
|
|||
32
themes.c
32
themes.c
|
|
@ -164,6 +164,14 @@ static const ul_theme ul_themes_breezy_light = {
|
|||
.color = 0x232629,
|
||||
.opacity = 178
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x3daee9,
|
||||
.corner_radius = 5,
|
||||
.indicator = {
|
||||
.bg_color = 0x3daee9
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -307,6 +315,14 @@ static const ul_theme ul_themes_breezy_dark = {
|
|||
.color = 0x232629,
|
||||
.opacity = 178
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x3daee9,
|
||||
.corner_radius = 5,
|
||||
.indicator = {
|
||||
.bg_color = 0x3daee9
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -449,6 +465,14 @@ static const ul_theme ul_themes_pmos_light = {
|
|||
.color = 0x232629,
|
||||
.opacity = 178
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x009900,
|
||||
.corner_radius = 5,
|
||||
.indicator = {
|
||||
.bg_color = 0x009900
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -591,6 +615,14 @@ static const ul_theme ul_themes_pmos_dark = {
|
|||
.color = 0x232629,
|
||||
.opacity = 178
|
||||
}
|
||||
},
|
||||
.bar = {
|
||||
.border_width = 1,
|
||||
.border_color = 0x009900,
|
||||
.corner_radius = 5,
|
||||
.indicator = {
|
||||
.bg_color = 0x009900
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue