diff --git a/examples/widgets/label/lv_example_label_1.c b/examples/widgets/label/lv_example_label_1.c index 821abdbf0..1e06f35a5 100644 --- a/examples/widgets/label/lv_example_label_1.c +++ b/examples/widgets/label/lv_example_label_1.c @@ -8,9 +8,7 @@ void lv_example_label_1(void) { lv_obj_t * label1 = lv_label_create(lv_screen_active()); lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/ - lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/ - lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center " - "and wrap long text automatically."); + lv_label_set_text(label1, "Recolor is not supported for v9 now."); lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/ lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0); lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40); diff --git a/examples/widgets/label/lv_example_label_1.py b/examples/widgets/label/lv_example_label_1.py index 254f48bc1..f4352e0f0 100755 --- a/examples/widgets/label/lv_example_label_1.py +++ b/examples/widgets/label/lv_example_label_1.py @@ -8,9 +8,7 @@ import display_driver # label1 = lv.label(lv.screen_active()) label1.set_long_mode(lv.label.LONG.WRAP) # Break the long lines*/ -label1.set_recolor(True) # Enable re-coloring by commands in the text -label1.set_text("#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center " - "and wrap long text automatically.") +label1.set_text("Recolor is not supported for v9 now.") label1.set_width(150) # Set smaller width to make the lines wrap label1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) label1.align(lv.ALIGN.CENTER, 0, -40) diff --git a/src/misc/lv_text.h b/src/misc/lv_text.h index 65d83cd5e..cf9ea140f 100644 --- a/src/misc/lv_text.h +++ b/src/misc/lv_text.h @@ -39,9 +39,8 @@ extern "C" { enum _lv_text_flag_t { LV_TEXT_FLAG_NONE = 0x00, - LV_TEXT_FLAG_RECOLOR = 0x01, /**< Enable parsing of recolor command*/ - LV_TEXT_FLAG_EXPAND = 0x02, /**< Ignore max-width to avoid automatic word wrapping*/ - LV_TEXT_FLAG_FIT = 0x04, /**< Max-width is already equal to the longest line. (Used to skip some calculation)*/ + LV_TEXT_FLAG_EXPAND = 0x01, /**< Ignore max-width to avoid automatic word wrapping*/ + LV_TEXT_FLAG_FIT = 0x02, /**< Max-width is already equal to the longest line. (Used to skip some calculation)*/ }; #ifdef DOXYGEN diff --git a/src/widgets/buttonmatrix/lv_buttonmatrix.c b/src/widgets/buttonmatrix/lv_buttonmatrix.c index 0f6cdca59..5c2b2e989 100644 --- a/src/widgets/buttonmatrix/lv_buttonmatrix.c +++ b/src/widgets/buttonmatrix/lv_buttonmatrix.c @@ -46,7 +46,6 @@ static bool button_is_inactive(lv_buttonmatrix_ctrl_t ctrl_bits); static bool button_is_click_trig(lv_buttonmatrix_ctrl_t ctrl_bits); static bool button_is_popover(lv_buttonmatrix_ctrl_t ctrl_bits); static bool button_is_checkable(lv_buttonmatrix_ctrl_t ctrl_bits); -static bool button_is_recolor(lv_buttonmatrix_ctrl_t ctrl_bits); static bool button_get_checked(lv_buttonmatrix_ctrl_t ctrl_bits); static uint32_t get_button_from_point(lv_obj_t * obj, lv_point_t * p); static void allocate_button_areas_and_controls(const lv_obj_t * obj, const char ** map); @@ -750,10 +749,6 @@ static void draw_main(lv_event_t * e) draw_rect_dsc_act.base.id1 = btn_i; - bool recolor = button_is_recolor(btnm->ctrl_bits[btn_i]); - if(recolor) draw_label_dsc_act.flag |= LV_TEXT_FLAG_RECOLOR; - else draw_label_dsc_act.flag &= ~LV_TEXT_FLAG_RECOLOR; - /*Remove borders on the edges if `LV_BORDER_SIDE_INTERNAL`*/ if(draw_rect_dsc_act.border_side & LV_BORDER_SIDE_INTERNAL) { draw_rect_dsc_act.border_side = LV_BORDER_SIDE_FULL; @@ -907,10 +902,6 @@ static bool button_get_checked(lv_buttonmatrix_ctrl_t ctrl_bits) return ctrl_bits & LV_BUTTONMATRIX_CTRL_CHECKED; } -static bool button_is_recolor(lv_buttonmatrix_ctrl_t ctrl_bits) -{ - return ctrl_bits & LV_BUTTONMATRIX_CTRL_RECOLOR; -} /** * Gives the button id of a button under a given point * @param obj pointer to a button matrix object diff --git a/src/widgets/buttonmatrix/lv_buttonmatrix.h b/src/widgets/buttonmatrix/lv_buttonmatrix.h index d168fbc2b..b12d28285 100644 --- a/src/widgets/buttonmatrix/lv_buttonmatrix.h +++ b/src/widgets/buttonmatrix/lv_buttonmatrix.h @@ -40,9 +40,9 @@ enum _lv_buttonmatrix_ctrl_t { LV_BUTTONMATRIX_CTRL_CHECKED = 0x0100, /**< Button is currently toggled (e.g. checked).*/ LV_BUTTONMATRIX_CTRL_CLICK_TRIG = 0x0200, /**< 1: Send LV_EVENT_VALUE_CHANGE on CLICK, 0: Send LV_EVENT_VALUE_CHANGE on PRESS*/ LV_BUTTONMATRIX_CTRL_POPOVER = 0x0400, /**< Show a popover when pressing this key*/ - LV_BUTTONMATRIX_CTRL_RECOLOR = 0x0800, /**< Enable text recoloring with `#color`*/ - _LV_BUTTONMATRIX_CTRL_RESERVED_1 = 0x1000, /**< Reserved for later use*/ - _LV_BUTTONMATRIX_CTRL_RESERVED_2 = 0x2000, /**< Reserved for later use*/ + _LV_BUTTONMATRIX_CTRL_RESERVED_1 = 0x0800, /**< Reserved for later use*/ + _LV_BUTTONMATRIX_CTRL_RESERVED_2 = 0x1000, /**< Reserved for later use*/ + _LV_BUTTONMATRIX_CTRL_RESERVED_3 = 0x2000, /**< Reserved for later use*/ LV_BUTTONMATRIX_CTRL_CUSTOM_1 = 0x4000, /**< Custom free to use flag*/ LV_BUTTONMATRIX_CTRL_CUSTOM_2 = 0x8000, /**< Custom free to use flag*/ }; diff --git a/src/widgets/label/lv_label.c b/src/widgets/label/lv_label.c index 77c75739f..36ccc011c 100644 --- a/src/widgets/label/lv_label.c +++ b/src/widgets/label/lv_label.c @@ -205,19 +205,6 @@ void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode) lv_label_refr_text(obj); } -void lv_label_set_recolor(lv_obj_t * obj, bool en) -{ - LV_ASSERT_OBJ(obj, MY_CLASS); - - lv_label_t * label = (lv_label_t *)obj; - if(label->recolor == en) return; - - label->recolor = en ? 1 : 0; - - /*Refresh the text because the potential color codes in text needs to be hidden or revealed*/ - lv_label_refr_text(obj); -} - void lv_label_set_text_selection_start(lv_obj_t * obj, uint32_t index) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -264,14 +251,6 @@ lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * obj) return label->long_mode; } -bool lv_label_get_recolor(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, MY_CLASS); - - lv_label_t * label = (lv_label_t *)obj; - return label->recolor; -} - void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t * pos) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -641,7 +620,6 @@ static void lv_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) label->text = NULL; label->static_txt = 0; - label->recolor = 0; label->dot_end = LV_LABEL_DOT_END_INV; label->long_mode = LV_LABEL_LONG_WRAP; label->offset.x = 0; @@ -709,7 +687,6 @@ static void lv_label_event(const lv_obj_class_t * class_p, lv_event_t * e) int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); lv_text_flag_t flag = LV_TEXT_FLAG_NONE; - if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR; if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND; int32_t w = lv_obj_get_content_width(obj); @@ -740,7 +717,6 @@ static void draw_main(lv_event_t * e) lv_obj_get_content_coords(obj, &txt_coords); lv_text_flag_t flag = LV_TEXT_FLAG_NONE; - if(label->recolor) flag |= LV_TEXT_FLAG_RECOLOR; if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND; if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT && !obj->w_layout) flag |= LV_TEXT_FLAG_FIT; @@ -876,7 +852,6 @@ static void lv_label_refr_text(lv_obj_t * obj) /*Calc. the height and longest line*/ lv_point_t size; lv_text_flag_t flag = LV_TEXT_FLAG_NONE; - if(label->recolor) flag |= LV_TEXT_FLAG_RECOLOR; if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND; if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT && !obj->w_layout) flag |= LV_TEXT_FLAG_FIT; @@ -1270,7 +1245,6 @@ static lv_text_flag_t get_label_flags(lv_label_t * label) { lv_text_flag_t flag = LV_TEXT_FLAG_NONE; - if(label->recolor) flag |= LV_TEXT_FLAG_RECOLOR; if(label->expand) flag |= LV_TEXT_FLAG_EXPAND; return flag; diff --git a/src/widgets/label/lv_label.h b/src/widgets/label/lv_label.h index b8d140322..b95f6a5ba 100644 --- a/src/widgets/label/lv_label.h +++ b/src/widgets/label/lv_label.h @@ -83,7 +83,6 @@ typedef struct { lv_point_t offset; /*Text draw position offset*/ lv_label_long_mode_t long_mode : 3; /*Determine what to do with the long texts*/ uint8_t static_txt : 1; /*Flag to indicate the text is static*/ - uint8_t recolor : 1; /*Enable in-line letter re-coloring*/ uint8_t expand : 1; /*Ignore real width (used by the library with LV_LABEL_LONG_SCROLL)*/ uint8_t dot_tmp_alloc : 1; /*1: dot is allocated, 0: dot directly holds up to 4 chars*/ uint8_t invalid_size_cache : 1; /*1: Recalculate size and update cache*/ @@ -137,14 +136,6 @@ void lv_label_set_text_static(lv_obj_t * obj, const char * text); */ void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode); -/** - * Enable the recoloring by in-line commands - * @param obj pointer to a label object - * @param en true: enable recoloring, false: disable - * @example "This is a #ff0000 red# word" - */ -void lv_label_set_recolor(lv_obj_t * obj, bool en); - /** * Set where text selection should start * @param obj pointer to a label object @@ -177,13 +168,6 @@ char * lv_label_get_text(const lv_obj_t * obj); */ lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * obj); -/** - * Get the recoloring attribute - * @param obj pointer to a label object - * @return true: recoloring is enabled, false: disable - */ -bool lv_label_get_recolor(const lv_obj_t * obj); - /** * Get the relative x and y coordinates of a letter * @param obj pointer to a label object diff --git a/src/widgets/roller/lv_roller.c b/src/widgets/roller/lv_roller.c index a6bf1b3ce..c5f7f32da 100644 --- a/src/widgets/roller/lv_roller.c +++ b/src/widgets/roller/lv_roller.c @@ -492,7 +492,6 @@ static void draw_main(lv_event_t * e) area_ok = _lv_area_intersect(&mask_sel, &layer->clip_area, &sel_area); if(area_ok) { lv_obj_t * label = get_label(obj); - if(lv_label_get_recolor(label)) label_dsc.flag |= LV_TEXT_FLAG_RECOLOR; /*Get the size of the "selected text"*/ lv_point_t res_p; @@ -546,7 +545,6 @@ static void draw_label(lv_event_t * e) lv_draw_label_dsc_t label_draw_dsc; lv_draw_label_dsc_init(&label_draw_dsc); lv_obj_init_draw_label_dsc(roller, LV_PART_MAIN, &label_draw_dsc); - if(lv_label_get_recolor(label_obj)) label_draw_dsc.flag |= LV_TEXT_FLAG_RECOLOR; lv_layer_t * layer = lv_event_get_layer(e); diff --git a/tests/src/test_cases/widgets/test_label.c b/tests/src/test_cases/widgets/test_label.c index 7be427c20..f76141421 100644 --- a/tests/src/test_cases/widgets/test_label.c +++ b/tests/src/test_cases/widgets/test_label.c @@ -42,15 +42,6 @@ void test_label_creation(void) TEST_ASSERT_EQUAL(lv_label_get_long_mode(label), LV_LABEL_LONG_WRAP); } -void test_label_recolor(void) -{ - lv_label_set_recolor(label, true); - TEST_ASSERT(lv_label_get_recolor(label)); - - lv_label_set_recolor(label, false); - TEST_ASSERT_FALSE(lv_label_get_recolor(label)); -} - void test_label_set_text(void) { const char * new_text = "Hello world";