merge master
This commit is contained in:
@@ -149,7 +149,6 @@ enum {
|
||||
LV_STATE_PRESSED = 0x20,
|
||||
LV_STATE_SCROLLED = 0x40,
|
||||
LV_STATE_DISABLED = 0x80,
|
||||
_LV_STATE_RESERVED = 0x80,
|
||||
|
||||
LV_STATE_ANY = 0x1FF, /**< Special value can be used in some functions to target all states */
|
||||
};
|
||||
@@ -203,7 +202,7 @@ enum {
|
||||
LV_OBJ_FLAG_FOCUS_BUBBLE = (1 << 14), /**< Propagate the focus to the parent */
|
||||
LV_OBJ_FLAG_ADV_HITTEST = (1 << 15), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners. */
|
||||
LV_OBJ_FLAG_IGNORE_LAYOUT = (1 << 16), /**< Make the object position-able by the layouts */
|
||||
LV_OBJ_FLAG_FLOATING = (1 << 17),
|
||||
LV_OBJ_FLAG_FLOATING = (1 << 17), /**< Do not scroll the object when the parent scrolls and ignore layout */
|
||||
|
||||
LV_OBJ_FLAG_LAYOUT_1 = (1 << 23), /** Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /** Custom flag, free to use by layouts*/
|
||||
|
||||
@@ -717,7 +717,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
|
||||
|
||||
has_com = _lv_area_intersect(&ca, &a, clip);
|
||||
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
|
||||
/*Avoid overlap in the middle with large radius*/
|
||||
if(ca.x1 <= w_half) ca.x1 = w_half + 1;
|
||||
|
||||
if(simple_mode) ca.x1 = LV_MAX(ca.x1, coords->x2);
|
||||
|
||||
/*Draw horizontal lines*/
|
||||
lv_coord_t w = lv_area_get_width(&ca);
|
||||
if(w > 0) {
|
||||
@@ -842,6 +846,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
|
||||
|
||||
has_com = _lv_area_intersect(&ca, &a, clip);
|
||||
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
|
||||
/*Avoid overlap in the middle with large radius*/
|
||||
if(ca.x2 > w_half) ca.x2 = w_half;
|
||||
|
||||
if(simple_mode) ca.x2 = LV_MIN(coords->x1, ca.x2);
|
||||
/*Draw vertical lines*/
|
||||
lv_coord_t w = lv_area_get_width(&ca);
|
||||
@@ -880,7 +887,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
|
||||
|
||||
has_com = _lv_area_intersect(&ca, &a, clip);
|
||||
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
|
||||
/*Avoid overlap in the middle with large radius*/
|
||||
if(ca.y2 > h_half) ca.y2 = h_half;
|
||||
|
||||
if(simple_mode) ca.y2 = LV_MIN(ca.y2, coords->y1);
|
||||
|
||||
/*Draw horizontal lines*/
|
||||
lv_coord_t w = lv_area_get_width(&ca);
|
||||
lv_coord_t h = lv_area_get_height(&ca);
|
||||
@@ -921,7 +932,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
|
||||
|
||||
has_com = _lv_area_intersect(&ca, &a, clip);
|
||||
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
|
||||
/*Avoid overlap in the middle with large radius*/
|
||||
if(ca.y1 <= h_half) ca.y1 = h_half + 1;
|
||||
|
||||
if(simple_mode) ca.y1 = LV_MAX(ca.y1, coords->y2);
|
||||
|
||||
/*Draw horizontal lines*/
|
||||
lv_coord_t w = lv_area_get_width(&ca);
|
||||
lv_coord_t h = lv_area_get_height(&ca);
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if LV_IMG_CACHE_DEF_SIZE
|
||||
static bool lv_img_cache_match(const void * src1, const void * src2);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -79,16 +82,8 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)
|
||||
}
|
||||
|
||||
for(i = 0; i < entry_cnt; i++) {
|
||||
bool match = false;
|
||||
lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src);
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
if(cache[i].dec_dsc.src == src && cache[i].dec_dsc.color.full == color.full) match = true;
|
||||
}
|
||||
else if(src_type == LV_IMG_SRC_FILE) {
|
||||
if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true;
|
||||
}
|
||||
|
||||
if(match) {
|
||||
if(color.full == cache[i].dec_dsc.color.full &&
|
||||
lv_img_cache_match(src, cache[i].dec_dsc.src)) {
|
||||
/* If opened increment its life.
|
||||
* Image difficult to open should live longer to keep avoid frequent their recaching.
|
||||
* Therefore increase `life` with `time_to_open`*/
|
||||
@@ -119,7 +114,6 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)
|
||||
else {
|
||||
LV_LOG_INFO("image draw: cache miss, cached to an empty entry");
|
||||
}
|
||||
|
||||
#else
|
||||
cached_src = &LV_GC_ROOT(_lv_img_cache_single);
|
||||
#endif
|
||||
@@ -128,8 +122,6 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)
|
||||
lv_res_t open_res = lv_img_decoder_open(&cached_src->dec_dsc, src, color);
|
||||
if(open_res == LV_RES_INV) {
|
||||
LV_LOG_WARN("Image draw cannot open the image resource");
|
||||
lv_img_decoder_close(&cached_src->dec_dsc);
|
||||
lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t));
|
||||
lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t));
|
||||
cached_src->life = INT32_MIN; /*Make the empty entry very "weak" to force its use */
|
||||
return NULL;
|
||||
@@ -175,11 +167,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt)
|
||||
entry_cnt = new_entry_cnt;
|
||||
|
||||
/*Clean the cache*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < entry_cnt; i++) {
|
||||
lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, sizeof(lv_img_decoder_dsc_t));
|
||||
lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i], sizeof(lv_img_cache_entry_t));
|
||||
}
|
||||
_lv_memset_00(LV_GC_ROOT(_lv_img_cache_array), entry_cnt * sizeof(lv_img_cache_entry_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -196,13 +184,12 @@ void lv_img_cache_invalidate_src(const void * src)
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < entry_cnt; i++) {
|
||||
if(cache[i].dec_dsc.src == src || src == NULL) {
|
||||
if(src == NULL || lv_img_cache_match(src, cache[i].dec_dsc.src)) {
|
||||
if(cache[i].dec_dsc.src != NULL) {
|
||||
lv_img_decoder_close(&cache[i].dec_dsc);
|
||||
}
|
||||
|
||||
lv_memset_00(&cache[i].dec_dsc, sizeof(lv_img_decoder_dsc_t));
|
||||
lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t));
|
||||
_lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -211,3 +198,17 @@ void lv_img_cache_invalidate_src(const void * src)
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if LV_IMG_CACHE_DEF_SIZE
|
||||
static bool lv_img_cache_match(const void * src1, const void * src2)
|
||||
{
|
||||
lv_img_src_t src_type = lv_img_src_get_type(src1);
|
||||
if(src_type == LV_IMG_SRC_VARIABLE)
|
||||
return src1 == src2;
|
||||
if(src_type != LV_IMG_SRC_FILE)
|
||||
return false;
|
||||
if(lv_img_src_get_type(src2) != LV_IMG_SRC_FILE)
|
||||
return false;
|
||||
return strcmp(src1, src2) == 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
typedef struct {
|
||||
lv_img_decoder_dsc_t dec_dsc; /**< Image information */
|
||||
|
||||
/** Count the cache entries's life. Add `time_tio_open` to `life` when the entry is used.
|
||||
/** Count the cache entries's life. Add `time_to_open` to `life` when the entry is used.
|
||||
* Decrement all lifes by one every in every ::lv_img_cache_open.
|
||||
* If life == 0 the entry can be reused */
|
||||
int32_t life;
|
||||
|
||||
@@ -725,7 +725,7 @@ static uint32_t lv_txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t byte_cnt = 0;
|
||||
for(i = 0; i < utf8_id; i++) {
|
||||
for(i = 0; i < utf8_id && txt[byte_cnt] != '\0'; i++) {
|
||||
uint8_t c_size = _lv_txt_encoded_size(&txt[byte_cnt]);
|
||||
byte_cnt += c_size > 0 ? c_size : 1;
|
||||
}
|
||||
|
||||
@@ -369,17 +369,34 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
*axis1 += anim_start_value_x;
|
||||
}
|
||||
else {
|
||||
*axis1 = *axis2 - anim_cur_value_x;
|
||||
*axis1 = *axis2 - anim_cur_value_x + 1;
|
||||
*axis2 -= anim_start_value_x;
|
||||
}
|
||||
if(sym) {
|
||||
lv_coord_t zero;
|
||||
zero = *axis1 + (-bar->min_value * anim_length) / range;
|
||||
if(*axis2 > zero)
|
||||
*axis1 = zero;
|
||||
else {
|
||||
*axis1 = *axis2;
|
||||
*axis2 = zero;
|
||||
lv_coord_t zero, shift;
|
||||
shift = (-bar->min_value * anim_length) / range;
|
||||
if(hor) {
|
||||
zero = *axis1 + shift;
|
||||
if(*axis2 > zero)
|
||||
*axis1 = zero;
|
||||
else {
|
||||
*axis1 = *axis2;
|
||||
*axis2 = zero;
|
||||
}
|
||||
} else {
|
||||
zero = *axis2 - shift + 1;
|
||||
if(*axis1 > zero)
|
||||
*axis2 = zero;
|
||||
else {
|
||||
*axis2 = *axis1;
|
||||
*axis1 = zero;
|
||||
}
|
||||
if(*axis2 < *axis1) {
|
||||
/* swap */
|
||||
zero = *axis1;
|
||||
*axis1 = *axis2;
|
||||
*axis2 = zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +436,13 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_draw_mask_radius_param_t mask_bg_param;
|
||||
lv_draw_mask_radius_init(&mask_bg_param, &bar_coords, bg_radius, false);
|
||||
lv_area_t bg_mask_area;
|
||||
bg_mask_area.x1 = obj->coords.x1 + bg_left;
|
||||
bg_mask_area.x2 = obj->coords.x2 - bg_right;
|
||||
bg_mask_area.y1 = obj->coords.y1 + bg_top;
|
||||
bg_mask_area.y2 = obj->coords.y2 - bg_bottom;
|
||||
|
||||
lv_draw_mask_radius_init(&mask_bg_param, &bg_mask_area, bg_radius, false);
|
||||
int16_t mask_bg_id = lv_draw_mask_add(&mask_bg_param, NULL);
|
||||
#endif
|
||||
|
||||
@@ -493,6 +516,17 @@ static lv_res_t lv_bar_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
/*Bg size is handled by lv_obj*/
|
||||
lv_coord_t * s = param;
|
||||
*s = LV_MAX(*s, indic_size);
|
||||
|
||||
/*Calculate the indicator area*/
|
||||
lv_coord_t bg_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
|
||||
|
||||
lv_coord_t pad = LV_MIN4(bg_left, bg_right, bg_top, bg_bottom);
|
||||
if(pad < 0) {
|
||||
*s = LV_MAX(*s, -pad);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file lv_label.c
|
||||
*
|
||||
*/
|
||||
@@ -914,10 +914,29 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
||||
|
||||
bool hor_anim = false;
|
||||
if(size.x > lv_area_get_width(&txt_coords)) {
|
||||
#if LV_USE_BIDI
|
||||
int32_t start, end;
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(label);
|
||||
|
||||
if (base_dir == LV_BIDI_DIR_AUTO)
|
||||
base_dir = _lv_bidi_detect_base_dir(label->text);
|
||||
|
||||
if (base_dir == LV_BIDI_DIR_RTL) {
|
||||
start = lv_area_get_width(&txt_coords) - size.x;
|
||||
end = 0;
|
||||
}
|
||||
else {
|
||||
start = 0;
|
||||
end = lv_area_get_width(&txt_coords) - size.x;
|
||||
}
|
||||
|
||||
lv_anim_set_values(&a, start, end);
|
||||
#else
|
||||
lv_anim_set_values(&a, 0, lv_area_get_width(&txt_coords) - size.x);
|
||||
lv_anim_set_exec_cb(&a, set_ofs_x_anim);
|
||||
lv_anim_set_time(&a, lv_anim_speed_to_time(anim_speed, a.start_value, a.end_value));
|
||||
lv_anim_set_playback_time(&a, a.time);
|
||||
#endif
|
||||
lv_anim_set_exec_cb(&a, set_ofs_x_anim);
|
||||
|
||||
lv_anim_t * anim_cur = lv_anim_get(obj, set_ofs_x_anim);
|
||||
int32_t act_time = 0;
|
||||
@@ -993,9 +1012,28 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
||||
|
||||
bool hor_anim = false;
|
||||
if(size.x > lv_area_get_width(&txt_coords)) {
|
||||
#if LV_USE_BIDI
|
||||
int32_t start, end;
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(label);
|
||||
|
||||
if (base_dir == LV_BIDI_DIR_AUTO)
|
||||
base_dir = _lv_bidi_detect_base_dir(label->text);
|
||||
|
||||
if (base_dir == LV_BIDI_DIR_RTL) {
|
||||
start = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
|
||||
end = 0;
|
||||
}
|
||||
else {
|
||||
start = 0;
|
||||
end = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
|
||||
}
|
||||
|
||||
lv_anim_set_values(&a, start, end);
|
||||
#else
|
||||
lv_anim_set_values(&a, 0, -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT);
|
||||
lv_anim_set_exec_cb(&a, set_ofs_x_anim);
|
||||
lv_anim_set_time(&a, lv_anim_speed_to_time(anim_speed, a.start_value, a.end_value));
|
||||
#endif
|
||||
|
||||
lv_anim_t * anim_cur = lv_anim_get(obj, set_ofs_x_anim);
|
||||
int32_t act_time = anim_cur ? anim_cur->act_time : 0;
|
||||
|
||||
@@ -161,8 +161,20 @@ char * lv_label_get_text(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the long mode of a label
|
||||
<<<<<<< HEAD
|
||||
* @param obj pointer to a label object
|
||||
* @return the current long mode
|
||||
=======
|
||||
* @param label pointer to a label object
|
||||
* @return the long mode
|
||||
*/
|
||||
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the align attribute
|
||||
* @param label pointer to a label object
|
||||
* @return LV_LABEL_ALIGN_LEFT/RIGHT/CENTER
|
||||
>>>>>>> master
|
||||
*/
|
||||
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * obj);
|
||||
|
||||
|
||||
@@ -171,8 +171,14 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
dist_right = LV_ABS((slider->right_knob_area.x1 + (slider->right_knob_area.x2 - slider->right_knob_area.x1) / 2) - p.x);
|
||||
|
||||
/* Use whichever one is closer */
|
||||
if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value;
|
||||
else slider->value_to_set = &slider->bar.start_value;
|
||||
if(dist_right < dist_left) {
|
||||
slider->value_to_set = &slider->bar.cur_value;
|
||||
slider->left_knob_focus = 0;
|
||||
}
|
||||
else {
|
||||
slider->value_to_set = &slider->bar.start_value;
|
||||
slider->left_knob_focus = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -188,8 +194,14 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
dist_right = LV_ABS((slider->right_knob_area.y1 + (slider->right_knob_area.y2 - slider->right_knob_area.y1) / 2) - p.y);
|
||||
|
||||
/* Use whichever one is closer */
|
||||
if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value;
|
||||
else slider->value_to_set = &slider->bar.start_value;
|
||||
if(dist_right < dist_left) {
|
||||
slider->value_to_set = &slider->bar.cur_value;
|
||||
slider->left_knob_focus = 0;
|
||||
}
|
||||
else {
|
||||
slider->value_to_set = &slider->bar.start_value;
|
||||
slider->left_knob_focus = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +288,10 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
slider->left_knob_focus = 0;
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER || indev_type == LV_INDEV_TYPE_KEYPAD) {
|
||||
slider->left_knob_focus = 0;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_COORD_CHG) {
|
||||
/* The knob size depends on slider size.
|
||||
|
||||
Reference in New Issue
Block a user