/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../libs.h" /** Maximum number of breakpoints a grid can support */ #define GRID_BREAKPOINT_COUNT 4 /** 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; /** Callback to receive when a grid child is to be resized */ typedef void gridchildresizecallback_t( void *user, uint8_t i, float screenWidth, float screenHeight, float x, float y, float width, float height ); /** Definition of a grid child's breakpoint */ typedef struct { uint8_t columns; uint8_t rows; uint8_t x; uint8_t y; } gridchildbreakpoint_t; /** Definition of a grid child */ typedef struct { gridchildbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT]; uint8_t breakpointCount; } gridchild_t; /** 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; /** Child items of the grid */ gridchild_t children[GRID_CHILD_COUNT]; uint8_t childCount; /** Internal size reference, used for caching resize events */ float width; float height; /** Pointer to any custom user data */ void *user; /** Callback to listen for when children are resized */ gridchildresizecallback_t *onResize; } grid_t;