卡片容器 (Cardview)

卡片效果容器控件,可以嵌套卡片,可以通过滑动来切换卡片。



用法

创建控件

开发者可以调用 gui_cardview_create() 来创建卡片容器控件。

回调

当卡片容器的状态改变时,它会触发一个回调,开发者可以在回调函数 gui_cardview_status_cb() 来做想做的事情。

设置风格

卡片容器控件有5种风格,开发者可以使用 gui_cardview_set_style() 来设置风格。

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_cardview_alignment() 来设置卡片自动中心对齐。

设置底部间隔

开发者可以调用函数 gui_cardview_set_bottom_space() 来设置卡片的底部间隔。

y轴方向滑动回调

卡片容器在y轴方向滑动的事件可以添加相应的回调函数 gui_cardview_up()

示例

请参考该章节:卡片 (Card)

API

Enums

enum T_CARDVIEW_STYLE

Values:

enumerator CLASSIC
enumerator REDUCTION

Functions

gui_cardview_t *gui_cardview_create(void *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)

cardview create.

参数:
  • parent – the father widget it nested in.

  • name – this tab widget’s name.

  • x – the X-axis coordinate of the widget.

  • x – the Y-axis coordinate of the widget.

  • w – the width of the widget.

  • h – the hight of the widget.

返回:

gui_cardview_t*

void gui_cardview_set_style(gui_cardview_t *this, T_CARDVIEW_STYLE style)

set cardview style.

参数:
  • this – widget pointer.

  • style – refer to T_SLIDE_STYLE.

void gui_cardview_status_cb(gui_cardview_t *this, void (*cb)(gui_cardview_t *this))

listen to cardview’s event.

参数:
  • this – widget pointer.

  • cb – callback to be triggered.

void gui_cardview_alignment(gui_cardview_t *this, int align_height)

automatic center alignment.

参数:
  • this – widget pointer.

  • align_height – align height.

void gui_cardview_set_bottom_space(gui_cardview_t *this, uint8_t bottom_space)

set bottom_space.

参数:
  • this – widget pointer.

  • bottom_space – bottom_space_count.

void gui_cardview_up(gui_cardview_t *this, void *callback, void *parameter)

Add a callback function to the event of sliding the cardview upwards in the Y-axis direction.

参数:
  • this – widget pointer.

  • callback – callback to be triggered.

  • parameter – parameter of callback function.

void gui_cardview_down(gui_cardview_t *this, void *callback, void *parameter)

Add a callback function to the event of sliding the cardview downwards in the Y-axis direction.

参数:
  • this – widget pointer.

  • callback – callback to be triggered.

  • parameter – parameter of callback function.

struct gui_cardview_t

cardview structure

Public Members

gui_obj_t base
uint16_t height
uint16_t card_height
uint16_t total_cnt
uint16_t cur_id
T_CARDVIEW_STYLE style
int16_t hold_y
int16_t target_y
int16_t offset_y
int16_t speed
int16_t recode[5]
void (*status_cb)(struct gui_cardview *this)
gui_animate_t *animate
uint8_t checksum
uint8_t bottom_space_count
int yold
int target
int start_x
int start_y
int align_hight
int get_yend
bool release
bool press
bool gesture_flag
bool top_slide_only
uint8_t status