AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Macros | Functions
gui_widgets.c File Reference

Implementations of modular, state-retaining GUI drawing widgets. More...

#include "gui_widgets.h"
#include <string.h>

Macros

#define GR_WHITE   ((GrColor){255,255,255,255})
 

Functions

static GrColor Gc (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 Constructs a GrColor value. More...
 
int Gr_DrawButton (GrRect bounds, const char *label, int enabled)
 Renders a custom clickable button. More...
 
int Gr_DrawRadioButton (float x, float y, int selected, const char *label)
 Renders a standard circular radio button with associated text label. More...
 
void Gr_DrawTextInBox (GrRect bounds, const char *text, int font_size, GrColor color)
 Utility helper to draw text aligned within a bounding box. More...
 
int Gr_DrawTextBox (GrRect bounds, char *text, size_t cap, int active, const char *placeholder)
 Renders an interactive input text box. More...
 
int Gr_DrawCustomSwitch (float x, float y, float w, float h, int active, const char *label)
 Draws a slide switch toggle. More...
 
int Gr_DrawSegmentedControl (GrRect bounds, const char *opts[], int count, int selected)
 Renders a segmented selector bar containing multiple text labels. More...
 
int Gr_DrawCustomDropdown (GrRect bounds, const char *label, const char *items[], int count, int *selected, int *open)
 Draws a custom drop-down menu selection modal. More...
 
int Gr_DrawCustomDropdownScrollable (GrRect bounds, const char *label, const char *items[], int count, int *selected, int *open, int *scroll, int max_visible)
 Extended custom dropdown featuring scrollbars for long list selections. More...
 

Detailed Description

Implementations of modular, state-retaining GUI drawing widgets.

Macro Definition Documentation

◆ GR_WHITE

#define GR_WHITE   ((GrColor){255,255,255,255})

Function Documentation

◆ Gc()

static GrColor Gc ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a 
)
static

Constructs a GrColor value.

Parameters
rRed channel.
gGreen channel.
bBlue channel.
aAlpha channel.
Returns
Constructed GrColor struct.

◆ Gr_DrawButton()

int Gr_DrawButton ( GrRect  bounds,
const char *  label,
int  enabled 
)

Renders a custom clickable button.

Parameters
boundsButton position and size.
labelText printed on the button.
enabled1 to allow clicks, 0 to draw grayed out and ignore input.
Returns
1 if the button was clicked during this frame; 0 otherwise.

◆ Gr_DrawCustomDropdown()

int Gr_DrawCustomDropdown ( GrRect  bounds,
const char *  label,
const char *  items[],
int  count,
int *  selected,
int *  open 
)

Draws a custom drop-down menu selection modal.

Parameters
boundsOuter selector box boundaries.
labelDisplay text of the active selection when closed.
itemsArray of options to display when expanded.
countNumber of items in array.
selectedPointer to selection index value (mutated in place).
openPointer to boolean toggle tracking expansion state (mutated in place).
Returns
1 if selection changed; 0 otherwise.

◆ Gr_DrawCustomDropdownScrollable()

int Gr_DrawCustomDropdownScrollable ( GrRect  bounds,
const char *  label,
const char *  items[],
int  count,
int *  selected,
int *  open,
int *  scroll,
int  max_visible 
)

Extended custom dropdown featuring scrollbars for long list selections.

Parameters
boundsOuter selector box boundaries.
labelDisplay text of the active selection when closed.
itemsArray of options to display when expanded.
countNumber of items in array.
selectedPointer to selection index value (mutated in place).
openPointer to boolean toggle tracking expansion state (mutated in place).
scrollPointer to scroll offset value (mutated in place).
max_visibleMaximum items to draw before triggering scrollbars.
Returns
1 if selection changed; 0 otherwise.

◆ Gr_DrawCustomSwitch()

int Gr_DrawCustomSwitch ( float  x,
float  y,
float  w,
float  h,
int  active,
const char *  label 
)

Draws a slide switch toggle.

Parameters
xLeft coordinate.
yTop coordinate.
wWidth.
hHeight.
active1 if switch is turned on, 0 if turned off.
labelToggle description label.
Returns
1 if switch state was toggled during this frame; 0 otherwise.

◆ Gr_DrawRadioButton()

int Gr_DrawRadioButton ( float  x,
float  y,
int  selected,
const char *  label 
)

Renders a standard circular radio button with associated text label.

Parameters
xHorizontal center coordinate.
yVertical center coordinate.
selected1 if active, 0 otherwise.
labelText printed next to the radio button.
Returns
1 if the radio button was clicked during this frame; 0 otherwise.

◆ Gr_DrawSegmentedControl()

int Gr_DrawSegmentedControl ( GrRect  bounds,
const char *  opts[],
int  count,
int  selected 
)

Renders a segmented selector bar containing multiple text labels.

Parameters
boundsSegment container boundaries.
optsArray of label strings representing selectable segments.
countNumber of options.
selectedCurrently active selection index.
Returns
Newly selected segment index, or the original index if no change occurred.

◆ Gr_DrawTextBox()

int Gr_DrawTextBox ( GrRect  bounds,
char *  text,
size_t  cap,
int  active,
const char *  placeholder 
)

Renders an interactive input text box.

Parameters
boundsText box coordinates.
textBuffer storing active characters (mutated in place).
capMaximum capacity of the text buffer.
active1 if text box has keyboard focus, 0 otherwise.
placeholderText displayed when the buffer is empty.
Returns
1 if keyboard focus state changed or text was edited; 0 otherwise.

◆ Gr_DrawTextInBox()

void Gr_DrawTextInBox ( GrRect  bounds,
const char *  text,
int  font_size,
GrColor  color 
)

Utility helper to draw text aligned within a bounding box.

Parameters
boundsOuter bounding rectangle.
textMessage to draw.
font_sizeHeight of font characters in pixels.
colorText color.