Moved some code around.
This commit is contained in:
@@ -8,68 +8,33 @@
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
|
||||
/** Maximum number of breakpoints a grid can support */
|
||||
#define GRID_BREAKPOINT_COUNT 4
|
||||
/** Maximum number of columns a grid can have */
|
||||
#define GRID_COLUMN_COUNT_MAX 16
|
||||
/** Maximum number of rows a grid can have */
|
||||
#define GRID_ROW_COUNT_MAX GRID_COLUMN_COUNT_MAX
|
||||
|
||||
/** Max number of children that a grid can support */
|
||||
#define GRID_CHILD_COUNT 32
|
||||
|
||||
/** Definition of a breakpoint */
|
||||
typedef struct {
|
||||
float width;
|
||||
} breakpointsize_t;
|
||||
|
||||
/** Definition of a grid breakpoint */
|
||||
typedef struct {
|
||||
uint8_t rows;
|
||||
uint8_t columns;
|
||||
float gutterX;
|
||||
float gutterY;
|
||||
} gridbreakpoint_t;
|
||||
|
||||
/** Definition of a grid child's breakpoint */
|
||||
typedef struct {
|
||||
uint8_t columns;
|
||||
uint8_t rows;
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} gridchildbreakpoint_t;
|
||||
|
||||
/** Callback to receive when a grid child is to be resized */
|
||||
typedef void gridchildresizecallback_t(
|
||||
void *user, uint8_t i, gridchildbreakpoint_t *breakpoint,
|
||||
float screenWidth, float screenHeight,
|
||||
float x, float y,
|
||||
float width, float height
|
||||
);
|
||||
|
||||
/** Definition of a grid child */
|
||||
typedef struct {
|
||||
gridchildbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT];
|
||||
uint8_t breakpointCount;
|
||||
} gridchild_t;
|
||||
/** Cell size for "auto", basically to fill the remaining space evenly */
|
||||
#define GRID_CEL_SIZE_AUTO -1
|
||||
|
||||
/** Definitio of a grid */
|
||||
typedef struct {
|
||||
/** Breakpoints */
|
||||
gridbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT];
|
||||
breakpointsize_t breakpointSizes[GRID_BREAKPOINT_COUNT];
|
||||
uint8_t breakpointCount;
|
||||
uint8_t breakpointCurrent;
|
||||
/** Count of columns/rows in the grid */
|
||||
uint8_t columns, rows;
|
||||
|
||||
/** Child items of the grid */
|
||||
gridchild_t children[GRID_CHILD_COUNT];
|
||||
uint8_t childCount;
|
||||
/** Cell Definitions, used to control how the cells will size themselves */
|
||||
float columnDefinitions[GRID_COLUMN_COUNT_MAX];
|
||||
float rowDefinitions[GRID_COLUMN_COUNT_MAX];
|
||||
|
||||
/** Settings to control gutters (space between cells) and border (of grid) */
|
||||
float gutterX, gutterY;
|
||||
float borderX, borderY;
|
||||
|
||||
/** Internal size reference, used for caching resize events */
|
||||
float width;
|
||||
float height;
|
||||
float x;
|
||||
float y;
|
||||
/** Calculated sizes and positions for each cell */
|
||||
float columnSizes[GRID_COLUMN_COUNT_MAX];
|
||||
float columnPositions[GRID_COLUMN_COUNT_MAX];
|
||||
float rowSizes[GRID_ROW_COUNT_MAX];
|
||||
float rowPositions[GRID_COLUMN_COUNT_MAX];
|
||||
|
||||
/** Pointer to any custom user data */
|
||||
void *user;
|
||||
|
||||
/** Callback to listen for when children are resized */
|
||||
gridchildresizecallback_t *onResize;
|
||||
/** Cached size of the grid */
|
||||
float width, height;
|
||||
} grid_t;
|
Reference in New Issue
Block a user