Cleaned up the grid code.
This commit is contained in:
@ -70,6 +70,8 @@
|
||||
|
||||
|
||||
// User Interface Objects
|
||||
#include "ui/grid.h"
|
||||
|
||||
#include "ui/frame.h"
|
||||
#include "ui/image.h"
|
||||
#include "ui/label.h"
|
||||
|
72
include/dawn/ui/grid.h
Normal file
72
include/dawn/ui/grid.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 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, int32_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;
|
||||
gridchildresizecallback_t *onResize;
|
||||
} gridchild_t;
|
||||
|
||||
/** Definitio of a grid */
|
||||
typedef struct {
|
||||
/** Breakpoints */
|
||||
gridbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT];
|
||||
breakpointsize_t breakpointSizes[GRID_BREAKPOINT_COUNT];
|
||||
uint8_t breakpointCount;
|
||||
|
||||
/** 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;
|
||||
float x;
|
||||
float y;
|
||||
|
||||
/** Pointer to any custom user data */
|
||||
void *user;
|
||||
} grid_t;
|
Reference in New Issue
Block a user