MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
mgdl-gui.h File Reference

MenuCreator class for simple Immediate Mode Gui. More...

#include "mgdl-types.h"
#include "mgdl-font.h"
#include "mgdl-color.h"

Go to the source code of this file.

Data Structures

struct  Menu
 Struct for holding the state of immeadiate mode gui menu. More...
 

Typedefs

typedef struct Menu Menu
 

Functions

void Menu_DrawCursor (void)
 Draws a cursor using the Default font and default values.
 
void _Menu_DrawCursorParams (short x, short y, short w, short h, Color4f *color)
 
void Menu_SetActive (Menu *menu)
 Set the menu to which the other functions are applied to.
 
void Menu_ReadDefaultInputs (void)
 reads the default cursor and mouse status into the gui system
 
MenuMenu_Create (Font *font, float textHeigh, float rowHeightEm)
 Creates a MenuCreator using font and parameters.
 
MenuMenu_CreateWindowed (Font *font, float textHeight, float rowHeightEm, short width, short height, const char *title)
 Creates a windowed menu.
 
MenuMenu_CreateDefault (void)
 Creates a MenuCreator using default font and settings.
 
void Menu_StartInput (short x, short y, short width, vec2 cursorPosition, bool buttonPress, bool buttonHeld)
 Starts the menu from given position and takes the input status.
 
void Menu_Start (short x, short y, short width)
 Starts the menu from given position and uses default inputs.
 
void Menu_SetColors (Color4f *bg, Color4f *text, Color4f *highlight)
 Sets the colors used in the menu.
 
void _Menu_TitleBar (void)
 Draws the window title bar.
 
void _Menu_Borders (void)
 Draws the window borders.
 
void Menu_Separator (void)
 Draws a line separating elements.
 
void Menu_Skip (short height)
 Leaves empty space for custom elements.
 
void Menu_Text (const char *text)
 Draws text.
 
void Menu_TextF (const char *format,...)
 Draws formatted text.
 
void Menu_Icon (IconSymbol icon, Color4f *color)
 Draws a colored icon.
 
bool Menu_Button (const char *text)
 Draws a button that can be clicked.
 
bool Menu_Toggle (const char *text, bool *valueRef)
 Draws a toggle that can be clicked.
 
void Menu_Flag (const char *text, bool enabled)
 Draws a text label with can be highlighted.
 
bool Menu_Slider (const char *text, float minValue, float maxValue, float *valueRef)
 Draws a slider that can be adjusted with mouse or by pressing buttons.
 

Detailed Description

MenuCreator class for simple Immediate Mode Gui.

This can be used to create simple menus with buttons and labels. Not much else yet. Added for version 0.100.0-muffintrap

Function Documentation

◆ Menu_Button()

bool Menu_Button ( const char *  text)

Draws a button that can be clicked.

Parameters
textText on the button.
Returns
True if the button was clicked.

◆ Menu_Create()

Menu * Menu_Create ( Font font,
float  textHeigh,
float  rowHeightEm 
)

Creates a MenuCreator using font and parameters.

Parameters
fontFont to use on the menu elements.
textHeightHeight of the text.
rowHeightEmHeight of the row relative to the text height. 1 Em is same as text height, 2 is twice etc. Controls the amount of padding above and below text on elements.
Returns
Menu struct that can be used to draw menus.

◆ Menu_CreateDefault()

Menu * Menu_CreateDefault ( void  )

Creates a MenuCreator using default font and settings.

Returns
Menu struct that can be used to draw menus.

◆ Menu_CreateWindowed()

Menu * Menu_CreateWindowed ( Font font,
float  textHeight,
float  rowHeightEm,
short  width,
short  height,
const char *  title 
)

Creates a windowed menu.

Parameters
fontFont to use on the menu elements.
textHeightHeight of the text.
rowHeightEmHeight of the row relative to the text height. 1 Em is same as text height, 2 is twice etc. Controls the amount of padding above and below text on elements.
Returns
Menu struct that can be used to draw menus.
Parameters
widthWidth of the window in pixels. -1 means automatic
heightHeight of the window in pixels. -1 means automatic
textTitle of the window.

◆ Menu_Flag()

void Menu_Flag ( const char *  text,
bool  enabled 
)

Draws a text label with can be highlighted.

Parameters
textText on the label.
enabledWhen true, the label uses highlight color

◆ Menu_Icon()

void Menu_Icon ( IconSymbol  icon,
Color4f color 
)

Draws a colored icon.

Parameters
iconThe icon to draw

◆ Menu_SetActive()

void Menu_SetActive ( Menu menu)

Set the menu to which the other functions are applied to.

Only one menu is drawn at one time, so using this function saves typing.

◆ Menu_SetColors()

void Menu_SetColors ( Color4f bg,
Color4f text,
Color4f highlight 
)

Sets the colors used in the menu.

Parameters
bgBackground color of labels and buttons.
textColor of the text.
highlightHighlight color to show hovered element.

◆ Menu_Skip()

void Menu_Skip ( short  height)

Leaves empty space for custom elements.

Parameters
heightHow much to move the position of next item downwards

◆ Menu_Slider()

bool Menu_Slider ( const char *  text,
float  minValue,
float  maxValue,
float *  valueRef 
)

Draws a slider that can be adjusted with mouse or by pressing buttons.

Parameters
textText on the slider.
minValueThe minimum value of the slider.
maxValueThe maximum value of the slider.
valueRefReference to the float value controlled by the slider.
Returns
True if the value was changed.

◆ Menu_Start()

void Menu_Start ( short  x,
short  y,
short  width 
)

Starts the menu from given position and uses default inputs.

This function sets up the menu state but does not draw anything yet. It uses the input status that was read when Menu_ReadDefaultInputs was last called. If the menu is windowed, the x and y only set the starting position

Parameters
xUpper left corner x of the first element.
yUpper left corner y of the first element.
widthWidth of the elements in the menu.

◆ Menu_StartInput()

void Menu_StartInput ( short  x,
short  y,
short  width,
vec2  cursorPosition,
bool  buttonPress,
bool  buttonHeld 
)

Starts the menu from given position and takes the input status.

This function sets up the menu state but does not draw anything yet. It requires the cursor position and button state.

Parameters
xUpper left corner x of the first element.
yUpper left corner y of the first element.
widthWidth of the elements in the menu.
cursorXcursorPosition Position of the cursor on the screen in pixels.
buttonPressIs the button pressed on this frame.

◆ Menu_Text()

void Menu_Text ( const char *  text)

Draws text.

Parameters
textText to be drawn.

◆ Menu_TextF()

void Menu_TextF ( const char *  format,
  ... 
)

Draws formatted text.

Parameters
textFormat string.
__VA_ARGS__Format parameters.

◆ Menu_Toggle()

bool Menu_Toggle ( const char *  text,
bool *  valueRef 
)

Draws a toggle that can be clicked.

Parameters
textText on the toggle.
valueRefPointer to the boolean controller by the toggle.
Returns
True if the toggle was clicked.