diff --git a/lv_conf_template.h b/lv_conf_template.h index 1b17c3c63..99c945fda 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -288,18 +288,6 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i #endif /*LV_USE_DEBUG*/ -/*================ - * THEME USAGE - *================*/ -#define LV_USE_THEME_TEMPL 0 /*Just for test*/ -#define LV_USE_THEME_DEFAULT 0 /*Built mainly from the built-in styles. Consumes very few RAM*/ -#define LV_USE_THEME_ALIEN 0 /*Dark futuristic theme*/ -#define LV_USE_THEME_NIGHT 0 /*Dark elegant theme*/ -#define LV_USE_THEME_MONO 0 /*Mono color theme for monochrome displays*/ -#define LV_USE_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/ -#define LV_USE_THEME_ZEN 0 /*Peaceful, mainly light theme */ -#define LV_USE_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/ - /*================== * FONT USAGE *===================*/ @@ -333,9 +321,6 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i */ #define LV_FONT_CUSTOM_DECLARE -/*Always set a default font from the built-in fonts*/ -#define LV_FONT_DEFAULT &lv_font_roboto_16 - /* Enable it if you have fonts with a lot of characters. * The limit depends on the font size, font face and bpp * but with > 10,000 characters if you see issues probably you need to enable it.*/ @@ -350,6 +335,23 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i /*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ typedef void * lv_font_user_data_t; + +/*================ + * THEME USAGE + *================*/ + +/*Always enable at least on theme*/ +#define LV_USE_THEME_MATERIAL 1 /*A fast and impressive theme*/ + +#define LV_THEME_DEFAULT_INIT lv_theme_material_init +#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED +#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE +#define LV_THEME_DEFAULT_FLAGS LV_THEME_MATERIAL_FLAG_NONE +#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_roboto_12 +#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_roboto_16 +#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_roboto_22 +#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_roboto_28 + /*================= * Text settings *=================*/ @@ -564,14 +566,14 @@ typedef void * lv_obj_user_data_t; #endif /*Table (dependencies: lv_label)*/ -#define LV_USE_TEXTAREABLE 1 -#if LV_USE_TEXTAREABLE +#define LV_USE_TABLE 1 +#if LV_USE_TABLE # define LV_TABLE_COL_MAX 12 #endif /*Tab (dependencies: lv_page, lv_btnm)*/ -#define LV_USE_TEXTAREABVIEW 1 -# if LV_USE_TEXTAREABVIEW != 0 +#define LV_USE_TABVIEW 1 +# if LV_USE_TABVIEW != 0 /*Time of slide animation [ms] (0: no animation)*/ # define LV_TABVIEW_DEF_ANIM_TIME 300 #endif diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 617685bb9..574a9f549 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -824,20 +824,20 @@ #endif /*Table (dependencies: lv_label)*/ -#ifndef LV_USE_TEXTAREABLE -#define LV_USE_TEXTAREABLE 1 +#ifndef LV_USE_TABLE +#define LV_USE_TABLE 1 #endif -#if LV_USE_TEXTAREABLE +#if LV_USE_TABLE #ifndef LV_TABLE_COL_MAX # define LV_TABLE_COL_MAX 12 #endif #endif /*Tab (dependencies: lv_page, lv_btnm)*/ -#ifndef LV_USE_TEXTAREABVIEW -#define LV_USE_TEXTAREABVIEW 1 +#ifndef LV_USE_TABVIEW +#define LV_USE_TABVIEW 1 #endif -# if LV_USE_TEXTAREABVIEW != 0 +# if LV_USE_TABVIEW != 0 /*Time of slide animation [ms] (0: no animation)*/ #ifndef LV_TABVIEW_DEF_ANIM_TIME # define LV_TABVIEW_DEF_ANIM_TIME 300 diff --git a/src/lv_core/lv_debug.c b/src/lv_core/lv_debug.c index aa6a0cd5a..cab7c977a 100644 --- a/src/lv_core/lv_debug.c +++ b/src/lv_core/lv_debug.c @@ -92,10 +92,24 @@ bool lv_debug_check_style(const lv_style_t * style) if(style == NULL) return true; /*NULL style is still valid*/ #if LV_USE_ASSERT_STYLE -// if(style->debug_sentinel != LV_STYLE_DEGUG_SENTINEL_VALUE) { -// LV_LOG_WARN("Invalid style (local variable or not initialized?)"); -// return false; -// } + if(style->sentinel != LV_DEBUG_STYLE_SENTINEL_VALUE) { + LV_LOG_WARN("Invalid style (local variable or not initialized?)"); + return false; + } +#endif + + return true; +} + +bool lv_debug_check_style_list(const lv_style_list_t * list) +{ + if(list == NULL) return true; /*NULL list is still valid*/ + +#if LV_USE_ASSERT_STYLE + if(list->sentinel != LV_DEBUG_STYLE_LIST_SENTINEL_VALUE) { + LV_LOG_WARN("Invalid style (local variable or not initialized?)"); + return false; + } #endif return true; diff --git a/src/lv_core/lv_debug.h b/src/lv_core/lv_debug.h index 43b350efb..93465441f 100644 --- a/src/lv_core/lv_debug.h +++ b/src/lv_core/lv_debug.h @@ -38,6 +38,8 @@ bool lv_debug_check_obj_valid(const lv_obj_t * obj); bool lv_debug_check_style(const lv_style_t * style); +bool lv_debug_check_style_list(const lv_style_list_t * list); + bool lv_debug_check_str(const void * str); void lv_debug_log_error(const char * msg, uint64_t value); @@ -85,6 +87,10 @@ do { \ #define LV_DEBUG_IS_STYLE(style_p) (lv_debug_check_style(style_p)) #endif +#ifndef LV_DEBUG_IS_STYLE_LIST +#define LV_DEBUG_IS_STYLE_LIST(list_p) (lv_debug_check_style_list(list_p)) +#endif + /*----------------- * ASSERTS *-----------------*/ @@ -144,8 +150,12 @@ do { \ # ifndef LV_ASSERT_STYLE # define LV_ASSERT_STYLE(style_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE(style_p), "Invalid style", style_p); # endif +# ifndef LV_ASSERT_STYLE_LIST +# define LV_ASSERT_STYLE_LIST(list_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE_LIST(list_p), "Invalid style list", list_p); +# endif #else -# define LV_ASSERT_STYLE(style) true +# define LV_ASSERT_STYLE(style_p) true +# define LV_ASSERT_STYLE_LIST(list_p) true #endif #else /* LV_USE_DEBUG == 0 */ diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index ee1e57d71..ef31cc2ea 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -108,7 +108,10 @@ void lv_init(void) #endif - lv_theme_t * th = lv_theme_default_init(0, NULL); + + lv_theme_t * th = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, LV_THEME_DEFAULT_COLOR_SECONDARY, + LV_THEME_DEFAULT_FLAGS, + LV_THEME_DEFAULT_FONT_SMALL, LV_THEME_DEFAULT_FONT_NORMAL, LV_THEME_DEFAULT_FONT_SUBTITLE, LV_THEME_DEFAULT_FONT_TITLE); lv_theme_set_act(th); /*Initialize the screen refresh system*/ @@ -2852,7 +2855,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t draw_dsc->pattern_repeat = lv_obj_get_style_pattern_repeat(obj, part); if(lv_img_src_get_type(draw_dsc->pattern_image) == LV_IMG_SRC_SYMBOL) { draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part); - draw_dsc->pattern_font = lv_obj_get_style_font(obj, part); + draw_dsc->pattern_font = lv_obj_get_style_text_font(obj, part); } else if(draw_dsc->pattern_recolor_opa > LV_OPA_MIN ) { draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part); } @@ -2914,8 +2917,11 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_ draw_dsc->color = lv_obj_get_style_text_color(obj, part); draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part); draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part); + draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part); + draw_dsc->underline = lv_obj_get_style_text_underline(obj, part); + draw_dsc->strikethrough = lv_obj_get_style_text_strikethrough(obj, part); - draw_dsc->font = lv_obj_get_style_font(obj, part); + draw_dsc->font = lv_obj_get_style_text_font(obj, part); if(draw_dsc->sel_start != LV_DRAW_LABEL_NO_TXT_SEL && draw_dsc->sel_end != LV_DRAW_LABEL_NO_TXT_SEL) { draw_dsc->color = lv_obj_get_style_text_sel_color(obj, part); diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 4b2fef536..9a3596482 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -26,6 +26,9 @@ extern "C" { #include "../lv_misc/lv_bidi.h" #include "../lv_hal/lv_hal.h" #include "../lv_draw/lv_draw_rect.h" +#include "../lv_draw/lv_draw_label.h" +#include "../lv_draw/lv_draw_line.h" +#include "../lv_draw/lv_draw_img.h" /********************* * DEFINES @@ -1099,11 +1102,13 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t * , _ptr); _LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char * , _ptr); _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int); _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int); +_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_UNDERLINE, text_underline, bool, _int); +_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_STRIKETHROUGH, text_strikethrough, bool, _int); _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t, _int); _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color); _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color); _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa); -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, font, const lv_font_t * , _ptr); +_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t * , _ptr); _LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int); _LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int); _LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int); diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index a728c18b2..f471013d0 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -41,7 +41,6 @@ static lv_style_t * get_local_style(lv_style_list_t * list); /********************** * GLOABAL VARIABLES **********************/ -//lv_style_t lv_style_transp_tight; /********************** * STATIC VARIABLES @@ -62,6 +61,9 @@ static lv_style_t * get_local_style(lv_style_list_t * list); void lv_style_init(lv_style_t * style) { style->map = NULL; +#if LV_USE_ASSERT_STYLE + style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE; +#endif } /** @@ -71,6 +73,9 @@ void lv_style_init(lv_style_t * style) */ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src) { + LV_ASSERT_STYLE(style_dest); + LV_ASSERT_STYLE(style_src); + if(style_src == NULL) return; if(style_src->map == NULL) return; @@ -89,6 +94,9 @@ void lv_style_list_init(lv_style_list_t * list) list->style_list = NULL; list->style_cnt = 0; list->has_local = 0; + #if LV_USE_ASSERT_STYLE + list->sentinel = LV_DEBUG_STYLE_LIST_SENTINEL_VALUE; +#endif } /** @@ -98,6 +106,9 @@ void lv_style_list_init(lv_style_list_t * list) */ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * list_src) { + LV_ASSERT_STYLE_LIST(list_dest); + LV_ASSERT_STYLE_LIST(list_src); + lv_style_list_reset(list_dest); if(list_src->style_list == NULL) return; @@ -126,6 +137,9 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis */ void lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style) { + LV_ASSERT_STYLE_LIST(list); + LV_ASSERT_STYLE(style); + if(list == NULL) return; /*Remove the style first if already exists*/ @@ -159,6 +173,9 @@ void lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style) */ void lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) { + LV_ASSERT_STYLE_LIST(list); + LV_ASSERT_STYLE(style); + if(list->style_cnt == 0) return; /*Check if the style really exists here*/ @@ -204,7 +221,10 @@ void lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) */ void lv_style_list_reset(lv_style_list_t * list) { + LV_ASSERT_STYLE_LIST(list); + if(list == NULL) return; + if(list->has_local) { lv_style_t * local = lv_style_list_get_style(list, 0); lv_style_reset(local); @@ -222,6 +242,8 @@ void lv_style_list_reset(lv_style_list_t * list) */ void lv_style_reset(lv_style_t * style) { + LV_ASSERT_STYLE(style); + lv_mem_free(style->map); style->map = NULL; } @@ -233,6 +255,8 @@ void lv_style_reset(lv_style_t * style) */ uint16_t lv_style_get_mem_size(const lv_style_t * style) { + LV_ASSERT_STYLE(style); + if(style->map == NULL) return 0; size_t i = 0; @@ -261,6 +285,8 @@ uint16_t lv_style_get_mem_size(const lv_style_t * style) */ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_int_t value) { + LV_ASSERT_STYLE(style); + int32_t id = get_property_index(style, prop); /*The property already exists but not sure it's state is the same*/ if(id >= 0) { @@ -305,6 +331,8 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in */ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t color) { + LV_ASSERT_STYLE(style); + int32_t id = get_property_index(style, prop); /*The property already exists but not sure it's state is the same*/ if(id >= 0) { @@ -350,6 +378,8 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ */ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa) { + LV_ASSERT_STYLE(style); + int32_t id = get_property_index(style, prop); /*The property already exists but not sure it's state is the same*/ if(id >= 0) { @@ -395,6 +425,8 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op */ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p) { + LV_ASSERT_STYLE(style); + int32_t id = get_property_index(style, prop); /*The property already exists but not sure it's state is the same*/ if(id >= 0) { @@ -441,6 +473,8 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void */ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, lv_style_int_t * res) { + LV_ASSERT_STYLE(style); + if(style == NULL) return -1; if(style->map == NULL) return -1; int32_t id = get_property_index(style, prop); @@ -473,6 +507,8 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, lv */ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, lv_opa_t * res) { + LV_ASSERT_STYLE(style); + if(style == NULL) return -1; if(style->map == NULL) return -1; int32_t id = get_property_index(style, prop); @@ -565,6 +601,8 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo */ void lv_style_list_set_local_int(lv_style_list_t * list, lv_style_property_t prop, lv_style_int_t value) { + LV_ASSERT_STYLE_LIST(list); + lv_style_t * local = get_local_style(list); _lv_style_set_int(local, prop, value); } @@ -579,6 +617,8 @@ void lv_style_list_set_local_int(lv_style_list_t * list, lv_style_property_t pro */ void lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t prop, lv_opa_t value) { + LV_ASSERT_STYLE_LIST(list); + lv_style_t * local = get_local_style(list); _lv_style_set_opa(local, prop, value); } @@ -593,6 +633,8 @@ void lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t pro */ void lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t prop, lv_color_t value) { + LV_ASSERT_STYLE_LIST(list); + lv_style_t * local = get_local_style(list); _lv_style_set_color(local, prop, value); } @@ -607,6 +649,8 @@ void lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t p */ void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value) { + LV_ASSERT_STYLE_LIST(list); + lv_style_t * local = get_local_style(list); _lv_style_set_ptr(local, prop, value); } @@ -624,6 +668,8 @@ void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t pro */ lv_res_t lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop, lv_style_int_t * res) { + LV_ASSERT_STYLE_LIST(list); + if(list == NULL) return LV_RES_INV; if(list->style_list == NULL) return LV_RES_INV; @@ -670,6 +716,8 @@ lv_res_t lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop, */ lv_res_t lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t prop, lv_color_t * res) { + LV_ASSERT_STYLE_LIST(list); + if(list == NULL) return LV_RES_INV; if(list->style_list == NULL) return LV_RES_INV; @@ -715,6 +763,8 @@ lv_res_t lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pro */ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop, lv_opa_t * res) { + LV_ASSERT_STYLE_LIST(list); + if(list == NULL) return LV_RES_INV; if(list->style_list == NULL) return LV_RES_INV; @@ -760,6 +810,8 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop, */ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, void ** res) { + LV_ASSERT_STYLE_LIST(list); + if(list == NULL) return LV_RES_INV; if(list->style_list == NULL) return LV_RES_INV; @@ -806,6 +858,9 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, */ static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop) { + + LV_ASSERT_STYLE(style); + if(style->map == NULL) return -1; uint8_t id_to_find = prop & 0xFF; @@ -856,6 +911,8 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop */ static lv_style_t * get_local_style(lv_style_list_t * list) { + LV_ASSERT_STYLE_LIST(list); + if(list->has_local) return lv_style_list_get_style(list, 0); lv_style_t * local_style = lv_mem_alloc(sizeof(lv_style_t)); diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 244c7437a..0d0f60e5c 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -25,9 +25,11 @@ extern "C" { * DEFINES *********************/ #define LV_RADIUS_CIRCLE (LV_COORD_MAX) /**< A very big radius to always draw as circle*/ - LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE); +#define LV_DEBUG_STYLE_SENTINEL_VALUE 0x2288AAEE +#define LV_DEBUG_STYLE_LIST_SENTINEL_VALUE 0x9977CCBB + /********************** * TYPEDEFS **********************/ @@ -135,9 +137,11 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_VALUE_FONT, 0x7, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_VALUE_STR, 0x7, LV_STYLE_ID_PTR + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT), + LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT), + LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT), + LV_STYLE_PROP_INIT(LV_STYLE_TEXT_UNDERLINE, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT), + LV_STYLE_PROP_INIT(LV_STYLE_TEXT_STRIKETHROUGH, 0x8, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_INHERIT), + LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_COLOR, 0x8, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), @@ -174,6 +178,9 @@ typedef uint16_t lv_style_state_t; typedef struct { uint8_t * map; +#if LV_USE_ASSERT_STYLE + uint32_t sentinel; +#endif }lv_style_t; typedef int16_t lv_style_int_t; @@ -181,6 +188,9 @@ typedef int16_t lv_style_int_t; typedef struct { lv_style_t ** style_list; +#if LV_USE_ASSERT_STYLE + uint32_t sentinel; +#endif uint8_t style_cnt; uint8_t has_local :1; }lv_style_list_t; diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 102520bb2..0e08ff691 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "lv_draw_arc.h" +#include "lv_draw_rect.h" #include "lv_draw_mask.h" #include "../lv_misc/lv_math.h" diff --git a/src/lv_draw/lv_draw_arc.h b/src/lv_draw/lv_draw_arc.h index caa63f14b..22e3faac3 100644 --- a/src/lv_draw/lv_draw_arc.h +++ b/src/lv_draw/lv_draw_arc.h @@ -13,7 +13,6 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "lv_draw.h" #include "lv_draw_line.h" /********************* diff --git a/src/lv_draw/lv_draw_img.h b/src/lv_draw/lv_draw_img.h index e1f5e238a..752604e49 100644 --- a/src/lv_draw/lv_draw_img.h +++ b/src/lv_draw/lv_draw_img.h @@ -13,7 +13,6 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "lv_draw.h" #include "lv_img_decoder.h" #include "lv_img_buf.h" diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 3249250a0..4722101c0 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -180,14 +180,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab sel_end = tmp; } -// lv_style_t line_style; -// if(dsc->underline || dsc->strikethrough) { -// lv_style_copy(&line_style, style); -// line_style.line.color = dsc->color; -// line_style.line.width = (dsc->font->line_height + 5) / 10; /*+5 for rounding*/ -// line_style.line.opa = dsc->opa; -// line_style.line.blend_mode = dsc->blend_mode; -// } + lv_draw_line_dsc_t line_dsc; + if(dsc->underline || dsc->strikethrough) { + lv_draw_line_dsc_init(&line_dsc); + line_dsc.color = dsc->color; + line_dsc.width = (dsc->font->line_height + 5) / 10; /*+5 for rounding*/ + line_dsc.opa = dsc->opa; + line_dsc.blend_mode = dsc->blend_mode; + } cmd_state_t cmd_state = CMD_STATE_WAIT; uint32_t i; @@ -294,25 +294,25 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab } } -// if(dsc->strikethrough) { -// lv_point_t p1; -// lv_point_t p2; -// p1.x = pos_x_start; -// p1.y = pos.y + (dsc->font->line_height / 2) + style->line.width / 2; -// p2.x = pos.x; -// p2.y = p1.y; -// lv_draw_line(&p1, &p2, mask, &line_style, opa_scale); -// } -// -// if(dsc->underline) { -// lv_point_t p1; -// lv_point_t p2; -// p1.x = pos_x_start; -// p1.y = pos.y + dsc->font->line_height - dsc->font->base_line + style->line.width / 2 + 1; -// p2.x = pos.x; -// p2.y = p1.y; -// lv_draw_line(&p1, &p2, mask, &line_style, opa_scale); -// } + if(dsc->strikethrough) { + lv_point_t p1; + lv_point_t p2; + p1.x = pos_x_start; + p1.y = pos.y + (dsc->font->line_height / 2) + line_dsc.width / 2; + p2.x = pos.x; + p2.y = p1.y; + lv_draw_line(&p1, &p2, mask, &line_dsc); + } + + if(dsc->underline) { + lv_point_t p1; + lv_point_t p2; + p1.x = pos_x_start; + p1.y = pos.y + dsc->font->line_height - dsc->font->base_line + line_dsc.width / 2 + 1; + p2.x = pos.x; + p2.y = p1.y; + lv_draw_line(&p1, &p2, mask, &line_dsc); + } #if LV_USE_BIDI lv_mem_buf_release(bidi_txt); diff --git a/src/lv_draw/lv_draw_label.h b/src/lv_draw/lv_draw_label.h index 2b178f040..e9c5af364 100644 --- a/src/lv_draw/lv_draw_label.h +++ b/src/lv_draw/lv_draw_label.h @@ -13,8 +13,9 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "lv_draw.h" #include "../lv_misc/lv_bidi.h" +#include "../lv_misc/lv_txt.h" +#include "../lv_core/lv_style.h" /********************* * DEFINES @@ -38,6 +39,9 @@ typedef struct { lv_coord_t ofs_y; lv_bidi_dir_t bidi_dir; lv_txt_flag_t flag; + lv_blend_mode_t blend_mode; + uint8_t underline :1; + uint8_t strikethrough :1; }lv_draw_label_dsc_t; /** Store some info to speed up drawing of very large texts @@ -63,7 +67,6 @@ typedef struct { void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc); - /** * Write a text * @param coords coordinates of the label diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 54290775f..142da0fc4 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -8,7 +8,6 @@ *********************/ #include #include -#include "lv_draw.h" #include "lv_draw_mask.h" #include "lv_draw_blend.h" #include "../lv_core/lv_refr.h" diff --git a/src/lv_draw/lv_draw_line.h b/src/lv_draw/lv_draw_line.h index 2d5d21131..fdcb3977d 100644 --- a/src/lv_draw/lv_draw_line.h +++ b/src/lv_draw/lv_draw_line.h @@ -13,6 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ +#include "../lv_core/lv_style.h" /********************* * DEFINES diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index c6abfe190..9bc727938 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -13,7 +13,6 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "lv_draw.h" #include "../lv_core/lv_style.h" /********************* diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index 20ecbe6ed..658b0b13a 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -35,15 +35,14 @@ **********************/ /** - * + * Draw a triangle * @param points pointer to an array with 3 points * @param clip_area the triangle will be drawn only in this area - * @param style style for of the triangle - * @param opa_scale scale down all opacities by the factor (0..255) + * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip_area, const lv_style_t * style, lv_opa_t opa_scale) +void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc) { - lv_draw_polygon(points, 3, clip_area, style, opa_scale); + lv_draw_polygon(points, 3, clip_area, draw_dsc); } /** @@ -51,11 +50,9 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip_area, co * @param points an array of points * @param point_cnt number of points * @param clip_area polygon will be drawn only in this area - * @param style style of the polygon - * @param opa_scale scale down all opacities by the factor (0..255) + * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * clip_area, const lv_style_t * style, - lv_opa_t opa_scale) +void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc) { if(point_cnt < 3) return; if(points == NULL) return; @@ -153,9 +150,7 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are }while( mask_cnt < point_cnt); - - - lv_draw_rect(&poly_coords, &poly_mask, style); + lv_draw_rect(&poly_coords, clip_area, draw_dsc); lv_draw_mask_remove_custom(mp); diff --git a/src/lv_draw/lv_draw_triangle.h b/src/lv_draw/lv_draw_triangle.h index 020ff0d75..888eeed90 100644 --- a/src/lv_draw/lv_draw_triangle.h +++ b/src/lv_draw/lv_draw_triangle.h @@ -13,7 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "lv_draw.h" +#include "lv_draw_rect.h" /********************* * DEFINES @@ -27,26 +27,22 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ - /** * Draw a triangle * @param points pointer to an array with 3 points * @param clip_area the triangle will be drawn only in this area - * @param style style for of the triangle - * @param opa_scale scale down all opacities by the factor (0..255) + * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip, const lv_style_t * style, lv_opa_t opa_scale); +void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip, lv_draw_rect_dsc_t * draw_dsc); /** * Draw a polygon. Only convex polygons are supported. * @param points an array of points * @param point_cnt number of points * @param clip_area polygon will be drawn only in this area - * @param style style of the polygon - * @param opa_scale scale down all opacities by the factor (0..255) + * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale); +void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * mask, lv_draw_rect_dsc_t * draw_dsc); /********************** * MACROS diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 605e4ad15..e808c0801 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -111,7 +111,7 @@ lv_style_t * lv_theme_get_style_part(lv_theme_style_t name, uint8_t part); /********************** * POST INCLUDE *********************/ -#include "lv_theme_def.h" +#include #ifdef __cplusplus } /* extern "C" */ diff --git a/src/lv_themes/lv_theme_def.h b/src/lv_themes/lv_theme_def.h deleted file mode 100644 index 7ebf3437c..000000000 --- a/src/lv_themes/lv_theme_def.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file lv_theme_alien.h - * - */ - -#ifndef LV_THEME_ALIEN_H -#define LV_THEME_ALIEN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "../lv_conf_internal.h" - -#if LV_USE_THEME_ALIEN - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Initialize the alien theme - * @param hue [0..360] hue value from HSV color space to define the theme's base color - * @param font pointer to a font (NULL to use the default) - */ -lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font); - -lv_theme_t * lv_theme_alien_get(void); -lv_style_t * lv_theme_alien_get_style_part(lv_theme_style_t name, uint8_t part); - -lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name); - -/********************** - * MACROS - **********************/ - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_THEME_ALIEN_H*/ diff --git a/src/lv_themes/lv_theme_def.c b/src/lv_themes/lv_theme_material.c similarity index 93% rename from src/lv_themes/lv_theme_def.c rename to src/lv_themes/lv_theme_material.c index bd3432d12..70a929b07 100644 --- a/src/lv_themes/lv_theme_def.c +++ b/src/lv_themes/lv_theme_material.c @@ -1,5 +1,5 @@ /** - * @file lv_theme_alien.c + * @file lv_theme_material.c * */ @@ -11,16 +11,11 @@ #include "../lv_widgets/lv_img.h" #include "../lv_misc/lv_types.h" -#if LV_USE_THEME_ALIEN +#if LV_USE_THEME_MATERIAL /********************* * DEFINES *********************/ -//#define COLOR_SCREEN lv_color_hex3(0x34a) -//#define COLOR_CONTAINER lv_color_hex3(0x888) -//#define COLOR_BACKGROUND lv_color_hex3(0x0f0) -//#define COLOR_ACCENT lv_color_hex3(0xf00) -//#define COLOR_DISABLED lv_color_hex3(0x999) #define COLOR_SCREEN lv_color_hex(0x22252a) #define COLOR_CONTAINER lv_color_hex(0x282b30) @@ -35,13 +30,20 @@ /********************** * STATIC PROTOTYPES **********************/ -void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name); +static void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name); /********************** * STATIC VARIABLES **********************/ static lv_theme_t theme; +static lv_color_t _color_primary; +static lv_color_t _color_secondary; +static uint32_t _flags; +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_style_t scr; @@ -118,11 +120,11 @@ static lv_style_t cpicker_bg, cpicker_indic; static lv_style_t mbox_btn, mbox_btn_bg; #endif -#if LV_USE_TEXTAREABVIEW +#if LV_USE_TABVIEW static lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabview_page_scrl; #endif -#if LV_USE_TEXTAREABLE +#if LV_USE_TABLE static lv_style_t table_cell; #endif @@ -164,7 +166,7 @@ static void basic_init(void) lv_style_set_pad_inner(&panel, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_text_color(&panel, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); lv_style_set_value_color(&panel, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); - lv_style_set_font(&panel, LV_STATE_NORMAL, &lv_font_roboto_16); + lv_style_set_text_font(&panel, LV_STATE_NORMAL, &lv_font_roboto_16); lv_style_set_image_recolor(&panel, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); lv_style_set_line_color(&panel, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); lv_style_set_line_width(&panel, LV_STATE_NORMAL, 1); @@ -222,6 +224,7 @@ static void bar_init(void) lv_style_set_radius(&bar_bg, LV_STATE_NORMAL, LV_RADIUS_CIRCLE); lv_style_set_bg_opa(&bar_bg, LV_STATE_NORMAL, LV_OPA_COVER); lv_style_set_bg_color(&bar_bg, LV_STATE_NORMAL, COLOR_BACKGROUND); + lv_style_set_value_color(&bar_bg, LV_STATE_NORMAL, LV_COLOR_WHITE); lv_style_set_outline_color(&bar_bg, LV_STATE_FOCUSED, COLOR_ACCENT); lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_width(&bar_bg, LV_STATE_FOCUSED, 3); @@ -231,6 +234,7 @@ static void bar_init(void) lv_style_set_radius(&bar_indic, LV_STATE_NORMAL, LV_RADIUS_CIRCLE); lv_style_set_bg_color(&bar_indic, LV_STATE_NORMAL, COLOR_ACCENT); lv_style_set_bg_color(&bar_indic, LV_STATE_DISABLED, COLOR_DISABLED); + lv_style_set_value_color(&bar_indic, LV_STATE_NORMAL, LV_COLOR_WHITE); #endif } @@ -270,6 +274,7 @@ static void slider_init(void) lv_style_init(&slider_knob); lv_style_set_bg_opa(&slider_knob, LV_STATE_NORMAL, LV_OPA_COVER); lv_style_set_bg_color(&slider_knob, LV_STATE_NORMAL, LV_COLOR_WHITE); + lv_style_set_value_color(&slider_knob, LV_STATE_NORMAL, LV_COLOR_WHITE); lv_style_set_radius(&slider_knob, LV_STATE_NORMAL, LV_RADIUS_CIRCLE); lv_style_set_pad_left(&slider_knob, LV_STATE_NORMAL, LV_DPI/20); lv_style_set_pad_right(&slider_knob, LV_STATE_NORMAL, LV_DPI/20); @@ -278,7 +283,7 @@ static void slider_init(void) #endif } -static void sw_init(void) +static void switch_init(void) { #if LV_USE_SWITCH != 0 lv_style_init(&sw_knob); @@ -292,7 +297,7 @@ static void sw_init(void) #endif } -static void lmeter_init(void) +static void linemeter_init(void) { #if LV_USE_LMETER != 0 lv_style_init(&lmeter); @@ -370,7 +375,7 @@ static void arc_init(void) #endif } -static void preload_init(void) +static void spinner_init(void) { #if LV_USE_SPINNER != 0 #endif @@ -463,15 +468,11 @@ static void cpicker_init(void) #endif } -static void cb_init(void) +static void checkbox_init(void) { #if LV_USE_CHECKBOX != 0 lv_style_init(&cb_bg); lv_style_set_radius(&cb_bg, LV_STATE_NORMAL, LV_DPI / 50); -// lv_style_set_pad_left(&cb_bg, LV_STATE_NORMAL, LV_DPI / 20); -// lv_style_set_pad_right(&cb_bg, LV_STATE_NORMAL, LV_DPI / 20); -// lv_style_set_pad_bottom(&cb_bg, LV_STATE_NORMAL, LV_DPI / 20); -// lv_style_set_pad_top(&cb_bg, LV_STATE_NORMAL, LV_DPI / 20); lv_style_set_pad_inner(&cb_bg, LV_STATE_NORMAL , LV_DPI / 20); lv_style_set_outline_color(&cb_bg, LV_STATE_FOCUSED, COLOR_ACCENT); lv_style_set_outline_opa(&cb_bg, LV_STATE_FOCUSED, LV_OPA_50); @@ -486,12 +487,15 @@ static void cb_init(void) lv_style_set_bg_color(&cb_bullet, LV_STATE_NORMAL, COLOR_ACCENT); lv_style_set_bg_opa(&cb_bullet, LV_STATE_NORMAL , LV_OPA_TRANSP); lv_style_set_bg_opa(&cb_bullet, LV_STATE_CHECKED , LV_OPA_COVER); + 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_border_opa(&cb_bullet, LV_STATE_CHECKED , LV_OPA_80); lv_style_set_transition_time(&cb_bullet, LV_STATE_NORMAL , 300); #endif } -static void btnm_init(void) +static void btnmatrix_init(void) { #if LV_USE_BTNMATRIX lv_style_init(&btnm_bg); @@ -522,7 +526,7 @@ static void btnm_init(void) #endif } -static void kb_init(void) +static void keyboard_init(void) { #if LV_USE_KEYBOARD lv_style_init(&kb_btn); @@ -540,7 +544,7 @@ static void kb_init(void) #endif } -static void mbox_init(void) +static void msgbox_init(void) { #if LV_USE_MSGBOX lv_style_init(&mbox_btn); @@ -578,7 +582,7 @@ static void page_init(void) #endif } -static void ta_init(void) +static void textarea_init(void) { #if LV_USE_TEXTAREA lv_style_init(&ta_bg); @@ -707,7 +711,7 @@ static void roller_init(void) static void tabview_init(void) { -#if LV_USE_TEXTAREABVIEW != 0 +#if LV_USE_TABVIEW != 0 lv_style_init(&tabview_btns_bg); lv_style_set_bg_opa(&tabview_btns_bg, LV_STATE_NORMAL, LV_OPA_COVER); lv_style_set_bg_color(&tabview_btns_bg, LV_STATE_NORMAL, COLOR_CONTAINER); @@ -715,7 +719,7 @@ static void tabview_init(void) lv_style_set_border_width(&tabview_btns_bg, LV_STATE_NORMAL, LV_DPI / 30 > 0 ? LV_DPI / 30 : 1); lv_style_set_border_side(&tabview_btns_bg, LV_STATE_NORMAL , LV_BORDER_SIDE_BOTTOM); lv_style_set_text_color(&tabview_btns_bg, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); - lv_style_set_font(&tabview_btns_bg, LV_STATE_NORMAL, &lv_font_roboto_16); + lv_style_set_text_font(&tabview_btns_bg, LV_STATE_NORMAL, &lv_font_roboto_16); lv_style_set_image_recolor(&tabview_btns_bg, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); @@ -751,7 +755,7 @@ static void tileview_init(void) static void table_init(void) { -#if LV_USE_TEXTAREABLE != 0 +#if LV_USE_TABLE != 0 lv_style_init(&table_cell); lv_style_set_border_color(&table_cell, LV_STATE_NORMAL, lv_color_hex(0x303338)); lv_style_set_border_width(&table_cell, LV_STATE_NORMAL, 1); @@ -777,15 +781,27 @@ static void win_init(void) **********************/ /** - * Initialize the alien theme - * @param hue [0..360] hue value from HSV color space to define the theme's base color - * @param font pointer to a font (NULL to use the default) + * Initialize the default + * @param color_primary the primary color of the theme + * @param color_secondary the secondary color for the theme + * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` + * @param font_small pointer to a small font + * @param font_normal pointer to a normal font + * @param font_subtitle pointer to a large font + * @param font_title pointer to a extra large font + * @return a pointer to reference this theme later */ -lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font) +lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, + lv_font_t * font_small, lv_font_t * font_normal, lv_font_t * font_subtitle, lv_font_t * font_title) { - lv_mem_monitor_t mon1; - lv_mem_monitor(&mon1); + _color_primary = color_primary; + _color_secondary = color_secondary; + _flags = flags; + _font_small = font_small; + _font_normal = font_normal; + _font_subtitle = font_subtitle; + _font_title = font_title; basic_init(); cont_init(); @@ -796,20 +812,20 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font) line_init(); led_init(); slider_init(); - sw_init(); - lmeter_init(); + switch_init(); + linemeter_init(); gauge_init(); arc_init(); - preload_init(); + spinner_init(); chart_init(); calendar_init(); cpicker_init(); - cb_init(); - btnm_init(); - kb_init(); - mbox_init(); + checkbox_init(); + btnmatrix_init(); + keyboard_init(); + msgbox_init(); page_init(); - ta_init(); + textarea_init(); spinbox_init(); list_init(); ddlist_init(); @@ -819,11 +835,8 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); - theme.apply_cb = lv_theme_alien_apply; + theme.apply_cb = lv_theme_material_apply; - lv_mem_monitor_t mon2; - lv_mem_monitor(&mon2); - printf("theme size: %d\n", mon1.free_size - mon2.free_size); return &theme; } @@ -837,7 +850,7 @@ lv_theme_t * lv_theme_alien_get(void) } -void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) +void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) { lv_style_list_t * list; @@ -891,7 +904,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); lv_style_list_reset(list); - lv_style_list_add_style(list, &btnm_btn); + lv_style_list_add_style(list, &kb_btn); break; #endif @@ -1049,7 +1062,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &sb); break; #endif -#if LV_USE_TEXTAREABVIEW +#if LV_USE_TABVIEW case LV_THEME_TABVIEW: list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); lv_style_list_reset(list); @@ -1176,7 +1189,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &chart_series); break; #endif -#if LV_USE_TEXTAREABLE +#if LV_USE_TABLE case LV_THEME_TABLE: list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); lv_style_list_reset(list); @@ -1262,6 +1275,23 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) break; #endif + +#if LV_USE_SPINBOX + case LV_THEME_SPINBOX: + list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); + lv_style_list_reset(list); + lv_style_list_add_style(list, &ta_oneline); + + list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); + lv_style_list_reset(list); + lv_style_list_add_style(list, &ta_cursor); + + list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_SCRLBAR); + lv_style_list_reset(list); + lv_style_list_add_style(list, &sb); + break; +#endif + #if LV_USE_CALENDAR case LV_THEME_CALENDAR: list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); diff --git a/src/lv_themes/lv_theme_material.h b/src/lv_themes/lv_theme_material.h new file mode 100644 index 000000000..cc9cb9727 --- /dev/null +++ b/src/lv_themes/lv_theme_material.h @@ -0,0 +1,57 @@ +/** + * @file lv_theme_material.h + * + */ + +#ifndef LV_THEME_MATERIAL_H +#define LV_THEME_MATERIAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_conf_internal.h" + +#if LV_USE_THEME_MATERIAL + +/********************* + * DEFINES + *********************/ +#define LV_THEME_MATERIAL_FLAG_NONE 0 + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + + +/** + * Initialize the default + * @param color_primary the primary color of the theme + * @param color_secondary the secondary color for the theme + * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` + * @param font_small pointer to a small font + * @param font_normal pointer to a normal font + * @param font_subtitle pointer to a large font + * @param font_title pointer to a extra large font + * @return a pointer to reference this theme later + */ +lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, + lv_font_t * font_small, lv_font_t * font_normal, lv_font_t * font_subtitle, lv_font_t * font_title); +/********************** + * MACROS + **********************/ + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*LV_THEME_ALIEN_H*/ diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index f16adbd4e..46a23f7c2 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -372,6 +372,17 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area draw_bg(bar, clip_area); draw_indic(bar, clip_area); + /*Get the value and draw it after the indicator*/ + lv_draw_rect_dsc_t draw_dsc; + lv_draw_rect_dsc_init(&draw_dsc); + draw_dsc.bg_opa = LV_OPA_TRANSP; + draw_dsc.border_opa = LV_OPA_TRANSP; + draw_dsc.shadow_opa = LV_OPA_TRANSP; + draw_dsc.pattern_opa = LV_OPA_TRANSP; + draw_dsc.outline_opa = LV_OPA_TRANSP; + lv_obj_init_draw_rect_dsc(bar, LV_BAR_PART_BG, &draw_dsc); + lv_draw_rect(&bar->coords, clip_area, &draw_dsc); + } else if(mode == LV_DESIGN_DRAW_POST) { } @@ -565,15 +576,20 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area) draw_indic_dsc.shadow_opa = shadow_opa; draw_indic_dsc.value_opa = value_opa; - /*Draw the border and the value*/ + /*Draw the border*/ draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.shadow_opa = LV_OPA_TRANSP; + draw_indic_dsc.value_opa = LV_OPA_TRANSP; draw_indic_dsc.pattern_image = NULL; lv_draw_rect(&ext->indic_area, clip_area, &draw_indic_dsc); lv_draw_mask_remove_id(mask_indic_id); lv_draw_mask_remove_id(mask_bg_id); + /*When not masks draw the value*/ + draw_indic_dsc.value_opa = value_opa; + lv_draw_rect(&ext->indic_area, clip_area, &draw_indic_dsc); + } /** diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 3d0cddeaa..51b4419cc 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -269,7 +269,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) * An element of the map should look like e.g.: * `ctrl_map[0] = width | LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_TGL_ENABLE` */ -void lv_btnmatrix_set_ctrl_map(const lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]) +void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]) { LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); @@ -285,7 +285,7 @@ void lv_btnmatrix_set_ctrl_map(const lv_obj_t * btnm, const lv_btnmatrix_ctrl_t * @param btnm pointer to button matrix object * @param id index of the currently pressed button (`LV_BTNMATRIX_BTN_NONE` to unpress) */ -void lv_btnmatrix_set_pressed(const lv_obj_t * btnm, uint16_t id) +void lv_btnmatrix_set_pressed(lv_obj_t * btnm, uint16_t id) { LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); diff --git a/src/lv_widgets/lv_btnmatrix.h b/src/lv_widgets/lv_btnmatrix.h index 9f2693b70..73b034a8b 100644 --- a/src/lv_widgets/lv_btnmatrix.h +++ b/src/lv_widgets/lv_btnmatrix.h @@ -106,7 +106,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]); * An element of the map should look like e.g.: * `ctrl_map[0] = width | LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_TGL_ENABLE` */ -void lv_btnmatrix_set_ctrl_map(const lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]); +void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]); /** * Set the pressed button i.e. visually highlight it. @@ -114,7 +114,7 @@ void lv_btnmatrix_set_ctrl_map(const lv_obj_t * btnm, const lv_btnmatrix_ctrl_t * @param btnm pointer to button matrix object * @param id index of the currently pressed button (`LV_BTNMATRIX_BTN_NONE` to unpress) */ -void lv_btnmatrix_set_pressed(const lv_obj_t * btnm, uint16_t id); +void lv_btnmatrix_set_pressed(lv_obj_t * btnm, uint16_t id); /** * Set a style of a button matrix diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index a047a931e..b6c749032 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -622,7 +622,7 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche */ static lv_coord_t get_header_height(lv_obj_t * calendar) { - const lv_font_t * font = lv_obj_get_style_font(calendar, LV_CALENDAR_PART_HEADER); + const lv_font_t * font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_HEADER); lv_style_int_t top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_HEADER); @@ -636,7 +636,7 @@ static lv_coord_t get_header_height(lv_obj_t * calendar) */ static lv_coord_t get_day_names_height(lv_obj_t * calendar) { - const lv_font_t * font = lv_obj_get_style_font(calendar, LV_CALENDAR_PART_DAY_NAMES); + const lv_font_t * font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_DAY_NAMES); lv_style_int_t top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_DAY_NAMES); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_DAY_NAMES); @@ -653,7 +653,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) lv_style_int_t header_top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER); lv_style_int_t header_left = lv_obj_get_style_pad_left(calendar, LV_CALENDAR_PART_HEADER); lv_style_int_t header_right = lv_obj_get_style_pad_right(calendar, LV_CALENDAR_PART_HEADER); - const lv_font_t * font = lv_obj_get_style_font(calendar, LV_CALENDAR_PART_HEADER); + const lv_font_t * font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_HEADER); lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); @@ -740,7 +740,7 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask) lv_style_int_t left = lv_obj_get_style_pad_left(calendar, LV_CALENDAR_PART_DAY_NAMES); lv_style_int_t right = lv_obj_get_style_pad_right(calendar, LV_CALENDAR_PART_DAY_NAMES); lv_style_int_t top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_DAY_NAMES); - const lv_font_t * font = lv_obj_get_style_font(calendar, LV_CALENDAR_PART_DAY_NAMES); + const lv_font_t * font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_DAY_NAMES); lv_coord_t w = lv_obj_get_width(calendar) - left - right; @@ -773,7 +773,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area) { lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); - const lv_font_t * nums_font = lv_obj_get_style_font(calendar, LV_CALENDAR_PART_DATE); + const lv_font_t * nums_font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_DATE); lv_style_int_t date_top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_DATE); lv_style_int_t date_bottom = lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_DATE); diff --git a/src/lv_widgets/lv_checkbox.c b/src/lv_widgets/lv_checkbox.c index 578f58899..f5be4477c 100644 --- a/src/lv_widgets/lv_checkbox.c +++ b/src/lv_widgets/lv_checkbox.c @@ -178,7 +178,7 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param lv_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb); if(sign == LV_SIGNAL_STYLE_CHG) { - const lv_font_t * font = lv_obj_get_style_font(ext->label, LV_LABEL_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(ext->label, LV_LABEL_PART_MAIN); lv_coord_t line_height = lv_font_get_line_height(font); lv_obj_set_size(ext->bullet, line_height, line_height); lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index c2873638e..ffe4ad06f 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -776,7 +776,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p else if(sign == LV_SIGNAL_STYLE_CHG) { lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DROPDOWN_PART_BTN); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DROPDOWN_PART_BTN); - const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DROPDOWN_PART_BTN); + const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_BTN); lv_obj_set_height(ddlist, top + bottom + lv_font_get_line_height(font)); if(ext->page) lv_obj_refresh_style(ext->page); @@ -940,7 +940,7 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id page->state_dsc.prev = page->state_dsc.act; /*Draw a rectangle under the selected item*/ - const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DROPDOWN_PART_LIST); + const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t line_space = lv_obj_get_style_text_line_space(ddlist, LV_DROPDOWN_PART_LIST); lv_coord_t font_h = lv_font_get_line_height(font); @@ -1095,7 +1095,7 @@ static void pos_selected(lv_obj_t * ddlist) { lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); - const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DROPDOWN_PART_LIST); + const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_LIST); lv_coord_t font_h = lv_font_get_line_height(font); lv_obj_t * scrl = lv_page_get_scrl(ext->page); lv_obj_t * label = get_label(ddlist); diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 813a5aa2e..9bb150fff 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -192,7 +192,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img) if(src_type == LV_IMG_SRC_SYMBOL) { /*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/ - const lv_font_t * font = lv_obj_get_style_font(img, LV_IMG_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(img, LV_IMG_PART_MAIN); lv_style_int_t letter_space = lv_obj_get_style_text_letter_space(img, LV_IMG_PART_MAIN); lv_style_int_t line_space = lv_obj_get_style_text_line_space(img, LV_IMG_PART_MAIN); lv_point_t size; diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index e5bd2fb9b..6dc33a8a3 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -402,7 +402,7 @@ static void refr_img(lv_obj_t * imgbtn) lv_res_t info_res = LV_RES_OK; if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { - const lv_font_t * font = lv_obj_get_style_font(imgbtn, LV_IMGBTN_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(imgbtn, LV_IMGBTN_PART_MAIN); header.h = lv_font_get_line_height(font); header.w = lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TXT_FLAG_NONE); header.always_zero = 0; diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index e3c45150f..ef91ff7de 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -565,7 +565,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_ uint32_t line_start = 0; uint32_t new_line_start = 0; lv_coord_t max_w = lv_area_get_width(&txt_coords); - const lv_font_t * font = lv_obj_get_style_font(label, LV_LABEL_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(label, LV_LABEL_PART_MAIN); lv_style_int_t line_space = lv_obj_get_style_text_line_space(label, LV_LABEL_PART_MAIN); lv_style_int_t letter_space = lv_obj_get_style_text_letter_space(label, LV_LABEL_PART_MAIN); lv_coord_t letter_height = lv_font_get_line_height(font); @@ -671,7 +671,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) uint32_t line_start = 0; uint32_t new_line_start = 0; lv_coord_t max_w = lv_area_get_width(&txt_coords); - const lv_font_t * font = lv_obj_get_style_font(label, LV_LABEL_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(label, LV_LABEL_PART_MAIN); lv_style_int_t line_space = lv_obj_get_style_text_line_space(label, LV_LABEL_PART_MAIN); lv_style_int_t letter_space = lv_obj_get_style_text_letter_space(label, LV_LABEL_PART_MAIN); lv_coord_t letter_height = lv_font_get_line_height(font); @@ -834,7 +834,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) uint32_t line_start = 0; uint32_t new_line_start = 0; lv_coord_t max_w = lv_area_get_width(&txt_coords); - const lv_font_t * font = lv_obj_get_style_font(label, LV_LABEL_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(label, LV_LABEL_PART_MAIN); lv_style_int_t line_space = lv_obj_get_style_text_line_space(label, LV_LABEL_PART_MAIN); lv_style_int_t letter_space = lv_obj_get_style_text_letter_space(label, LV_LABEL_PART_MAIN); lv_coord_t letter_height = lv_font_get_line_height(font); @@ -1179,7 +1179,7 @@ static void lv_label_refr_text(lv_obj_t * label) lv_area_t txt_coords; get_txt_coords(label, &txt_coords); lv_coord_t max_w = lv_area_get_width(&txt_coords); - const lv_font_t * font = lv_obj_get_style_font(label, LV_LABEL_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(label, LV_LABEL_PART_MAIN); lv_style_int_t line_space = lv_obj_get_style_text_line_space(label, LV_LABEL_PART_MAIN); lv_style_int_t letter_space = lv_obj_get_style_text_letter_space(label, LV_LABEL_PART_MAIN); diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index 3eec32557..b4adb9159 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -778,7 +778,7 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para sign == LV_SIGNAL_STYLE_CHG) { lv_obj_t * label = lv_list_get_btn_label(btn); if(label) { - const lv_font_t * font = lv_obj_get_style_font(label, LV_LABEL_PART_MAIN); + const lv_font_t * font = lv_obj_get_style_text_font(label, LV_LABEL_PART_MAIN); lv_coord_t font_h = lv_font_get_line_height(font); if(lv_obj_get_base_dir(btn) == LV_BIDI_DIR_RTL) { lv_coord_t pad = lv_obj_get_style_pad_left(btn, LV_BTN_PART_MAIN); diff --git a/src/lv_widgets/lv_msgbox.c b/src/lv_widgets/lv_msgbox.c index 488b0fe9e..32aa0903b 100644 --- a/src/lv_widgets/lv_msgbox.c +++ b/src/lv_widgets/lv_msgbox.c @@ -515,7 +515,7 @@ static void mbox_realign(lv_obj_t * mbox) lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(mbox, LV_MSGBOX_PART_BTN_BG); lv_style_int_t btn_top = lv_obj_get_style_pad_top(mbox, LV_MSGBOX_PART_BTN); lv_style_int_t btn_bottom = lv_obj_get_style_pad_bottom(mbox, LV_MSGBOX_PART_BTN); - const lv_font_t * font = lv_obj_get_style_font(mbox, LV_MSGBOX_PART_BTN); + const lv_font_t * font = lv_obj_get_style_text_font(mbox, LV_MSGBOX_PART_BTN); lv_coord_t font_h = lv_font_get_line_height(font); lv_obj_set_size(ext->btnm, w, font_h + btn_top + btn_bottom + bg_top + bg_bottom); diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 683c2adf6..c7da24e37 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -241,7 +241,7 @@ void lv_roller_set_visible_row_count(lv_obj_t * roller, uint8_t row_cnt) LV_ASSERT_OBJ(roller, LV_OBJX_NAME); uint8_t n_line_space = (row_cnt > 1) ? row_cnt - 1 : 1; - const lv_font_t * font = lv_obj_get_style_font(roller, LV_ROLLER_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); lv_obj_set_height(roller, lv_font_get_line_height(font) * row_cnt + line_space * n_line_space); @@ -371,7 +371,7 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli else if(mode == LV_DESIGN_DRAW_MAIN) { draw_bg(roller, clip_area); - const lv_font_t * font = lv_obj_get_style_font(roller, LV_ROLLER_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); lv_area_t rect_area; @@ -572,7 +572,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, int32_t id = -1; lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); - const lv_font_t * font = lv_obj_get_style_font(roller, LV_ROLLER_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); @@ -677,7 +677,7 @@ static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim_en) lv_obj_t * roller_scrl = lv_page_get_scrl(roller); lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); - const lv_font_t * font = lv_obj_get_style_font(roller, LV_ROLLER_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); lv_coord_t h = lv_obj_get_height(roller); @@ -821,7 +821,7 @@ static void inf_normalize(void * scrl) ext->sel_opt_id += (LV_ROLLER_INF_PAGES / 2) * real_id_cnt; /*Select the middle page*/ /*Move to the new id*/ - const lv_font_t * font = lv_obj_get_style_font(roller, LV_ROLLER_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); lv_coord_t h = lv_obj_get_height(roller); diff --git a/src/lv_widgets/lv_spinbox.h b/src/lv_widgets/lv_spinbox.h index 6f0b748fe..5edfa64c4 100644 --- a/src/lv_widgets/lv_spinbox.h +++ b/src/lv_widgets/lv_spinbox.h @@ -23,7 +23,7 @@ extern "C" { #endif #include "../lv_core/lv_obj.h" -#include "../lv_widgets/lv_ta.h" +#include "../lv_widgets/lv_textarea.h" /********************* * DEFINES diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index c647b7b7e..21642d13d 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -7,7 +7,7 @@ * INCLUDES *********************/ #include "lv_table.h" -#if LV_USE_TEXTAREABLE != 0 +#if LV_USE_TABLE != 0 #include "../lv_core/lv_debug.h" #include "../lv_misc/lv_txt.h" @@ -863,7 +863,7 @@ static void refr_size(lv_obj_t * table) cell_bottom[i] = lv_obj_get_style_pad_bottom(table, LV_TABLE_PART_CELL1 + i); letter_space[i] = lv_obj_get_style_text_letter_space(table, LV_TABLE_PART_CELL1 + i); line_space[i] = lv_obj_get_style_text_line_space(table, LV_TABLE_PART_CELL1 + i); - font[i] = lv_obj_get_style_font(table, LV_TABLE_PART_CELL1 + i); + font[i] = lv_obj_get_style_text_font(table, LV_TABLE_PART_CELL1 + i); } diff --git a/src/lv_widgets/lv_table.h b/src/lv_widgets/lv_table.h index 0cbb1b212..eac35556c 100644 --- a/src/lv_widgets/lv_table.h +++ b/src/lv_widgets/lv_table.h @@ -15,7 +15,7 @@ extern "C" { *********************/ #include "../lv_conf_internal.h" -#if LV_USE_TEXTAREABLE != 0 +#if LV_USE_TABLE != 0 /*Testing of dependencies*/ #if LV_USE_LABEL == 0 @@ -238,7 +238,7 @@ bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col) * MACROS **********************/ -#endif /*LV_USE_TEXTAREABLE*/ +#endif /*LV_USE_TABLE*/ #ifdef __cplusplus } /* extern "C" */ diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 4d7a26f59..edb3c8127 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -7,7 +7,7 @@ * INCLUDES *********************/ #include "lv_tabview.h" -#if LV_USE_TEXTAREABVIEW != 0 +#if LV_USE_TABVIEW != 0 #include "lv_btnmatrix.h" #include "../lv_core/lv_debug.h" @@ -864,7 +864,7 @@ static void refr_btns_size(lv_obj_t * tabview) lv_style_int_t tab_top = lv_obj_get_style_pad_top(tabview, LV_TABVIEW_PART_TAB); lv_style_int_t tab_bottom = lv_obj_get_style_pad_bottom(tabview, LV_TABVIEW_PART_TAB); - const lv_font_t * font = lv_obj_get_style_font(tabview, LV_TABVIEW_PART_TAB); + const lv_font_t * font = lv_obj_get_style_text_font(tabview, LV_TABVIEW_PART_TAB); /*Set the tabs height/width*/ lv_coord_t btns_w; diff --git a/src/lv_widgets/lv_tabview.h b/src/lv_widgets/lv_tabview.h index e116921d6..54649c26a 100644 --- a/src/lv_widgets/lv_tabview.h +++ b/src/lv_widgets/lv_tabview.h @@ -15,7 +15,7 @@ extern "C" { *********************/ #include "../lv_conf_internal.h" -#if LV_USE_TEXTAREABVIEW != 0 +#if LV_USE_TABVIEW != 0 /*Testing of dependencies*/ #if LV_USE_BTNMATRIX == 0 @@ -176,7 +176,7 @@ lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview); * MACROS **********************/ -#endif /*LV_USE_TEXTAREABVIEW*/ +#endif /*LV_USE_TABVIEW*/ #ifdef __cplusplus } /* extern "C" */ diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 995d51f58..c84bfb1e5 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -160,6 +160,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) ext->max_length = copy_ext->max_length; ext->cursor.pos = copy_ext->cursor.pos; ext->cursor.valid_x = copy_ext->cursor.valid_x; + ext->cursor.hidden = copy_ext->cursor.hidden; lv_style_list_copy(&ext->cursor.style, ©_ext->cursor.style); @@ -591,7 +592,7 @@ void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos) /*Position the label to make the cursor visible*/ lv_obj_t * label_par = lv_obj_get_parent(ext->label); lv_point_t cur_pos; - const lv_font_t * font = lv_obj_get_style_font(ta, LV_TEXTAREA_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG); lv_style_int_t top = lv_obj_get_style_pad_top(ta, LV_TEXTAREA_PART_BG); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ta, LV_TEXTAREA_PART_BG); lv_area_t label_cords; @@ -739,7 +740,7 @@ void lv_textarea_set_one_line(lv_obj_t * ta, bool en) lv_style_int_t top = lv_obj_get_style_pad_top(ta, LV_TEXTAREA_PART_BG); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ta, LV_TEXTAREA_PART_BG); lv_style_int_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_BG); - const lv_font_t * font = lv_obj_get_style_font(ta, LV_TEXTAREA_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); ext->one_line = 1; @@ -1215,7 +1216,7 @@ void lv_textarea_cursor_down(lv_obj_t * ta) /*Increment the y with one line and keep the valid x*/ lv_style_int_t line_space = lv_obj_get_style_text_line_space(ta, LV_TEXTAREA_PART_BG); - const lv_font_t * font = lv_obj_get_style_font(ta, LV_TEXTAREA_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); pos.y += font_h + line_space + 1; pos.x = ext->cursor.valid_x; @@ -1247,7 +1248,7 @@ void lv_textarea_cursor_up(lv_obj_t * ta) /*Decrement the y with one line and keep the valid x*/ lv_style_int_t line_space = lv_obj_get_style_text_line_space(ta, LV_TEXTAREA_PART_BG); - const lv_font_t * font = lv_obj_get_style_font(ta, LV_TEXTAREA_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); pos.y -= font_h + line_space - 1; pos.x = ext->cursor.valid_x; @@ -1397,7 +1398,7 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param if(ext->one_line) { lv_style_int_t top = lv_obj_get_style_pad_top(ta, LV_TEXTAREA_PART_BG); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ta, LV_TEXTAREA_PART_BG); - const lv_font_t * font = lv_obj_get_style_font(ta, LV_TEXTAREA_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG); /*In one line mode refresh the Text Area height because 'vpad' can modify it*/ lv_coord_t font_h = lv_font_get_line_height(font); @@ -1511,7 +1512,7 @@ static lv_res_t lv_textarea_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { /*Set ext. size because the cursor might be out of this object*/ lv_style_int_t line_space = lv_obj_get_style_text_line_space(ta, LV_TEXTAREA_PART_BG); - const lv_font_t * font = lv_obj_get_style_font(ta, LV_TEXTAREA_PART_BG); + const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG); lv_coord_t font_h = lv_font_get_line_height(font); scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, line_space + font_h); } else if(sign == LV_SIGNAL_COORD_CHG) {