maug
Quick and dirty C mini-augmentation library.
|
Tools for drawing interactive GUI elements in a RetroFlat program. More...
Topics | |
RetroGUI Overrideable Config | |
Options to configure RetroGUI behavior defined at compile time. | |
RetroGUI Controls | |
Files | |
file | retrogui.h |
Data Structures | |
struct | RETROGUI |
Macros | |
#define | RETROGUI_TRACE_LVL 0 |
#define | RETROGUI_FLAGS_DIRTY 0x01 |
RETROGUI::flags indicating controls should be redrawn. | |
#define | RETROGUI_FLAGS_FONT_OWNED 0x02 |
RETROGUI::flags indicating GUI font is owned by this RETROGUI and can/will be freed by retrogui_destroy(). | |
#define | RETROGUI_FILLBAR_FLAG_SHOWNUM 0x02 |
#define | _retrogui_copy_str(field, src_str, dest_ctl, str_tmp, str_sz) |
#define | RETROGUI_IDC_NONE 0 |
#define | retrogui_focus_next(gui) |
#define | retrogui_focus_prev(gui) |
#define | RETROGUI_CTL_TABLE_CONSTS(idx, c_name, c_fields) |
Typedefs | |
typedef int16_t | retrogui_idc_t |
Unique identifying constant number for controls. | |
typedef void(* | retrogui_xy_cb) (retroflat_pxxy_t *x, retroflat_pxxy_t *y, void *data) |
Functions | |
MERROR_RETVAL | retrogui_push_listbox_item (struct RETROGUI *gui, retrogui_idc_t idc, const char *item, size_t item_sz) |
retrogui_idc_t | retrogui_poll_ctls (struct RETROGUI *gui, RETROFLAT_IN_KEY *p_input, struct RETROFLAT_INPUT *input_evt) |
Poll for the last clicked control and maintain listboxes and menus. | |
MERROR_RETVAL | retrogui_redraw_ctls (struct RETROGUI *gui) |
MERROR_RETVAL | retrogui_sz_ctl (struct RETROGUI *gui, retrogui_idc_t idc, retroflat_pxxy_t *p_w, retroflat_pxxy_t *p_h, retroflat_pxxy_t max_w, retroflat_pxxy_t max_h) |
MERROR_RETVAL | retrogui_pos_ctl (struct RETROGUI *gui, retrogui_idc_t idc, retroflat_pxxy_t x, retroflat_pxxy_t y, retroflat_pxxy_t w, retroflat_pxxy_t h) |
MERROR_RETVAL | retrogui_push_ctl (struct RETROGUI *gui, union RETROGUI_CTL *ctl) |
MERROR_RETVAL | retrogui_set_font (struct RETROGUI *gui, const char *font_path) |
Load the RetroFont API for the given RETROGUI to draw its controls with. Use RetroGXCache API if available. | |
MERROR_RETVAL | retrogui_get_ctl_text (struct RETROGUI *gui, retrogui_idc_t idc, char *buffer, size_t buffer_sz) |
ssize_t | retrogui_get_ctl_sel_idx (struct RETROGUI *gui, retrogui_idc_t idc) |
MERROR_RETVAL | retrogui_set_ctl_text (struct RETROGUI *gui, retrogui_idc_t idc, size_t buffer_sz, const char *fmt,...) |
MERROR_RETVAL | retrogui_set_ctl_image (struct RETROGUI *gui, retrogui_idc_t idc, const char *path, uint8_t flags) |
Set the image displayed by an IMAGE-type RETROGUI_CTL. | |
MERROR_RETVAL | retrogui_set_ctl_level (struct RETROGUI *gui, retrogui_idc_t idc, uint16_t level, uint16_t max, uint8_t flags) |
Set the current progress level displayed by a FILLBAR-type RETROGUI_CTL. | |
MERROR_RETVAL | retrogui_init_ctl (union RETROGUI_CTL *ctl, uint8_t type, size_t idc) |
retrogui_idc_t | retrogui_focus_iter (struct RETROGUI *gui, size_t start, ssize_t incr) |
Increment RETROGUI::focus, skipping elements that cannot hold focus. | |
MERROR_RETVAL | retrogui_init (struct RETROGUI *gui) |
Prepare a RETROGUI controller for use. | |
MERROR_RETVAL | retrogui_remove_ctl (struct RETROGUI *gui, retrogui_idc_t idc) |
Remove a control with the given unique identifier index from the given RETROGUI controller. | |
MERROR_RETVAL | retrogui_destroy (struct RETROGUI *gui) |
Free memory held by a RETROGUI controller internally and clean up any subordinate controls. | |
Tools for drawing interactive GUI elements in a RetroFlat program.
This library works well with the RetroFlat Window API.
/ * These are arbitrary; they only must be unique! * / # define EXAMPLE_IDC_LABEL 10 # define EXAMPLE_IDC_BUTTON 20 # define EXAMPLE_IDC_FILLBAR 30 / * Insert the label control. * / retrogui_init_ctl( &ctl, RETROGUI_CTL_TYPE_LABEL, EXAMPLE_IDC_LABEL ); ctl.base.x = 10; ctl.base.y = 10; ctl.base.w = 100; ctl.base.h = 20; ctl.base.fg_color = RETROFLAT_COLOR_WHITE; ctl.BUTTON.label = "Example\nLabel"; ctl.BUTTON.label_sz = maug_strlen( ctl.BUTTON.label ); retval = retrogui_push_ctl( gui_p, &ctl ); maug_cleanup_if_not_ok(); / * Insert the button control. * / retrogui_init_ctl( &ctl, RETROGUI_CTL_TYPE_BUTTON, EXAMPLE_IDC_BUTTON ); ctl.base.x = 10; ctl.base.y = 40; ctl.base.w = 60; ctl.base.h = 20; ctl.BUTTON.label = "Test"; ctl.BUTTON.label_sz = maug_strlen( ctl.BUTTON.label ); retval = retrogui_push_ctl( gui_p, &ctl ); maug_cleanup_if_not_ok(); / * Insert the fillbar control. * / retrogui_init_ctl( &ctl, RETROGUI_CTL_TYPE_FILLBAR, EXAMPLE_IDC_FILLBAR ); ctl.base.x = 10; ctl.base.y = 70; ctl.base.w = 100; ctl.base.h = 10; ctl.base.bg_color = RETROFLAT_COLOR_BLACK; ctl.base.fg_color = RETROFLAT_COLOR_RED; retval = retrogui_push_ctl( gui_p, &ctl ); maug_cleanup_if_not_ok(); / * Set the level of the inserted fillbar to 50%. * / retval = retrogui_set_ctl_level( gui_p, EXAMPLE_IDC_FILLBAR, 50, 100, 0 );
#define _retrogui_copy_str | ( | field, | |
src_str, | |||
dest_ctl, | |||
str_tmp, | |||
str_sz ) |
#define RETROGUI_CTL_TABLE_CONSTS | ( | idx, | |
c_name, | |||
c_fields ) |
#define retrogui_focus_next | ( | gui | ) |
#define retrogui_focus_prev | ( | gui | ) |
|
Free memory held by a RETROGUI controller internally and clean up any subordinate controls.
|
Increment RETROGUI::focus, skipping elements that cannot hold focus.
start | Value to start from, either 0 for the first element or ctl_count - 1 for the last. |
incr | 1 or -1, depending on whether to increment forwards or backwards. |
|
Prepare a RETROGUI controller for use.
gui | Pointer to a RETROGUI struct to initialize. |
retrogui_idc_t retrogui_poll_ctls | ( | struct RETROGUI * | gui, |
RETROFLAT_IN_KEY * | p_input, | ||
struct RETROFLAT_INPUT * | input_evt ) |
Poll for the last clicked control and maintain listboxes and menus.
input | Input integer returned from retroflat_poll_input(). |
input_evt | RETROFLAT_INPUT initialized by retroflat_poll_input(). |
|
Remove a control with the given unique identifier index from the given RETROGUI controller.
gui | Pointer to a RETROGUI struct to remove a control from. |
idc | Unique identifier index of the control to remove. |
MERROR_RETVAL retrogui_set_ctl_image | ( | struct RETROGUI * | gui, |
retrogui_idc_t | idc, | ||
const char * | path, | ||
uint8_t | flags ) |
Set the image displayed by an IMAGE-type RETROGUI_CTL.
idc | Unique identifier index of the control to adjust. |
path | Filesystem path to pass to retroflat_load_bitmap(). |
flags | Flags from the RetroFlat Drawing API to pass to retroflat_load_bitmap(). |
MERROR_RETVAL retrogui_set_ctl_level | ( | struct RETROGUI * | gui, |
retrogui_idc_t | idc, | ||
uint16_t | level, | ||
uint16_t | max, | ||
uint8_t | flags ) |
Set the current progress level displayed by a FILLBAR-type RETROGUI_CTL.
idc | Unique identifier index of the control to adjust. |
level | Numeric value out of the max param (e.g. 50 for half if max is 100). |
max | The maximum possible value. |
MERROR_RETVAL retrogui_set_font | ( | struct RETROGUI * | gui, |
const char * | font_path ) |
Load the RetroFont API for the given RETROGUI to draw its controls with. Use RetroGXCache API if available.
Fonts loaded with this function will be automatically freed by calling retrogui_destroy() on this RETROGUI.