Canvas#

class Canvas#

A canvas for user interface elements. See stock_canvas() and add_canvas().

RectTransform rect_transform()#

The rect transform for the UI object.

LayoutElement layout_element()#

How much space the UI object asks a layout for.

Note

Only has an effect when the object is in a panel that has a layout. A canvas is not inside a layout and does not have one.

bool visible()#
void set_visible(bool value)#

Whether the UI object is visible.

Note

This is the object’s own setting, which is what it was last set to. An object is only drawn when everything it is inside is visible as well, so an interface can be built with its parts visible, inside a panel that is not, and shown all at once by making that panel visible.

Panel add_panel(bool visible = true)#

Create a panel within this object.

Parameters:
  • visible – Whether the new panel is visible.

Text add_text(std::string content, bool visible = true)#

Add text to this object.

Parameters:
  • content – The text.

  • visible – Whether the text is visible.

InputField add_input_field(bool visible = true)#

Add an input field to this object.

Parameters:
  • visible – Whether the input field is visible.

Button add_button(std::string content, bool visible = true)#

Add a button to this object.

Parameters:
  • content – The label for the button.

  • visible – Whether the button is visible.

Toggle add_toggle(std::string content, bool visible = true)#

Add a toggle to this object.

Parameters:
  • content – The label for the toggle.

  • visible – Whether the toggle is visible.

ToggleGroup add_toggle_group()#

Add a toggle group to this object, to make a set of toggles into radio buttons.

Note

The group is not drawn and does not take up any space. The toggles that belong to it can be added anywhere.

Slider add_slider(bool vertical = false, bool visible = true)#

Add a slider to this object.

Parameters:
  • vertical – Whether the slider runs from bottom to top, rather than from left to right.

  • visible – Whether the slider is visible.

Dropdown add_dropdown(bool visible = true)#

Add a dropdown to this object.

Parameters:
  • visible – Whether the dropdown is visible.

Image add_image(bool visible = true)#

Add an image to this object.

Parameters:
  • visible – Whether the image is visible.

ScrollView add_scroll_view(bool visible = true)#

Add a scroll view to this object.

Parameters:
  • visible – Whether the scroll view is visible.

void remove()#

Remove the UI object.