Skip to content

Commit

Permalink
feat(label) Add and handle recolor flag
Browse files Browse the repository at this point in the history
  • Loading branch information
C47D committed Sep 30, 2024
1 parent 690ac91 commit 5cc39b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/widgets/label/lv_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ static void lv_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
lv_label_t * label = (lv_label_t *)obj;

label->text = NULL;
label->recolor = 0;
label->static_txt = 0;
label->dot_end = LV_LABEL_DOT_END_INV;
label->long_mode = LV_LABEL_LONG_WRAP;
Expand Down Expand Up @@ -764,6 +765,7 @@ 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);
Expand Down Expand Up @@ -1317,6 +1319,7 @@ 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;

lv_obj_t * obj = (lv_obj_t *) label;
Expand Down
1 change: 1 addition & 0 deletions src/widgets/label/lv_label_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct _lv_label_t {
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 */
Expand Down

0 comments on commit 5cc39b4

Please sign in to comment.