Grid

The Grid Widget allows a display widget set in a grid view.

Usage

Create Grid Widget

Use gui_grid_create() to create a grid widget. Populate the grid with widgets in the order they were created.

Set Grid Style

There are two styles in the grid widget gui_grid_style().

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

Example

Classic 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.

Parameters:
  • parent – The father widget the grid is nested in.

  • x – The X-axis coordinate.

  • y – The Y-axis coordinate.

  • row – Number of rows.

  • col – Number of columns.

  • gap_col – Gap between two columns.

  • gap_row – Gap between two rows.

Returns:

Return the grid widget pointer.

void gui_grid_style(gui_grid_t *grid, T_GUI_GRID_STYLE style)

Configure the grid style.

Parameters:
  • grid – The grid widget pointer.

  • style – The grid style (GRID_CLASSIC or GRID_SCALE).

struct gui_grid_t

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