卡片容器控件

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



用法

创建控件

开发者可以调用 gui_cardview_create(parent, name, x, y, w, h) 来创建卡片容器控件。

回调

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

设置风格

卡片容器控件有5种风格,开发者可以使用 gui_cardview_set_style(this, 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,
} T_SLIDE_STYLE;

设置中心对齐

开发者可以调用函数gui_cardview_alignment(this, align_hight)来设置卡片自动中心对齐。

设置底部间隔

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

y轴方向滑动回调

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

示例

请参考这一章节的实现:

card

API

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_animate(gui_cardview_t *_this, uint32_t dur, int repeat_count, void *callback, void *p)

set animate to cardview widget

参数:
  • o – widget object pointer

  • dur – Animation duration

  • repeat_count – Repeat play times, -1 means play on repeat forever

  • callback – animate frame callback

  • p – parameter

void gui_cardview_set_style(gui_cardview_t *this, T_SLIDE_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_hight)

automatic center alignment

参数:
  • this – widget pointer

  • align_hight

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

  • parameter

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

  • parameter

struct gui_cardview_t
#include <gui_cardview.h>

cardview structure

Public Members

gui_obj_t base
uint16_t height
uint16_t card_height
uint16_t total_cnt
uint16_t cur_id
T_SLIDE_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