mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix(label): use LV_LABEL_LONG_MODE_* instead of LV_LABEL_LONG_*
This commit is contained in:
parent
f23b42be7f
commit
db11e7bae5
@ -262,7 +262,7 @@ static void profile_create(lv_obj_t * parent)
|
|||||||
lv_obj_t * dsc = lv_label_create(panel1);
|
lv_obj_t * dsc = lv_label_create(panel1);
|
||||||
lv_obj_add_style(dsc, &style_text_muted, 0);
|
lv_obj_add_style(dsc, &style_text_muted, 0);
|
||||||
lv_label_set_text_static(dsc, "This is a short description of me. Take a look at my profile!");
|
lv_label_set_text_static(dsc, "This is a short description of me. Take a look at my profile!");
|
||||||
lv_label_set_long_mode(dsc, LV_LABEL_LONG_WRAP);
|
lv_label_set_long_mode(dsc, LV_LABEL_LONG_MODE_WRAP);
|
||||||
|
|
||||||
lv_obj_t * email_icn = lv_label_create(panel1);
|
lv_obj_t * email_icn = lv_label_create(panel1);
|
||||||
lv_obj_add_style(email_icn, &style_icon, 0);
|
lv_obj_add_style(email_icn, &style_icon, 0);
|
||||||
|
@ -75,7 +75,7 @@ void lv_example_style_16(void)
|
|||||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||||
lv_obj_set_width(label, LV_PCT(80));
|
lv_obj_set_width(label, LV_PCT(80));
|
||||||
lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
|
lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void lv_example_style_17(void)
|
|||||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||||
lv_obj_set_width(label, LV_PCT(80));
|
lv_obj_set_width(label, LV_PCT(80));
|
||||||
lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
|
lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void lv_example_style_18(void)
|
|||||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||||
lv_obj_set_width(label, LV_PCT(80));
|
lv_obj_set_width(label, LV_PCT(80));
|
||||||
lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
|
lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
void lv_example_label_1(void)
|
void lv_example_label_1(void)
|
||||||
{
|
{
|
||||||
lv_obj_t * label1 = lv_label_create(lv_screen_active());
|
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_long_mode(label1, LV_LABEL_LONG_MODE_WRAP); /*Break the long lines*/
|
||||||
lv_label_set_text(label1, "Recolor is not supported for v9 now.");
|
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_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_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
|
||||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);
|
lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);
|
||||||
|
|
||||||
lv_obj_t * label2 = lv_label_create(lv_screen_active());
|
lv_obj_t * label2 = lv_label_create(lv_screen_active());
|
||||||
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
lv_label_set_long_mode(label2, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||||
lv_obj_set_width(label2, 150);
|
lv_obj_set_width(label2, 150);
|
||||||
lv_label_set_text(label2, "It is a circularly scrolling text. ");
|
lv_label_set_text(label2, "It is a circularly scrolling text. ");
|
||||||
lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40);
|
lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#if LV_USE_LABEL && LV_BUILD_EXAMPLES
|
#if LV_USE_LABEL && LV_BUILD_EXAMPLES
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show customizing the circular scrolling animation of a label with `LV_LABEL_LONG_SCROLL_CIRCULAR`
|
* Show customizing the circular scrolling animation of a label with `LV_LABEL_LONG_MODE_SCROLL_CIRCULAR`
|
||||||
* long mode.
|
* long mode.
|
||||||
*/
|
*/
|
||||||
void lv_example_label_5(void)
|
void lv_example_label_5(void)
|
||||||
@ -20,7 +20,7 @@ void lv_example_label_5(void)
|
|||||||
lv_style_set_anim(&label_style, &animation_template);
|
lv_style_set_anim(&label_style, &animation_template);
|
||||||
|
|
||||||
lv_obj_t * label1 = lv_label_create(lv_screen_active());
|
lv_obj_t * label1 = lv_label_create(lv_screen_active());
|
||||||
lv_label_set_long_mode(label1, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
lv_label_set_long_mode(label1, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||||
lv_obj_set_width(label1, 150);
|
lv_obj_set_width(label1, 150);
|
||||||
lv_label_set_text(label1, "It is a circularly scrolling text. ");
|
lv_label_set_text(label1, "It is a circularly scrolling text. ");
|
||||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, 40);
|
lv_obj_align(label1, LV_ALIGN_CENTER, 0, 40);
|
||||||
|
@ -159,7 +159,7 @@ static lv_obj_t * create_text(lv_obj_t * parent, const char * icon, const char *
|
|||||||
if(txt) {
|
if(txt) {
|
||||||
label = lv_label_create(obj);
|
label = lv_label_create(obj);
|
||||||
lv_label_set_text(label, txt);
|
lv_label_set_text(label, txt);
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
|
||||||
lv_obj_set_flex_grow(label, 1);
|
lv_obj_set_flex_grow(label, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,12 @@ extern "C" {
|
|||||||
#define lv_chart_set_all_value lv_chart_set_all_values
|
#define lv_chart_set_all_value lv_chart_set_all_values
|
||||||
#define lv_calendar_set_showed_date lv_calendar_set_month_shown
|
#define lv_calendar_set_showed_date lv_calendar_set_month_shown
|
||||||
|
|
||||||
|
#define LV_LABEL_LONG_WRAP LV_LABEL_LONG_MODE_WRAP
|
||||||
|
#define LV_LABEL_LONG_DOT LV_LABEL_LONG_MODE_DOTS
|
||||||
|
#define LV_LABEL_LONG_SCROLL LV_LABEL_LONG_MODE_SCROLL
|
||||||
|
#define LV_LABEL_LONG_SCROLL_CIRCULAR LV_LABEL_LONG_MODE_SCROLL_CIRCULAR
|
||||||
|
#define LV_LABEL_LONG_CLIP LV_LABEL_LONG_MODE_CLIP
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* DEPRECATED FUNCTIONS
|
* DEPRECATED FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
@ -86,7 +86,7 @@ static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||||||
lv_obj_remove_flag(mo_prev, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
lv_obj_remove_flag(mo_prev, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||||
|
|
||||||
lv_obj_t * label = lv_label_create(obj);
|
lv_obj_t * label = lv_label_create(obj);
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
|
||||||
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
|
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
|
||||||
lv_obj_set_flex_grow(label, 1);
|
lv_obj_set_flex_grow(label, 1);
|
||||||
|
|
||||||
|
@ -229,7 +229,8 @@ void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode)
|
|||||||
lv_anim_delete(obj, set_ofs_y_anim);
|
lv_anim_delete(obj, set_ofs_y_anim);
|
||||||
lv_point_set(&label->offset, 0, 0);
|
lv_point_set(&label->offset, 0, 0);
|
||||||
|
|
||||||
if(long_mode == LV_LABEL_LONG_SCROLL || long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR || long_mode == LV_LABEL_LONG_CLIP)
|
if(long_mode == LV_LABEL_LONG_MODE_SCROLL || long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR ||
|
||||||
|
long_mode == LV_LABEL_LONG_MODE_CLIP)
|
||||||
label->expand = 1;
|
label->expand = 1;
|
||||||
else
|
else
|
||||||
label->expand = 0;
|
label->expand = 0;
|
||||||
@ -344,7 +345,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t
|
|||||||
uint32_t new_line_start = 0;
|
uint32_t new_line_start = 0;
|
||||||
while(txt[new_line_start] != '\0') {
|
while(txt[new_line_start] != '\0') {
|
||||||
bool last_line = y + letter_height + line_space + letter_height > max_h;
|
bool last_line = y + letter_height + line_space + letter_height > max_h;
|
||||||
if(last_line && label->long_mode == LV_LABEL_LONG_DOT) flag |= LV_TEXT_FLAG_BREAK_ALL;
|
if(last_line && label->long_mode == LV_LABEL_LONG_MODE_DOTS) flag |= LV_TEXT_FLAG_BREAK_ALL;
|
||||||
|
|
||||||
new_line_start += lv_text_get_next_line(&txt[line_start], LV_TEXT_LEN_MAX, font, letter_space, max_w, NULL, flag);
|
new_line_start += lv_text_get_next_line(&txt[line_start], LV_TEXT_LEN_MAX, font, letter_space, max_w, NULL, flag);
|
||||||
if(byte_id < new_line_start || txt[new_line_start] == '\0')
|
if(byte_id < new_line_start || txt[new_line_start] == '\0')
|
||||||
@ -435,7 +436,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in, bool
|
|||||||
/*If dots will be shown, break the last visible line anywhere,
|
/*If dots will be shown, break the last visible line anywhere,
|
||||||
*not only at word boundaries.*/
|
*not only at word boundaries.*/
|
||||||
bool last_line = y + letter_height + line_space + letter_height > max_h;
|
bool last_line = y + letter_height + line_space + letter_height > max_h;
|
||||||
if(last_line && label->long_mode == LV_LABEL_LONG_DOT) flag |= LV_TEXT_FLAG_BREAK_ALL;
|
if(last_line && label->long_mode == LV_LABEL_LONG_MODE_DOTS) flag |= LV_TEXT_FLAG_BREAK_ALL;
|
||||||
|
|
||||||
new_line_start += lv_text_get_next_line(&txt[line_start], LV_TEXT_LEN_MAX, font, letter_space, max_w, NULL, flag);
|
new_line_start += lv_text_get_next_line(&txt[line_start], LV_TEXT_LEN_MAX, font, letter_space, max_w, NULL, flag);
|
||||||
|
|
||||||
@ -556,7 +557,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos)
|
|||||||
int32_t y = 0;
|
int32_t y = 0;
|
||||||
while(txt[line_start] != '\0') {
|
while(txt[line_start] != '\0') {
|
||||||
bool last_line = y + letter_height + line_space + letter_height > max_h;
|
bool last_line = y + letter_height + line_space + letter_height > max_h;
|
||||||
if(last_line && label->long_mode == LV_LABEL_LONG_DOT) flag |= LV_TEXT_FLAG_BREAK_ALL;
|
if(last_line && label->long_mode == LV_LABEL_LONG_MODE_DOTS) flag |= LV_TEXT_FLAG_BREAK_ALL;
|
||||||
|
|
||||||
new_line_start += lv_text_get_next_line(&txt[line_start], LV_TEXT_LEN_MAX, font, letter_space, max_w, NULL, flag);
|
new_line_start += lv_text_get_next_line(&txt[line_start], LV_TEXT_LEN_MAX, font, letter_space, max_w, NULL, flag);
|
||||||
|
|
||||||
@ -715,7 +716,7 @@ static void lv_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||||||
label->recolor = 0;
|
label->recolor = 0;
|
||||||
label->static_txt = 0;
|
label->static_txt = 0;
|
||||||
label->dot_begin = LV_LABEL_DOT_BEGIN_INV;
|
label->dot_begin = LV_LABEL_DOT_BEGIN_INV;
|
||||||
label->long_mode = LV_LABEL_LONG_WRAP;
|
label->long_mode = LV_LABEL_LONG_MODE_WRAP;
|
||||||
lv_point_set(&label->offset, 0, 0);
|
lv_point_set(&label->offset, 0, 0);
|
||||||
|
|
||||||
#if LV_LABEL_LONG_TXT_HINT
|
#if LV_LABEL_LONG_TXT_HINT
|
||||||
@ -730,7 +731,7 @@ static void lv_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
lv_obj_remove_flag(obj, LV_OBJ_FLAG_CLICKABLE);
|
lv_obj_remove_flag(obj, LV_OBJ_FLAG_CLICKABLE);
|
||||||
lv_label_set_long_mode(obj, LV_LABEL_LONG_WRAP);
|
lv_label_set_long_mode(obj, LV_LABEL_LONG_MODE_WRAP);
|
||||||
lv_label_set_text(obj, LV_LABEL_DEFAULT_TEXT);
|
lv_label_set_text(obj, LV_LABEL_DEFAULT_TEXT);
|
||||||
|
|
||||||
LV_TRACE_OBJ_CREATE("finished");
|
LV_TRACE_OBJ_CREATE("finished");
|
||||||
@ -818,7 +819,8 @@ static void draw_main(lv_event_t * e)
|
|||||||
label_draw_dsc.ofs_x = label->offset.x;
|
label_draw_dsc.ofs_x = label->offset.x;
|
||||||
label_draw_dsc.ofs_y = label->offset.y;
|
label_draw_dsc.ofs_y = label->offset.y;
|
||||||
#if LV_LABEL_LONG_TXT_HINT
|
#if LV_LABEL_LONG_TXT_HINT
|
||||||
if(label->long_mode != LV_LABEL_LONG_SCROLL_CIRCULAR && lv_area_get_height(&txt_coords) >= LV_LABEL_HINT_HEIGHT_LIMIT) {
|
if(label->long_mode != LV_LABEL_LONG_MODE_SCROLL_CIRCULAR &&
|
||||||
|
lv_area_get_height(&txt_coords) >= LV_LABEL_HINT_HEIGHT_LIMIT) {
|
||||||
label_draw_dsc.hint = &label->hint;
|
label_draw_dsc.hint = &label->hint;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -836,7 +838,7 @@ static void draw_main(lv_event_t * e)
|
|||||||
|
|
||||||
/* In SCROLL and SCROLL_CIRCULAR mode the CENTER and RIGHT are pointless, so remove them.
|
/* In SCROLL and SCROLL_CIRCULAR mode the CENTER and RIGHT are pointless, so remove them.
|
||||||
* (In addition, they will create misalignment in this situation)*/
|
* (In addition, they will create misalignment in this situation)*/
|
||||||
if((label->long_mode == LV_LABEL_LONG_SCROLL || label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) &&
|
if((label->long_mode == LV_LABEL_LONG_MODE_SCROLL || label->long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR) &&
|
||||||
(label_draw_dsc.align == LV_TEXT_ALIGN_CENTER || label_draw_dsc.align == LV_TEXT_ALIGN_RIGHT)) {
|
(label_draw_dsc.align == LV_TEXT_ALIGN_CENTER || label_draw_dsc.align == LV_TEXT_ALIGN_RIGHT)) {
|
||||||
lv_point_t size;
|
lv_point_t size;
|
||||||
lv_text_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
|
lv_text_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
|
||||||
@ -852,12 +854,12 @@ static void draw_main(lv_event_t * e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(label->long_mode == LV_LABEL_LONG_WRAP) {
|
if(label->long_mode == LV_LABEL_LONG_MODE_WRAP) {
|
||||||
int32_t s = lv_obj_get_scroll_top(obj);
|
int32_t s = lv_obj_get_scroll_top(obj);
|
||||||
lv_area_move(&txt_coords, 0, -s);
|
lv_area_move(&txt_coords, 0, -s);
|
||||||
txt_coords.y2 = obj->coords.y2;
|
txt_coords.y2 = obj->coords.y2;
|
||||||
}
|
}
|
||||||
if(label->long_mode == LV_LABEL_LONG_SCROLL || label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) {
|
if(label->long_mode == LV_LABEL_LONG_MODE_SCROLL || label->long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR) {
|
||||||
const lv_area_t clip_area_ori = layer->_clip_area;
|
const lv_area_t clip_area_ori = layer->_clip_area;
|
||||||
layer->_clip_area = txt_clip;
|
layer->_clip_area = txt_clip;
|
||||||
lv_draw_label(layer, &label_draw_dsc, &txt_coords);
|
lv_draw_label(layer, &label_draw_dsc, &txt_coords);
|
||||||
@ -870,7 +872,7 @@ static void draw_main(lv_event_t * e)
|
|||||||
lv_area_t clip_area_ori = layer->_clip_area;
|
lv_area_t clip_area_ori = layer->_clip_area;
|
||||||
layer->_clip_area = txt_clip;
|
layer->_clip_area = txt_clip;
|
||||||
|
|
||||||
if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) {
|
if(label->long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR) {
|
||||||
lv_point_t size;
|
lv_point_t size;
|
||||||
lv_text_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
|
lv_text_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
|
||||||
LV_COORD_MAX, flag);
|
LV_COORD_MAX, flag);
|
||||||
@ -899,7 +901,7 @@ static void draw_main(lv_event_t * e)
|
|||||||
static void overwrite_anim_property(lv_anim_t * dest, const lv_anim_t * src, lv_label_long_mode_t mode)
|
static void overwrite_anim_property(lv_anim_t * dest, const lv_anim_t * src, lv_label_long_mode_t mode)
|
||||||
{
|
{
|
||||||
switch(mode) {
|
switch(mode) {
|
||||||
case LV_LABEL_LONG_SCROLL:
|
case LV_LABEL_LONG_MODE_SCROLL:
|
||||||
/** If the dest animation is already running, overwrite is not allowed */
|
/** If the dest animation is already running, overwrite is not allowed */
|
||||||
if(dest->act_time <= 0)
|
if(dest->act_time <= 0)
|
||||||
dest->act_time = src->act_time;
|
dest->act_time = src->act_time;
|
||||||
@ -908,7 +910,7 @@ static void overwrite_anim_property(lv_anim_t * dest, const lv_anim_t * src, lv_
|
|||||||
dest->completed_cb = src->completed_cb;
|
dest->completed_cb = src->completed_cb;
|
||||||
dest->playback_delay = src->playback_delay;
|
dest->playback_delay = src->playback_delay;
|
||||||
break;
|
break;
|
||||||
case LV_LABEL_LONG_SCROLL_CIRCULAR:
|
case LV_LABEL_LONG_MODE_SCROLL_CIRCULAR:
|
||||||
/** If the dest animation is already running, overwrite is not allowed */
|
/** If the dest animation is already running, overwrite is not allowed */
|
||||||
if(dest->act_time <= 0)
|
if(dest->act_time <= 0)
|
||||||
dest->act_time = src->act_time;
|
dest->act_time = src->act_time;
|
||||||
@ -951,7 +953,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
|||||||
lv_obj_refresh_self_size(obj);
|
lv_obj_refresh_self_size(obj);
|
||||||
|
|
||||||
/*In scroll mode start an offset animation*/
|
/*In scroll mode start an offset animation*/
|
||||||
if(label->long_mode == LV_LABEL_LONG_SCROLL) {
|
if(label->long_mode == LV_LABEL_LONG_MODE_SCROLL) {
|
||||||
const lv_anim_t * anim_template = lv_obj_get_style_anim(obj, LV_PART_MAIN);
|
const lv_anim_t * anim_template = lv_obj_get_style_anim(obj, LV_PART_MAIN);
|
||||||
uint32_t anim_time = lv_obj_get_style_anim_duration(obj, LV_PART_MAIN);
|
uint32_t anim_time = lv_obj_get_style_anim_duration(obj, LV_PART_MAIN);
|
||||||
if(anim_time == 0) anim_time = LV_LABEL_DEF_SCROLL_SPEED;
|
if(anim_time == 0) anim_time = LV_LABEL_DEF_SCROLL_SPEED;
|
||||||
@ -1062,7 +1064,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*In roll inf. mode keep the size but start offset animations*/
|
/*In roll inf. mode keep the size but start offset animations*/
|
||||||
else if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) {
|
else if(label->long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR) {
|
||||||
const lv_anim_t * anim_template = lv_obj_get_style_anim(obj, LV_PART_MAIN);
|
const lv_anim_t * anim_template = lv_obj_get_style_anim(obj, LV_PART_MAIN);
|
||||||
uint32_t anim_time = lv_obj_get_style_anim_duration(obj, LV_PART_MAIN);
|
uint32_t anim_time = lv_obj_get_style_anim_duration(obj, LV_PART_MAIN);
|
||||||
if(anim_time == 0) anim_time = LV_LABEL_DEF_SCROLL_SPEED;
|
if(anim_time == 0) anim_time = LV_LABEL_DEF_SCROLL_SPEED;
|
||||||
@ -1142,7 +1144,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
|||||||
label->offset.y = 0;
|
label->offset.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(label->long_mode == LV_LABEL_LONG_DOT) {
|
else if(label->long_mode == LV_LABEL_LONG_MODE_DOTS) {
|
||||||
if(size.y > lv_area_get_height(&txt_coords) && /*Text overflows available area*/
|
if(size.y > lv_area_get_height(&txt_coords) && /*Text overflows available area*/
|
||||||
size.y > lv_font_get_line_height(font) && /*No break requested, so no dots required*/
|
size.y > lv_font_get_line_height(font) && /*No break requested, so no dots required*/
|
||||||
lv_text_get_encoded_length(label->text) > LV_LABEL_DOT_NUM) { /*Do not turn all characters into dots*/
|
lv_text_get_encoded_length(label->text) > LV_LABEL_DOT_NUM) { /*Do not turn all characters into dots*/
|
||||||
@ -1177,7 +1179,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
|||||||
lv_label_set_dots(obj, byte_id);
|
lv_label_set_dots(obj, byte_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(label->long_mode == LV_LABEL_LONG_CLIP || label->long_mode == LV_LABEL_LONG_WRAP) {
|
else if(label->long_mode == LV_LABEL_LONG_MODE_CLIP || label->long_mode == LV_LABEL_LONG_MODE_WRAP) {
|
||||||
/*Do nothing*/
|
/*Do nothing*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SELECTION_OFF);
|
|||||||
|
|
||||||
/** Long mode behaviors. Used in 'lv_label_ext_t'*/
|
/** Long mode behaviors. Used in 'lv_label_ext_t'*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LV_LABEL_LONG_WRAP, /**< Keep the object width, wrap lines longer than object width and expand the object height*/
|
LV_LABEL_LONG_MODE_WRAP, /**< Keep the object width, wrap lines longer than object width and expand the object height*/
|
||||||
LV_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
|
LV_LABEL_LONG_MODE_DOTS, /**< Keep the size and write dots at the end if the text is too long*/
|
||||||
LV_LABEL_LONG_SCROLL, /**< Keep the size and roll the text back and forth*/
|
LV_LABEL_LONG_MODE_SCROLL, /**< Keep the size and roll the text back and forth*/
|
||||||
LV_LABEL_LONG_SCROLL_CIRCULAR, /**< Keep the size and roll the text circularly*/
|
LV_LABEL_LONG_MODE_SCROLL_CIRCULAR, /**< Keep the size and roll the text circularly*/
|
||||||
LV_LABEL_LONG_CLIP, /**< Keep the size and clip the text out of it*/
|
LV_LABEL_LONG_MODE_CLIP, /**< Keep the size and clip the text out of it*/
|
||||||
} lv_label_long_mode_t;
|
} lv_label_long_mode_t;
|
||||||
|
|
||||||
#if LV_USE_OBJ_PROPERTY
|
#if LV_USE_OBJ_PROPERTY
|
||||||
|
@ -48,7 +48,7 @@ struct _lv_label_t {
|
|||||||
lv_label_long_mode_t long_mode : 4; /**< Determine what to do with the long texts */
|
lv_label_long_mode_t long_mode : 4; /**< Determine what to do with the long texts */
|
||||||
uint8_t static_txt : 1; /**< Flag to indicate the text is static */
|
uint8_t static_txt : 1; /**< Flag to indicate the text is static */
|
||||||
uint8_t recolor : 1; /**< Enable in-line letter re-coloring*/
|
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 expand : 1; /**< Ignore real width (used by the library with LV_LABEL_LONG_MODE_SCROLL) */
|
||||||
uint8_t invalid_size_cache : 1; /**< 1: Recalculate size and update cache */
|
uint8_t invalid_size_cache : 1; /**< 1: Recalculate size and update cache */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ lv_obj_t * lv_list_add_button(lv_obj_t * list, const void * icon, const char * t
|
|||||||
if(txt) {
|
if(txt) {
|
||||||
lv_obj_t * label = lv_label_create(obj);
|
lv_obj_t * label = lv_label_create(obj);
|
||||||
lv_label_set_text(label, txt);
|
lv_label_set_text(label, txt);
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
|
||||||
lv_obj_set_flex_grow(label, 1);
|
lv_obj_set_flex_grow(label, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt)
|
|||||||
{
|
{
|
||||||
lv_obj_t * header = lv_win_get_header(win);
|
lv_obj_t * header = lv_win_get_header(win);
|
||||||
lv_obj_t * title = lv_label_create(header);
|
lv_obj_t * title = lv_label_create(header);
|
||||||
lv_label_set_long_mode(title, LV_LABEL_LONG_DOT);
|
lv_label_set_long_mode(title, LV_LABEL_LONG_MODE_DOTS);
|
||||||
lv_label_set_text(title, txt);
|
lv_label_set_text(title, txt);
|
||||||
lv_obj_set_flex_grow(title, 1);
|
lv_obj_set_flex_grow(title, 1);
|
||||||
return title;
|
return title;
|
||||||
|
@ -38,7 +38,7 @@ void tearDown(void)
|
|||||||
void test_label_creation(void)
|
void test_label_creation(void)
|
||||||
{
|
{
|
||||||
TEST_ASSERT_EQUAL_STRING(lv_label_get_text(label), LV_LABEL_DEFAULT_TEXT);
|
TEST_ASSERT_EQUAL_STRING(lv_label_get_text(label), LV_LABEL_DEFAULT_TEXT);
|
||||||
TEST_ASSERT_EQUAL(lv_label_get_long_mode(label), LV_LABEL_LONG_WRAP);
|
TEST_ASSERT_EQUAL(lv_label_get_long_mode(label), LV_LABEL_LONG_MODE_WRAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_label_set_text(void)
|
void test_label_set_text(void)
|
||||||
@ -151,7 +151,7 @@ void test_label_long_text_multiline_get_letter_pos_align_left(void)
|
|||||||
|
|
||||||
void test_label_long_text_get_letter_pos_align_left(void)
|
void test_label_long_text_get_letter_pos_align_left(void)
|
||||||
{
|
{
|
||||||
lv_label_set_long_mode(long_label, LV_LABEL_LONG_WRAP);
|
lv_label_set_long_mode(long_label, LV_LABEL_LONG_MODE_WRAP);
|
||||||
lv_obj_set_width(long_label, 150);
|
lv_obj_set_width(long_label, 150);
|
||||||
lv_obj_set_height(long_label, 500);
|
lv_obj_set_height(long_label, 500);
|
||||||
lv_obj_set_style_text_align(long_label, LV_TEXT_ALIGN_LEFT, LV_STYLE_STATE_CMP_SAME);
|
lv_obj_set_style_text_align(long_label, LV_TEXT_ALIGN_LEFT, LV_STYLE_STATE_CMP_SAME);
|
||||||
@ -278,7 +278,7 @@ void test_label_long_text_multiline_get_letter_pos_align_right(void)
|
|||||||
|
|
||||||
void test_label_long_text_get_letter_pos_align_right(void)
|
void test_label_long_text_get_letter_pos_align_right(void)
|
||||||
{
|
{
|
||||||
lv_label_set_long_mode(long_label, LV_LABEL_LONG_WRAP);
|
lv_label_set_long_mode(long_label, LV_LABEL_LONG_MODE_WRAP);
|
||||||
lv_obj_set_width(long_label, 150);
|
lv_obj_set_width(long_label, 150);
|
||||||
lv_obj_set_height(long_label, 500);
|
lv_obj_set_height(long_label, 500);
|
||||||
lv_obj_set_style_text_align(long_label, LV_TEXT_ALIGN_RIGHT, LV_STYLE_STATE_CMP_SAME);
|
lv_obj_set_style_text_align(long_label, LV_TEXT_ALIGN_RIGHT, LV_STYLE_STATE_CMP_SAME);
|
||||||
@ -405,7 +405,7 @@ void test_label_long_text_multiline_get_letter_pos_align_center(void)
|
|||||||
|
|
||||||
void test_label_long_text_get_letter_pos_align_center(void)
|
void test_label_long_text_get_letter_pos_align_center(void)
|
||||||
{
|
{
|
||||||
lv_label_set_long_mode(long_label, LV_LABEL_LONG_WRAP);
|
lv_label_set_long_mode(long_label, LV_LABEL_LONG_MODE_WRAP);
|
||||||
lv_obj_set_width(long_label, 150);
|
lv_obj_set_width(long_label, 150);
|
||||||
lv_obj_set_height(long_label, 500);
|
lv_obj_set_height(long_label, 500);
|
||||||
lv_obj_set_style_text_align(long_label, LV_TEXT_ALIGN_CENTER, LV_STYLE_STATE_CMP_SAME);
|
lv_obj_set_style_text_align(long_label, LV_TEXT_ALIGN_CENTER, LV_STYLE_STATE_CMP_SAME);
|
||||||
@ -582,7 +582,7 @@ void test_label_rtl_dot_long_mode(void)
|
|||||||
|
|
||||||
lv_obj_t * test_label = lv_label_create(screen);
|
lv_obj_t * test_label = lv_label_create(screen);
|
||||||
lv_obj_set_style_text_font(test_label, &lv_font_dejavu_16_persian_hebrew, 0);
|
lv_obj_set_style_text_font(test_label, &lv_font_dejavu_16_persian_hebrew, 0);
|
||||||
lv_label_set_long_mode(test_label, LV_LABEL_LONG_DOT);
|
lv_label_set_long_mode(test_label, LV_LABEL_LONG_MODE_DOTS);
|
||||||
lv_obj_set_style_base_dir(test_label, LV_BASE_DIR_RTL, 0);
|
lv_obj_set_style_base_dir(test_label, LV_BASE_DIR_RTL, 0);
|
||||||
lv_obj_set_size(test_label, 300, lv_font_dejavu_16_persian_hebrew.line_height);
|
lv_obj_set_size(test_label, 300, lv_font_dejavu_16_persian_hebrew.line_height);
|
||||||
lv_label_set_text(test_label, message);
|
lv_label_set_text(test_label, message);
|
||||||
@ -610,7 +610,7 @@ void test_label_max_width(void)
|
|||||||
lv_obj_set_style_max_width(test_label2, 200, LV_PART_MAIN);
|
lv_obj_set_style_max_width(test_label2, 200, LV_PART_MAIN);
|
||||||
lv_obj_set_style_bg_color(test_label2, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN);
|
lv_obj_set_style_bg_color(test_label2, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN);
|
||||||
lv_obj_set_style_bg_opa(test_label2, LV_OPA_100, LV_PART_MAIN);
|
lv_obj_set_style_bg_opa(test_label2, LV_OPA_100, LV_PART_MAIN);
|
||||||
lv_label_set_long_mode(test_label2, LV_LABEL_LONG_DOT);
|
lv_label_set_long_mode(test_label2, LV_LABEL_LONG_MODE_DOTS);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/label_max_width.png");
|
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/label_max_width.png");
|
||||||
}
|
}
|
||||||
|
@ -302,10 +302,10 @@ void test_label_properties(void)
|
|||||||
TEST_ASSERT_EQUAL_STRING("Hello world", lv_obj_get_property(obj, LV_PROPERTY_LABEL_TEXT).ptr);
|
TEST_ASSERT_EQUAL_STRING("Hello world", lv_obj_get_property(obj, LV_PROPERTY_LABEL_TEXT).ptr);
|
||||||
|
|
||||||
prop.id = LV_PROPERTY_LABEL_LONG_MODE;
|
prop.id = LV_PROPERTY_LABEL_LONG_MODE;
|
||||||
prop.num = LV_LABEL_LONG_SCROLL;
|
prop.num = LV_LABEL_LONG_MODE_SCROLL;
|
||||||
TEST_ASSERT_TRUE(lv_obj_set_property(obj, &prop) == LV_RESULT_OK);
|
TEST_ASSERT_TRUE(lv_obj_set_property(obj, &prop) == LV_RESULT_OK);
|
||||||
TEST_ASSERT_EQUAL_INT(LV_LABEL_LONG_SCROLL, lv_label_get_long_mode(obj));
|
TEST_ASSERT_EQUAL_INT(LV_LABEL_LONG_MODE_SCROLL, lv_label_get_long_mode(obj));
|
||||||
TEST_ASSERT_EQUAL_INT(LV_LABEL_LONG_SCROLL, lv_obj_get_property(obj, LV_PROPERTY_LABEL_LONG_MODE).num);
|
TEST_ASSERT_EQUAL_INT(LV_LABEL_LONG_MODE_SCROLL, lv_obj_get_property(obj, LV_PROPERTY_LABEL_LONG_MODE).num);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SELECTION
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
prop.id = LV_PROPERTY_LABEL_TEXT_SELECTION_START;
|
prop.id = LV_PROPERTY_LABEL_TEXT_SELECTION_START;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user