diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 59307fa08..eeb15fd0f 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -768,7 +768,7 @@ #endif #if LV_USE_LED #ifndef LV_LED_BRIGHT_MIN -# define LV_LED_BRIGHT_MIN 60 /*Minimal brightness*/ +# define LV_LED_BRIGHT_MIN 100 /*Minimal brightness*/ #endif #ifndef LV_LED_BRIGHT_MAX # define LV_LED_BRIGHT_MAX 255 /*Maximal brightness*/ diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index ffb1498a1..9fac2b858 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3842,10 +3842,22 @@ static void trans_anim_ready_cb(lv_anim_t * a) lv_style_trans_t * tr = a->var; /* Remove the transitioned property from trans. style - * to allow changing it by normal styles*/ - lv_style_list_t * list = lv_obj_get_style_list(tr->obj, tr->part); - lv_style_t * style_trans = lv_style_list_get_transition_style(list); - lv_style_remove_prop(style_trans, tr->prop); + * if there no more transitions for this property + * It allows changing it by normal styles*/ + + bool running = false; + lv_style_trans_t * tr_i; + LV_LL_READ(LV_GC_ROOT(_lv_obj_style_trans_ll), tr_i) { + if(tr_i != tr && tr_i->obj == tr->obj && tr_i->part == tr->part && tr_i->prop == tr->prop) { + running = true; + } + } + + if(!running) { + lv_style_list_t * list = lv_obj_get_style_list(tr->obj, tr->part); + lv_style_t * style_trans = lv_style_list_get_transition_style(list); + lv_style_remove_prop(style_trans, tr->prop); + } lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); lv_mem_free(tr); diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index e4b419544..94396a9ad 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -347,7 +347,7 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, if(flat) wcorr_i = (LV_MATH_ABS(ydiff) << 5) / LV_MATH_ABS(xdiff); else wcorr_i = (LV_MATH_ABS(xdiff) << 5) / LV_MATH_ABS(ydiff); - w = (w * wcorr[wcorr_i]) >> 7; + w = (w * wcorr[wcorr_i] + 63) >> 7; /*+ 63 for rounding*/ int32_t w_half0 = w >> 1; int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/ diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 29f50bbaa..dac90d957 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -133,7 +133,6 @@ typedef enum { #endif #if LV_USE_TEXTAREA LV_THEME_TEXTAREA, - LV_THEME_TEXTAREA_ONELINE, #endif #if LV_USE_TILEVIEW LV_THEME_TILEVIEW, diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 0b819eb2a..9a63ae525 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -8,6 +8,7 @@ *********************/ #include #include "lv_theme.h" +#include "lv_theme_material.h" #include "../lv_widgets/lv_img.h" #include "../lv_misc/lv_types.h" @@ -16,8 +17,52 @@ /********************* * DEFINES *********************/ -#define TRANSITION_TIME 200 -#define BORDER_WIDTH (LV_DPI / 50 > 0 ? LV_DPI / 50 : 1) + +/*SCREEN*/ +#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xeaeff3) : lv_color_hex(0x22252a)) +#define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xbababa)) + +/*BUTTON*/ +#define COLOR_BTN (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x303439)) +#define COLOR_BTN_PR (IS_LIGHT ? lv_color_mix(_color_primary, COLOR_BTN, LV_OPA_10) : lv_color_mix(_color_primary, COLOR_BTN, LV_OPA_10)) +#define COLOR_BTN_CHK (_color_primary) +#define COLOR_BTN_CHK_PR (lv_color_darken(_color_primary, LV_OPA_30)) +#define COLOR_BTN_DIS (IS_LIGHT ? lv_color_hex3(0x888) : lv_color_hex3(0x888)) + +#define COLOR_BTN_BORDER _color_primary +#define COLOR_BTN_BORDER_PR _color_primary +#define COLOR_BTN_BORDER_CHK _color_primary +#define COLOR_BTN_BORDER_CHK_PR _color_primary +#define COLOR_BTN_BORDER_INA (IS_LIGHT ? lv_color_hex(0x606060) : lv_color_hex(0x404040)) + +/*BACKGROUND*/ +#define COLOR_BG (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x303439)) +#define COLOR_BG_PR (IS_LIGHT ? lv_color_hex(0xeeeeee) : lv_color_hex(0x494f57)) +#define COLOR_BG_CHK _color_primary +#define COLOR_BG_PR_CHK lv_color_darken(_color_primary, LV_OPA_20) +#define COLOR_BG_DIS COLOR_BG + +#define COLOR_BG_BORDER (IS_LIGHT ? lv_color_hex(0xdfe7ed) : lv_color_hex(0x404040)) +#define COLOR_BG_BORDER_PR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0x404040)) +#define COLOR_BG_BORDER_CHK (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0x404040)) +#define COLOR_BG_BORDER_CHK_PR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0x404040)) +#define COLOR_BG_BORDER_DIS (IS_LIGHT ? lv_color_hex(0xdfe7ed) : lv_color_hex(0x404040)) + +#define COLOR_BG_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff)) +#define COLOR_BG_TEXT_PR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff)) +#define COLOR_BG_TEXT_CHK (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff)) +#define COLOR_BG_TEXT_CHK_PR (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff)) +#define COLOR_BG_TEXT_DIS (IS_LIGHT ? lv_color_hex3(0xaaa) : lv_color_hex3(0x777)) + +/*SECONDARY BACKGROUND*/ +#define COLOR_BG_SEC (IS_LIGHT ? lv_color_hex(0xd4d7d9) : lv_color_hex(0x45494d)) +#define COLOR_BG_SEC_BORDER (IS_LIGHT ? lv_color_hex(0xdfe7ed) : lv_color_hex(0x404040)) +#define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad)) +#define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad)) + +#define TRANSITION_TIME 150 + +#define IS_LIGHT palette == LV_THEME_MATERIAL_PALETTE_LIGHT /********************** * TYPEDEFS @@ -28,19 +73,6 @@ **********************/ static void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name); -static inline lv_color_t color_scr(lv_state_t state); -static inline lv_color_t color_panel(lv_state_t state); -static inline lv_color_t color_bg(lv_state_t state); -static inline lv_color_t color_btn(lv_state_t state); -static inline lv_color_t color_scr_border(lv_state_t state); -static inline lv_color_t color_panel_border(lv_state_t state); -static inline lv_color_t color_bg_border(lv_state_t state); -static inline lv_color_t color_btn_border(lv_state_t state); -static inline lv_color_t color_scr_txt(lv_state_t state); -static inline lv_color_t color_panel_txt(lv_state_t state); -static inline lv_color_t color_bg_txt(lv_state_t state); -static inline lv_color_t color_btn_txt(lv_state_t state); - /********************** * STATIC VARIABLES **********************/ @@ -51,16 +83,18 @@ static lv_font_t * _font_small; static lv_font_t * _font_normal; static lv_font_t * _font_subtitle; static lv_font_t * _font_title; +static lv_theme_material_palette_t palette = LV_THEME_MATERIAL_PALETTE_DARK; static lv_style_t scr; -static lv_style_t panel; /*General fancy panel like car to hold other objects*/ static lv_style_t bg; +static lv_style_t bg_click; +static lv_style_t bg_sec; static lv_style_t btn; -static lv_style_t pad; - +static lv_style_t pad_inner; +static lv_style_t pad_small; #if LV_USE_ARC - static lv_style_t arc; + static lv_style_t arc_indic; static lv_style_t arc_bg; #endif @@ -82,7 +116,7 @@ static lv_style_t pad; #endif #if LV_USE_CHART - static lv_style_t chart_series_bg, chart_series; + static lv_style_t chart_bg, chart_series_bg, chart_series; #endif #if LV_USE_CHECKBOX @@ -90,7 +124,7 @@ static lv_style_t pad; #endif #if LV_USE_DROPDOWN - static lv_style_t ddlist_btn, ddlist_page, ddlist_sel; + static lv_style_t ddlist_page, ddlist_sel; #endif #if LV_USE_GAUGE @@ -98,7 +132,7 @@ static lv_style_t pad; #endif #if LV_USE_KEYBOARD - static lv_style_t kb_bg, kb_btn; + static lv_style_t kb_bg; #endif #if LV_USE_LED @@ -113,11 +147,6 @@ static lv_style_t pad; static lv_style_t list_bg, list_btn; #endif -#if LV_USE_MSGBOX - static lv_style_t mbox_btn_bg; - -#endif - #if LV_USE_PAGE static lv_style_t sb; #endif @@ -131,7 +160,7 @@ static lv_style_t pad; #endif #if LV_USE_SPINBOX - static lv_style_t spinbox_btn, spinbox_cursor; + static lv_style_t spinbox_cursor; #endif #if LV_USE_SWITCH @@ -147,7 +176,7 @@ static lv_style_t pad; #endif #if LV_USE_TEXTAREA - static lv_style_t ta_bg, ta_cursor, ta_oneline, ta_placeholder; + static lv_style_t ta_cursor, ta_placeholder; #endif /********************** @@ -163,85 +192,99 @@ static void basic_init(void) { lv_style_init(&scr); lv_style_set_bg_opa(&scr, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&scr, LV_STATE_DEFAULT, color_scr(LV_STATE_DEFAULT)); - lv_style_set_text_color(&scr, LV_STATE_DEFAULT, color_scr_txt(LV_STATE_DEFAULT)); - lv_style_set_value_color(&scr, LV_STATE_DEFAULT, color_scr_txt(LV_STATE_DEFAULT)); - lv_style_set_border_width(&scr, LV_STATE_DEFAULT, 1); - lv_style_set_border_color(&scr, LV_STATE_DEFAULT, color_scr_border(LV_STATE_DEFAULT)); + lv_style_set_bg_color(&scr, LV_STATE_DEFAULT, COLOR_SCR); + lv_style_set_text_color(&scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT); + lv_style_set_value_color(&scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT); lv_style_set_border_post(&scr, LV_STATE_DEFAULT, true); - lv_style_init(&panel); - lv_style_set_radius(&panel, LV_STATE_DEFAULT, LV_DPI / 25); - lv_style_set_bg_opa(&panel, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&panel, LV_STATE_DEFAULT, color_panel(LV_STATE_DEFAULT)); - lv_style_set_border_color(&panel, LV_STATE_DEFAULT, color_panel_border(LV_STATE_DEFAULT)); - lv_style_set_border_color(&panel, LV_STATE_FOCUSED, color_panel_border(LV_STATE_FOCUSED)); - lv_style_set_border_width(&panel, LV_STATE_DEFAULT, BORDER_WIDTH); - lv_style_set_border_side(&panel, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP); - lv_style_set_border_post(&panel, LV_STATE_DEFAULT, true); - lv_style_set_text_font(&panel, LV_STATE_DEFAULT, _font_normal); - lv_style_set_text_color(&panel, LV_STATE_DEFAULT, color_panel_txt(LV_STATE_DEFAULT)); - lv_style_set_value_color(&panel, LV_STATE_DEFAULT, color_panel_txt(LV_STATE_DEFAULT)); - lv_style_set_image_recolor(&panel, LV_STATE_DEFAULT, color_panel_txt(LV_STATE_DEFAULT)); - lv_style_set_line_color(&panel, LV_STATE_DEFAULT, color_panel_txt(LV_STATE_DEFAULT)); - lv_style_set_line_width(&panel, LV_STATE_DEFAULT, 1); - lv_style_set_transition_time(&panel, LV_STATE_DEFAULT, TRANSITION_TIME); - lv_style_set_pad_left(&panel, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_pad_right(&panel, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_pad_top(&panel, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_pad_bottom(&panel, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_pad_inner(&panel, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_transition_prop_1(&panel, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR); lv_style_init(&bg); lv_style_set_radius(&bg, LV_STATE_DEFAULT, LV_DPI / 25); lv_style_set_bg_opa(&bg, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&bg, LV_STATE_DEFAULT, color_bg(LV_STATE_DEFAULT)); - lv_style_set_border_color(&bg, LV_STATE_DEFAULT, color_bg_border(LV_STATE_DEFAULT)); - lv_style_set_border_color(&bg, LV_STATE_FOCUSED, color_bg_border(LV_STATE_FOCUSED)); - lv_style_set_border_width(&bg, LV_STATE_DEFAULT, BORDER_WIDTH); + lv_style_set_bg_color(&bg, LV_STATE_DEFAULT, COLOR_BG); + lv_style_set_border_color(&bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); + lv_style_set_border_color(&bg, LV_STATE_FOCUSED, _color_primary); + lv_style_set_border_width(&bg, LV_STATE_DEFAULT, (LV_DPI / 60 > 0 ? LV_DPI / 60 : 1)); + lv_style_set_border_post(&bg, LV_STATE_DEFAULT, true); lv_style_set_text_font(&bg, LV_STATE_DEFAULT, _font_normal); - lv_style_set_text_color(&bg, LV_STATE_DEFAULT, color_bg_txt(LV_STATE_DEFAULT)); - lv_style_set_value_color(&bg, LV_STATE_DEFAULT, color_bg_txt(LV_STATE_DEFAULT)); - lv_style_set_image_recolor(&bg, LV_STATE_DEFAULT, color_bg_txt(LV_STATE_DEFAULT)); - lv_style_set_line_color(&bg, LV_STATE_DEFAULT, color_bg_txt(LV_STATE_DEFAULT)); + lv_style_set_text_color(&bg, LV_STATE_DEFAULT, COLOR_BG_TEXT); + lv_style_set_value_color(&bg, LV_STATE_DEFAULT, COLOR_BG_TEXT); + lv_style_set_image_recolor(&bg, LV_STATE_DEFAULT, COLOR_BG_TEXT); + lv_style_set_line_color(&bg, LV_STATE_DEFAULT, COLOR_BG_TEXT); lv_style_set_line_width(&bg, LV_STATE_DEFAULT, 1); lv_style_set_pad_left(&bg, LV_STATE_DEFAULT, LV_DPI / 5); lv_style_set_pad_right(&bg, LV_STATE_DEFAULT, LV_DPI / 5); lv_style_set_pad_top(&bg, LV_STATE_DEFAULT, LV_DPI / 5); lv_style_set_pad_bottom(&bg, LV_STATE_DEFAULT, LV_DPI / 5); lv_style_set_pad_inner(&bg, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_transition_time(&panel, LV_STATE_DEFAULT, TRANSITION_TIME); + lv_style_set_transition_time(&bg, LV_STATE_DEFAULT, TRANSITION_TIME); + lv_style_set_transition_prop_6(&bg, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR); + + lv_style_init(&bg_sec); + lv_style_copy(&bg_sec, &bg); + lv_style_set_bg_color(&bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC); + lv_style_set_border_color(&bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_BORDER); + lv_style_set_text_color(&bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT); + lv_style_set_value_color(&bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT); + lv_style_set_image_recolor(&bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT); + lv_style_set_line_color(&bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT); + + lv_style_init(&bg_click); + lv_style_set_bg_color(&bg_click, LV_STATE_PRESSED, COLOR_BG_PR); + lv_style_set_bg_color(&bg_click, LV_STATE_CHECKED, COLOR_BG_CHK); + lv_style_set_bg_color(&bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_PR_CHK); + lv_style_set_bg_color(&bg_click, LV_STATE_DISABLED, COLOR_BG_DIS); + lv_style_set_border_color(&bg_click, LV_STATE_FOCUSED | LV_STATE_PRESSED, lv_color_darken(_color_primary, LV_OPA_20)); + lv_style_set_border_color(&bg_click, LV_STATE_PRESSED, COLOR_BG_BORDER_PR); + lv_style_set_border_color(&bg_click, LV_STATE_CHECKED, COLOR_BG_BORDER_CHK); + lv_style_set_border_color(&bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_BORDER_CHK_PR); + lv_style_set_border_color(&bg_click, LV_STATE_DISABLED, COLOR_BG_BORDER_DIS); + lv_style_set_text_color(&bg_click, LV_STATE_PRESSED, COLOR_BG_TEXT_PR); + lv_style_set_text_color(&bg_click, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK); + lv_style_set_text_color(&bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_TEXT_CHK_PR); + lv_style_set_text_color(&bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS); + lv_style_set_image_recolor(&bg_click, LV_STATE_PRESSED, COLOR_BG_TEXT_PR); + lv_style_set_image_recolor(&bg_click, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK); + lv_style_set_image_recolor(&bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_TEXT_CHK_PR); + lv_style_set_image_recolor(&bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS); + lv_style_set_transition_prop_5(&bg_click, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR); lv_style_init(&btn); lv_style_set_radius(&btn, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_bg_opa(&btn, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&btn, LV_STATE_DEFAULT, color_btn(LV_STATE_DEFAULT)); - lv_style_set_bg_color(&btn, LV_STATE_PRESSED, color_btn(LV_STATE_PRESSED)); - lv_style_set_bg_color(&btn, LV_STATE_CHECKED, color_btn(LV_STATE_CHECKED)); - lv_style_set_bg_color(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, color_btn(LV_STATE_CHECKED | LV_STATE_PRESSED)); - lv_style_set_bg_color(&btn, LV_STATE_DISABLED, color_btn(LV_STATE_DISABLED)); - lv_style_set_border_color(&btn, LV_STATE_DEFAULT, color_btn_border(LV_STATE_DEFAULT)); - lv_style_set_border_color(&btn, LV_STATE_PRESSED, color_btn_border(LV_STATE_PRESSED)); - lv_style_set_border_width(&btn, LV_STATE_DEFAULT, BORDER_WIDTH); + lv_style_set_bg_color(&btn, LV_STATE_DEFAULT, COLOR_BTN); + lv_style_set_bg_color(&btn, LV_STATE_PRESSED, COLOR_BTN_PR); + lv_style_set_bg_color(&btn, LV_STATE_CHECKED, COLOR_BTN_CHK); + lv_style_set_bg_color(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, COLOR_BTN_CHK_PR); + lv_style_set_bg_color(&btn, LV_STATE_DISABLED, COLOR_BTN_DIS); + lv_style_set_border_color(&btn, LV_STATE_DEFAULT, COLOR_BTN_BORDER); + lv_style_set_border_color(&btn, LV_STATE_PRESSED, COLOR_BTN_BORDER_PR); + lv_style_set_border_color(&btn, LV_STATE_DISABLED, COLOR_BTN_BORDER_INA); + lv_style_set_border_width(&btn, LV_STATE_DEFAULT, (LV_DPI / 60 > 0 ? LV_DPI / 60 : 1)); lv_style_set_border_width(&btn, LV_STATE_CHECKED, 0); - lv_style_set_text_color(&btn, LV_STATE_DEFAULT, color_btn_txt(LV_STATE_DEFAULT)); - lv_style_set_text_color(&btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED)); - lv_style_set_text_color(&btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_CHECKED)); - lv_style_set_text_color(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, color_btn_txt(LV_STATE_CHECKED | LV_STATE_PRESSED)); - lv_style_set_text_color(&btn, LV_STATE_DISABLED, color_btn_txt(LV_STATE_DISABLED)); - lv_style_set_image_recolor(&btn, LV_STATE_DEFAULT, color_btn_txt(LV_STATE_DEFAULT)); - lv_style_set_image_recolor(&btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED)); - lv_style_set_image_recolor(&btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_CHECKED)); - lv_style_set_image_recolor(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, - color_btn_txt(LV_STATE_CHECKED | LV_STATE_PRESSED)); - lv_style_set_image_recolor(&btn, LV_STATE_DISABLED, color_btn_txt(LV_STATE_DISABLED)); - lv_style_set_value_color(&btn, LV_STATE_DEFAULT, color_btn_txt(LV_STATE_DEFAULT)); + + lv_style_set_text_color(&btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); + lv_style_set_text_color(&btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); + lv_style_set_text_color(&btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); + lv_style_set_text_color(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff)); + lv_style_set_text_color(&btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888)); + + lv_style_set_image_recolor(&btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); + lv_style_set_image_recolor(&btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); + lv_style_set_image_recolor(&btn, LV_STATE_PRESSED, lv_color_hex(0xffffff)); + lv_style_set_image_recolor(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff)); + lv_style_set_image_recolor(&btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888)); + + lv_style_set_value_color(&btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); + lv_style_set_value_color(&btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); + lv_style_set_value_color(&btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); + lv_style_set_value_color(&btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff)); + lv_style_set_value_color(&btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888)); lv_style_set_pad_left(&btn, LV_STATE_DEFAULT, LV_DPI / 5); lv_style_set_pad_right(&btn, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_pad_top(&btn, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_bottom(&btn, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_set_pad_top(&btn, LV_STATE_DEFAULT, LV_DPI / 15); + lv_style_set_pad_bottom(&btn, LV_STATE_DEFAULT, LV_DPI / 15); lv_style_set_pad_inner(&btn, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_outline_width(&btn, LV_STATE_DEFAULT, 3); lv_style_set_outline_opa(&btn, LV_STATE_DEFAULT, LV_OPA_0); @@ -250,15 +293,18 @@ static void basic_init(void) lv_style_set_transition_time(&btn, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_prop_5(&btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR); lv_style_set_transition_prop_6(&btn, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); - lv_style_set_transition_delay(&btn, LV_STATE_DEFAULT, 100); + lv_style_set_transition_delay(&btn, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_delay(&btn, LV_STATE_PRESSED, 0); - lv_style_init(&pad); - lv_style_set_pad_top(&pad, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_bottom(&pad, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_left(&pad, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_right(&pad, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_inner(&pad, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_init(&pad_inner); + lv_style_set_pad_inner(&pad_inner, LV_STATE_DEFAULT, LV_DPI / 10); + + lv_style_init(&pad_small); + lv_style_set_pad_left(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_set_pad_right(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_set_pad_top(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_set_pad_bottom(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_set_pad_inner(&pad_small, LV_STATE_DEFAULT, LV_DPI / 20); } static void cont_init(void) @@ -288,8 +334,8 @@ static void bar_init(void) lv_style_init(&bar_bg); lv_style_set_radius(&bar_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_bg_opa(&bar_bg, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&bar_bg, LV_STATE_DEFAULT, color_bg(LV_STATE_DEFAULT)); - lv_style_set_value_color(&bar_bg, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_bg_color(&bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC); + lv_style_set_value_color(&bar_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE); lv_style_set_outline_color(&bar_bg, LV_STATE_DEFAULT, _color_primary); lv_style_set_outline_opa(&bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50); @@ -302,7 +348,7 @@ static void bar_init(void) lv_style_set_radius(&bar_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_bg_color(&bar_indic, LV_STATE_DEFAULT, _color_primary); lv_style_set_bg_color(&bar_indic, LV_STATE_DISABLED, lv_color_hex3(0x888)); - lv_style_set_value_color(&bar_indic, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_value_color(&bar_indic, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE); #endif } @@ -341,8 +387,8 @@ static void slider_init(void) #if LV_USE_SLIDER != 0 lv_style_init(&slider_knob); lv_style_set_bg_opa(&slider_knob, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&slider_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_value_color(&slider_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_bg_color(&slider_knob, LV_STATE_DEFAULT, IS_LIGHT ? _color_primary : LV_COLOR_WHITE); + lv_style_set_value_color(&slider_knob, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE); lv_style_set_radius(&slider_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_pad_left(&slider_knob, LV_STATE_DEFAULT, LV_DPI / 20); lv_style_set_pad_right(&slider_knob, LV_STATE_DEFAULT, LV_DPI / 20); @@ -359,10 +405,10 @@ static void switch_init(void) lv_style_set_bg_opa(&sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&sw_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_style_set_radius(&sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_pad_top(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 20); - lv_style_set_pad_bottom(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 20); - lv_style_set_pad_left(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 20); - lv_style_set_pad_right(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 20); + lv_style_set_pad_top(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 22); + lv_style_set_pad_bottom(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 22); + lv_style_set_pad_left(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 22); + lv_style_set_pad_right(&sw_knob, LV_STATE_DEFAULT, - LV_DPI / 22); #endif } @@ -370,22 +416,19 @@ static void linemeter_init(void) { #if LV_USE_LINEMETER != 0 lv_style_init(&lmeter); - lv_style_copy(&lmeter, &panel); lv_style_set_radius(&lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_border_side(&lmeter, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); - lv_style_set_bg_opa(&lmeter, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_pad_left(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_right(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_top(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_inner(&lmeter, LV_STATE_DEFAULT, LV_DPI / 6); - lv_style_set_scale_width(&lmeter, LV_STATE_DEFAULT, LV_DPI / 12); + lv_style_set_scale_width(&lmeter, LV_STATE_DEFAULT, LV_DPI / 8); lv_style_set_line_color(&lmeter, LV_STATE_DEFAULT, _color_primary); lv_style_set_scale_grad_color(&lmeter, LV_STATE_DEFAULT, _color_primary); - lv_style_set_scale_end_color(&lmeter, LV_STATE_DEFAULT, lv_color_hex3(0x888)); + lv_style_set_scale_end_color(&lmeter, LV_STATE_DEFAULT, lv_color_hex3(0x666)); lv_style_set_line_rounded(&lmeter, LV_STATE_DEFAULT, true); - lv_style_set_line_width(&lmeter, LV_STATE_DEFAULT, LV_DPI / 25); - lv_style_set_scale_end_line_width(&lmeter, LV_STATE_DEFAULT, LV_DPI / 50); + lv_style_set_line_width(&lmeter, LV_STATE_DEFAULT, LV_DPI / 20); + lv_style_set_scale_end_line_width(&lmeter, LV_STATE_DEFAULT, LV_DPI / 30); #endif } @@ -393,21 +436,19 @@ static void gauge_init(void) { #if LV_USE_GAUGE != 0 lv_style_init(&gauge_main); - lv_style_copy(&gauge_main, &panel); - lv_style_set_radius(&gauge_main, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_border_side(&gauge_main, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); lv_style_set_line_color(&gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888)); lv_style_set_scale_grad_color(&gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888)); lv_style_set_scale_end_color(&gauge_main, LV_STATE_DEFAULT, _color_primary); - lv_style_set_line_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 50); - lv_style_set_scale_end_line_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 25); - lv_style_set_scale_end_border_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 50); - lv_style_set_bg_opa(&gauge_main, LV_STATE_DEFAULT, LV_OPA_COVER); + lv_style_set_line_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 40); + lv_style_set_scale_end_line_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 50); + lv_style_set_scale_end_border_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 25); lv_style_set_pad_left(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_right(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_top(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_inner(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 6); - lv_style_set_scale_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 12); + lv_style_set_pad_inner(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 7); + lv_style_set_scale_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 10); + lv_style_set_radius(&gauge_main, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); + lv_style_set_border_width(&gauge_main, LV_STATE_DEFAULT, LV_DPI / 50); lv_style_init(&gauge_strong); lv_style_set_line_color(&gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888)); @@ -415,13 +456,13 @@ static void gauge_init(void) lv_style_set_scale_end_color(&gauge_strong, LV_STATE_DEFAULT, _color_primary); lv_style_set_line_width(&gauge_strong, LV_STATE_DEFAULT, LV_DPI / 25); lv_style_set_scale_end_line_width(&gauge_strong, LV_STATE_DEFAULT, LV_DPI / 25); - lv_style_set_scale_width(&gauge_strong, LV_STATE_DEFAULT, LV_DPI / 7); + lv_style_set_scale_width(&gauge_strong, LV_STATE_DEFAULT, LV_DPI / 6); lv_style_init(&gauge_needle); - lv_style_set_line_color(&gauge_needle, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_line_color(&gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE); lv_style_set_line_width(&gauge_needle, LV_STATE_DEFAULT, LV_DPI / 20); lv_style_set_bg_opa(&gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&gauge_needle, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_bg_color(&gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE); lv_style_set_radius(&gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_size(&gauge_needle, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_set_pad_inner(&gauge_needle, LV_STATE_DEFAULT, LV_DPI / 10); @@ -431,13 +472,13 @@ static void gauge_init(void) static void arc_init(void) { #if LV_USE_ARC != 0 - lv_style_init(&arc); - lv_style_set_line_color(&arc, LV_STATE_DEFAULT, _color_primary); - lv_style_set_line_width(&arc, LV_STATE_DEFAULT, LV_DPI / 8); - lv_style_set_line_rounded(&arc, LV_STATE_DEFAULT, true); + lv_style_init(&arc_indic); + lv_style_set_line_color(&arc_indic, LV_STATE_DEFAULT, _color_primary); + lv_style_set_line_width(&arc_indic, LV_STATE_DEFAULT, LV_DPI / 8); + lv_style_set_line_rounded(&arc_indic, LV_STATE_DEFAULT, true); lv_style_init(&arc_bg); - lv_style_set_line_color(&arc_bg, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_style_set_line_color(&arc_bg, LV_STATE_DEFAULT, COLOR_BG_SEC); lv_style_set_line_width(&arc_bg, LV_STATE_DEFAULT, LV_DPI / 8); lv_style_set_line_rounded(&arc_bg, LV_STATE_DEFAULT, true); @@ -453,6 +494,9 @@ static void spinner_init(void) static void chart_init(void) { #if LV_USE_CHART + lv_style_init(&chart_bg); + lv_style_set_text_color(&chart_bg, LV_STATE_DEFAULT, COLOR_BG_TEXT_DIS); + lv_style_init(&chart_series_bg); lv_style_set_line_width(&chart_series_bg, LV_STATE_DEFAULT, 1); lv_style_set_line_dash_width(&chart_series_bg, LV_STATE_DEFAULT, 4); @@ -460,12 +504,12 @@ static void chart_init(void) lv_style_set_pad_bottom(&chart_series_bg, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_left(&chart_series_bg, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_right(&chart_series_bg, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_line_color(&chart_series_bg, LV_STATE_DEFAULT, lv_color_hex3(0x555)); + lv_style_set_line_color(&chart_series_bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_init(&chart_series); - lv_style_set_line_width(&chart_series, LV_STATE_DEFAULT, 1); - lv_style_set_size(&chart_series, LV_STATE_DEFAULT, 2); - lv_style_set_pad_inner(&chart_series, LV_STATE_DEFAULT, 2); + lv_style_set_line_width(&chart_series, LV_STATE_DEFAULT, LV_DPI / 50); + lv_style_set_size(&chart_series, LV_STATE_DEFAULT, LV_DPI / 40); + lv_style_set_pad_inner(&chart_series, LV_STATE_DEFAULT, 2); /*Space between columns*/ lv_style_set_radius(&chart_series, LV_STATE_DEFAULT, 1); #endif @@ -480,23 +524,24 @@ static void calendar_init(void) lv_style_set_pad_left(&calendar_header, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_set_pad_right(&calendar_header, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_set_pad_bottom(&calendar_header, LV_STATE_DEFAULT, LV_DPI / 7); - lv_style_set_text_color(&calendar_header, LV_STATE_PRESSED, LV_COLOR_WHITE); + lv_style_set_text_color(&calendar_header, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x888888) : LV_COLOR_WHITE); lv_style_init(&calendar_daynames); - lv_style_set_text_color(&calendar_daynames, LV_STATE_DEFAULT, lv_color_hex3(0xeee)); + lv_style_set_text_color(&calendar_daynames, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex3(0xeee)); lv_style_set_pad_left(&calendar_daynames, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_set_pad_right(&calendar_daynames, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_set_pad_bottom(&calendar_daynames, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_init(&calendar_date_nums); lv_style_set_radius(&calendar_date_nums, LV_STATE_DEFAULT, LV_DPI / 50); - lv_style_set_text_color(&calendar_date_nums, LV_STATE_CHECKED, LV_COLOR_WHITE); + lv_style_set_text_color(&calendar_date_nums, LV_STATE_CHECKED, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE); lv_style_set_text_color(&calendar_date_nums, LV_STATE_FOCUSED, _color_primary); lv_style_set_bg_opa(&calendar_date_nums, LV_STATE_CHECKED, LV_OPA_20); lv_style_set_bg_opa(&calendar_date_nums, LV_STATE_PRESSED, LV_OPA_20); lv_style_set_bg_opa(&calendar_date_nums, LV_STATE_PRESSED | LV_STATE_CHECKED, LV_OPA_40); - lv_style_set_bg_color(&calendar_date_nums, LV_STATE_CHECKED, LV_COLOR_WHITE); + lv_style_set_bg_color(&calendar_date_nums, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x666666) : LV_COLOR_WHITE); + lv_style_set_bg_color(&calendar_date_nums, LV_STATE_CHECKED, IS_LIGHT ? _color_primary : LV_COLOR_WHITE); lv_style_set_border_width(&calendar_date_nums, LV_STATE_CHECKED, 2); lv_style_set_border_side(&calendar_date_nums, LV_STATE_CHECKED, LV_BORDER_SIDE_LEFT); lv_style_set_border_color(&calendar_date_nums, LV_STATE_CHECKED, _color_primary); @@ -510,11 +555,10 @@ static void calendar_init(void) static void cpicker_init(void) { #if LV_USE_CPICKER - lv_style_init(&cpicker_bg); lv_style_set_scale_width(&cpicker_bg, LV_STATE_DEFAULT, LV_DPI / 4); lv_style_set_bg_opa(&cpicker_bg, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&cpicker_bg, LV_STATE_DEFAULT, color_scr(LV_STATE_DEFAULT)); + lv_style_set_bg_color(&cpicker_bg, LV_STATE_DEFAULT, COLOR_SCR); lv_style_set_pad_inner(&cpicker_bg, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_radius(&cpicker_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); @@ -546,18 +590,13 @@ static void checkbox_init(void) lv_style_set_transition_prop_6(&cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); lv_style_init(&cb_bullet); + lv_style_set_outline_opa(&cb_bullet, LV_STATE_FOCUSED, LV_OPA_TRANSP); lv_style_set_radius(&cb_bullet, LV_STATE_DEFAULT, LV_DPI / 50); - lv_style_set_bg_color(&cb_bullet, LV_STATE_DEFAULT, _color_primary); - lv_style_set_bg_opa(&cb_bullet, LV_STATE_CHECKED, LV_OPA_COVER); - lv_style_set_border_width(&cb_bullet, LV_STATE_DEFAULT, BORDER_WIDTH); - lv_style_set_border_color(&cb_bullet, LV_STATE_DEFAULT, color_bg_border(LV_STATE_DEFAULT)); - lv_style_set_border_color(&cb_bullet, LV_STATE_PRESSED, color_bg_border(LV_STATE_PRESSED)); - lv_style_set_border_opa(&cb_bullet, LV_STATE_CHECKED, LV_OPA_80); lv_style_set_pattern_image(&cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK); lv_style_set_pattern_recolor(&cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE); lv_style_set_text_font(&cb_bullet, LV_STATE_CHECKED, _font_small); lv_style_set_transition_time(&cb_bullet, LV_STATE_DEFAULT, TRANSITION_TIME); - lv_style_set_transition_prop_5(&cb_bullet, LV_STATE_DEFAULT, LV_STYLE_BG_OPA); + lv_style_set_transition_prop_5(&cb_bullet, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR); lv_style_set_transition_prop_6(&cb_bullet, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR); #endif } @@ -572,7 +611,7 @@ static void btnmatrix_init(void) lv_style_set_radius(&btnm_bg, LV_STATE_DEFAULT, LV_DPI / 20); lv_style_set_clip_corner(&btnm_bg, LV_STATE_DEFAULT, true); lv_style_set_border_post(&btnm_bg, LV_STATE_DEFAULT, true); - lv_style_set_bg_color(&btnm_bg, LV_STATE_DEFAULT, color_bg(LV_STATE_DEFAULT)); + lv_style_set_bg_color(&btnm_bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_init(&btnm_btn); lv_style_set_radius(&btnm_btn, LV_STATE_DEFAULT, 0); @@ -583,17 +622,10 @@ static void btnmatrix_init(void) static void keyboard_init(void) { #if LV_USE_KEYBOARD - lv_style_init(&kb_btn); - lv_style_set_radius(&kb_btn, LV_STATE_DEFAULT, LV_DPI / 50); - lv_style_set_border_width(&kb_btn, LV_STATE_DEFAULT, 1); - lv_style_init(&kb_bg); - lv_style_copy(&kb_bg, &panel); - lv_style_set_pad_inner(&kb_bg, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_left(&kb_bg, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_right(&kb_bg, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_top(&kb_bg, LV_STATE_DEFAULT, LV_DPI / 20); - lv_style_set_pad_bottom(&kb_bg, LV_STATE_DEFAULT, LV_DPI / 20); + lv_style_set_radius(&kb_bg, LV_STATE_DEFAULT, 0); + lv_style_set_border_width(&kb_bg, LV_STATE_DEFAULT, (LV_DPI / 40 > 0 ? LV_DPI / 40 - 1 : 1)); + lv_style_set_border_side(&kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP); #endif } @@ -601,8 +633,7 @@ static void keyboard_init(void) static void msgbox_init(void) { #if LV_USE_MSGBOX - lv_style_init(&mbox_btn_bg); - lv_style_set_pad_inner(&mbox_btn_bg, LV_STATE_DEFAULT, LV_DPI / 10); + #endif } @@ -611,7 +642,7 @@ static void page_init(void) #if LV_USE_PAGE lv_style_init(&sb); lv_style_set_bg_opa(&sb, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&sb, LV_STATE_DEFAULT, lv_color_hex(0x3a3d42)); + lv_style_set_bg_color(&sb, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_radius(&sb, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_size(&sb, LV_STATE_DEFAULT, LV_DPI / 30); lv_style_set_pad_right(&sb, LV_STATE_DEFAULT, LV_DPI / 20); @@ -623,44 +654,20 @@ static void page_init(void) static void textarea_init(void) { #if LV_USE_TEXTAREA - lv_style_init(&ta_bg); - lv_style_copy(&ta_bg, &panel); - lv_style_set_border_side(&ta_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); - lv_style_set_pad_left(&ta_bg, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_right(&ta_bg, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_top(&ta_bg, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_bottom(&ta_bg, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_init(&ta_cursor); - lv_style_set_border_color(&ta_cursor, LV_STATE_DEFAULT, lv_color_hex(0x6c737b)); + lv_style_set_border_color(&ta_cursor, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT); lv_style_set_border_width(&ta_cursor, LV_STATE_DEFAULT, 2); lv_style_set_pad_left(&ta_cursor, LV_STATE_DEFAULT, 1); lv_style_set_border_side(&ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT); - lv_style_init(&ta_oneline); - lv_style_set_border_width(&ta_oneline, LV_STATE_DEFAULT, 1); - lv_style_set_radius(&ta_oneline, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_border_color(&ta_oneline, LV_STATE_DEFAULT, lv_color_hex(0x3b3e43)); - lv_style_set_border_color(&ta_oneline, LV_STATE_FOCUSED, _color_primary); - lv_style_set_text_color(&ta_oneline, LV_STATE_DEFAULT, lv_color_hex(0x6c737b)); - lv_style_set_pad_left(&ta_oneline, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_right(&ta_oneline, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_top(&ta_oneline, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_bottom(&ta_oneline, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_transition_time(&ta_oneline, LV_STATE_DEFAULT, TRANSITION_TIME); - lv_style_set_transition_prop_6(&ta_oneline, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR); - lv_style_init(&ta_placeholder); - lv_style_set_text_color(&ta_placeholder, LV_STATE_DEFAULT, lv_color_hex(0x3b3e43)); + lv_style_set_text_color(&ta_placeholder, LV_STATE_DEFAULT, COLOR_BG_TEXT_DIS); #endif } static void spinbox_init(void) { #if LV_USE_SPINBOX - lv_style_init(&spinbox_btn); - lv_style_copy(&spinbox_btn, &ta_bg); - lv_style_set_bg_color(&spinbox_btn, LV_STATE_PRESSED, lv_color_hex3(0xaaa)); lv_style_init(&spinbox_cursor); lv_style_set_bg_opa(&spinbox_cursor, LV_STATE_DEFAULT, LV_OPA_COVER); @@ -676,7 +683,6 @@ static void list_init(void) { #if LV_USE_LIST != 0 lv_style_init(&list_bg); - lv_style_copy(&list_bg, &panel); lv_style_set_pad_left(&list_bg, LV_STATE_DEFAULT, 0); lv_style_set_pad_right(&list_bg, LV_STATE_DEFAULT, 0); lv_style_set_pad_top(&list_bg, LV_STATE_DEFAULT, 0); @@ -684,38 +690,39 @@ static void list_init(void) lv_style_set_pad_inner(&list_bg, LV_STATE_DEFAULT, 0); lv_style_init(&list_btn); - lv_style_set_radius(&list_btn, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_radius(&list_btn, LV_STATE_PRESSED, 0); - lv_style_set_radius(&list_btn, LV_STATE_CHECKED, 0); - lv_style_set_bg_opa(&list_btn, LV_STATE_PRESSED, LV_OPA_COVER); - lv_style_set_bg_opa(&list_btn, LV_STATE_CHECKED, LV_OPA_COVER); - lv_style_set_bg_color(&list_btn, LV_STATE_DEFAULT, color_btn(LV_STATE_DEFAULT)); - lv_style_set_bg_color(&list_btn, LV_STATE_PRESSED, color_btn(LV_STATE_PRESSED)); - lv_style_set_bg_color(&list_btn, LV_STATE_DISABLED, color_btn(LV_STATE_DISABLED)); - lv_style_set_bg_color(&list_btn, LV_STATE_CHECKED, color_btn(LV_STATE_CHECKED)); - lv_style_set_bg_color(&list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, color_btn(LV_STATE_CHECKED | LV_STATE_PRESSED)); - lv_style_set_text_color(&list_btn, LV_STATE_DEFAULT, color_btn_txt(LV_STATE_DEFAULT)); - lv_style_set_text_color(&list_btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED)); - lv_style_set_text_color(&list_btn, LV_STATE_DISABLED, color_btn_txt(LV_STATE_DISABLED)); - lv_style_set_image_recolor(&list_btn, LV_STATE_DEFAULT, color_btn_txt(LV_STATE_DEFAULT)); - lv_style_set_image_recolor(&list_btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED)); - lv_style_set_image_recolor(&list_btn, LV_STATE_DISABLED, color_btn_txt(LV_STATE_DISABLED)); + lv_style_set_bg_opa(&list_btn, LV_STATE_DEFAULT, LV_OPA_COVER); + lv_style_set_bg_color(&list_btn, LV_STATE_DEFAULT, COLOR_BG); + lv_style_set_bg_color(&list_btn, LV_STATE_PRESSED, COLOR_BG_PR); + lv_style_set_bg_color(&list_btn, LV_STATE_DISABLED, COLOR_BG_DIS); + lv_style_set_bg_color(&list_btn, LV_STATE_CHECKED, COLOR_BG_CHK); + lv_style_set_bg_color(&list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, COLOR_BG_PR_CHK); + + lv_style_set_text_color(&list_btn, LV_STATE_DEFAULT, COLOR_BG_TEXT); + lv_style_set_text_color(&list_btn, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK); + lv_style_set_text_color(&list_btn, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS); + + lv_style_set_image_recolor(&list_btn, LV_STATE_DEFAULT, COLOR_BG_TEXT); + lv_style_set_image_recolor(&list_btn, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK); + lv_style_set_image_recolor(&list_btn, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS); - lv_style_set_border_width(&list_btn, LV_STATE_DEFAULT, 1); lv_style_set_border_side(&list_btn, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM); - lv_style_set_border_color(&list_btn, LV_STATE_DEFAULT, lv_color_hex(0x979a9f)); - lv_style_set_border_color(&list_btn, LV_STATE_FOCUSED, _color_primary); - lv_style_set_border_color(&list_btn, LV_STATE_FOCUSED | LV_STATE_CHECKED, lv_color_hex(0x979a9f)); + lv_style_set_border_color(&list_btn, LV_STATE_DEFAULT, COLOR_BG_BORDER); + lv_style_set_border_width(&list_btn, LV_STATE_DEFAULT, 1); lv_style_set_pad_left(&list_btn, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_right(&list_btn, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_top(&list_btn, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_bottom(&list_btn, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_inner(&list_btn, LV_STATE_DEFAULT, LV_DPI / 10); + + lv_style_set_transform_width(&list_btn, LV_STATE_DEFAULT, - LV_DPI / 10); + lv_style_set_transform_width(&list_btn, LV_STATE_PRESSED, 0); + lv_style_set_transform_width(&list_btn, LV_STATE_CHECKED, 0); + lv_style_set_transform_width(&list_btn, LV_STATE_DISABLED, 0); + lv_style_set_transition_time(&list_btn, LV_STATE_DEFAULT, TRANSITION_TIME); - lv_style_set_transition_prop_4(&list_btn, LV_STATE_DEFAULT, LV_STYLE_RADIUS); - lv_style_set_transition_prop_5(&list_btn, LV_STATE_DEFAULT, LV_STYLE_BG_OPA); - lv_style_set_transition_prop_6(&list_btn, LV_STATE_DEFAULT, LV_STYLE_BG_OPA); + lv_style_set_transition_prop_5(&list_btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR); + lv_style_set_transition_prop_4(&list_btn, LV_STATE_DEFAULT, LV_STYLE_TRANSFORM_WIDTH); #endif } @@ -723,28 +730,14 @@ static void ddlist_init(void) { #if LV_USE_DROPDOWN != 0 - lv_style_init(&ddlist_btn); - lv_style_copy(&ddlist_btn, &panel); - lv_style_set_border_side(&ddlist_btn, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); - lv_style_set_bg_color(&ddlist_btn, LV_STATE_PRESSED, lv_color_hex3(0x666)); - lv_style_set_pad_top(&ddlist_btn, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_set_pad_bottom(&ddlist_btn, LV_STATE_DEFAULT, LV_DPI / 10); - lv_style_init(&ddlist_page); - lv_style_copy(&ddlist_page, &panel); - lv_style_set_border_side(&ddlist_page, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); - lv_style_set_bg_color(&ddlist_page, LV_STATE_DEFAULT, lv_color_hex(0xf0f0f0)); - lv_style_set_text_color(&ddlist_page, LV_STATE_DEFAULT, lv_color_hex3(0x333)); lv_style_set_text_line_space(&ddlist_page, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_border_post(&ddlist_page, LV_STATE_DEFAULT, true); lv_style_init(&ddlist_sel); lv_style_set_bg_opa(&ddlist_sel, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&ddlist_sel, LV_STATE_DEFAULT, _color_primary); - - lv_style_set_bg_color(&ddlist_sel, LV_STATE_PRESSED, LV_COLOR_SILVER); - - lv_style_set_text_color(&ddlist_sel, LV_STATE_DEFAULT, lv_color_hex3(0x333)); + lv_style_set_text_color(&ddlist_sel, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex3(0x333) : lv_color_hex3(0xfff)); + lv_style_set_bg_color(&ddlist_sel, LV_STATE_PRESSED, COLOR_BG_PR); #endif } @@ -752,7 +745,6 @@ static void roller_init(void) { #if LV_USE_ROLLER != 0 lv_style_init(&roller_bg); - lv_style_copy(&roller_bg, &ta_bg); lv_style_set_text_line_space(&roller_bg, LV_STATE_DEFAULT, LV_DPI / 8); lv_style_init(&roller_sel); @@ -767,26 +759,27 @@ static void tabview_init(void) #if LV_USE_TABVIEW != 0 lv_style_init(&tabview_btns_bg); lv_style_set_bg_opa(&tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&tabview_btns_bg, LV_STATE_DEFAULT, color_panel(LV_STATE_DEFAULT)); - lv_style_set_border_color(&tabview_btns_bg, LV_STATE_DEFAULT, color_panel_border(LV_STATE_DEFAULT)); + lv_style_set_bg_color(&tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG); + lv_style_set_border_color(&tabview_btns_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0xe4eaf0) : lv_color_hex(0x3b3e42)); lv_style_set_border_width(&tabview_btns_bg, LV_STATE_DEFAULT, LV_DPI / 30 > 0 ? LV_DPI / 30 : 1); lv_style_set_border_side(&tabview_btns_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM); - lv_style_set_text_color(&tabview_btns_bg, LV_STATE_DEFAULT, lv_color_hex(0x979a9f)); + lv_style_set_text_color(&tabview_btns_bg, LV_STATE_DEFAULT, COLOR_SCR_TEXT); lv_style_set_text_font(&tabview_btns_bg, LV_STATE_DEFAULT, _font_normal); lv_style_set_image_recolor(&tabview_btns_bg, LV_STATE_DEFAULT, lv_color_hex(0x979a9f)); + lv_style_set_pad_top(&tabview_btns_bg, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_init(&tabview_btns); lv_style_set_bg_opa(&tabview_btns, LV_STATE_PRESSED, LV_OPA_50); lv_style_set_bg_color(&tabview_btns, LV_STATE_PRESSED, lv_color_hex3(0x888)); - lv_style_set_text_color(&tabview_btns, LV_STATE_CHECKED, color_panel_txt(LV_STATE_CHECKED)); - lv_style_set_pad_top(&tabview_btns, LV_STATE_DEFAULT, LV_DPI / 5); - lv_style_set_pad_bottom(&tabview_btns, LV_STATE_DEFAULT, LV_DPI / 5); + lv_style_set_text_color(&tabview_btns, LV_STATE_CHECKED, COLOR_SCR_TEXT); + lv_style_set_pad_top(&tabview_btns, LV_STATE_DEFAULT, LV_DPI / 7); + lv_style_set_pad_bottom(&tabview_btns, LV_STATE_DEFAULT, LV_DPI / 7); lv_style_init(&tabview_indic); lv_style_set_bg_opa(&tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&tabview_indic, LV_STATE_DEFAULT, _color_primary); - lv_style_set_size(&tabview_indic, LV_STATE_DEFAULT, LV_DPI / 20 > 0 ? LV_DPI / 20 : 1); + lv_style_set_size(&tabview_indic, LV_STATE_DEFAULT, LV_DPI / 25 > 0 ? LV_DPI / 25 : 1); lv_style_set_radius(&tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); @@ -809,13 +802,13 @@ static void table_init(void) { #if LV_USE_TABLE != 0 lv_style_init(&table_cell); - lv_style_set_border_color(&table_cell, LV_STATE_DEFAULT, lv_color_hex(0x303338)); + lv_style_set_border_color(&table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_border_width(&table_cell, LV_STATE_DEFAULT, 1); lv_style_set_border_side(&table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); - lv_style_set_pad_left(&table_cell, LV_STATE_DEFAULT, LV_DPI / 7); - lv_style_set_pad_right(&table_cell, LV_STATE_DEFAULT, LV_DPI / 7); - lv_style_set_pad_top(&table_cell, LV_STATE_DEFAULT, LV_DPI / 7); - lv_style_set_pad_bottom(&table_cell, LV_STATE_DEFAULT, LV_DPI / 7); + lv_style_set_pad_left(&table_cell, LV_STATE_DEFAULT, LV_DPI / 8); + lv_style_set_pad_right(&table_cell, LV_STATE_DEFAULT, LV_DPI / 8); + lv_style_set_pad_top(&table_cell, LV_STATE_DEFAULT, LV_DPI / 8); + lv_style_set_pad_bottom(&table_cell, LV_STATE_DEFAULT, LV_DPI / 8); #endif } @@ -908,13 +901,13 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_OBJ: lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); - lv_style_list_add_style(list, &panel); + lv_style_list_add_style(list, &bg); break; #if LV_USE_CONT case LV_THEME_CONT: lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); - lv_style_list_add_style(list, &panel); + lv_style_list_add_style(list, &bg); break; #endif @@ -929,6 +922,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG); + list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); + lv_style_list_add_style(list, &bg); lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); @@ -941,12 +936,15 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_KEYBOARD: lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); + lv_style_list_add_style(list, &scr); lv_style_list_add_style(list, &kb_bg); + lv_style_list_add_style(list, &pad_small); + lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); - lv_style_list_add_style(list, &btn); - lv_style_list_add_style(list, &kb_btn); + lv_style_list_add_style(list, &bg); + lv_style_list_add_style(list, &bg_click); break; #endif @@ -954,7 +952,6 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_BAR: lv_obj_clean_style_list(obj, LV_BAR_PART_BG); list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); - lv_style_list_add_style(list, &bar_bg); lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); @@ -1017,7 +1014,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); - lv_style_list_add_style(list, &arc); + lv_style_list_add_style(list, &arc_indic); break; #endif @@ -1029,7 +1026,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); - lv_style_list_add_style(list, &arc); + lv_style_list_add_style(list, &arc_indic); break; #endif @@ -1057,6 +1054,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); + lv_style_list_add_style(list, &btn); lv_style_list_add_style(list, &cb_bullet); break; #endif @@ -1071,7 +1069,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_MSGBOX_BTNS: lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); - lv_style_list_add_style(list, &mbox_btn_bg); + lv_style_list_add_style(list, &pad_inner); lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); @@ -1090,11 +1088,11 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_PAGE: lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); - lv_style_list_add_style(list, &panel); + lv_style_list_add_style(list, &bg); lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRL); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRL); - lv_style_list_add_style(list, &pad); + lv_style_list_add_style(list, &pad_inner); lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRLBAR); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRLBAR); @@ -1153,6 +1151,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_ROLLER: lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); + lv_style_list_add_style(list, &bg); lv_style_list_add_style(list, &roller_bg); lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED); @@ -1173,6 +1172,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_LIST: lv_obj_clean_style_list(obj, LV_LIST_PART_BG); list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); + lv_style_list_add_style(list, &bg); lv_style_list_add_style(list, &list_bg); lv_obj_clean_style_list(obj, LV_LIST_PART_SCRL); @@ -1193,10 +1193,13 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_DROPDOWN: lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); - lv_style_list_add_style(list, &ddlist_btn); + lv_style_list_add_style(list, &bg); + lv_style_list_add_style(list, &bg_click); + lv_style_list_add_style(list, &pad_small); lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); + lv_style_list_add_style(list, &bg); lv_style_list_add_style(list, &ddlist_page); lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCRLBAR); @@ -1213,7 +1216,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_CHART: lv_obj_clean_style_list(obj, LV_CHART_PART_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); - lv_style_list_add_style(list, &panel); + lv_style_list_add_style(list, &bg); + lv_style_list_add_style(list, &chart_bg); lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); @@ -1276,7 +1280,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_TEXTAREA: lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); - lv_style_list_add_style(list, &ta_bg); + lv_style_list_add_style(list, &bg); + lv_style_list_add_style(list, &pad_small); lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); @@ -1291,23 +1296,6 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &sb); break; - case LV_THEME_TEXTAREA_ONELINE: - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); - lv_style_list_add_style(list, &ta_oneline); - - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); - lv_style_list_add_style(list, &ta_placeholder); - - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); - lv_style_list_add_style(list, &ta_cursor); - - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCRLBAR); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCRLBAR); - lv_style_list_add_style(list, &sb); - break; #endif @@ -1315,7 +1303,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_SPINBOX: lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); - lv_style_list_add_style(list, &ta_bg); + lv_style_list_add_style(list, &bg); + lv_style_list_add_style(list, &pad_small); lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); @@ -1325,7 +1314,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_SPINBOX_BTN: lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); - lv_style_list_add_style(list, &spinbox_btn); + lv_style_list_add_style(list, &bg); + lv_style_list_add_style(list, &bg_click); break; #endif @@ -1333,7 +1323,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_CALENDAR: lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); - lv_style_list_add_style(list, &panel); + lv_style_list_add_style(list, &bg); lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); @@ -1364,6 +1354,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_LINEMETER: lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); + lv_style_list_add_style(list, &bg); lv_style_list_add_style(list, &lmeter); break; #endif @@ -1371,6 +1362,7 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) case LV_THEME_GAUGE: lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); + lv_style_list_add_style(list, &bg); lv_style_list_add_style(list, &gauge_main); lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR); @@ -1396,198 +1388,5 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) * STATIC FUNCTIONS **********************/ -static inline lv_color_t color_scr(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0x22252a); - } -} - -static inline lv_color_t color_panel(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0x282b30); - } -} - -static inline lv_color_t color_bg(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0x2f3237); - } -} - -static inline lv_color_t color_btn(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - return lv_color_hex(0x303439); - case LV_STATE_PRESSED: - return lv_color_hex(0x43484f); - case LV_STATE_CHECKED: - return _color_primary; - case LV_STATE_CHECKED | LV_STATE_PRESSED: - return lv_color_lighten(_color_primary, LV_OPA_20); - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return _color_primary; - } -} - -static inline lv_color_t color_scr_border(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0x555555); - } -} - -static inline lv_color_t color_panel_border(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0x3b3e42); - case LV_STATE_FOCUSED: - return _color_primary; - } -} - - -static inline lv_color_t color_bg_border(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - return lv_color_hex(0x606060); - case LV_STATE_PRESSED: - return lv_color_hex(0x404040); - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0x606060); - } -} - -static inline lv_color_t color_btn_border(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - return lv_color_hex(0x606060); - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return LV_COLOR_RED; - } -} - - -static inline lv_color_t color_scr_txt(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0xbababa); - } -} - -static inline lv_color_t color_panel_txt(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0xa5a8ad); - } -} - - -static inline lv_color_t color_bg_txt(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - case LV_STATE_DISABLED: - default: - return lv_color_hex(0xa5a8ad); - } -} - -static inline lv_color_t color_btn_txt(lv_state_t state) -{ - switch(state) { - case LV_STATE_DEFAULT: - case LV_STATE_PRESSED: - case LV_STATE_CHECKED: - case LV_STATE_FOCUSED: - case LV_STATE_EDITED: - case LV_STATE_HOVERED: - return lv_color_hex(0xffffff); - case LV_STATE_DISABLED: - return lv_color_hex(0x888888); - default: - return lv_color_hex(0xffffff); - } -} #endif diff --git a/src/lv_themes/lv_theme_material.h b/src/lv_themes/lv_theme_material.h index 9a4ddb581..c7e9b0ff3 100644 --- a/src/lv_themes/lv_theme_material.h +++ b/src/lv_themes/lv_theme_material.h @@ -20,17 +20,21 @@ extern "C" { /********************* * DEFINES *********************/ -#define LV_THEME_MATERIAL_FLAG_NONE 0 /********************** * TYPEDEFS **********************/ +typedef enum { + LV_THEME_MATERIAL_PALETTE_LIGHT, + LV_THEME_MATERIAL_PALETTE_DARK, +}lv_theme_material_palette_t; + + /********************** * GLOBAL PROTOTYPES **********************/ - /** * Initialize the default * @param color_primary the primary color of the theme diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index a64ac45d2..441a6ea87 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -828,24 +828,6 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &style_bg); lv_style_list_add_style(list, &style_tight); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCRLBAR); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCRLBAR); - lv_style_list_add_style(list, &style_bg); - break; - - case LV_THEME_TEXTAREA_ONELINE: - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); - lv_style_list_add_style(list, &style_bg); - - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); - - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); - lv_style_list_add_style(list, &style_bg); - lv_style_list_add_style(list, &style_tight); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCRLBAR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCRLBAR); lv_style_list_add_style(list, &style_bg); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index a84bc100d..bf9001474 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -635,19 +635,22 @@ void lv_dropdown_open(lv_obj_t * ddlist, lv_anim_enable_t anim) else if(ext->dir == LV_DROPDOWN_DIR_RIGHT)lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); lv_obj_t * scr = lv_scr_act(); + bool moved = false; if(ext->dir != LV_DROPDOWN_DIR_UP) { if(ext->page->coords.y2 > scr->coords.y2) { lv_obj_set_y(ext->page, lv_obj_get_y(ext->page) - (ext->page->coords.y2 - scr->coords.y2)); + moved = true; } } else { if(ext->page->coords.y1 < 0) { lv_obj_set_y(ext->page, 0); + moved = true; } } #if LV_USE_ANIMATION - if(anim == LV_ANIM_ON && ext->dir != LV_DROPDOWN_DIR_UP) { + if(anim == LV_ANIM_ON && ext->dir != LV_DROPDOWN_DIR_UP && !moved) { lv_anim_t a; lv_anim_init(&a); lv_anim_set_var(&a, ddlist); diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index f353cc282..7dafc5c12 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -1,4 +1,4 @@ -/** + /** * @file lv_gauge.c * */ @@ -27,7 +27,7 @@ #define LV_GAUGE_DEF_NEEDLE_COLOR LV_COLOR_RED #define LV_GAUGE_DEF_LABEL_COUNT 6 #define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/ -#define LV_GAUGE_DEF_ANGLE 220 +#define LV_GAUGE_DEF_ANGLE 270 /********************** * TYPEDEFS diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index e6fe6af94..954873473 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -73,8 +73,8 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy) ext->min_value = 0; ext->max_value = 100; ext->cur_value = 0; - ext->line_cnt = 21; /*Odd scale number looks better*/ - ext->scale_angle = 240; /*(scale_num - 1) * N looks better */ + ext->line_cnt = 18; + ext->scale_angle = 240; ext->angle_ofs = 0; /*The signal and design functions are not copied so set them here*/ diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 020da1f43..a9eb66a08 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -43,7 +43,8 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_page_sb_refresh(lv_obj_t * page); +static void scrlbar_refresh(lv_obj_t * page); +static void scrl_reposition(lv_obj_t * page); static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_area, lv_design_mode_t mode); static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param); static lv_style_list_t * lv_page_get_style(lv_obj_t * page, uint8_t part); @@ -152,7 +153,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) } - lv_page_sb_refresh(page); + scrlbar_refresh(page); LV_LOG_INFO("page created"); @@ -199,7 +200,7 @@ void lv_page_set_scrlbar_mode(lv_obj_t * page, lv_scrlbar_mode_t sb_mode) ext->scrlbar.hor_draw = 0; ext->scrlbar.ver_draw = 0; - lv_page_sb_refresh(page); + scrlbar_refresh(page); lv_obj_invalidate(page); } @@ -807,14 +808,12 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) } } else if(sign == LV_SIGNAL_STYLE_CHG) { - ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_COORD_CHG, &ext->scrl->coords); - lv_style_int_t sb_width = lv_obj_get_style_size(page, LV_PAGE_PART_SCRLBAR); lv_area_set_height(&ext->scrlbar.hor_area, sb_width); lv_area_set_width(&ext->scrlbar.ver_area, sb_width); /*The scrollbars are important only if they are visible now*/ - if(ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) lv_page_sb_refresh(page); + if(ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) scrlbar_refresh(page); /*Refresh the ext. size because the scrollbars might be positioned out of the page*/ refr_ext_draw_pad(page); @@ -827,7 +826,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_COORD_CHG, &ext->scrl->coords); /*The scrollbars are important only if they are visible now*/ - if(ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) lv_page_sb_refresh(page); + if(ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) scrlbar_refresh(page); } } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { @@ -893,17 +892,6 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page); if(sign == LV_SIGNAL_COORD_CHG) { - /*Limit the position of the scrollable object to be always visible - * (Do not let its edge inner then its parent respective edge)*/ - lv_coord_t new_x = lv_obj_get_x(scrl); - lv_coord_t new_y = lv_obj_get_y(scrl); - bool refr_x = false; - bool refr_y = false; - lv_area_t page_coords; - lv_area_t scrl_coords; - lv_obj_get_coords(scrl, &scrl_coords); - lv_obj_get_coords(page, &page_coords); - lv_obj_t * page_parent = lv_obj_get_parent(page); /*Handle scroll propagation*/ @@ -933,64 +921,14 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } - lv_style_int_t left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG); - lv_style_int_t right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG); - lv_style_int_t top = lv_obj_get_style_pad_top(page, LV_PAGE_PART_BG); - lv_style_int_t bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_BG); - - /*scrollable width smaller then page width? -> align to left*/ - if(lv_area_get_width(&scrl_coords) + left + right <= lv_area_get_width(&page_coords)) { - if(scrl_coords.x1 != page_coords.x1 + left) { - new_x = left; - refr_x = true; - } - } - else { - /*The edges of the scrollable can not be in the page (minus hpad) */ - if(scrl_coords.x2 < page_coords.x2 - right) { - new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) - right; /* Right align */ - refr_x = true; - lv_page_start_edge_flash(page, LV_PAGE_EDGE_RIGHT); - } - else if(scrl_coords.x1 > page_coords.x1 + left) { - new_x = left; /*Left align*/ - refr_x = true; - lv_page_start_edge_flash(page, LV_PAGE_EDGE_LEFT); - } - } - - /*scrollable height smaller then page height? -> align to top*/ - if(lv_area_get_height(&scrl_coords) + top + bottom <= lv_area_get_height(&page_coords)) { - if(scrl_coords.y1 != page_coords.y1 + top) { - new_y = top; - refr_y = true; - } - } - else { - /*The edges of the scrollable can not be in the page (minus vpad) */ - if(scrl_coords.y2 < page_coords.y2 - bottom) { - new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) - bottom; /* Bottom align */ - refr_y = true; - lv_page_start_edge_flash(page, LV_PAGE_EDGE_BOTTOM); - } - else if(scrl_coords.y1 > page_coords.y1 + top) { - new_y = top; /*Top align*/ - refr_y = true; - lv_page_start_edge_flash(page, LV_PAGE_EDGE_TOP); - } - } - - if(refr_x || refr_y) { - lv_obj_set_pos(scrl, new_x, new_y); - } - - lv_page_sb_refresh(page); + scrl_reposition(page); + } + else if(sign == LV_SIGNAL_STYLE_CHG) { + scrl_reposition(page); } else if(sign == LV_SIGNAL_DRAG_BEGIN) { if(page_ext->scrlbar.mode == LV_SCRLBAR_MODE_DRAG) { - page_ext->scrlbar.ver_draw = 1; - page_ext->scrlbar.hor_draw = 1; - lv_obj_invalidate(page); + scrlbar_refresh(page); } } else if(sign == LV_SIGNAL_DRAG_END) { @@ -1126,12 +1064,78 @@ static lv_style_list_t * lv_page_get_style(lv_obj_t * page, uint8_t part) return style_dsc_p; } +static void scrl_reposition(lv_obj_t * page) +{ + /*Limit the position of the scrollable object to be always visible + * (Do not let its edge inner then its parent respective edge)*/ + lv_obj_t * scrl = lv_page_get_scrl(page); + lv_coord_t new_x = lv_obj_get_x(scrl); + lv_coord_t new_y = lv_obj_get_y(scrl); + bool refr_x = false; + bool refr_y = false; + lv_area_t page_coords; + lv_area_t scrl_coords; + lv_obj_get_coords(scrl, &scrl_coords); + lv_obj_get_coords(page, &page_coords); + + lv_style_int_t left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG); + lv_style_int_t right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG); + lv_style_int_t top = lv_obj_get_style_pad_top(page, LV_PAGE_PART_BG); + lv_style_int_t bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_BG); + + /*scrollable width smaller then page width? -> align to left*/ + if(lv_area_get_width(&scrl_coords) + left + right <= lv_area_get_width(&page_coords)) { + if(scrl_coords.x1 != page_coords.x1 + left) { + new_x = left; + refr_x = true; + } + } + else { + /*The edges of the scrollable can not be in the page (minus hpad) */ + if(scrl_coords.x2 < page_coords.x2 - right) { + new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) - right; /* Right align */ + refr_x = true; + lv_page_start_edge_flash(page, LV_PAGE_EDGE_RIGHT); + } + else if(scrl_coords.x1 > page_coords.x1 + left) { + new_x = left; /*Left align*/ + refr_x = true; + lv_page_start_edge_flash(page, LV_PAGE_EDGE_LEFT); + } + } + + /*scrollable height smaller then page height? -> align to top*/ + if(lv_area_get_height(&scrl_coords) + top + bottom <= lv_area_get_height(&page_coords)) { + if(scrl_coords.y1 != page_coords.y1 + top) { + new_y = top; + refr_y = true; + } + } + else { + /*The edges of the scrollable can not be in the page (minus vpad) */ + if(scrl_coords.y2 < page_coords.y2 - bottom) { + new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) - bottom; /* Bottom align */ + refr_y = true; + lv_page_start_edge_flash(page, LV_PAGE_EDGE_BOTTOM); + } + else if(scrl_coords.y1 > page_coords.y1 + top) { + new_y = top; /*Top align*/ + refr_y = true; + lv_page_start_edge_flash(page, LV_PAGE_EDGE_TOP); + } + } + + if(refr_x || refr_y) { + lv_obj_set_pos(scrl, new_x, new_y); + } + scrlbar_refresh(page); +} /** * Refresh the position and size of the scroll bars. * @param page pointer to a page object */ -static void lv_page_sb_refresh(lv_obj_t * page) +static void scrlbar_refresh(lv_obj_t * page) { lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_obj_t * scrl = ext->scrl; @@ -1183,10 +1187,19 @@ static void lv_page_sb_refresh(lv_obj_t * page) lv_obj_invalidate_area(page, &sb_area_tmp); } - if(ext->scrlbar.mode == LV_SCRLBAR_MODE_DRAG && lv_indev_is_dragging(lv_indev_get_act()) == false) { - ext->scrlbar.hor_draw = 0; - ext->scrlbar.ver_draw = 0; - return; + if(ext->scrlbar.mode == LV_SCRLBAR_MODE_DRAG) { + lv_obj_t * indev_obj = lv_indev_get_obj_act(); + + if(indev_obj == NULL) return; + while(indev_obj && lv_obj_get_drag_parent(indev_obj)) { + indev_obj = lv_obj_get_parent(indev_obj); + } + + if(indev_obj != scrl) { + ext->scrlbar.hor_draw = 0; + ext->scrlbar.ver_draw = 0; + return; + } } /*Full sized horizontal scrollbar*/ @@ -1232,7 +1245,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) (obj_h - size_tmp - 2 * sb_ver_pad)) / (scrl_h + bg_top + bg_bottom - obj_h)); - if(ext->scrlbar.mode == LV_SCRLBAR_MODE_AUTO) ext->scrlbar.ver_draw = 1; + if(ext->scrlbar.mode == LV_SCRLBAR_MODE_AUTO || ext->scrlbar.mode == LV_SCRLBAR_MODE_DRAG) ext->scrlbar.ver_draw = 1; } /*Invalidate the new scrollbar areas*/ diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index e43a74504..1ca8495cc 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -89,7 +89,7 @@ lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy) if(copy == NULL) { lv_obj_set_click(sw, true); lv_obj_add_protect(sw, LV_PROTECT_PRESS_LOST); - lv_obj_set_size(sw, LV_DPI / 2, LV_DPI / 4); + lv_obj_set_size(sw, 4 * LV_DPI / 10, LV_DPI / 4); lv_bar_set_range(sw, 0, 1); lv_theme_apply(sw, LV_THEME_SWITCH);