add multi language support system + lv_label_set_text_multi

This commit is contained in:
Gabor Kiss-Vamosi
2019-01-16 09:57:07 +01:00
parent 6d449962ff
commit d0f42c26cc
5 changed files with 145 additions and 5 deletions

View File

@@ -35,6 +35,7 @@
**********************/
static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
static void lang_set_core(lv_obj_t * obj);
static void refresh_childen_style(lv_obj_t * obj);
static void delete_children(lv_obj_t * obj);
static bool lv_obj_design(lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
@@ -48,6 +49,9 @@ static lv_obj_t * act_scr = NULL;
static lv_obj_t * top_layer = NULL;
static lv_obj_t * sys_layer = NULL;
static lv_ll_t scr_ll; /*Linked list of screens*/
#if USE_LV_MULTI_LANG
static uint8_t lang_act = 0;
#endif
/**********************
* MACROS
@@ -456,6 +460,33 @@ void lv_scr_load(lv_obj_t * scr)
lv_obj_invalidate(act_scr);
}
/*--------------
* Language
*--------------*/
/**
* Change the language
* @param lang_id the id of the
*/
void lv_lang_set(uint8_t lang_id)
{
#if USE_LV_MULTI_LANG
lang_act = lang_id;
lv_obj_t * i;
LL_READ(scr_ll, i) {
i->signal_func(i, LV_SIGNAL_LANG_CHG, NULL);
lang_set_core(i);
}
#else
LV_LOG_WARN("lv_lang_act: multiple languages are not enabled. See lv_conf.h USE_LV_MULTI_LANG ")
return 0;
#endif
}
/*--------------------
* Parent/children set
*--------------------*/
@@ -1287,6 +1318,24 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1
* Getter functions
*======================*/
/*--------------
* Language
*--------------*/
/**
* Return with ID of the currently selected language
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
*/
lv_obj_t * lv_lang_act(void)
{
#if USE_LV_MULTI_LANG
return lang_act;
#else
LV_LOG_WARN("lv_lang_act: multiple languages are not enabled. See lv_conf.h USE_LV_MULTI_LANG ")
return 0;
#endif
}
/*------------------
* Screen get
*-----------------*/
@@ -1891,6 +1940,20 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj)
}
/**
* Change the language of the children. (Called recursively)
* @param obj pointer to an object
*/
static void lang_set_core(lv_obj_t * obj)
{
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
i->signal_func(i, LV_SIGNAL_LANG_CHG, NULL);
lang_set_core(i);
}
}
/**
* Recursively refresh the style of the children. Go deeper until a not NULL style is found
* because the NULL styles are inherited from the parent

View File

@@ -90,6 +90,7 @@ enum
LV_SIGNAL_CORD_CHG,
LV_SIGNAL_STYLE_CHG,
LV_SIGNAL_REFR_EXT_SIZE,
LV_SIGNAL_LANG_CHG,
LV_SIGNAL_GET_TYPE,
_LV_SIGNAL_FEEDBACK_SECTION_START,
@@ -550,6 +551,16 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1
* Getter functions
*======================*/
/*--------------
* Language
*--------------*/
/**
* Return with ID of the currently selected language
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
*/
lv_obj_t * lv_lang_act(void);
/*------------------
* Screen get
*-----------------*/