lv_img multi lang fixes

This commit is contained in:
Gabor Kiss-Vamosi
2019-01-23 15:24:56 +01:00
parent 97b9fce748
commit 6cd62851bb
2 changed files with 32 additions and 0 deletions

View File

@@ -78,6 +78,9 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
ext->w = lv_obj_get_width(new_img);
ext->h = lv_obj_get_height(new_img);
ext->auto_size = 1;
#if USE_LV_MULTI_LANG
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
#endif
/*Init the new object*/
lv_obj_set_signal_func(new_img, lv_img_signal);
@@ -265,6 +268,21 @@ const char * lv_img_get_file_name(const lv_obj_t * img)
else return "";
}
/**
* Get the source ID of the image. (Used by the multi-language feature)
* @param img pointer to an image
* @return ID of the source
*/
uint16_t lv_img_get_text_lang(lv_obj_t * img)
{
#if USE_LV_MULTI_LANG
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
return ext->lang_txt_id;
#else
LV_LOG_WARN("lv_img_get_text_lang: multiple languages are not enabled. See lv_conf.h USE_LV_MULTI_LANG ")
return NULL;
#endif
}
/**
* Get the auto size enable attribute

View File

@@ -94,6 +94,13 @@ static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
(void) fn;
}
/**
* Set an ID which means a the same source but on different languages
* @param img pointer to an image object
* @param src_id ID of the source
*/
void lv_img_set_src_multi(lv_obj_t * img, uint32_t txt_id);
/**
* Enable the auto size feature.
* If enabled the object size will be same as the picture size.
@@ -141,6 +148,13 @@ const void * lv_img_get_src(lv_obj_t * img);
*/
const char * lv_img_get_file_name(const lv_obj_t * img);
/**
* Get the source ID of the image. (Used by the multi-language feature)
* @param img pointer to an image
* @return ID of the source
*/
uint16_t lv_img_get_text_lang(lv_obj_t * img);
/**
* Get the auto size enable attribute
* @param img pointer to an image