diff --git a/lv_conf_template.h b/lv_conf_template.h index 6d116edea..acf9bcc87 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -463,8 +463,8 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #define LV_USE_THEME_DEFAULT 1 #if LV_USE_THEME_DEFAULT -/*1: Light mode; 0: Dark mode*/ -# define LV_THEME_DEFAULT_PALETTE_LIGHT 1 +/*0: Light mode; 1: Dark mode*/ +# define LV_THEME_DEFAULT_DARK 0 /*1: Enable grow on press*/ # define LV_THEME_DEFAULT_GROW 1 diff --git a/src/core/lv_theme.c b/src/core/lv_theme.c index 9bd3fab6d..f8a0f50ae 100644 --- a/src/core/lv_theme.c +++ b/src/core/lv_theme.c @@ -95,18 +95,6 @@ const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj) return th ? th->font_large : LV_FONT_DEFAULT; } -lv_palette_t lv_theme_get_palette_primary(lv_obj_t * obj) -{ - lv_theme_t * th = lv_theme_get_from_obj(obj); - return th ? th->palette_primary : LV_PALETTE_BLUE_GREY; -} - -lv_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj) -{ - lv_theme_t * th = lv_theme_get_from_obj(obj); - return th ? th->palette_secondary : LV_PALETTE_BLUE; -} - lv_color_t lv_theme_get_color_primary(lv_obj_t * obj) { lv_theme_t * th = lv_theme_get_from_obj(obj); diff --git a/src/core/lv_theme.h b/src/core/lv_theme.h index bc23a41ca..f287a2c61 100644 --- a/src/core/lv_theme.h +++ b/src/core/lv_theme.h @@ -33,8 +33,6 @@ typedef struct _lv_theme_t { struct _lv_theme_t * parent; /**< Apply the current theme's style on top of this theme.*/ void * user_data; struct _lv_disp_t * disp; - lv_palette_t palette_primary; - lv_palette_t palette_secondary; lv_color_t color_primary; lv_color_t color_secondary; const lv_font_t * font_small; @@ -94,10 +92,6 @@ const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj); */ const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj); -lv_palette_t lv_theme_get_palette_primary(lv_obj_t * obj); - -lv_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj); - /** * Get the primary color of the theme * @return the color diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index c792ec380..7c5f0ccd8 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -33,8 +33,8 @@ #define BORDER_WIDTH LV_DPX(2) #define OUTLINE_WIDTH LV_DPX(3) -#define PAD_DEF (disp_size == DISP_LARGE ? LV_DPX(24) : disp_size == DISP_MEDIUM ? LV_DPX(20) : LV_DPX(20)) -#define PAD_SMALL (disp_size == DISP_LARGE ? LV_DPX(14) : disp_size == DISP_MEDIUM ? LV_DPX(12) : LV_DPX(12)) +#define PAD_DEF (disp_size == DISP_LARGE ? LV_DPX(24) : disp_size == DISP_MEDIUM ? LV_DPX(20) : LV_DPX(16)) +#define PAD_SMALL (disp_size == DISP_LARGE ? LV_DPX(14) : disp_size == DISP_MEDIUM ? LV_DPX(12) : LV_DPX(10)) #define PAD_TINY (disp_size == DISP_LARGE ? LV_DPX(8) : disp_size == DISP_MEDIUM ? LV_DPX(6) : LV_DPX(2)) /********************** @@ -165,8 +165,6 @@ static my_theme_styles_t * styles; static lv_theme_t theme; static disp_size_t disp_size; static bool inited; -static lv_color_t color_primary; -static lv_color_t color_secondary; static lv_color_t color_scr; static lv_color_t color_text; static lv_color_t color_card; @@ -206,17 +204,11 @@ static void style_init(void) 0 }; - color_primary = lv_palette_main(theme.palette_primary); - color_secondary = lv_palette_main(theme.palette_secondary); - color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD; color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY; - theme.color_primary = color_primary; - theme.color_secondary = color_secondary; - static lv_style_transition_dsc_t trans_delayed; lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70); @@ -263,13 +255,13 @@ static void style_init(void) lv_style_set_line_width(&styles->card, LV_DPX(1)); style_init_reset(&styles->outline_primary); - lv_style_set_outline_color(&styles->outline_primary, color_primary); + lv_style_set_outline_color(&styles->outline_primary, theme.color_primary); lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH); lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH); lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50); style_init_reset(&styles->outline_secondary); - lv_style_set_outline_color(&styles->outline_secondary, color_secondary); + lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary); lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH); lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50); @@ -338,23 +330,23 @@ static void style_init(void) lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY); style_init_reset(&styles->bg_color_primary); - lv_style_set_bg_color(&styles->bg_color_primary, color_primary); + lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary); lv_style_set_text_color(&styles->bg_color_primary, lv_color_white()); lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); style_init_reset(&styles->bg_color_primary_muted); - lv_style_set_bg_color(&styles->bg_color_primary_muted, color_primary); - lv_style_set_text_color(&styles->bg_color_primary_muted, color_primary); + lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary); + lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary); lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20); style_init_reset(&styles->bg_color_secondary); - lv_style_set_bg_color(&styles->bg_color_secondary, color_secondary); + lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER); style_init_reset(&styles->bg_color_secondary_muted); - lv_style_set_bg_color(&styles->bg_color_secondary_muted, color_secondary); - lv_style_set_text_color(&styles->bg_color_secondary_muted, color_secondary); + lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary); + lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary); lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20); style_init_reset(&styles->bg_color_grey); @@ -380,7 +372,7 @@ static void style_init(void) #endif style_init_reset(&styles->knob); - lv_style_set_bg_color(&styles->knob, color_primary); + lv_style_set_bg_color(&styles->knob, theme.color_primary); lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER); lv_style_set_pad_all(&styles->knob, LV_DPX(6)); lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE); @@ -395,14 +387,14 @@ static void style_init(void) lv_style_set_arc_rounded(&styles->arc_indic, true); style_init_reset(&styles->arc_indic_primary); - lv_style_set_arc_color(&styles->arc_indic_primary, color_primary); + lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary); #endif #if LV_USE_CHECKBOX style_init_reset(&styles->cb_marker); lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3)); lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH); - lv_style_set_border_color(&styles->cb_marker, color_primary); + lv_style_set_border_color(&styles->cb_marker, theme.color_primary); lv_style_set_bg_color(&styles->cb_marker, color_card); lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER); lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); @@ -514,7 +506,7 @@ static void style_init(void) #if LV_USE_TABVIEW style_init_reset(&styles->tab_btn); - lv_style_set_border_color(&styles->tab_btn, color_primary); + lv_style_set_border_color(&styles->tab_btn, theme.color_primary); lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2); lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM); #endif @@ -557,8 +549,7 @@ static void style_init(void) * GLOBAL FUNCTIONS **********************/ -lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primary, lv_palette_t palette_secondary, bool dark, - const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_large) +lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) { /*This trick is required only to avoid the garbage collection of @@ -574,11 +565,11 @@ lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primar else disp_size = DISP_LARGE; theme.disp = disp; - theme.palette_primary = palette_primary; - theme.palette_secondary = palette_secondary; - theme.font_small = font_small; - theme.font_normal = font_normal; - theme.font_large = font_large; + theme.color_primary = color_primary; + theme.color_secondary = color_secondary; + theme.font_small = font; + theme.font_normal = font; + theme.font_large = font; theme.apply_cb = theme_apply; theme.flags = dark ? MODE_DARK : 0; @@ -938,6 +929,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_TABVIEW if(lv_obj_check_type(obj, &lv_tabview_class)) { lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->pad_zero, 0); return; } #endif diff --git a/src/extra/themes/default/lv_theme_default.h b/src/extra/themes/default/lv_theme_default.h index a536c92c2..ef8502622 100644 --- a/src/extra/themes/default/lv_theme_default.h +++ b/src/extra/themes/default/lv_theme_default.h @@ -36,8 +36,7 @@ extern "C" { * @param font pointer to a font to use. * @return a pointer to reference this theme later */ -lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primary, lv_palette_t palette_secondary, - bool dark, const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_large); +lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font); bool lv_theme_default_is_inited(void); diff --git a/src/hal/lv_hal_disp.c b/src/hal/lv_hal_disp.c index 3ed258caa..812bae36c 100644 --- a/src/hal/lv_hal_disp.c +++ b/src/hal/lv_hal_disp.c @@ -132,7 +132,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) #if LV_USE_THEME_DEFAULT if(lv_theme_default_is_inited() == false) { - disp->theme = lv_theme_default_init(disp, LV_PALETTE_BLUE, LV_PALETTE_CYAN, !LV_THEME_DEFAULT_PALETTE_LIGHT, LV_FONT_DEFAULT, LV_FONT_DEFAULT, LV_FONT_DEFAULT); + disp->theme = lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT); } #endif diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 39747d4af..876bf1f46 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -1398,12 +1398,12 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #endif #if LV_USE_THEME_DEFAULT -/*1: Light mode; 0: Dark mode*/ -#ifndef LV_THEME_DEFAULT_PALETTE_LIGHT -# ifdef CONFIG_LV_THEME_DEFAULT_PALETTE_LIGHT -# define LV_THEME_DEFAULT_PALETTE_LIGHT CONFIG_LV_THEME_DEFAULT_PALETTE_LIGHT +/*0: Light mode; 1: Dark mode*/ +#ifndef LV_THEME_DEFAULT_DARK +# ifdef CONFIG_LV_THEME_DEFAULT_DARK +# define LV_THEME_DEFAULT_DARK CONFIG_LV_THEME_DEFAULT_DARK # else -# define LV_THEME_DEFAULT_PALETTE_LIGHT 1 +# define LV_THEME_DEFAULT_DARK 0 # endif #endif diff --git a/src/widgets/lv_switch.c b/src/widgets/lv_switch.c index c5b257854..e31df09e4 100644 --- a/src/widgets/lv_switch.c +++ b/src/widgets/lv_switch.c @@ -43,8 +43,8 @@ static void draw_main(lv_event_t * e); const lv_obj_class_t lv_switch_class = { .constructor_cb = lv_switch_constructor, .event_cb = lv_switch_event, - .width_def = (5 * LV_DPI_DEF) / 11, - .height_def = LV_DPI_DEF / 4, + .width_def = (4 * LV_DPI_DEF) / 10, + .height_def = (4 * LV_DPI_DEF) / 17, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .instance_size = sizeof(lv_switch_t), .base_class = &lv_obj_class