55 lines
2.6 KiB
C
55 lines
2.6 KiB
C
#ifndef PGPL_GUI_HELPERS_H
|
|
#define PGPL_GUI_HELPERS_H
|
|
|
|
#include <pgpl/gui/predef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* This function basically subtracts margin, border and padding from the
|
|
* max_width and max_height, and then return that through the width and height
|
|
* pointers. */
|
|
void pgpl_gui_widget_max_content_size(PGPL_GuiWidget *widget,
|
|
PGPL_GuiTheme *theme, double *width,
|
|
double *height, double max_width,
|
|
double max_height);
|
|
|
|
/* This function lets you configure a theme with just a base_color, which in
|
|
* this case is the brightest color that should be used (text, active), a font
|
|
* size for the content and a font. This will calculate the other colors,
|
|
* margin, border, padding and other font sizes based on those values. */
|
|
void pgpl_gui_theme_configure(PGPL_GuiTheme *theme, PGPL_Color base_color,
|
|
double content_font_size, PGPL_Font *font);
|
|
|
|
/* This will do a full render on a widget, it will account for it's offset, if
|
|
* it has a border or background, it's margin, border and padding sizes and also
|
|
* if it expands on the x and y axis. It then calls the widgets render function
|
|
* at the correct x and y offset. */
|
|
void pgpl_gui_widget_render_full(PGPL_GuiWidget *widget,
|
|
PGPL_Renderer *renderer, PGPL_GuiTheme *theme,
|
|
double x, double y, double max_width,
|
|
double max_height);
|
|
|
|
/* Checks if x and y lie within the visible bounds of a widget, accounting for
|
|
* margin, border and padding and returns true or false. */
|
|
bool pgpl_gui_widget_within_bounds(PGPL_GuiWidget *widget, PGPL_GuiTheme *theme,
|
|
double widget_x, double widget_y,
|
|
double max_width, double max_height,
|
|
double x, double y);
|
|
|
|
/* This configures all of the widget properties that should be configurable by
|
|
* the user. Check the PGPL_GuiWidget struct comment for more info. */
|
|
void pgpl_gui_widget_configure(PGPL_GuiWidget *widget, double offset_x,
|
|
double offset_y, bool expand_x, bool expand_y,
|
|
bool border, bool background,
|
|
PGPL_GuiFontSize font_size,
|
|
PGPL_GuiTheme *theme_override,
|
|
bool use_theme_override, bool ignore_margin,
|
|
bool ignore_border, bool ignore_padding);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|