1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

Merge pull request #159 from BenArtes/btns_pos

Add btns_pos to ext_attr w/ get + set functions and TOP / BOTTOM impl.
This commit is contained in:
Gabor Kiss-Vamosi 2018-06-07 15:44:56 +02:00 committed by GitHub
commit f9f542e7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 1 deletions

View File

@ -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) {

View File

@ -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