Skip to content

Interface

Functions

Add Column

Adds a column to the current layout with width width. - Positive values of width just specify the width in pixels. - 0 means use the default control width - not always a good choice. - Negative values specify filling to the right until width + 1 pixels away from the edge. - e.g -1 fills entirely to the right, while -20 leaves a 19 pixel gap on the right.

Parameters:

NameTypeDescription
widthIntegerWidth of the column in pixels

Signatures:

void add_column(int width)

Add Column Relative

Adds a column to the current layout with width width percentage of the container’s width.

Parameters:

NameTypeDescription
widthDoublePercentage of the container’s width (between 0 and 1)

Signatures:

void add_column_relative(double width)

Bitmap Button

Bitmap Button

Creates a button with a bitmap in it, and no label. Returns whether the button was clicked.

Parameters:

NameTypeDescription
bmpBitmapThe bitmap to show inside the button

Return Type: Boolean

Signatures:

bool bitmap_button(bitmap bmp)

Bitmap Button

Creates a button with a bitmap in it at a specific position on screen. Returns whether the button was clicked.

Parameters:

NameTypeDescription
bmpBitmapThe bitmap to show inside the button
rectRectangleThe rectangle to display the button in

Return Type: Boolean

Signatures:

bool bitmap_button(bitmap bmp, const rectangle &rect)

Bitmap Button

Creates a button with a bitmap in it at a specific position on screen. Returns whether the button was clicked.

Parameters:

NameTypeDescription
bmpBitmapThe bitmap to show inside the button
rectRectangleThe rectangle to display the button in
optsDrawing OptionsThe drawing options

Return Type: Boolean

Signatures:

bool bitmap_button(bitmap bmp, const rectangle &rect, drawing_options opts)

Bitmap Button

Creates a button with a bitmap in it, and no label. Returns whether the button was clicked.

Parameters:

NameTypeDescription
bmpBitmapThe bitmap to show inside the button
optsDrawing OptionsThe drawing options

Return Type: Boolean

Signatures:

bool bitmap_button(bitmap bmp, drawing_options opts)

Bitmap Button

Creates a button with a bitmap in it and a label. Returns whether the button was clicked.

Parameters:

NameTypeDescription
labelStringThe label to show in front of the button
bmpBitmapThe bitmap to show inside the button

Return Type: Boolean

Signatures:

bool bitmap_button(const string &label, bitmap bmp)

Bitmap Button

Creates a button with a bitmap in it and a label. Returns whether the button was clicked.

Parameters:

NameTypeDescription
labelStringThe label to show in front of the button
bmpBitmapThe bitmap to show inside the button
optsDrawing OptionsThe drawing options

Return Type: Boolean

Signatures:

bool bitmap_button(const string &label, bitmap bmp, drawing_options opts)

Button

Button

Creates a button at a specific position on screen. Returns whether the button was clicked.

Parameters:

NameTypeDescription
textStringThe text to show inside the button
rectRectangleThe rectangle to display the button in

Return Type: Boolean

Signatures:

bool button(const string &text, const rectangle &rect)

Button

Creates a button without a label. Returns whether the button was clicked.

Parameters:

NameTypeDescription
textStringThe text to show inside the button

Return Type: Boolean

Signatures:

bool button(const string &text)

Button

Creates a button with a label. Returns whether the button was clicked. Example usage: c++ // Test if clicked: if (button("Button 1", "Click me!")) { // do stuff.. }

Parameters:

NameTypeDescription
labelStringThe label to show in front of the button
textStringThe text to show inside the button

Return Type: Boolean

Signatures:

bool button(const string &label, const string &text)

Checkbox

Checkbox

Creates a checkbox at a specific position on screen. Returns the updated value of the checkbox.

Parameters:

NameTypeDescription
textStringThe text to show next to the checkbox
valueBooleanThe current value of the checkbox
rectRectangleThe rectangle to display the checkbox in

Return Type: Boolean

Signatures:

bool checkbox(const string &text, const bool &value, const rectangle &rect)

Checkbox

Creates a checkbox. Returns the updated value of the checkbox.

Parameters:

NameTypeDescription
textStringThe text to show next to the checkbox
valueBooleanThe current value of the checkbox

Return Type: Boolean

Signatures:

bool checkbox(const string &text, const bool &value)

Checkbox

Creates a checkbox with a label. Returns the updated value of the checkbox. Example usage: c++ my_bool = checkbox("Checkbox 1", "Enabled?", my_bool);

Parameters:

NameTypeDescription
labelStringThe label to show in front of the checkbox
textStringThe text to show next to the checkbox
valueBooleanThe current value of the checkbox

Return Type: Boolean

Signatures:

bool checkbox(const string &label, const string &text, const bool &value)

Color Slider

Color Slider

Creates a set of RGBA sliders to adjust a color, at a specific position on screen. Returns the updated color value of the slider.

Parameters:

NameTypeDescription
clrColorThe current value of the color slider
rectRectangleThe rectangle to display the slider in.

Return Type: Color

Signatures:

color color_slider(const color &clr, const rectangle &rect)

Color Slider

Creates a set of RGBA sliders to adjust a color. Returns the updated color value of the slider.

Parameters:

NameTypeDescription
clrColorThe current value of the color slider

Return Type: Color

Signatures:

color color_slider(const color &clr)

Color Slider

Creates a set of RGBA sliders to adjust a color, with a label. Returns the updated color value of the slider. Example usage: c++ my_color = color_slider("Player Color", my_color);

Parameters:

NameTypeDescription
labelStringThe label to show in front of the slider
clrColorThe current value of the color slider

Return Type: Color

Signatures:

color color_slider(const string &label, const color &clr)

Disable Interface

Disables the interface temporarily. Elements created after this function will appear disabled and cannot be interacted with.

Signatures:

void disable_interface()

Draw Interface

Draws the user interface that all the previous calls (such as Start Panel, Button, etc) have created. Make sure to call this! Without calling it, the interface won’t be visible.

Signatures:

void draw_interface()

Enable Interface

Re-enables the interface, reverses the effects of disabling the interface.

Signatures:

void enable_interface()

End Inset

Finishes the creation of an inset area.

Parameters:

NameTypeDescription
nameStringThe area’s name - must match with Start Inset

Signatures:

void end_inset(const string &name)

End Panel

Finishes the creation of a panel.

Parameters:

NameTypeDescription
nameStringThe name shown in the panel’s titlebar - must match with Start Panel

Signatures:

void end_panel(const string &name)

End Popup

Finishes the creation of a popup.

Parameters:

NameTypeDescription
nameStringThe popup’s name - must match with Start Popup

Signatures:

void end_popup(const string &name)

End Treenode

Finishes the creation of a tree node.

Parameters:

NameTypeDescription
labelStringThe node’s name - must match with Start Treenode

Signatures:

void end_treenode(const string &label)

Enter Column

Begins placing elements inside the current column. Must be paired with a call to Leave Column.

Signatures:

void enter_column()

Get Interface Label Width

Returns the width of element labels. Default is 60 pixels.

Return Type: Integer

Signatures:

int get_interface_label_width()

Creates a collapsable header with a label. Returns whether the header is expanded or not. Note: Unlike Start Panel and other similar functions, there is no need to ‘end’ this one. Example usage: c++ if (header("Section A")) { // elements inside header go here }

Parameters:

NameTypeDescription
labelStringThe label to show in the header

Return Type: Boolean

Signatures:

bool header(const string &label)

Hsb Color Slider

Hsb Color Slider

Creates a set of HSBA (hue, saturation, brightness, alpha) sliders to adjust a color, at a specific position on screen. Returns the updated color value of the slider.

Parameters:

NameTypeDescription
clrColorThe current value of the color slider
rectRectangleThe rectangle to display the slider in.

Return Type: Color

Signatures:

color hsb_color_slider(const color &clr, const rectangle &rect)

Hsb Color Slider

Creates a set of HSBA (hue, saturation, brightness, alpha) sliders to adjust a color. Returns the updated color value of the slider.

Parameters:

NameTypeDescription
clrColorThe current value of the color slider

Return Type: Color

Signatures:

color hsb_color_slider(const color &clr)

Hsb Color Slider

Creates a set of HSBA (hue, saturation, brightness, alpha) sliders to adjust a color, with a label. Returns the updated color value of the slider. Example usage: c++ my_color = hsb_color_slider("Player Color", my_color);

Parameters:

NameTypeDescription
labelStringThe label to show in front of the slider
clrColorThe current value of the color slider

Return Type: Color

Signatures:

color hsb_color_slider(const string &label, const color &clr)

Interface Enabled

Returns if the interface is currently enabled or not.

Return Type: Boolean

Signatures:

bool interface_enabled()

Interface Style Panel

A utility function to show a ‘Style Panel’, which will allows you to experiment with different interface styles.

Parameters:

NameTypeDescription
initial_rectangleRectangleThe initial position/size the panel starts off in

Signatures:

void interface_style_panel(const rectangle &initial_rectangle)

Label

Label

Creates a label.

Parameters:

NameTypeDescription
labelStringThe label to show

Signatures:

void label(const string &label)

Label

Creates a label at a specific position on screen.

Parameters:

NameTypeDescription
labelStringThe label to show
rectRectangleThe rectangle to display the label in

Signatures:

void label(const string &label, const rectangle &rect)

Last Element Changed

Returns if the last created element was changed at all (such as dragged, typed in, etc)

Return Type: Boolean

Signatures:

bool last_element_changed()

Last Element Confirmed

Returns if the last created element was ‘confirmed’ (such as clicking a button, or hitting enter in a text box)

Return Type: Boolean

Signatures:

bool last_element_confirmed()

Leave Column

Stops placing elements inside the current column and moves to the next one.

Signatures:

void leave_column()

Number Box

Number Box

Creates a number entry box at a specific position on screen. Returns the updated value of the number box.

Parameters:

NameTypeDescription
valueFloatThe current value of the number box
stepFloatThe amount incremented when dragging on the box
rectRectangleThe rectangle to display the slider in

Return Type: Float

Signatures:

float number_box(const float &value, float step, const rectangle &rect)

Number Box

Creates a number entry box with a label. Returns the updated value of the number box.

Parameters:

NameTypeDescription
valueFloatThe current value of the number box
stepFloatThe amount incremented when dragging on the box

Return Type: Float

Signatures:

float number_box(const float &value, float step)

Number Box

Creates a number entry box with a label. Returns the updated value of the number box. Example usage: c++ my_float = number_box("Percentage", my_float, 1);

Parameters:

NameTypeDescription
labelStringThe label to show in front of the number box
valueFloatThe current value of the number box
stepFloatThe amount incremented when dragging on the box

Return Type: Float

Signatures:

float number_box(const string &label, const float &value, float step)

Open Popup

Makes the popup named name open/popup at the cursor’s position.

Parameters:

NameTypeDescription
nameStringThe popup’s name. Must match with the same name used in Start Popup

Signatures:

void open_popup(const string &name)

Paragraph

Paragraph

Creates a paragraph of text that auto-wraps.

Parameters:

NameTypeDescription
textStringThe text to show

Signatures:

void paragraph(const string &text)

Paragraph

Creates a paragraph of text that auto-wraps at a specific position on screen.

Parameters:

NameTypeDescription
textStringThe text to show
rectRectangleThe rectangle to display the label in

Signatures:

void paragraph(const string &text, const rectangle &rect)

Reset Layout

Resets to the default layout of a single column with default height.

Signatures:

void reset_layout()

Set Interface Accent Color

Sets the color of accents in the interface, and the contrast of how strongly they appear when hovering/interacting.

Parameters:

NameTypeDescription
clrColorThe color of accents
contrastFloatThe strength of how much the accents show (between 0 and 1)

Signatures:

void set_interface_accent_color(color clr, float contrast)

Set Interface Border Color

Sets the interface’s border color.

Parameters:

NameTypeDescription
clrColorThe color to set borders to

Signatures:

void set_interface_border_color(color clr)

Set Interface Colors Auto

A convenience function to set the majority of the interface’s colors in one go. Some colors will be automatically chosen based on the parameters (such as text color).

Parameters:

NameTypeDescription
main_clrColorThe main color of the interface - also decides if the interface is light or dark mode
accent_clrColorThe color used to accent the interface - this will appear in highlighted areas
contrastFloatThe contrast between the frames of elements/containers and their internal elements
accent_contrastFloatHow strongly the accent color is used, for instance when highlighting elements
border_contrastFloatSimply the opacity of the borders

Signatures:

void set_interface_colors_auto(color main_clr, color accent_clr, float contrast, float accent_contrast, float border_contrast)

Set Interface Element Color

Sets the main color of elements in the interface, and the contrast between their frame and internal pieces.

Parameters:

NameTypeDescription
clrColorThe color of elements
contrastFloatThe contrast between the frame of elements and their internal pieces (between 0 and 1)

Signatures:

void set_interface_element_color(color clr, float contrast)

Set Interface Element Shadows

Sets the style of element’s shadows. Use a fully transparent color to disable them.

Parameters:

NameTypeDescription
radiusIntegerThe radius of the shadow’s blur
clrColorThe color of the shadows (commonly black, but can do coloured and semi-transparent too)
offsetPoint 2dThe offset in x/y coordinates of the shadows from their casting elements

Signatures:

void set_interface_element_shadows(int radius, color clr, point_2d offset)

Set Interface Font

Set Interface Font

Sets the interface’s font.

Parameters:

NameTypeDescription
fntStringThe name of the font to be used

Signatures:

void set_interface_font(const string &fnt)

Set Interface Font

Sets the interface’s font.

Parameters:

NameTypeDescription
fntFontThe font to be used

Signatures:

void set_interface_font(font fnt)

Set Interface Font Size

Sets the interface’s font size.

Parameters:

NameTypeDescription
sizeIntegerThe font size to be used

Signatures:

void set_interface_font_size(int size)

Set Interface Label Width

Sets the width of element labels. This is the maximum width in pixels that a label can span in front of an element. Default is 60 pixels.

Parameters:

NameTypeDescription
widthIntegerThe width of labels

Signatures:

void set_interface_label_width(int width)

Set Interface Panel Shadows

Sets the style of panel’s shadows. Use a fully transparent color to disable them.

Parameters:

NameTypeDescription
radiusIntegerThe radius of the shadow’s blur
clrColorThe color of the shadows (commonly black, but can do coloured and semi-transparent too)
offsetPoint 2dThe offset in x/y coordinates of the shadows from their casting elements

Signatures:

void set_interface_panel_shadows(int radius, color clr, point_2d offset)

Set Interface Root Text Color

Sets color of text drawn directly onto the main window

Parameters:

NameTypeDescription
clrColorThe color to set text drawn on the main window to

Signatures:

void set_interface_root_text_color(color clr)

Set Interface Shadows

Sets the style of all interface shadows. Use a fully transparent color to disable them.

Parameters:

NameTypeDescription
radiusIntegerThe radius of the shadow’s blur
clrColorThe color of the shadows (commonly black, but can do coloured and semi-transparent too)
offsetPoint 2dThe offset in x/y coordinates of the shadows from their casting elements

Signatures:

void set_interface_shadows(int radius, color clr, point_2d offset)

Set Interface Spacing

Sets the spacing within the interface.

Parameters:

NameTypeDescription
spacingIntegerThe distance between elements
paddingIntegerThe padding within elements

Signatures:

void set_interface_spacing(int spacing, int padding)

Set Interface Style

Set Interface Style

Sets the interface style to one of the presets in the interface_style enum.

Parameters:

NameTypeDescription
styleInterface StyleThe preset style to use

Signatures:

void set_interface_style(interface_style style)

Set Interface Style

Sets the interface style to one of the presets in the interface_style enum. Also accepts a color used to customize the interface.

Parameters:

NameTypeDescription
styleInterface StyleThe preset style to use
clrColorThe color to style the interface after

Signatures:

void set_interface_style(interface_style style, color clr)

Set Interface Text Color

Sets the interface’s text color.

Parameters:

NameTypeDescription
clrColorThe color to set text to

Signatures:

void set_interface_text_color(color clr)

Set Layout Height

Sets the height of each row in the interface in pixels. 0 resets to default.

Parameters:

NameTypeDescription
heightIntegerHeight of rows in pixels

Signatures:

void set_layout_height(int height)

Single Line Layout

Starts layouting all elements onto a single row. Reset with reset_layout().

Signatures:

void single_line_layout()

Slider

Slider

Creates a slider at a specific position on screen. Returns the updated value of the slider.

Parameters:

NameTypeDescription
valueFloatThe current value of the slider
min_valueFloatThe minimum value of the slider
max_valueFloatThe maximum value of the slider
rectRectangleThe rectangle to display the slider in

Return Type: Float

Signatures:

float slider(const float &value, float min_value, float max_value, const rectangle &rect)

Slider

Creates a slider without a label. Returns the updated value of the slider.

Parameters:

NameTypeDescription
valueFloatThe current value of the slider
min_valueFloatThe minimum value of the slider
max_valueFloatThe maximum value of the slider

Return Type: Float

Signatures:

float slider(const float &value, float min_value, float max_value)

Slider

Creates a slider with a label. Returns the updated value of the slider. Example usage: c++ my_float = slider("Percentage", my_float, 0, 100);

Parameters:

NameTypeDescription
labelStringThe label to show in front of the slider
valueFloatThe current value of the slider
min_valueFloatThe minimum value of the slider
max_valueFloatThe maximum value of the slider

Return Type: Float

Signatures:

float slider(const string &label, const float &value, float min_value, float max_value)

Split Into Columns

Split Into Columns

Adds count columns to the current layout, with equal widths

Parameters:

NameTypeDescription
countIntegerNumber of columns to add

Signatures:

void split_into_columns(int count)

Split Into Columns

Adds count columns to the current layout, with equal widths. Has extra parameter last_width, which lets you specify a specific width (in pixels) for the last column.

Parameters:

NameTypeDescription
countIntegerNumber of columns to add
last_widthIntegerThe width of the last column in pixels

Signatures:

void split_into_columns(int count, int last_width)

Split Into Columns Relative

Adds count columns to the current layout, with equal widths. Has extra parameter last_width, which lets you specify a specific width (relative to the width of the container, between 0 and 1) for the last column.

Parameters:

NameTypeDescription
countIntegerNumber of columns to add
last_widthDoubleThe width of the last column as percentage of the container’s width (between 0 and 1)

Signatures:

void split_into_columns_relative(int count, double last_width)

Start Custom Layout

Clears the default layout so that a custom layout can be made.

Signatures:

void start_custom_layout()

Start Inset

Start Inset

Starts the creation of an inset area inside an arbitrary rectangle. The function must be accompanied by a call to End Inset with the same name.

Parameters:

NameTypeDescription
nameStringThe name of the area
rectRectangleThe rectangle for the inset

Signatures:

void start_inset(const string &name, const rectangle &rect)

Start Inset

Starts the creation of an inset area inside a panel/popup. Use as follows: c++ start_inset("Inset area", 60); // elements inside area goes here end_inset("Inset area"); The function must be accompanied by a call to End Inset with the same name.

Parameters:

NameTypeDescription
nameStringThe name of the area
heightIntegerHeight of the inset area in pixels. -1 fills entire space. Use negative heights to fill up to height away from the bottom

Signatures:

void start_inset(const string &name, int height)

Start Panel

Starts the creation of a draggable panel with a title bar. Returns whether the panel is visible or not. Use as follows: c++ if (start_panel("My panel", rectangle_from(0,0,100,100))) { // Rest of interface goes here end_panel("My panel"); } After calling this, you can then call functions to add elements such as buttons and text boxes inside the panel. The function must be accompanied by a call to End Panel, that is only called if the panel is visible, and is passed the same name.

Parameters:

NameTypeDescription
nameStringThe name shown in the panel’s titlebar
initial_rectangleRectangleThe initial position/size the panel starts off in

Return Type: Boolean

Signatures:

bool start_panel(const string &name, rectangle initial_rectangle)

Start Popup

Starts the creation of a popup. Returns whether the popup is visible or not. Usage is the same as Start Panel, other than the ‘starting rectangle’ will be automatically calculated. The function must be accompanied by a call to End Popup with the same name.

Parameters:

NameTypeDescription
nameStringThe name of the popup

Return Type: Boolean

Signatures:

bool start_popup(const string &name)

Start Treenode

Starts the creation of a tree node (such as those in a file tree view). Returns whether the tree node is expanded or not. Usage is the same as Start Panel. The function must be accompanied by a call to End Treenode with the same name.

Parameters:

NameTypeDescription
labelStringThe name of the node

Return Type: Boolean

Signatures:

bool start_treenode(const string &label)

Text Box

Text Box

Creates a text entry box with a label. Returns the updated value of the text box.

Parameters:

NameTypeDescription
valueStringThe current value of the text box

Return Type: String

Signatures:

string text_box(const string &value)

Text Box

Creates a text entry box at a specific position on screen. Returns the updated value of the text box. Example usage: c++ my_string = text_box("Name", my_string);

Parameters:

NameTypeDescription
valueStringThe current value of the text box
rectRectangleThe rectangle to display the button in

Return Type: String

Signatures:

string text_box(const string &value, const rectangle &rect)

Text Box

Creates a text entry box with a label. Returns the updated value of the text box. Example usage: c++ my_string = text_box("Name", my_string);

Parameters:

NameTypeDescription
labelStringThe label to show in front of the text box
valueStringThe current value of the text box

Return Type: String

Signatures:

string text_box(const string &label, const string &value)