Merge pull request #1032 from littlevgl/t_minor_fixes

Minor fixes for compiler warnings/-Werrors
This commit is contained in:
embeddedt
2019-04-20 09:09:06 -04:00
committed by GitHub
5 changed files with 24 additions and 54 deletions

View File

@@ -154,29 +154,6 @@ bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p)
return is_on;
}
#if LV_USE_EXTENDED_CLICK_AREA_TINY
/**
* Check if a point is on an area
* @param a_p pointer to an area
* @param p_p pointer to a point
* @param ext_hor extended horizontal padding
* @param ext_ver extended horizontal padding
* @return false:the point is out of the area
*/
bool lv_area_ext_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, uint8_t ext_hor, uint8_t ext_ver)
{
bool is_on = false;
if(( (p_p->x + ext_hor) >= a_p->x1 && p_p->x <= (a_p->x2 + ext_hor) ) &&
( (p_p->y + ext_ver) >= a_p->y1 && p_p->y <= (a_p->y2 + ext_ver)) ) {
is_on = true;
}
return is_on;
}
#endif
/**
* Check if two area has common parts
* @param a1_p pointer to an area.

View File

@@ -145,18 +145,6 @@ void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t *
*/
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p);
#if LV_USE_EXTENDED_CLICK_AREA_TINY
/**
* Check if a point is on an area
* @param a_p pointer to an area
* @param p_p pointer to a point
* @param ext_hor extended horizontal padding
* @param ext_ver extended horizontal padding
* @return false:the point is out of the area
*/
bool lv_area_ext_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, uint8_t ext_hor, uint8_t ext_ver);
#endif
/**
* Check if two area has common parts
* @param a1_p pointer to an area.

View File

@@ -97,7 +97,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->txt_sel_start = LV_LABEL_TEXT_SEL_OFF;
ext->txt_sel_end = LV_LABEL_TEXT_SEL_OFF;
#endif
ext->dot_tmp_ptr = NULL;
ext->dot.tmp_ptr = NULL;
ext->dot_tmp_alloc = 0;
lv_obj_set_design_cb(new_label, lv_label_design);
@@ -130,12 +130,12 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
}
if(copy_ext->dot_tmp_alloc && copy_ext->dot_tmp_ptr ){
int len = strlen(copy_ext->dot_tmp_ptr);
lv_label_set_dot_tmp(new_label, ext->dot_tmp_ptr, len);
if(copy_ext->dot_tmp_alloc && copy_ext->dot.tmp_ptr ){
int len = strlen(copy_ext->dot.tmp_ptr);
lv_label_set_dot_tmp(new_label, ext->dot.tmp_ptr, len);
}
else{
memcpy(ext->dot_tmp, copy_ext->dot_tmp, sizeof(ext->dot_tmp));
memcpy(ext->dot.tmp, copy_ext->dot.tmp, sizeof(ext->dot.tmp));
}
ext->dot_tmp_alloc = copy_ext->dot_tmp_alloc;
ext->dot_end = copy_ext->dot_end;
@@ -1119,19 +1119,19 @@ static bool lv_label_set_dot_tmp(lv_obj_t *label, char *data, uint16_t len){
if( len > sizeof(char *) ){
/* Memory needs to be allocated. Allocates an additional byte
* for a NULL-terminator so it can be copied. */
ext->dot_tmp_ptr = lv_mem_alloc(len + 1);
if( ext->dot_tmp_ptr == NULL ){
ext->dot.tmp_ptr = lv_mem_alloc(len + 1);
if( ext->dot.tmp_ptr == NULL ){
LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr");
return false;
}
memcpy(ext->dot_tmp_ptr, data, len);
ext->dot_tmp_ptr[len]='\0';
memcpy(ext->dot.tmp_ptr, data, len);
ext->dot.tmp_ptr[len]='\0';
ext->dot_tmp_alloc = true;
}
else {
/* Characters can be directly stored in object */
ext->dot_tmp_alloc = false;
memcpy(ext->dot_tmp, data, len);
memcpy(ext->dot.tmp, data, len);
}
return true;
}
@@ -1144,10 +1144,10 @@ static bool lv_label_set_dot_tmp(lv_obj_t *label, char *data, uint16_t len){
static char * lv_label_get_dot_tmp(lv_obj_t *label){
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if( ext->dot_tmp_alloc ){
return ext->dot_tmp_ptr;
return ext->dot.tmp_ptr;
}
else{
return ext->dot_tmp;
return ext->dot.tmp;
}
}
@@ -1158,11 +1158,11 @@ static char * lv_label_get_dot_tmp(lv_obj_t *label){
*/
static void lv_label_dot_tmp_free(lv_obj_t *label){
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if( ext->dot_tmp_alloc && ext->dot_tmp_ptr ){
lv_mem_free(ext->dot_tmp_ptr);
if( ext->dot_tmp_alloc && ext->dot.tmp_ptr ){
lv_mem_free(ext->dot.tmp_ptr);
}
ext->dot_tmp_alloc = false;
ext->dot_tmp_ptr = NULL;
ext->dot.tmp_ptr = NULL;
}
#endif

View File

@@ -64,9 +64,9 @@ typedef struct
/*New data for this type */
char * text; /*Text of the label*/
union{
char * dot_tmp_ptr; /* Pointer to the allocated memory containing the character which are replaced by dots (Handled by the library)*/
char dot_tmp[ sizeof(char *) ]; /* Directly store the characters if <=4 characters */
};
char * tmp_ptr; /* Pointer to the allocated memory containing the character which are replaced by dots (Handled by the library)*/
char tmp[ sizeof(char *) ]; /* Directly store the characters if <=4 characters */
} dot;
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
lv_point_t offset; /*Text draw position offset*/