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

Returns:

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.

Parameters:
  • 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

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