mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge pull request #1653 from mibcat/tabview-set-tab-name
widget tableview: add new function lv_tabview_set_tab_name() to change a tab name during runtime
This commit is contained in:
commit
abff805509
@ -25,6 +25,7 @@ Available in the `dev` branch
|
||||
- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes
|
||||
- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions
|
||||
- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions
|
||||
- Add `lv_tabview_set_tab_name()` function - used to change a tab's name
|
||||
|
||||
### Bugfixes
|
||||
- `tileview` fix navigation when not screen sized
|
||||
|
@ -448,6 +448,36 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
|
||||
lv_btnmatrix_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_CHECK_STATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of a tab.
|
||||
* @param tabview pointer to Tab view object
|
||||
* @param id index of the tab the name should be set
|
||||
* @param name new tab name
|
||||
*/
|
||||
void lv_tabview_set_tab_name(lv_obj_t *tabview, uint16_t id, char *name)
|
||||
{
|
||||
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||
|
||||
/* get tabview's ext pointer which contains the tab name pointer list */
|
||||
lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
/* check for valid tab index */
|
||||
if (ext->tab_cnt > id)
|
||||
{
|
||||
/* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */
|
||||
char *str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1);
|
||||
LV_ASSERT_MEM(str);
|
||||
|
||||
/* store new tab name at allocated memory */
|
||||
strcpy(str, name);
|
||||
/* update pointer */
|
||||
ext->tab_name_ptr[id] = str;
|
||||
|
||||
/* force redrawing of the tab headers */
|
||||
lv_obj_invalidate(ext->btns);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the animation time of tab view when a new tab is loaded
|
||||
* @param tabview pointer to Tab view object
|
||||
|
@ -119,6 +119,14 @@ void lv_tabview_clean_tab(lv_obj_t * tab);
|
||||
*/
|
||||
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim);
|
||||
|
||||
/**
|
||||
* Set the name of a tab.
|
||||
* @param tabview pointer to Tab view object
|
||||
* @param id index of the tab the name should be set
|
||||
* @param name new tab name
|
||||
*/
|
||||
void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name);
|
||||
|
||||
/**
|
||||
* Set the animation time of tab view when a new tab is loaded
|
||||
* @param tabview pointer to Tab view object
|
||||
|
Loading…
x
Reference in New Issue
Block a user