选项卡容器 (Tabview)
选项卡容器控件 (Tabview) 是一个用于存储选项卡 (Tab) 的容器,并根据用户选择切换并显示不同的选项卡。如下图所示,每个矩形表示不同的选项卡控件,9个选项卡控件共同组成选项卡容器,其中蓝色区域代表当前显示区域。idx
表示X轴上的索引,idy
表示Y轴上的索引。

选项卡分布
用法
创建选项卡容器
使用 gui_tabview_create()
函数可以创建一个选项卡容器。
选项卡切换
在使用过程中,默认情况下选项卡页的切换一般是通过左右或者上下滑动进行,如果用户希望快速切换到某一个指定的选项卡页时,就需要使用 gui_tabview_jump_tab()
这个函数来实现。该函数可以实现跳转到指定选项卡页的功能,并通过 idx
和 idy
来指定选项卡页的位置。
设置选项卡切换风格
开发者可以使用 gui_tabview_set_style()
来设置所需的选项卡容器样式。默认情况下,使用的是经典样式 CLASSIC
。具体的切换风格请参考下列枚举:
typedef enum t_slide_style
{
CLASSIC = 0x0000,
REDUCTION = 0x0001,
FADE = 0x0002,
REDUCTION_FADE = 0x0003,
STACKING = 0x0004,
TAB_ROTATE = 0x0005,
TAB_CUBE = 0x0006,
TAB_PAGE = 0x0007,
TAB_ROTATE_BOOK = 0x0008,
} T_SLIDE_STYLE;
设置选项卡循环显示
选项卡容器循环功能是一项巧妙的特性,可以让用户轻松地遍历所有已创建的选项卡页。通过使用 gui_tabview_loop_x()
启用x反向的循环显示功能,gui_tabview_loop_y()
启用y反向的循环显示功能,如图a所示,可以看到蓝色的外框表示当前屏幕的可视选项卡控件。箭头的方向表示选项卡切换的方向。当向左滑动时,一旦所有选项卡都移至可见范围的左侧,再次左滑将从最左侧已创建的选项卡开始循环。相反,如图b所示,当再次向右滑动时,显示将从最右侧的选项卡开始循环。

图 a

图 b
示例
请参考该章节:选项卡 (Tab)
API
Enums
Functions
-
gui_tabview_t *gui_tabview_create(void *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)
-
Creates a tabview widget, which can nest tabs.
- 参数:
parent – The parent widget it is nested in.
filename – The tabview widget’s name.
x – The X-axis coordinate relative to the parent widget.
y – The Y-axis coordinate relative to the parent widget.
w – Width.
h – Height.
- 返回:
-
The widget object pointer.
-
void gui_tabview_jump_tab(gui_tabview_t *parent_tabview, int8_t idx, int8_t idy)
-
Jumps to a specified tab.
- 参数:
parent_tabview – Tabview pointer.
idx – Horizontal index value.
idy – Vertical index value.
-
void gui_tabview_set_style(gui_tabview_t *_this, T_SLIDE_STYLE style)
-
Configures the slide effect.
- 参数:
_this – Tabview pointer.
style – Refer to T_SLIDE_STYLE.
-
void gui_tabview_loop_x(gui_tabview_t *tabview, bool loop)
-
Configures the tabview loop_x sliding feature.
- 参数:
tabview – Tabview pointer.
loop – Loops when set to true, does not loop when set to false.
-
void gui_tabview_loop_y(gui_tabview_t *tabview, bool loop)
-
Configures the tabview loop_y sliding feature.
- 参数:
tabview – Tabview pointer.
loop – Loops when set to true, does not loop when set to false.
-
void gui_tabview_tp_disable(gui_tabview_t *tabview, bool disable_tp)
-
Disables touchpad action for the tabview.
- 参数:
tabview – Tabview pointer.
disable_tp – True to disable touchpad action, false to enable it.
-
void gui_tabview_enable_pre_load(gui_tabview_t *_this, bool enable)
-
Enables or disables tab widget cache.
- 参数:
_this – Tabview pointer.
enable – True to enable tab widget cache, false to disable it.
-
void gui_tabview_tab_change(gui_tabview_t *tabview, void *callback, void *parameter)
-
Registers a callback for tab change.
- 参数:
tabview – Tabview pointer.
callback – Callback function.
parameter – Callback parameter.
-
struct gui_tabview_tab_id_t
-
struct gui_index_t
-
struct gui_jump_t
-
struct gui_tabview_t
-
Tabview structure.
Public Members
-
gui_obj_t base
-
uint16_t tab_cnt
-
int8_t tab_cnt_left
-
int8_t tab_cnt_right
-
int8_t tab_cnt_up
-
int8_t tab_cnt_down
-
gui_tabview_tab_id_t cur_id
-
gui_tabview_tab_id_t last_id
-
gui_jump_t jump
-
T_SLIDE_STYLE style
-
int16_t release_x
-
int16_t release_y
-
uint8_t loop_x
-
uint8_t loop_y
-
bool enable_pre_load
-
bool tab_change_ready
-
bool tab_need_pre_load
-
bool tp_disable
-
bool initial
-
uint8_t *left_shot
-
uint8_t *center_shot
-
uint8_t *right_shot
-
uint8_t checksum
-
gui_obj_t base