网格

网格组件可以在网格视图中显示组件集。

用法

创建网格组件

开发者可以通过gui_grid_create(parent, x, y, row, col, gap, col, gap_row) 创建网格组件, 按照创建的顺序用控件填充网格。

设置网格样式

开发者可以使用gui_grid_style(grid, style) 进行设置样式,总共有以下两种样式。

/** @brief  support two style */
typedef enum
{
    GRID_CLASSIC,         //!< Evenly layout vertically and horizontally
    GRID_SCALE,           //!< scale by slide
} T_GUI_GRID_STYLE;

示例

经典样式

#include <gui_obj.h>
#include <gui_grid.h>
#include "gui_magic_img.h"
#include "root_image_hongkong/ui_resource.h"

void page_tb_grid(void *parent)
{
    void *array[] = {CLOCK_BIN, EMAIL_BIN, SPORT_BIN, SLEEP_BIN, MAP_BIN};
    gui_grid_t *grid = gui_grid_create(parent, 0, 0, 2, 3, 210, 100);
    gui_grid_style(grid, GRID_CLASSIC);
    for (size_t i = 0; i < 5; i++)
    {
        gui_img_creat_from_mem(grid, "1", array[i], 0, 0, 0, 0);
    }
}


API

Enums

enum T_GUI_GRID_STYLE

support two style

Values:

enumerator GRID_CLASSIC

Evenly layout vertically and horizontally.

enumerator GRID_SCALE

scale by slide

Functions

gui_grid_t *gui_grid_create(void *parent, int16_t x, int16_t y, int16_t row, int16_t col, uint16_t gap_col, uint16_t gap_row)

create a grid widget.

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

  • x – the X-axis coordinate.

  • y – the Y-axis coordinate.

  • row – Rows number.

  • col – Columns number.

  • gap_col – gap between two Columns.

  • gap_row – gap between two Rows.

返回:

return the widget object pointer Example usage

{
  void *array[] = {
      DOG40_BIN,
      DOG60_BIN,
      DOG80_BIN,
      DOG100_BIN,
      DOG120_BIN,
      DOG140_BIN,
      DOG160_BIN,
      DOG180_BIN,
      DOG200_BIN,
      DOG220_BIN,
      DOG240_BIN,};
  gui_grid_t *grid = gui_grid_create(&(app->screen), 100, 200, 7
                                     , 2, 30, 30);
  for (size_t i = 0; i < 6; i++)
  {
      gui_img_creat_from_mem(grid, "grid_image", array[i], 0, 0, 0, 0);
  }}

void gui_grid_style(gui_grid_t *grid, T_GUI_GRID_STYLE style)

config grid style

参数:
  • grid – grid wodget pointer

  • style – GRID_CLASSIC, GRID_SCALE Example usage

    {
      void *array[] = {
          DOG40_BIN,
          DOG60_BIN,
          DOG80_BIN,
          DOG100_BIN,
          DOG120_BIN,
          DOG140_BIN,
          DOG160_BIN,
          DOG180_BIN,
          DOG200_BIN,
          DOG220_BIN,
          DOG240_BIN,};
      gui_grid_t *grid = gui_grid_create(&(app->screen), 100, 200, 7
                                         , 2, 30, 30);
      gui_grid_style(grid, GRID_SCALE);
      for (size_t i = 0; i < 6; i++)
      {
          gui_img_creat_from_mem(grid, "grid_image", array[i], 0, 0, 0, 0);
      }}
    

struct gui_grid_t
#include <gui_grid.h>

Public Members

gui_obj_t base
int16_t row
int16_t col
uint16_t gap_col
uint16_t gap_row
uint16_t gap_col_scale
uint16_t gap_row_scale
float scale
int yold
int start_x
int start_y
int id_offset
int row_count
bool row_count_flag
bool col_count_flag
T_GUI_GRID_STYLE style
int col_count
int change_threshold