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:
Name | Type | Description |
---|---|---|
width | Integer | Width of the column in pixels |
Signatures:
Add Column Relative
Adds a column to the current layout with width width
percentage of the container’s width.
Parameters:
Name | Type | Description |
---|---|---|
width | Double | Percentage of the container’s width (between 0 and 1) |
Signatures:
Bitmap Button
Bitmap Button
Creates a button with a bitmap in it, and no label. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to show inside the button |
Return Type: Boolean
Signatures:
Bitmap Button
Creates a button with a bitmap in it at a specific position on screen. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to show inside the button |
rect | Rectangle | The rectangle to display the button in |
Return Type: Boolean
Signatures:
Bitmap Button
Creates a button with a bitmap in it at a specific position on screen. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to show inside the button |
rect | Rectangle | The rectangle to display the button in |
opts | Drawing Options | The drawing options |
Return Type: Boolean
Signatures:
Bitmap Button
Creates a button with a bitmap in it, and no label. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to show inside the button |
opts | Drawing Options | The drawing options |
Return Type: Boolean
Signatures:
Bitmap Button
Creates a button with a bitmap in it and a label. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the button |
bmp | Bitmap | The bitmap to show inside the button |
Return Type: Boolean
Signatures:
Bitmap Button
Creates a button with a bitmap in it and a label. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the button |
bmp | Bitmap | The bitmap to show inside the button |
opts | Drawing Options | The drawing options |
Return Type: Boolean
Signatures:
Button
Button
Creates a button at a specific position on screen. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The text to show inside the button |
rect | Rectangle | The rectangle to display the button in |
Return Type: Boolean
Usage:
Signatures:
Button
Creates a button without a label. Returns whether the button was clicked.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The text to show inside the button |
Return Type: Boolean
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the button |
text | String | The text to show inside the button |
Return Type: Boolean
Signatures:
Checkbox
Checkbox
Creates a checkbox at a specific position on screen. Returns the updated value of the checkbox.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The text to show next to the checkbox |
value | Boolean | The current value of the checkbox |
rect | Rectangle | The rectangle to display the checkbox in |
Return Type: Boolean
Signatures:
Checkbox
Creates a checkbox. Returns the updated value of the checkbox.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The text to show next to the checkbox |
value | Boolean | The current value of the checkbox |
Return Type: Boolean
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the checkbox |
text | String | The text to show next to the checkbox |
value | Boolean | The current value of the checkbox |
Return Type: Boolean
Signatures:
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:
Name | Type | Description |
---|---|---|
clr | Color | The current value of the color slider |
rect | Rectangle | The rectangle to display the slider in. |
Return Type: Color
Signatures:
Color Slider
Creates a set of RGBA sliders to adjust a color. Returns the updated color value of the slider.
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The current value of the color slider |
Return Type: Color
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the slider |
clr | Color | The current value of the color slider |
Return Type: Color
Signatures:
Disable Interface
Disables the interface temporarily. Elements created after this function will appear disabled and cannot be interacted with.
Signatures:
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.
Usage:
Signatures:
Enable Interface
Re-enables the interface, reverses the effects of disabling the interface.
Signatures:
End Inset
Finishes the creation of an inset area.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The area’s name - must match with Start Inset |
Signatures:
End Panel
Finishes the creation of a panel.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name shown in the panel’s titlebar - must match with Start Panel |
Signatures:
End Popup
Finishes the creation of a popup.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The popup’s name - must match with Start Popup |
Signatures:
End Treenode
Finishes the creation of a tree node.
Parameters:
Name | Type | Description |
---|---|---|
label_text | String | The node’s name - must match with Start Treenode |
Signatures:
Enter Column
Begins placing elements inside the current column. Must be paired with a call to Leave Column
.
Signatures:
Get Interface Label Width
Returns the width of element labels. Default is 60 pixels.
Return Type: Integer
Signatures:
Header
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in the header |
Return Type: Boolean
Signatures:
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:
Name | Type | Description |
---|---|---|
clr | Color | The current value of the color slider |
rect | Rectangle | The rectangle to display the slider in. |
Return Type: Color
Signatures:
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:
Name | Type | Description |
---|---|---|
clr | Color | The current value of the color slider |
Return Type: Color
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the slider |
clr | Color | The current value of the color slider |
Return Type: Color
Signatures:
Interface Enabled
Returns if the interface is currently enabled or not.
Return Type: Boolean
Signatures:
Interface Style Panel
A utility function to show a ‘Style Panel’, which will allows you to experiment with different interface styles.
Parameters:
Name | Type | Description |
---|---|---|
initial_rectangle | Rectangle | The initial position/size the panel starts off in |
Signatures:
Label Element
Label Element
Creates a label with the given text.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The label to show |
Signatures:
Label Element
Creates a label at a specific position on screen.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The label to show |
rect | Rectangle | The rectangle to display the label in |
Signatures:
Last Element Changed
Returns if the last created element was changed at all (such as dragged, typed in, etc)
Return Type: Boolean
Signatures:
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:
Leave Column
Stops placing elements inside the current column and moves to the next one.
Signatures:
Number Box
Number Box
Creates a number entry box at a specific position on screen. Returns the updated value of the number box.
Parameters:
Name | Type | Description |
---|---|---|
value | Float | The current value of the number box |
step | Float | The amount incremented when dragging on the box |
rect | Rectangle | The rectangle to display the slider in |
Return Type: Float
Signatures:
Number Box
Creates a number entry box with a label. Returns the updated value of the number box.
Parameters:
Name | Type | Description |
---|---|---|
value | Float | The current value of the number box |
step | Float | The amount incremented when dragging on the box |
Return Type: Float
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the number box |
value | Float | The current value of the number box |
step | Float | The amount incremented when dragging on the box |
Return Type: Float
Signatures:
Open Popup
Makes the popup named name
open/popup at the cursor’s position.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The popup’s name. Must match with the same name used in Start Popup |
Signatures:
Paragraph
Paragraph
Creates a paragraph of text that auto-wraps.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The text to show |
Signatures:
Paragraph
Creates a paragraph of text that auto-wraps at a specific position on screen.
Parameters:
Name | Type | Description |
---|---|---|
text | String | The text to show |
rect | Rectangle | The rectangle to display the label in |
Signatures:
Reset Layout
Resets to the default layout of a single column with default height.
Signatures:
Set Interface Accent Color
Sets the color of accents in the interface, and the contrast of how strongly they appear when hovering/interacting.
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The color of accents |
contrast | Float | The strength of how much the accents show (between 0 and 1) |
Signatures:
Set Interface Border Color
Sets the interface’s border color.
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The color to set borders to |
Signatures:
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:
Name | Type | Description |
---|---|---|
main_clr | Color | The main color of the interface - also decides if the interface is light or dark mode |
accent_clr | Color | The color used to accent the interface - this will appear in highlighted areas |
contrast | Float | The contrast between the frames of elements/containers and their internal elements |
accent_contrast | Float | How strongly the accent color is used, for instance when highlighting elements |
border_contrast | Float | Simply the opacity of the borders |
Signatures:
Set Interface Element Color
Sets the main color of elements in the interface, and the contrast between their frame and internal pieces.
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The color of elements |
contrast | Float | The contrast between the frame of elements and their internal pieces (between 0 and 1) |
Signatures:
Set Interface Element Shadows
Sets the style of element’s shadows. Use a fully transparent color to disable them.
Parameters:
Name | Type | Description |
---|---|---|
radius | Integer | The radius of the shadow’s blur |
clr | Color | The color of the shadows (commonly black, but can do coloured and semi-transparent too) |
offset | Point 2d | The offset in x/y coordinates of the shadows from their casting elements |
Signatures:
Set Interface Font
Set Interface Font
Sets the interface’s font.
Parameters:
Name | Type | Description |
---|---|---|
fnt | String | The name of the font to be used |
Signatures:
Set Interface Font
Sets the interface’s font.
Parameters:
Name | Type | Description |
---|---|---|
fnt | Font | The font to be used |
Signatures:
Set Interface Font Size
Sets the interface’s font size.
Parameters:
Name | Type | Description |
---|---|---|
size | Integer | The font size to be used |
Signatures:
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:
Name | Type | Description |
---|---|---|
width | Integer | The width of labels |
Signatures:
Set Interface Panel Shadows
Sets the style of panel’s shadows. Use a fully transparent color to disable them.
Parameters:
Name | Type | Description |
---|---|---|
radius | Integer | The radius of the shadow’s blur |
clr | Color | The color of the shadows (commonly black, but can do coloured and semi-transparent too) |
offset | Point 2d | The offset in x/y coordinates of the shadows from their casting elements |
Signatures:
Set Interface Root Text Color
Sets color of text drawn directly onto the main window
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The color to set text drawn on the main window to |
Signatures:
Set Interface Shadows
Sets the style of all interface shadows. Use a fully transparent color to disable them.
Parameters:
Name | Type | Description |
---|---|---|
radius | Integer | The radius of the shadow’s blur |
clr | Color | The color of the shadows (commonly black, but can do coloured and semi-transparent too) |
offset | Point 2d | The offset in x/y coordinates of the shadows from their casting elements |
Signatures:
Set Interface Spacing
Sets the spacing within the interface.
Parameters:
Name | Type | Description |
---|---|---|
spacing | Integer | The distance between elements |
padding | Integer | The padding within elements |
Signatures:
Set Interface Style
Set Interface Style
Sets the interface style to one of the presets in the interface_style enum.
Parameters:
Name | Type | Description |
---|---|---|
style | Interface Style | The preset style to use |
Signatures:
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:
Name | Type | Description |
---|---|---|
style | Interface Style | The preset style to use |
clr | Color | The color to style the interface after |
Signatures:
Set Interface Text Color
Sets the interface’s text color.
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The color to set text to |
Signatures:
Set Layout Height
Sets the height of each row in the interface in pixels. 0 resets to default.
Parameters:
Name | Type | Description |
---|---|---|
height | Integer | Height of rows in pixels |
Signatures:
Single Line Layout
Starts layouting all elements onto a single row. Reset with reset_layout()
.
Signatures:
Slider
Slider
Creates a slider at a specific position on screen. Returns the updated value of the slider.
Parameters:
Name | Type | Description |
---|---|---|
value | Float | The current value of the slider |
min_value | Float | The minimum value of the slider |
max_value | Float | The maximum value of the slider |
rect | Rectangle | The rectangle to display the slider in |
Return Type: Float
Usage:
Signatures:
Slider
Creates a slider without a label. Returns the updated value of the slider.
Parameters:
Name | Type | Description |
---|---|---|
value | Float | The current value of the slider |
min_value | Float | The minimum value of the slider |
max_value | Float | The maximum value of the slider |
Return Type: Float
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the slider |
value | Float | The current value of the slider |
min_value | Float | The minimum value of the slider |
max_value | Float | The maximum value of the slider |
Return Type: Float
Signatures:
Split Into Columns
Split Into Columns
Adds count
columns to the current layout, with equal widths
Parameters:
Name | Type | Description |
---|---|---|
count | Integer | Number of columns to add |
Signatures:
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:
Name | Type | Description |
---|---|---|
count | Integer | Number of columns to add |
last_width | Integer | The width of the last column in pixels |
Signatures:
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:
Name | Type | Description |
---|---|---|
count | Integer | Number of columns to add |
last_width | Double | The width of the last column as percentage of the container’s width (between 0 and 1) |
Signatures:
Start Custom Layout
Clears the default layout so that a custom layout can be made.
Signatures:
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:
Name | Type | Description |
---|---|---|
name | String | The name of the area |
rect | Rectangle | The rectangle for the inset |
Signatures:
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:
Name | Type | Description |
---|---|---|
name | String | The name of the area |
height | Integer | Height of the inset area in pixels. -1 fills entire space. Use negative heights to fill up to height away from the bottom |
Signatures:
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:
Name | Type | Description |
---|---|---|
name | String | The name shown in the panel’s titlebar |
initial_rectangle | Rectangle | The initial position/size the panel starts off in |
Return Type: Boolean
Signatures:
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:
Name | Type | Description |
---|---|---|
name | String | The name of the popup |
Return Type: Boolean
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The name of the node |
Return Type: Boolean
Signatures:
Text Box
Text Box
Creates a text entry box with a label. Returns the updated value of the text box.
Parameters:
Name | Type | Description |
---|---|---|
value | String | The current value of the text box |
Return Type: String
Signatures:
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:
Name | Type | Description |
---|---|---|
value | String | The current value of the text box |
rect | Rectangle | The rectangle to display the button in |
Return Type: String
Usage:
Signatures:
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:
Name | Type | Description |
---|---|---|
label_text | String | The label to show in front of the text box |
value | String | The current value of the text box |
Return Type: String
Signatures: