1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/src/lv_widgets/lv_tabview.h

185 lines
4.6 KiB
C
Raw Normal View History

2017-08-23 14:24:34 +02:00
/**
* @file lv_tabview.h
2018-06-19 09:49:58 +02:00
*
2017-08-23 14:24:34 +02:00
*/
#ifndef LV_TABVIEW_H
#define LV_TABVIEW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
2017-08-23 14:24:34 +02:00
2020-02-15 00:33:26 +01:00
#if LV_USE_TABVIEW != 0
2017-08-23 14:24:34 +02:00
/*Testing of dependencies*/
#if LV_USE_BTNMATRIX == 0
#error "lv_tabview: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) "
2017-08-23 14:24:34 +02:00
#endif
#if LV_USE_PAGE == 0
#error "lv_tabview: lv_page is required. Enable it in lv_conf.h (LV_USE_PAGE 1) "
2017-08-23 14:24:34 +02:00
#endif
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
2020-02-14 22:04:00 +01:00
#include "../lv_widgets/lv_win.h"
#include "../lv_widgets/lv_page.h"
2017-08-23 14:24:34 +02:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
2019-06-27 18:07:26 -04:00
/** Position of tabview buttons. */
2019-09-19 14:58:07 +02:00
enum {
2020-03-09 15:19:23 +01:00
LV_TABVIEW_TAB_POS_NONE,
LV_TABVIEW_TAB_POS_TOP,
LV_TABVIEW_TAB_POS_BOTTOM,
LV_TABVIEW_TAB_POS_LEFT,
LV_TABVIEW_TAB_POS_RIGHT
2019-09-19 14:58:07 +02:00
};
2018-09-18 14:30:48 +02:00
typedef uint8_t lv_tabview_btns_pos_t;
2017-08-23 14:24:34 +02:00
/*Data of tab*/
2020-02-26 19:48:27 +01:00
typedef struct {
2018-06-19 09:49:58 +02:00
/*Ext. of ancestor*/
2017-08-23 14:24:34 +02:00
/*New data for this type */
lv_obj_t * btns;
2017-08-23 14:24:34 +02:00
lv_obj_t * indic;
lv_obj_t * content; /*A background page which holds tab's pages*/
2017-08-23 14:24:34 +02:00
const char ** tab_name_ptr;
2017-11-23 21:28:36 +01:00
lv_point_t point_last;
uint16_t tab_cur;
2017-08-23 14:24:34 +02:00
uint16_t tab_cnt;
#if LV_USE_ANIMATION
2017-10-30 17:11:56 +01:00
uint16_t anim_time;
#endif
2019-09-19 14:58:07 +02:00
lv_tabview_btns_pos_t btns_pos : 3;
2018-06-19 09:49:58 +02:00
} lv_tabview_ext_t;
2017-08-23 14:24:34 +02:00
2018-09-18 13:59:40 +02:00
enum {
LV_TABVIEW_PART_BG = LV_OBJ_PART_MAIN,
_LV_TABVIEW_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_LAST,
LV_TABVIEW_PART_BG_SCRL = _LV_OBJ_PART_REAL_LAST,
2020-01-18 23:34:34 +01:00
LV_TABVIEW_PART_TAB_BG,
2020-03-09 15:19:23 +01:00
LV_TABVIEW_PART_TAB_BTN,
2020-01-01 18:46:22 +01:00
LV_TABVIEW_PART_INDIC,
_LV_TABVIEW_PART_REAL_LAST,
2018-09-18 13:59:40 +02:00
};
2020-01-01 18:46:22 +01:00
typedef uint8_t lv_tabview_part_t;
2017-08-23 14:24:34 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a Tab view object
2017-08-23 14:24:34 +02:00
* @param par pointer to an object, it will be the parent of the new tab
* @param copy pointer to a tab object, if not NULL then the new object will be copied from it
* @return pointer to the created tab
*/
lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy);
2017-08-23 14:24:34 +02:00
/**
* Delete all children of the scrl object, without deleting scrl child.
* @param tabview pointer to an object
*/
void lv_tabview_clean(lv_obj_t * tabview);
/*======================
* Add/remove functions
*=====================*/
2017-08-23 14:24:34 +02:00
/**
* Add a new tab with the given name
* @param tabview pointer to Tab view object where to ass the new tab
* @param name the text on the tab button
* @return pointer to the created page object (lv_page). You can create your content here
2017-08-23 14:24:34 +02:00
*/
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name);
/*=====================
* Setter functions
*====================*/
2017-08-23 14:24:34 +02:00
/**
* Set a new tab
* @param tabview pointer to Tab view object
* @param id index of a tab to load
2019-06-11 13:51:14 +02:00
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
2017-08-23 14:24:34 +02:00
*/
2019-06-11 13:51:14 +02:00
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim);
2017-08-23 14:24:34 +02:00
/**
* Set the animation time of tab view when a new tab is loaded
* @param tabview pointer to Tab view object
2017-12-19 22:00:32 +01:00
* @param anim_time time of animation in milliseconds
*/
2017-12-19 22:00:32 +01:00
void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time);
/**
* Set the position of tab select buttons
* @param tabview pointer to a tab view object
* @param btns_pos which button position
*/
2019-04-04 07:15:40 +02:00
void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos);
/*=====================
* Getter functions
*====================*/
2017-08-23 14:24:34 +02:00
/**
* Get the index of the currently active tab
* @param tabview pointer to Tab view object
* @return the active tab index
*/
uint16_t lv_tabview_get_tab_act(const lv_obj_t * tabview);
2017-08-23 14:24:34 +02:00
/**
* Get the number of tabs
* @param tabview pointer to Tab view object
* @return tab count
*/
uint16_t lv_tabview_get_tab_count(const lv_obj_t * tabview);
2017-08-23 14:24:34 +02:00
/**
* Get the page (content area) of a tab
* @param tabview pointer to Tab view object
* @param id index of the tab (>= 0)
* @return pointer to page (lv_page) object
*/
lv_obj_t * lv_tabview_get_tab(const lv_obj_t * tabview, uint16_t id);
2017-08-23 14:24:34 +02:00
/**
* Get the animation time of tab view when a new tab is loaded
* @param tabview pointer to Tab view object
* @return time of animation in milliseconds
*/
uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview);
2017-08-23 14:24:34 +02:00
/**
* Get position of tab select buttons
* @param tabview pointer to a ab view object
*/
2019-04-04 07:15:40 +02:00
lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview);
2017-08-23 14:24:34 +02:00
/**********************
* MACROS
**********************/
2020-02-15 00:33:26 +01:00
#endif /*LV_USE_TABVIEW*/
2017-08-23 14:24:34 +02:00
#ifdef __cplusplus
} /* extern "C" */
#endif
2019-04-04 07:15:40 +02:00
#endif /*LV_TABVIEW_H*/