1 /** 2 * @file lv_tabview.h 3 * 4 */ 5 6 #ifndef LV_TABVIEW_H 7 #define LV_TABVIEW_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../lv_conf_internal.h" 17 18 #if LV_USE_TABVIEW != 0 19 20 /*Testing of dependencies*/ 21 #if LV_USE_BTNMATRIX == 0 22 #error "lv_tabview: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) " 23 #endif 24 25 #if LV_USE_PAGE == 0 26 #error "lv_tabview: lv_page is required. Enable it in lv_conf.h (LV_USE_PAGE 1) " 27 #endif 28 29 #include "../lv_core/lv_obj.h" 30 #include "../lv_widgets/lv_win.h" 31 #include "../lv_widgets/lv_page.h" 32 33 /********************* 34 * DEFINES 35 *********************/ 36 37 /********************** 38 * TYPEDEFS 39 **********************/ 40 41 /** Position of tabview buttons. */ 42 enum { 43 LV_TABVIEW_TAB_POS_NONE, 44 LV_TABVIEW_TAB_POS_TOP, 45 LV_TABVIEW_TAB_POS_BOTTOM, 46 LV_TABVIEW_TAB_POS_LEFT, 47 LV_TABVIEW_TAB_POS_RIGHT 48 }; 49 typedef uint8_t lv_tabview_btns_pos_t; 50 51 /*Data of tab*/ 52 typedef struct { 53 /*Ext. of ancestor*/ 54 /*New data for this type */ 55 lv_obj_t * btns; 56 lv_obj_t * indic; 57 lv_obj_t * content; /*A background page which holds tab's pages*/ 58 const char ** tab_name_ptr; 59 lv_point_t point_last; 60 uint16_t tab_cur; 61 uint16_t tab_cnt; 62 #if LV_USE_ANIMATION 63 uint16_t anim_time; 64 #endif 65 lv_tabview_btns_pos_t btns_pos : 3; 66 } lv_tabview_ext_t; 67 68 enum { 69 LV_TABVIEW_PART_BG = LV_OBJ_PART_MAIN, 70 _LV_TABVIEW_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_LAST, 71 72 LV_TABVIEW_PART_BG_SCRLLABLE = _LV_OBJ_PART_REAL_LAST, 73 LV_TABVIEW_PART_TAB_BG, 74 LV_TABVIEW_PART_TAB_BTN, 75 LV_TABVIEW_PART_INDIC, 76 _LV_TABVIEW_PART_REAL_LAST, 77 }; 78 typedef uint8_t lv_tabview_part_t; 79 80 /********************** 81 * GLOBAL PROTOTYPES 82 **********************/ 83 84 /** 85 * Create a Tab view object 86 * @param par pointer to an object, it will be the parent of the new tab 87 * @param copy pointer to a tab object, if not NULL then the new object will be copied from it 88 * @return pointer to the created tab 89 */ 90 lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy); 91 92 /*====================== 93 * Add/remove functions 94 *=====================*/ 95 96 /** 97 * Add a new tab with the given name 98 * @param tabview pointer to Tab view object where to ass the new tab 99 * @param name the text on the tab button 100 * @return pointer to the created page object (lv_page). You can create your content here 101 */ 102 lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name); 103 104 /** 105 * Delete all children of a tab created by `lv_tabview_add_tab`. 106 * @param tab pointer to a tab 107 */ 108 void lv_tabview_clean_tab(lv_obj_t * tab); 109 110 /*===================== 111 * Setter functions 112 *====================*/ 113 114 /** 115 * Set a new tab 116 * @param tabview pointer to Tab view object 117 * @param id index of a tab to load 118 * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 119 */ 120 void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim); 121 122 /** 123 * Set the name of a tab. 124 * @param tabview pointer to Tab view object 125 * @param id index of the tab the name should be set 126 * @param name new tab name 127 */ 128 void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name); 129 130 /** 131 * Set the animation time of tab view when a new tab is loaded 132 * @param tabview pointer to Tab view object 133 * @param anim_time time of animation in milliseconds 134 */ 135 void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time); 136 137 /** 138 * Set the position of tab select buttons 139 * @param tabview pointer to a tab view object 140 * @param btns_pos which button position 141 */ 142 void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos); 143 144 /*===================== 145 * Getter functions 146 *====================*/ 147 148 /** 149 * Get the index of the currently active tab 150 * @param tabview pointer to Tab view object 151 * @return the active tab index 152 */ 153 uint16_t lv_tabview_get_tab_act(const lv_obj_t * tabview); 154 155 /** 156 * Get the number of tabs 157 * @param tabview pointer to Tab view object 158 * @return tab count 159 */ 160 uint16_t lv_tabview_get_tab_count(const lv_obj_t * tabview); 161 /** 162 * Get the page (content area) of a tab 163 * @param tabview pointer to Tab view object 164 * @param id index of the tab (>= 0) 165 * @return pointer to page (lv_page) object 166 */ 167 lv_obj_t * lv_tabview_get_tab(const lv_obj_t * tabview, uint16_t id); 168 169 /** 170 * Get the animation time of tab view when a new tab is loaded 171 * @param tabview pointer to Tab view object 172 * @return time of animation in milliseconds 173 */ 174 uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview); 175 176 /** 177 * Get position of tab select buttons 178 * @param tabview pointer to a ab view object 179 */ 180 lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview); 181 182 /********************** 183 * MACROS 184 **********************/ 185 186 #endif /*LV_USE_TABVIEW*/ 187 188 #ifdef __cplusplus 189 } /* extern "C" */ 190 #endif 191 192 #endif /*LV_TABVIEW_H*/ 193