页面 (Page)

页面控件是一个容器控件,可以让开发人员能够沿着y轴建立一个包含其他控件的页面。创建页面控件后,可以在该控件上添加其他的控件,如按钮控件,图片控件等等。页面控件可以超出屏幕显示边界,用户可以通过向上或向下滑动来访问添加到页面控件上的其他控件。

用法

创建页面控件

开发者可以使用 gui_page_create() 函数来创建一个页面控件。页面控件是一个垂直排列的容器,允许向其中添加其他控件。页面控件的高度由添加的控件数量决定,当添加的其他控件越多时,其高度也就越高。

示例

#include "root_image_hongkong/ui_resource.h"
#include <gui_img.h>
#include "gui_win.h"
#include "gui_text.h"
#include <draw_font.h>
#include "gui_button.h"
#include "gui_page.h"

extern void callback_prism(void *obj, gui_event_t e);

void page_tb_activity(void *parent)
{
    gui_img_create_from_mem(parent, "page1", ACTIVITY_BIN, 0, 0, 0, 0);
    gui_win_t *win_function = gui_win_create(parent, "win_function", 0, 0, 368, 448);
    gui_obj_add_event_cb(win_function, (gui_event_cb_t)callback_prism, GUI_EVENT_TOUCH_LONG, NULL);

    gui_page_t *pg1 = gui_page_create(parent, "page", 0, 0, 0, 0);

    gui_img_t *img1 = gui_img_create_from_mem(pg1, "img1", BUTTON1_BIN, 0, 150, 0, 0);
    gui_img_t *img2 = gui_img_create_from_mem(pg1, "img2", BUTTON2_BIN, 0, 230, 0, 0);
    gui_img_t *img3 = gui_img_create_from_mem(pg1, "img3", BUTTON3_BIN, 0, 300, 0, 0);
    gui_img_t *img4 = gui_img_create_from_mem(pg1, "img4", PLAYER_MUSIC_REWIND_ICON_BIN, 0, 380, 0, 0);
    gui_img_t *img5 = gui_img_create_from_mem(pg1, "img5", PLAYER_MUSIC_WIND_ICON_BIN, 0, 460, 0, 0);
}


API

Defines

GUI_PAGE_MAX_SPEED 60
GUI_PAGE_MIN_SPEED 7

Enums

enum T_PAGE_REBOUND_TYPE

Values:

enumerator PAGE_REBOUND_NOT
enumerator PAGE_REBOUND_UP
enumerator PAGE_REBOUND_DOWN

Functions

void gui_page_update(gui_obj_t *obj)

Update the page widget.

参数:

obj – Widget pointer.

void gui_page_destroy(gui_obj_t *obj)

Destroy the page widget.

参数:

obj – Widget pointer.

void gui_page_ctor(gui_page_t*, gui_obj_t *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)

Construct a page widget.

参数:
  • this – Widget pointer.

  • parent – The father widget the page nested in.

  • filename – The page widget name.

  • x – The X-axis coordinate.

  • x – The Y-axis coordinate.

  • w – The width.

  • h – The height.

gui_page_t *gui_page_create(void *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)

Create a page widget.

Example usage

{
     char* ptxt = "page_name";
     parent = (void *)gui_page_create(parent, ptxt, x, y, w, h);
}
参数:
  • parent – The father widget the page nested in.

  • filename – The page widget name.

  • x – The X-axis coordinate.

  • x – The Y-axis coordinate.

  • w – The width.

  • h – The height.

返回:

Return the widget object pointer.

gui_page_t *gui_page_create_horizontal(void *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)

Create a page widget horizontal.

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

  • filename – The page widget name.

  • x – The X-axis coordinate.

  • x – The Y-axis coordinate.

  • w – The width.

  • h – The height.

返回:

Return the widget object pointer.

void gui_page_add_scroll_bar(gui_page_t*, void *bar_pic, IMG_SOURCE_MODE_TYPE src_mode)

Add a scroll bar to the page widget.

参数:
  • this – Widget object pointer.

  • bar_pic – Bar picture address.

  • src_mode – Image source mode, 0 memory and 1 file system.

void gui_page_set_offset(gui_page_t*, int offset)

Set the page offset.

参数:
  • this – Widget object pointer.

  • offset – Page offset.

int gui_page_get_offset(gui_page_t*)

Get the page offset.

参数:

this – Widget object pointer.

返回:

Page offset.

void gui_page_set_animate(gui_page_t*, uint32_t dur, int repeat_count, void *callback, void *p)

Set animation for the page 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_page_rebound(gui_page_t*, bool rebound)

Configure rebound for the page widget.

参数:
  • this – Widget object pointer.

  • rebound – True: configure rebound; false: not rebound.

void gui_page_rebound_horizontal(gui_page_t*, bool rebound)

Configure horizontal rebound for the page widget.

参数:
  • this – Widget object pointer.

  • rebound – True: configure rebound; false: not rebound.

void gui_page_center_alignment(gui_page_t *page, int align_height)

Perform automatic center alignment for the page widget.

参数:
  • page – Widget pointer.

  • align_height – Page center aligned height.

void gui_page_set_only_top_slide(gui_page_t *page, bool flag)

Set the only top slide flag for the page widget.

参数:
  • page – Widget pointer.

  • flag – True: only top slide; false: all slide.

struct gui_page_t

PAGE widget structure.

Public Members

gui_obj_t base
uint32_t current_id
uint32_t widget_count
uint32_t width
int yold
int16_t recode[5]
int speed
int target
int start_x
int start_y
int align_hight
gui_img_t *scroll_bar
int get_yend
gui_animate_t *animate
void (*ctor)(struct gui_page*, gui_obj_t *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)
bool release
bool press
bool gesture_flag
bool top_slide_only
uint8_t status
IMG_SOURCE_MODE_TYPE src_mode
uint8_t checksum