93 lines
2.5 KiB
C
93 lines
2.5 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include <dawn/dawn.h>
|
|
|
|
/**
|
|
* Initialize a grid system.
|
|
*
|
|
* @param grid Grid system to initialize.
|
|
*/
|
|
void gridInit(grid_t *grid);
|
|
|
|
/**
|
|
* Adds a breakpoint to a grid system.
|
|
*
|
|
* @param grid Grid to add to.
|
|
* @param width Screen dimension width of the breakpoint.
|
|
* @param rows How many rows at this breakpoint.
|
|
* @param columns How many columns at this breakpoint.
|
|
* @param gutterX Gutter X at this breakpoint.
|
|
* @param gutterY Gutter Y at this breakpoint.
|
|
* @return Index of the breakpoint within the grid.
|
|
*/
|
|
uint8_t gridAddBreakpoint(
|
|
grid_t *grid, float width,
|
|
uint8_t rows, uint8_t columns,
|
|
float gutterX, float gutterY
|
|
);
|
|
|
|
/**
|
|
* Add a child to the grid.
|
|
*
|
|
* @param grid Grid to add the child to.
|
|
* @return The grid child item that was added.
|
|
*/
|
|
gridchild_t * gridAddChild(grid_t *grid);
|
|
|
|
|
|
/**
|
|
* Add a breakpoint to a grid child.
|
|
*
|
|
* @param child Child to add the breakpoint to.
|
|
* @param x Column X position.
|
|
* @param y Row Y position.
|
|
* @param columns Count of columns this child will span.
|
|
* @param rows Count of rows this child will span.
|
|
* @return The index to the breakpoint in question.
|
|
*/
|
|
uint8_t gridChildAddBreakpoint(gridchild_t *child,
|
|
uint8_t x, uint8_t y, uint8_t columns, uint8_t rows
|
|
);
|
|
|
|
/**
|
|
* Get the breakpoint (index) from a grid and screen width.
|
|
*
|
|
* @param grid Grid to get from.
|
|
* @param screenWidth Screen width to use.
|
|
* @return Grid index.
|
|
*/
|
|
uint8_t gridGetBreakpoint(grid_t *grid, float screenWidth);
|
|
|
|
/**
|
|
* Retreive the breakpoint to use for a child. Takes missing breakpoints into
|
|
* consideration.
|
|
*
|
|
* @param child Child to get the breakpoint from.
|
|
* @param bp Breakpoint index to use.
|
|
* @return The childs matching breakpoint
|
|
*/
|
|
gridchildbreakpoint_t * gridChildGetBreakpoint(gridchild_t *child, uint8_t bp);
|
|
|
|
/**
|
|
* Set the size of a grid system. This will only update if it's found to be
|
|
* necessary.
|
|
*
|
|
* @param grid Grid system to resize.
|
|
* @param screenWidth Current screen width.
|
|
* @param screenHeight Current screen height.
|
|
* @param width Width of the grid itself, useful for nested grids.
|
|
* @param height Height of the grid itself, useful for nested grids.
|
|
* @param x X position of this grid (to offset children by).
|
|
* @param y Y position of this grid (to offset children by).
|
|
*/
|
|
void gridSetSize(grid_t *grid,
|
|
float screenWidth, float screenHeight,
|
|
float width, float height,
|
|
float x, float y
|
|
); |