Skip to content

Interface

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)

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)

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)

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)

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)

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)

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

Parameters:

NameTypeDescription
label_textStringThe 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_text, bitmap bmp)

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

Parameters:

NameTypeDescription
label_textStringThe 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_text, bitmap bmp, drawing_options opts)

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)

Usage:  {</>}


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)

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
label_textStringThe label to show in front of the button
textStringThe text to show inside the button

Return Type: Boolean

Signatures:

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

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)

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)

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
label_textStringThe 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_text, const string &text, const bool &value)

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)

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)

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
label_textStringThe 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_text, const color &clr)

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

Signatures:

void disable_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()

Usage:  {</>}


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

Signatures:

void enable_interface()

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)

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)

Finishes the creation of a popup.

Parameters:

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

Signatures:

void end_popup(const string &name)

Finishes the creation of a tree node.

Parameters:

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

Signatures:

void end_treenode(const string &label_text)

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

Signatures:

void enter_column()

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
label_textStringThe label to show in the header

Return Type: Boolean

Signatures:

bool header(const string &label_text)

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)

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)

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
label_textStringThe 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_text, const color &clr)

Returns if the interface is currently enabled or not.

Return Type: Boolean

Signatures:

bool interface_enabled()

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)

Creates a label with the given text.

Parameters:

NameTypeDescription
textStringThe label to show

Signatures:

void label_element(const string &text)

Creates a label at a specific position on screen.

Parameters:

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

Signatures:

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

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

Return Type: Boolean

Signatures:

bool last_element_changed()

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()

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

Signatures:

void leave_column()

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)

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)

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
label_textStringThe 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_text, const float &value, float step)

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)

Creates a paragraph of text that auto-wraps.

Parameters:

NameTypeDescription
textStringThe text to show

Signatures:

void paragraph(const string &text)

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)

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

Signatures:

void reset_layout()

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)

Sets the interface’s border color.

Parameters:

NameTypeDescription
clrColorThe color to set borders to

Signatures:

void set_interface_border_color(color clr)

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)

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)

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)

Sets the interface’s font.

Parameters:

NameTypeDescription
fntStringThe name of the font to be used

Signatures:

void set_interface_font(const string &fnt)

Sets the interface’s font.

Parameters:

NameTypeDescription
fntFontThe font to be used

Signatures:

void set_interface_font(font fnt)

Sets the interface’s font size.

Parameters:

NameTypeDescription
sizeIntegerThe font size to be used

Signatures:

void set_interface_font_size(int size)

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)

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)

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)

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)

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)

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)

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)

Sets the interface’s text color.

Parameters:

NameTypeDescription
clrColorThe color to set text to

Signatures:

void set_interface_text_color(color clr)

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)

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

Signatures:

void single_line_layout()

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)

Usage:  {</>}


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)

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
label_textStringThe 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_text, const float &value, float min_value, float max_value)

Adds count columns to the current layout, with equal widths

Parameters:

NameTypeDescription
countIntegerNumber of columns to add

Signatures:

void split_into_columns(int count)

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)

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)

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

Signatures:

void start_custom_layout()

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)

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)

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)

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)

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
label_textStringThe name of the node

Return Type: Boolean

Signatures:

bool start_treenode(const string &label_text)

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)

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)

Usage:  {</>}


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
label_textStringThe 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_text, const string &value)