new font and anti-alising system release for test
This commit is contained in:
@@ -436,14 +436,14 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
else if (obj_num == 1) {
|
||||
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
/*If are two object in the row then align them proportionally*/
|
||||
/*If there are two object in the row then align them proportionally*/
|
||||
else if (obj_num == 2) {
|
||||
lv_obj_t * obj1 = child_rs;
|
||||
lv_obj_t * obj2 = lv_ll_get_prev(&cont->child_ll, child_rs);
|
||||
w_row = lv_obj_get_width(obj1) + lv_obj_get_width(obj2);
|
||||
lv_coord_t pad = (w_obj - w_row) / 3;
|
||||
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y);
|
||||
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y);
|
||||
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2);
|
||||
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2);
|
||||
}
|
||||
/* Align the children (from child_rs to child_rc)*/
|
||||
else {
|
||||
@@ -454,7 +454,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
while(child_tmp != NULL) {
|
||||
if(lv_obj_get_hidden(child_tmp) == false &&
|
||||
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
|
||||
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y);
|
||||
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
|
||||
act_x += lv_obj_get_width(child_tmp) + new_opad;
|
||||
}
|
||||
if(child_tmp == child_rc) break;
|
||||
|
||||
250
lv_objx/lv_img.c
250
lv_objx/lv_img.c
@@ -37,7 +37,6 @@
|
||||
**********************/
|
||||
static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode_t mode);
|
||||
static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param);
|
||||
static bool lv_img_is_symbol(const char * txt);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -70,10 +69,12 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Extend the basic object to image object*/
|
||||
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t));
|
||||
lv_mem_assert(ext);
|
||||
ext->fn = NULL;
|
||||
ext->src = NULL;
|
||||
ext->src_type = LV_IMG_SRC_UNKNOWN;
|
||||
ext->w = lv_obj_get_width(new_img);
|
||||
ext->h = lv_obj_get_height(new_img);
|
||||
ext->transp = 0;
|
||||
ext->chroma_keyed = 0;
|
||||
ext->alpha_byte = 0;
|
||||
ext->auto_size = 1;
|
||||
|
||||
/*Init the new object*/
|
||||
@@ -91,7 +92,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
} else {
|
||||
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
lv_img_set_file(new_img, copy_ext->fn);
|
||||
lv_img_set_src(new_img, copy_ext->src);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_img);
|
||||
@@ -100,20 +101,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
return new_img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. LV_FS_RES_OK or any error from lv_fs_res_t
|
||||
*/
|
||||
lv_fs_res_t lv_img_create_file(const char * fn, const lv_color_int_t * data)
|
||||
{
|
||||
const lv_img_raw_header_t * raw_p = (lv_img_raw_header_t *) data;
|
||||
lv_fs_res_t res;
|
||||
res = lv_ufs_create_const(fn, data, raw_p->w * raw_p->h * sizeof(lv_color_t) + sizeof(lv_img_raw_header_t));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
@@ -125,16 +112,88 @@ lv_fs_res_t lv_img_create_file(const char * fn, const lv_color_int_t * data)
|
||||
* @param img pointer to an image object
|
||||
* @param data the image data
|
||||
*/
|
||||
void lv_img_set_data(lv_obj_t * img, lv_img_dsc_t * data)
|
||||
void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
{
|
||||
lv_img_src_t src_type = lv_img_get_src_type(src_img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
ext->px_data = data;
|
||||
ext->w = data->w;
|
||||
ext->h = data->h;
|
||||
ext->transp = data->chroma_key;
|
||||
ext->alpha_byte = data->alpha;
|
||||
lv_obj_set_size(img, data->w, data->h);
|
||||
|
||||
if(src_type == LV_IMG_SRC_UNKNOWN) {
|
||||
if(ext->src_type == LV_IMG_SRC_SYMBOL || ext->src_type == LV_IMG_SRC_FILE) {
|
||||
lv_mem_free(ext->src);
|
||||
}
|
||||
ext->src = NULL;
|
||||
ext->src_type = LV_IMG_SRC_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ext->src_type = src_type;
|
||||
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
ext->src = src_img;
|
||||
ext->w = ((lv_img_t*)src_img)->header.w;
|
||||
ext->h = ((lv_img_t*)src_img)->header.h;
|
||||
ext->chroma_keyed = ((lv_img_t*)src_img)->header.chroma_keyed;
|
||||
ext->alpha_byte = ((lv_img_t*)src_img)->header.alpha_byte;
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
|
||||
else if(src_type == LV_IMG_SRC_FILE) {
|
||||
lv_fs_file_t file;
|
||||
lv_fs_res_t res;
|
||||
lv_img_t img_file_data;
|
||||
uint32_t rn;
|
||||
res = lv_fs_open(&file, src_img, LV_FS_MODE_RD);
|
||||
if(res == LV_FS_RES_OK) {
|
||||
res = lv_fs_read(&file, &img_file_data, sizeof(img_file_data), &rn);
|
||||
}
|
||||
|
||||
/*Create a dummy header on fs error*/
|
||||
if(res != LV_FS_RES_OK || rn != sizeof(img_file_data)) {
|
||||
img_file_data.header.w = lv_obj_get_width(img);
|
||||
img_file_data.header.h = lv_obj_get_height(img);
|
||||
img_file_data.header.chroma_keyed = 0;
|
||||
img_file_data.header.alpha_byte = 0;
|
||||
}
|
||||
|
||||
lv_fs_close(&file);
|
||||
|
||||
ext->w = img_file_data.header.w;
|
||||
ext->h = img_file_data.header.h;
|
||||
ext->chroma_keyed = img_file_data.header.chroma_keyed;
|
||||
ext->alpha_byte = img_file_data.header.alpha_byte;
|
||||
|
||||
/* If the new and the old src are the same then it was only a refresh.*/
|
||||
if(ext->src != src_img) {
|
||||
lv_mem_free(ext->src);
|
||||
char * new_fn = lv_mem_alloc(strlen(src_img) + 1);
|
||||
strcpy(new_fn, src_img);
|
||||
ext->src = new_fn;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else if(src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_style_t * style = lv_obj_get_style(img);
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
ext->w = size.x;
|
||||
ext->h = size.y;
|
||||
ext->chroma_keyed = 1; /*Symbols always have transparent parts, Important because of cover check in the design function*/
|
||||
|
||||
/* If the new and the old src are the same then it was only a refresh.*/
|
||||
if(ext->src != src_img) {
|
||||
lv_mem_free(ext->src);
|
||||
char * new_txt = lv_mem_alloc(strlen(src_img) + 1);
|
||||
strcpy(new_txt, src_img);
|
||||
ext->src = new_txt;
|
||||
}
|
||||
}
|
||||
|
||||
if(lv_img_get_auto_size(img) != false) {
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
|
||||
lv_obj_invalidate(img);
|
||||
}
|
||||
@@ -146,62 +205,7 @@ void lv_img_set_data(lv_obj_t * img, lv_img_dsc_t * data)
|
||||
*/
|
||||
void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
{
|
||||
|
||||
return;
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
/*Handle normal images*/
|
||||
if(lv_img_is_symbol(fn) == false) {
|
||||
lv_fs_file_t file;
|
||||
lv_fs_res_t res;
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t rn;
|
||||
res = lv_fs_open(&file, fn, LV_FS_MODE_RD);
|
||||
if(res == LV_FS_RES_OK) {
|
||||
res = lv_fs_read(&file, &header, sizeof(header), &rn);
|
||||
}
|
||||
|
||||
/*Create a dummy header on fs error*/
|
||||
if(res != LV_FS_RES_OK || rn != sizeof(header)) {
|
||||
header.w = lv_obj_get_width(img);
|
||||
header.h = lv_obj_get_height(img);
|
||||
header.transp = 0;
|
||||
}
|
||||
|
||||
lv_fs_close(&file);
|
||||
|
||||
ext->w = header.w;
|
||||
ext->h = header.h;
|
||||
ext->transp = header.transp;
|
||||
}
|
||||
/*Handle symbol texts*/
|
||||
else {
|
||||
lv_style_t * style = lv_obj_get_style(img);
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, fn, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
ext->w = size.x;
|
||||
ext->h = size.y;
|
||||
ext->transp = 1; /*Symbols always have transparent parts*/
|
||||
}
|
||||
|
||||
if(fn != NULL) {
|
||||
/* Don't refresh if set the the current 'fn'
|
||||
* 'lv_mem_realloc' first allocates a new mem and then frees the old
|
||||
* in this case it would free itself so it wouldn't be anything to 'strcpy' */
|
||||
if(ext->fn != fn) {
|
||||
ext->fn = lv_mem_realloc(ext->fn, strlen(fn) + 1);
|
||||
strcpy(ext->fn, fn);
|
||||
}
|
||||
} else {
|
||||
ext->fn = NULL;
|
||||
}
|
||||
|
||||
|
||||
if(lv_img_get_auto_size(img) != false) {
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
|
||||
lv_obj_invalidate(img);
|
||||
lv_img_set_src(img, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,6 +226,17 @@ void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
lv_img_src_t lv_img_get_src_type(const void * src)
|
||||
{
|
||||
if(src == NULL) return LV_IMG_SRC_UNKNOWN;
|
||||
const uint8_t * u8_p = src;
|
||||
|
||||
/*The first byte shows the type of the image source*/
|
||||
if(u8_p[0] >= 'A' && u8_p[0] <= 'Z') return LV_IMG_SRC_FILE; /*It's a driver letter*/
|
||||
else if(u8_p[0] >= 127) return LV_IMG_SRC_SYMBOL; /*After ASCII letteres only symbols (even UTF-8) can be*/
|
||||
else if(((u8_p[0] & 0xFC) >> 2) == LV_IMG_FORMAT_RAW_INTERNAL) return LV_IMG_SRC_VARIABLE; /*Mask the file format part og of lv_img_t header. IT should be 0 which means C array */
|
||||
else return LV_IMG_SRC_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the file set for an image
|
||||
@@ -232,7 +247,7 @@ const char * lv_img_get_file_name(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
return ext->fn;
|
||||
return ext->src;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,30 +284,40 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
bool cover = false;
|
||||
if(ext->transp == 0 && ext->alpha_byte == 0) cover = lv_area_is_in(mask, &img->coords);
|
||||
if(ext->src_type == LV_IMG_SRC_UNKNOWN || ext->src_type == LV_IMG_SRC_SYMBOL) return false;
|
||||
|
||||
if(ext->chroma_keyed == 0 && ext->alpha_byte == 0) cover = lv_area_is_in(mask, &img->coords);
|
||||
return cover;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
if(ext->h == 0 || ext->w == 0) return true;
|
||||
lv_area_t cords;
|
||||
/*Create a default style for symbol texts*/
|
||||
bool sym = false;//lv_img_is_symbol(ext->fn);
|
||||
lv_area_t coords;
|
||||
|
||||
lv_obj_get_coords(img, &cords);
|
||||
lv_obj_get_coords(img, &coords);
|
||||
|
||||
lv_area_t cords_tmp;
|
||||
cords_tmp.y1 = cords.y1;
|
||||
cords_tmp.y2 = cords.y1 + ext->h - 1;
|
||||
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
lv_area_t cords_tmp;
|
||||
cords_tmp.y1 = coords.y1;
|
||||
cords_tmp.y2 = coords.y1 + ext->h - 1;
|
||||
|
||||
for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
|
||||
cords_tmp.x1 = cords.x1;
|
||||
cords_tmp.x2 = cords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
if(sym == false) lv_draw_img(&cords_tmp, mask, style, NULL, ext->px_data);
|
||||
else lv_draw_label(&cords_tmp, mask, style, ext->fn, LV_TXT_FLAG_NONE, NULL);
|
||||
for(; cords_tmp.y1 < coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
|
||||
cords_tmp.x1 = coords.x1;
|
||||
cords_tmp.x2 = coords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 < coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
lv_draw_img(&cords_tmp, mask, style, ext->src);
|
||||
}
|
||||
}
|
||||
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_draw_label(&coords, mask, style, ext->src, LV_TXT_FLAG_NONE, NULL);
|
||||
|
||||
} else {
|
||||
|
||||
/*Trigger the error handler of image drawer*/
|
||||
lv_draw_img(&img->coords, mask, style, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -316,36 +341,21 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_mem_free(ext->fn);
|
||||
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_mem_free(ext->src);
|
||||
ext->src = NULL;
|
||||
ext->src_type = LV_IMG_SRC_UNKNOWN;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Refresh the file name to refresh the symbol text size*/
|
||||
if(lv_img_is_symbol(ext->fn) != false) {
|
||||
lv_img_set_file(img, ext->fn);
|
||||
if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_img_set_src(img, ext->src);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* From the settings in lv_conf.h and the file name
|
||||
* tells it a filename or a symbol text.
|
||||
* @param txt a file name (e.g. "U:/file1") or a symbol (e.g. SYMBOL_OK)
|
||||
* @return true: 'txt' is a symbol text, false: 'txt' is a file name
|
||||
*/
|
||||
static bool lv_img_is_symbol(const char * txt)
|
||||
{
|
||||
if(txt == NULL) return false;
|
||||
|
||||
/* if txt begins with an upper case letter then it refers to a driver
|
||||
* so it is a file name*/
|
||||
if(txt[0] >= 'A' && txt[0] <= 'Z') return false;
|
||||
|
||||
/*If not returned during the above tests then consider as text*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,15 +34,14 @@ typedef struct
|
||||
{
|
||||
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
union {
|
||||
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
||||
lv_img_dsc_t * px_data; /*Image file name. E.g. "U:/my_image"*/
|
||||
};
|
||||
lv_coord_t w; /*Width of the image (doubled when upscaled) (Handled by the library)*/
|
||||
lv_coord_t h; /*Height of the image (doubled when upscaled) (Handled by the library)*/
|
||||
const void * src; /*Image source: Pointer to an array or a file or a symbol*/
|
||||
|
||||
lv_coord_t w; /*Width of the image (doubled when upscaled) (Handled by the library)*/
|
||||
lv_coord_t h; /*Height of the image (doubled when upscaled) (Handled by the library)*/
|
||||
uint8_t src_type :2; /*See: lv_img_src_t*/
|
||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||
uint8_t transp :1; /*Transp. bit in the image header (Handled by the library)*/
|
||||
uint8_t alpha_byte :1; /*Extra byte for every pixel to define opacity*/
|
||||
uint8_t chroma_keyed :1; /*1: Chroma keyed image, LV_COLOR_TRANSP (lv_conf.h) pixels will be transparent (Handled by the library)*/
|
||||
uint8_t alpha_byte :1; /*1: Extra byte for every pixel to define opacity*/
|
||||
}lv_img_ext_t;
|
||||
|
||||
/**********************
|
||||
@@ -57,18 +56,17 @@ typedef struct
|
||||
*/
|
||||
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. LV_FS_RES_OK or any error from lv_fs_res_t
|
||||
*/
|
||||
lv_fs_res_t lv_img_create_file(const char * fn, const lv_color_int_t * data);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the pixel map to display by the image
|
||||
* @param img pointer to an image object
|
||||
* @param data the image data
|
||||
*/
|
||||
void lv_img_set_src(lv_obj_t * img, const void * src_img);
|
||||
|
||||
/**
|
||||
* Set a file to the image
|
||||
* @param img pointer to an image object
|
||||
@@ -98,6 +96,8 @@ static inline void lv_img_set_style(lv_obj_t *img, lv_style_t *style)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
lv_img_src_t lv_img_get_src_type(const void * src);
|
||||
|
||||
/**
|
||||
* Get the name of the file set for an image
|
||||
* @param img pointer to an image
|
||||
@@ -128,7 +128,7 @@ static inline lv_style_t* lv_img_get_style(lv_obj_t *img)
|
||||
**********************/
|
||||
|
||||
/*Use this macro to declare an image in a c file*/
|
||||
#define LV_IMG_DECLARE(var_name) extern const lv_color_int_t var_name[];
|
||||
#define LV_IMG_DECLARE(var_name) extern const lv_img_t var_name;
|
||||
|
||||
#endif /*USE_LV_IMG*/
|
||||
|
||||
|
||||
@@ -297,6 +297,8 @@ void lv_label_set_body_draw(lv_obj_t *label, bool body_en)
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
ext->body_draw = body_en == false ? 0 : 1;
|
||||
|
||||
lv_obj_refresh_ext_size(label);
|
||||
|
||||
lv_obj_invalidate(label);
|
||||
}
|
||||
|
||||
@@ -629,20 +631,29 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
/* A label never covers an area */
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_area_t cords;
|
||||
lv_area_t coords;
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
lv_obj_get_coords(label, &cords);
|
||||
lv_obj_get_coords(label, &coords);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(label);
|
||||
if(lv_group_get_focused(g) == label) {
|
||||
lv_draw_rect(&cords, mask, style);
|
||||
lv_draw_rect(&coords, mask, style);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
if(ext->body_draw) lv_draw_rect(&cords, mask, style);
|
||||
if(ext->body_draw) {
|
||||
lv_area_t bg;
|
||||
lv_obj_get_coords(label, &bg);
|
||||
bg.x1 -= style->body.padding.hor;
|
||||
bg.x2 += style->body.padding.hor;
|
||||
bg.y1 -= style->body.padding.ver;
|
||||
bg.y2 += style->body.padding.ver;
|
||||
|
||||
lv_draw_rect(&bg, mask, style);
|
||||
}
|
||||
|
||||
/*TEST: draw a background for the label*/
|
||||
// lv_draw_rect(&label->coords, mask, &lv_style_plain_color);
|
||||
@@ -653,7 +664,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
|
||||
lv_draw_label(&cords, mask, style, ext->text, flag, &ext->offset);
|
||||
lv_draw_label(&coords, mask, style, ext->text, flag, &ext->offset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -696,6 +707,13 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
if(ext->body_draw) {
|
||||
lv_style_t * style = lv_label_get_style(label);
|
||||
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.hor);
|
||||
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.ver);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action)
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
@@ -176,9 +176,9 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
|
||||
lv_obj_set_width(liste, w);
|
||||
#if USE_LV_IMG != 0
|
||||
lv_obj_t * img = NULL;
|
||||
if(img_fn != NULL && img_fn[0] != '\0') {
|
||||
if(img_src) {
|
||||
img = lv_img_create(liste, NULL);
|
||||
lv_img_set_file(img, img_fn);
|
||||
lv_img_set_src(img, img_src);
|
||||
lv_obj_set_style(img, ext->style_img);
|
||||
lv_obj_set_click(img, false);
|
||||
if(img_signal == NULL) img_signal = lv_obj_get_signal_func(img);
|
||||
|
||||
@@ -88,7 +88,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action);
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_action_t rel_action);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
|
||||
@@ -145,11 +145,11 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/**
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_path path of an image on the control button
|
||||
* @param img_src an image source ('lv_img_t' variable, path to file or a symbol)
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const char * img_path, lv_action_t rel_action)
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_action)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
@@ -161,7 +161,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const char * img_path, lv_action_t rel
|
||||
|
||||
lv_obj_t * img = lv_img_create(btn, NULL);
|
||||
lv_obj_set_click(img, false);
|
||||
lv_img_set_file(img, img_path);
|
||||
lv_img_set_src(img, img_src);
|
||||
|
||||
lv_win_realign(win);
|
||||
|
||||
|
||||
@@ -93,11 +93,11 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
/**
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_path path of an image on the control button
|
||||
* @param img_src an image source ('lv_img_t' variable, path to file or a symbol)
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const char * img_path, lv_action_t rel_action);
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_action);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
|
||||
Reference in New Issue
Block a user