diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index f73fb8f66..79c5162d5 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -386,6 +386,19 @@ void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t } } +/** + * Set the position of tab select buttons + * @param tabview pointer to a tan view object + * @param btns_pos which button position + */ +void lv_tabview_set_btns_pos(lv_obj_t *tabview, lv_tabview_btns_pos_t btns_pos) +{ + lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview); + + ext->btns_pos = btns_pos; + tabview_realign(tabview); +} + /*===================== * Getter functions *====================*/ @@ -491,6 +504,16 @@ lv_style_t * lv_tabview_get_style(lv_obj_t *tabview, lv_tabview_style_t type) return NULL; } +/** + * Get position of tab select buttons + * @param tabview pointer to a ab view object + */ +lv_tabview_btns_pos_t lv_tabview_get_btns_pos(lv_obj_t *tabview) +{ + lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview); + return ext->btns_pos; +} + /********************** * STATIC FUNCTIONS **********************/ @@ -754,7 +777,18 @@ static void tabview_realign(lv_obj_t * tabview) } lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns)); - lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + switch(ext->btns_pos) + { + case LV_TABVIEW_BTNS_POS_TOP: + lv_obj_align(ext->btns, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + break; + case LV_TABVIEW_BTNS_POS_BOTTOM: + lv_obj_align(ext->content, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_align(ext->btns, ext->content, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + break; + } + lv_obj_t * pages = lv_obj_get_child(ext->content, NULL); while(pages != NULL) { diff --git a/lv_objx/lv_tabview.h b/lv_objx/lv_tabview.h index e6e602cd4..ed955771a 100644 --- a/lv_objx/lv_tabview.h +++ b/lv_objx/lv_tabview.h @@ -57,6 +57,7 @@ typedef struct uint8_t slide_enable :1; /*1: enable horizontal sliding by touch pad*/ uint8_t draging :1; uint8_t drag_hor :1; + uint8_t btns_pos : 1; lv_tabview_action_t tab_load_action; }lv_tabview_ext_t; @@ -70,6 +71,11 @@ typedef enum { LV_TABVIEW_STYLE_BTN_TGL_PR, }lv_tabview_style_t; +typedef enum { + LV_TABVIEW_BTNS_POS_TOP, + LV_TABVIEW_BTNS_POS_BOTTOM, +} lv_tabview_btns_pos_t; + /********************** * GLOBAL PROTOTYPES **********************/ @@ -143,6 +149,13 @@ void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time); */ void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t *style); +/** + * Set the position of tab select buttons + * @param tabview pointer to a tan view object + * @param btns_pos which button position + */ +void lv_tabview_set_btns_pos(lv_obj_t *tabview, lv_tabview_btns_pos_t btns_pos); + /*===================== * Getter functions *====================*/ @@ -197,6 +210,12 @@ uint16_t lv_tabview_get_anim_time(lv_obj_t * tabview); */ lv_style_t * lv_tabview_get_style(lv_obj_t *tabview, lv_tabview_style_t type); +/** + * Get position of tab select buttons + * @param tabview pointer to a ab view object + */ +lv_tabview_btns_pos_t lv_tabview_get_btns_pos(lv_obj_t *tabview); + /********************** * MACROS