Dawn/src/display/ui/frame.h

67 lines
1.6 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../../libs.h"
#include "../shaderprogram.h"
#include "../primitive/primitive.h"
#include "../primitive/quad.h"
#include "../font.h"
/** Size of the border (in pixels) on each edge */
#define FRAME_BORDER_SIZE 16
/** Total border size for a given frame on each axis */
#define FRAME_BORDER_SIZE_FULL FRAME_BORDER_SIZE * 2
/** How many quads are within the frame */
#define FRAME_PRIMITIVE_COUNT 9
typedef struct {
texture_t *texture;
primitive_t primitive;
} frame_t;
/**
* Initialize a GUI Frame.
*
* @param frame Frame to initialize.
*/
void frameInit(frame_t *frame);
/**
* Set the size of the frame (including the size of the border).
*
* @param frame Frame to set the size of.
* @param width Width of the frame.
* @param height Height of the frame
*/
void frameSetSize(frame_t *frame, float width, float height);
/**
* Set the size of the frame's innards (size excluding the borders).
*
* @param frame Frame to set the size of
* @param width Width of the inner frame.
* @param height Height of the inner frame.
*/
void frameSetInnerSize(frame_t *frame, float width, float height);
/**
* Render a game frame.
*
* @param frame Frame to render.
* @param shader Shader to use while rendering.
* @param x X position.
* @param y Y position.
*/
void frameRender(frame_t *frame, shaderprogram_t *shader, float x, float y);
/**
* Cleanup a previously initialized frame.
*
* @param frame Frame to dispose.
*/
void frameDispose(frame_t *frame);