Module api.gui
Contains all GUI function, tools and classes.
The GUI is a big tree containing various elements (or widgets) (called "components" and "layouts") nested together.
Most of the GUI functionality is available as soon as the application starts, within the Console State.
However, some extra functionality of the GUI is available only in the GUI State.
Other states do not have access to GUI functions and elements.
Tables
comp | Contains all UI components (widgets) and base classes. |
layout | Contains all UI layouts and base classes. |
util | Contains all util function for the UI. |
Class util.Rect
util.rect.h | Height of the rectangle |
util.rect.w | Width of the rectangle |
util.rect.x | Horizontal position of the upper left corner |
util.rect.y | Vertical position of the upper left corner |
util.rect:contains(x, y) | Checks if Rect contains the position on the screen. |
util.rect:intersects(other) | Checks if Rect intersects another Rect. |
util.rect:new(x, y, w, h) | Creates a new Rect. |
Class util.MouseEvent
util.mouseevent.button | Mouse button related to the event: 0 = left, 1 = middle, 2 = right |
util.mouseevent.type | Event type: 0 = mouse pressed, 1 = mouse released, 2 = mouse clicked, 3 = mouse enter, 4 = mouse exited, 5 = mouse moved, 6 = mouse wheel event, 7 = mouse double clicked |
util.mouseevent.x | Horizontal position of the mouse when event was triggered |
util.mouseevent.xrel | Relative horizontal position when event was triggered |
util.mouseevent.y | Horizontal position of the mouse when event was triggered |
util.mouseevent.yrel | Relative vertical position when event was triggered |
Class util.Size
util.Alignment | Alignment of the layout item |
util.Orientation | Orientation of the layout item |
util.downcast(layout) | Properly set correct metatable of the object for most derived object |
util.size.h | Height of the size element |
util.size.h | Height of the size |
util.size.w | Width of the size |
util.size.w | Width of the size element |
util.size:new(w, h) | Creates a new Size |
Class comp.ILayoutItem
comp.ilayoutitem:addHighPriorityProcessingComponent() | Adds a component which will have priority in handling Input Actions |
comp.ilayoutitem:destroy() | Destroys the item: the item cannot belong to a layout of component. |
comp.ilayoutitem:getBeginFrameTimes() | Returns the rendering preparation time |
comp.ilayoutitem:getEventTimes() | Returns the events processing time |
comp.ilayoutitem:getId() | Obtains the id of the ui item. |
comp.ilayoutitem:getRenderTimes() | Returns the rendering time |
comp.ilayoutitem:getStepTimes() | Returns the gui update time |
comp.ilayoutitem:getSwapTimes() | Returns the rendering finish time |
comp.ilayoutitem:removeHighPriorityProcessingComponent() | Remove a component which was added via addHighPriorityProcessingComponent |
Class comp.Component
comp.component:addLifeTimeChecker() | Obtains an object from the component that can be used to check whether the component has been destroyed. |
comp.component:addStyleClass(class) | Assigns a style class to the component. |
comp.component:calcMinimumSize() | Gets minimum size taken by the component. |
comp.component:getContentRect() | Gets Rect size for the component. |
comp.component:getCore() | Returns the Core object for all Components |
comp.component:getLayout() | Returns layout of the component. |
comp.component:getName() | Receives the name of the component. |
comp.component:getParent() | Gets parent of component (automatically downcasted). |
comp.component:hasFocus() | Checks if component has focus. |
comp.component:insertMouseListener(func) | Prepends a mouse listener that will be called before all other listeners. |
comp.component:invokeLater(callback) | Invoke a stored function at the beginning of the next frame. |
comp.component:isEnabled() | Checks if the object is interactable. |
comp.component:isVisible() | Checks if the object is visible. |
comp.component:new(name, id) | Creates a new Component instance. |
comp.component:onDestroy(callback) | Adds a callback to be called when the item is destroyed. |
comp.component:onStep(callback) | Adds a callback to be called each gui update. |
comp.component:onVisibilityChange() | Adds a callback to be called when the visibility changes. |
comp.component:removeMouseListener() | Removes the mouse listener attached to the component. |
comp.component:removeStyleClass(class) | Removes a style class to the component. |
comp.component:setEnabled(enabled) | Makes the object (un)interactable. |
comp.component:setFocus() | Sets a component to have focus. |
comp.component:setFocusable() | Enables/disable focus on this component |
comp.component:setGravity(horizontal, vertical) | Sets the alignment of the component. |
comp.component:setHighlighted(highlighted) | Sets highlighted. |
comp.component:setId(id) | Gives the component a unique identifier. |
comp.component:setInputActionBubbleUpAcceptFilter(a, whether) | Sets a handler for a list of input actions and decide whether to enable those input actions or not |
comp.component:setInputActionForward(sourceIa, targetComp, targetIa) | Forwards an input action to a target component with a specified source and target action. |
comp.component:setInputActionHandler(ia, handlerFn, func) | Sets an handler for an input action, and another callback to determine whether it is enabled or not. |
comp.component:setLayout(layout) | Sets a layout (the component takes ownership of the layout). |
comp.component:setMaximumSize(size) | Set the maximum size that the components takes up. |
comp.component:setMinimumSize(size) | Set the minimum size that the components takes up. |
comp.component:setMouseListener(func) | Forwards mouse events to the component under the cursor. |
comp.component:setName(name) | Gives the component a name, used to apply styles. |
comp.component:setStyleClassList(list) | Assigns a style class to the component. |
comp.component:setTooltip(text) | Sets the tooltip of the component. |
comp.component:setTransparent(transparent) | Sets transparency. |
comp.component:setVisible(visible, emitSignal) | Sets visibility. |
Util
util.check(reference) | Checks if a component is still alive using the LifeTimeChecker. |
util.destroyLater(comp) | Delete a gui element at the beginning of the next frame. |
util.getById(id) | Returns the component with the given id. |
util.getCommandTimes() | Returns commands processing time Available only within GUI State. |
util.getGameUI() | Returns the GameUI. |
util.getInputMode() | Returns the current InputMode. |
util.getMouseScreenPos() | Returns the screet coordinate at the mouse position. |
util.getReplicateTimes() | Returns the sync time between gui and simulation Available only within GUI State. |
util.getStepTimes() | Returns the simulation update time Available only within GUI State. |
Class comp.Window
comp.window:addHideOnCloseHandler() | Adds a default handler for "onClose" that hides the window when it is closed. |
comp.window:close() | Closes the window. |
comp.window:getContent() | Returns the window content. |
comp.window:isAttached() | Checks if window is attached. |
comp.window:isPinnable() | Checks if window is pinnable. |
comp.window:isPinned() | Checks if window is pinned. |
comp.window:maximize() | Maximizes the window to its maximisedSize size. |
comp.window:minimize() | Minimizes the window to its minimizedSize size. |
comp.window:new(title, content) | Creates a new Window. |
comp.window:onClose(callback) | Adds a parameterless callback, which is called when the window is closed. |
comp.window:onMove(callback) | Adds a parameterless callback, which is called when the window is moved |
comp.window:remove(win) | Removes a window from the UI and returns it. |
comp.window:setAttached(b) | Sets the window to be attached. |
comp.window:setContent(content) | Sets the window content. |
comp.window:setIcon(icon) | Sets the window icon. |
comp.window:setLocateButtonVisible(b) | Adds a button to follow entities and other objects. |
comp.window:setMaximiseSize() | Set the size when maximised. |
comp.window:setMovable(b) | Sets the window to be movable. |
comp.window:setPinButtonVisible(b) | Adds a button to pin the window. |
comp.window:setPinned(b) | Sets the window to be pinned. |
comp.window:setPosition(x, y) | Sets the window position. |
comp.window:setResizable(b) | Sets the window to be resizable. |
comp.window:setSize(size) | Sets the window size. |
comp.window:setTitle(title) | Sets the window title. |
Class comp.GameUI
comp.gameui:getMainRendererComponent() | Obtains the main 3d scene. |
comp.gameui:getViewManager() | Obtains the view manager. |
comp.gameui:playCutscene(fileName) | Plays a cutscene. |
comp.gameui:playSoundEffect(name) | Plays a single sound effect. |
comp.gameui:playTrack(filename, offset) | Plays a single track with the music player. |
comp.gameui:setConstructionAngle(angle) | Sets the default construction angle for constructions. |
Class comp.RendererComponent
comp.renderercomponent:getCameraController() | Gets the camera controller for the component. |
comp.renderercomponent:getTerrainPos() | Gets the terrain position pointed by the mouse. |
comp.renderercomponent:stopAction() | Stops the current Action (bulldoze, build construction, etc.) |
Class util.CameraController
util.cameracontroller:focus(entity) | Focuses the camera on an entity. |
util.cameracontroller:follow(entity, jump) | Sets camera to follow an Entity. |
util.cameracontroller:getCameraData() | Obtains the current camera data. |
util.cameracontroller:getFollowEntity() | Gets the entity currently being followed. |
util.cameracontroller:setCameraData(center, dist, angle, pitch) | Sets the camera data with custom position and other information. |
Class util.ViewManager
util.viewmanager:closeAll() | Closes all currently open entity windows. |
util.viewmanager:openWindow(entity, above, tabIndex) | Focuses the camera on an entity. |
Class comp.TextInputField
comp.textinputfield:OnFocusChange(callback) | Sets a callback that is called when the focus changes. |
comp.textinputfield:getSelectedText() | Gets selected text. |
comp.textinputfield:getText() | Returns the text in the input field. |
comp.textinputfield:new() | Creates a new text input field with placeholder text. |
comp.textinputfield:onCancel(callback) | Sets a callback that is called when enter is pressed. |
comp.textinputfield:onChange(callback) | Sets a callback that is called when the text changes. |
comp.textinputfield:onEnter(callback) | Sets a callback that is called when enter is pressed. |
comp.textinputfield:selectAll() | Selects entire text |
comp.textinputfield:setDeselectOnFocusLost() | Clear selection when focus is lost |
comp.textinputfield:setMaxLength() | Sets the maximal length of the input text. |
comp.textinputfield:setText() | Sets the text of the field to the given text. |
Class comp.TextView
comp.textview:getSelectedText() | Gets selected text. |
comp.textview:getText() | Gets the entire text. |
comp.textview:getTextAlignment() | Gets the alignment of the text |
comp.textview:getTextAlignment2() | Gets the alignment of the text |
comp.textview:new() | Creates a new text view with some text. |
comp.textview:setSelectable() | Sets the text as selectable. |
comp.textview:setText() | Sets the text |
comp.textview:setTextAlignment() | Sets the alignment of the text |
Class comp.CheckBox
comp.checkbox:isSelected() | Return selection status for the checkbox |
comp.checkbox:new() | Gets the entire text. |
comp.checkbox:onToggle(callback) | Sets a callback that is called when the checkbox is selected |
comp.checkbox:setSelected(value, emit) | Sets the checkbox as selected. |
comp.checkbox:setText() | Sets the label text of the checkbox. |
Class comp.ImageView
comp.imageview:setImage() | Sets the image of the image view. |
comp.imageview:setText() | Creates a new imageview with a texture. |
Class comp.ContentView
comp.contentview:getContent() | Returns the content |
comp.contentview:setContent() | Sets the content (takes ownership of content) |
comp.contentview:setContentAlignment() | Sets the alignment of the content |
Class comp.ToggleButton
comp.togglebutton:isSelected() | TReturns whether the toggle button is toggled |
comp.togglebutton:new(child) | Creates a toggle button with a child element. |
comp.togglebutton:onToggle() | Calls the callback when the button is toggled |
comp.togglebutton:setSelected() | TReturns whether the toggle status of the button |
comp.togglebutton:toggle() | TToggles the button |
Class comp.Button
comp.button:click() | Triggers a button click |
comp.button:new(child, clickOnPress) | Creates a button with a child element. |
comp.button:onClick() | Calls the callback when the button is clicked |
Class comp.ToggleButtonGroup
comp.togglebuttongroup:add() | Adds a new toggle button to the group, takes ownership of the button |
comp.togglebuttongroup:getButton() | Returns a button with the given index |
comp.togglebuttongroup:getNumButtons() | Returns the number of buttons |
comp.togglebuttongroup:getSelectedIndex() | Returns the index of the selected button |
comp.togglebuttongroup:new() | Creates a toggle button group. |
comp.togglebuttongroup:onCurrentIndexChanged() | Calls the callback when one button is toggled with the index of the button |
comp.togglebuttongroup:setEmitSignal() | Sets the group to trigger a signal when pressed |
comp.togglebuttongroup:setOneButtonMustAlwaysBeSelected() | Prevents deselecting all buttons |
Class comp.Table
comp.table:addRow(components) | Adds a new row of components |
comp.table:deleteAll() | Remove all rows and all components |
comp.table:deleteRows() | Remove all rows between first and last |
comp.table:getNumCols() | Gets the number of columns of the table |
comp.table:getNumRows() | Gets the number of rows of the cable |
comp.table:insertRow(components) | Adds a new row of components at the given index |
comp.table:new(numColumns, selectable) | Create a new table with a set number of columns and an optional selection policy. |
comp.table:setColWeight() | Sets the column weight (affects the width) |
comp.table:setColWidth() | Set the column default width. |
comp.table:setHeader(components) | Sets the header for the table |
comp.table:setMaxColWidth() | Sets the column maximum width |
comp.table:setMinColWidth() | Sets the column minimum width |
comp.table:setNumCols() | Sets the number of columns. |
comp.table:setOrder() | Sort the rows with a given order. |
Class comp.ScrollArea
comp.ScrollBarPolicy | The visibility policy for the ScrollBar |
comp.scrollarea:SetHorizontalScrollBarPolicy(policy) | Sets the policy for the horizontal scrollbar |
comp.scrollarea:ensureVisible() | Ensures a child component is visible |
comp.scrollarea:getContent() | Returns content of the scroll area. |
comp.scrollarea:getScrollOffset() | Returns current scroll offset. |
comp.scrollarea:getViewportRect() | Return the Rect of the visible portion |
comp.scrollarea:new() | Makes a new scroll area with given component and names. |
comp.scrollarea:onScroll() | Sets a callback for scrolling |
comp.scrollarea:setContent() | Sets the content of the scroll area |
comp.scrollarea:setScrollOffset() | Scrolls to given position. |
comp.scrollarea:setVerticalScrollBarPolicy(policy) | Sets the policy for the vertical scrollbar |
Class comp.ComboBox
comp.combobox:addItem() | Adds a new item at the bottom of the combo box |
comp.combobox:addItemFactory(callback) | Adds a new component at the bottom of the combo box, callback is called each time the combbox is open |
comp.combobox:clear() | Remove all entries from the combo box |
comp.combobox:getCurrentIndex() | Gets currently selected index. |
comp.combobox:getNumItems() | Returns the number of items in a layout. |
comp.combobox:new() | Makes a new empty combo box. |
comp.combobox:onIndexChanged(callback) | Add callback that is called when the current index changes. |
Class comp.DoubleSpinBox
comp.doublespinbox:getMaximum() | Returns the current maximum possible value for the spinbox |
comp.doublespinbox:getMinimum() | Returns the current minimum possible value for the spinbox |
comp.doublespinbox:getValue() | Returns the current value of the spinbox |
comp.doublespinbox:new() | Makes a new spin box with default values. |
comp.doublespinbox:onChange(callback) | Adds a callback for when the spinbox changes value. |
comp.doublespinbox:setMaximum() | Sets maximum selectable value for the spin box |
comp.doublespinbox:setMinimum() | Sets minimum selectable value for the spin box |
comp.doublespinbox:setStep() | Sets the interval between values of the spinbox |
comp.doublespinbox:setValue() | Sets the current value of the spinbox |
Class comp.SpinBox
comp.spinbox:getValue() | Returns the current value of the spinbox |
comp.spinbox:new() | Makes a new spin box with default values. |
comp.spinbox:onChange(callback) | Adds a callback for when the spinbox changes value. |
comp.spinbox:setRange() | Sets minimum and maximum selectable values for the spin box |
comp.spinbox:setValue() | Sets the current value of the spinbox |
Class comp.AbstractSlider
comp.abstractslider:getPageStep() | Gets the current page step of the slider |
comp.abstractslider:getPageStep() | Gets the current minimum value of the slider |
comp.abstractslider:getPageStep() | Gets the current maximum value of the slider |
comp.abstractslider:getStep() | Gets the current step of the slider |
comp.abstractslider:getValue() | Sets the current value of the slider |
comp.abstractslider:onValueChanged() | Get called when the slider value changes. |
comp.abstractslider:setDefaultValue() | Sets the default value of the slider |
comp.abstractslider:setMaximum() | Sets the maximum value of the slider |
comp.abstractslider:setMinimum() | Sets the minimum size of the slider |
comp.abstractslider:setPageStep() | Sets the big increment size of the slider (controlled with page buttons) |
comp.abstractslider:setStep() | Sets the increment size of the slider |
comp.abstractslider:setValue() | Sets the value of the slider |
Class comp.Slider
comp.slider:new() | Creates a new vertical or horizontal slider |
Class comp.Slider2
comp.slider2:getValue() | Sets the current value of the slider |
comp.slider2:new() | Creates a new 2d slider |
comp.slider2:onValueChanged(callback) | Adds a callback for the slider, that is called when the slider value changes |
comp.slider2:setMaximum() | Sets the maximum value for the slider |
comp.slider2:setMinimum() | Sets the minimum value for the slider |
comp.slider2:setValue() | Sets the default value for the slider |
comp.slider2:setValue() | Sets the value of the slider to the given one |
comp.slider2:setValue() | Sets the default step for the slider |
Class comp.TabWidget
comp.tabwidget:addSpace() | Adds a space after the selected tab |
comp.tabwidget:addTab() | Adds tab at the end, uses indicator to display the tab |
comp.tabwidget:addTabText() | Adds tab at the end, uses text as indicator for the tab |
comp.tabwidget:getCurrentTab() | (deprecated) Use getCurrentTabIndex instead |
comp.tabwidget:getCurrentTabIndex() | Gets the tab index that is currently selected |
comp.tabwidget:getIndicator() | Gets the indicator component at the given index |
comp.tabwidget:getNumTabs() | Gets the numer of tabs |
comp.tabwidget:getTab() | Gets the tab at specified index |
comp.tabwidget:insertTab() | Inserts tab at given position, uses indicator to display the tab |
comp.tabwidget:new(orientation) | Creates a new tab widget with tabs on the given position |
comp.tabwidget:onCurrentChanged(int) | Called when the tab changes, |
comp.tabwidget:setCurrentTab() | Sets the tab that is currently selected |
comp.tabwidget:setDeselectAllowed() | Allow selecting no tab at all |
Class comp.ProgressBar
comp.progressbar:getProgress() | Gets the current progress |
comp.progressbar:new() | Creates a new progress bar |
comp.progressbar:setColor() | Sets the color of the progress bar |
comp.progressbar:setProgress(The) | Sets the current progress |
comp.progressbar:setTask() | Adds some text to the bar |
Class comp.Chart
comp.chart:addSeries() | Adds a new data series to the graph |
comp.chart:clear() | Clears all data from the graph |
comp.chart:new() | Creates a new chart |
comp.chart:setAxis() | Sets the axis values and the range of the axis |
comp.chart:setColor() | Sets the color of the bar |
comp.chart:setLabelFormatter(axis, callback) | Sets a function to be called to format axis numbers into labels |
comp.chart:setLineWidth() | Sets the line with of the graph |
comp.chart:setSeriesLabels() | Sets the labels for the series |
comp.chart:setType(type) | Sets the type of graph |
Class comp.ColorChooserButton
comp.colorchooserbutton:new() | Creates a new color picker button. |
comp.colorchooserbutton:onSelect(callback) | Called when the color is selected |
comp.colorchooserbutton:setColor() | Sets the currently selected color. |
Class comp.ColorPicker
comp.colorpicker:new() | Creates a new color picker |
comp.colorpicker:onColorChanged(callback) | Called when the selected color changes |
comp.colorpicker:setColor() | Sets the color of the color picker |
Class comp.ColorChooser
comp.colorchooser:new() | Creates a new color chooser |
comp.colorchooser:onSelect(callback) | Called when the color is selected. |
Class comp.LineRenderView
comp.linerenderview:addLine(from, to) | Add a new displayed line from from to to |
comp.linerenderview:clear() | Clear all lines added so far. |
comp.linerenderview:new() | Creates a new line render component |
comp.linerenderview:setColor(color) | Called to set the color of all lines added to this |
comp.linerenderview:setWidth(width) | Set the width of all lines of the component. |
Class comp.List
comp.list:addItem(item) | Adds an item to the list |
comp.list:clear(emitSignal) | Clear items from list |
comp.list:getItem(index) | Returns component at position index |
comp.list:getNumItems() | Returns number of items in the list |
comp.list:getSelectedIndex() | Returns currently selected item |
comp.list:new(drawBackground, orientation, autoDeselectDisabledItems) | Creates a new list component |
comp.list:onActivate(callback) | Called when an item is activated |
comp.list:onHover(callback) | Called when an item is hovered on |
comp.list:onSelect(callback) | Called when an item is selected |
comp.list:removeItem(index, emitSignal) | Removes an item from the list |
comp.list:select(index, emitSignal) | Selects an item in the list |
comp.list:setDeselectAllowed(deselectAllowed) | Set policy to allow no selected item |
comp.list:setEmitSignalOnReselect(emitSignal) | Set policy not to emit a signal when the same item is selected |
Class layout.ILayout
layout.ilayout:getItem() | Get the item at the given index. |
layout.ilayout:getNumItems() | Get the number of items in a layout |
layout.ilayout:removeItem() | Removes an item from the layout, returns an object having ownership of the removed item. |
Class layout.LayoutBase
layout.layoutbase:addItem() | Adds an item to the layout. |
layout.layoutbase:getComponent() | Get the component stored in the layout. |
layout.layoutbase:insertItem() | Adds an item to the layout at given position. |
layout.layoutbase:setGravity() | Sets the alignment of the component. |
layout.layoutbase:setId() | Sets a name for the layout. |
layout.layoutbase:setId() | Sets a unique id for the layout. |
Class layout.BoxLayout
layout.boxlayout:new(orientation) | Creates a new layout with the given orientation. |
Class layout.AbsoluteLayout
layout.absolutelayout:addItem() | Adds an item with the given geometry to the layout. |
layout.absolutelayout:deleteAll() | Removes all childs and deletes them. |
layout.absolutelayout:getIndex() | Get the index of the item at given position. |
layout.absolutelayout:new(orientation) | Creates a new layout with the given orientation. |
layout.absolutelayout:setItemPosition() | [Deprecated] Sets item at position. |
layout.absolutelayout:setPosition() | Sets the position of the item at given index at the given position. |
Class layout.FloatingLayout
layout.floatinglayout:addItem() | Adds an item with the given alignments. |
layout.floatinglayout:deleteAll() | Removes and deletes all elements in the layout. |
layout.floatinglayout:insertItem() | Adds and items (and takes ownership), at the given position and with the given alignments. |
layout.floatinglayout:new() | Creates a new layout |
layout.floatinglayout:setAlignment() | Sets the alignment of the item at the position. |
Tables
- comp
- Contains all UI components (widgets) and base classes.
- layout
- Contains all UI layouts and base classes.
- util
- Contains all util function for the UI.
Class util.Rect
A UI Rectangle.- util.rect.h
-
Height of the rectangle
- h int
- util.rect.w
-
Width of the rectangle
- w int
- util.rect.x
-
Horizontal position of the upper left corner
- x int
- util.rect.y
-
Vertical position of the upper left corner
- y int
- util.rect:contains(x, y)
-
Checks if Rect contains the position on the screen.
Parameters:
- x int x coordinate
- y int y coordinate
- util.rect:intersects(other)
-
Checks if Rect intersects another Rect.
Parameters:
- other Rect the other Rect
- util.rect:new(x, y, w, h)
-
Creates a new Rect.
It can be called either empty or with all parameters.
Parameters:
- x optional int x coordinate of the upper left corner
- y optional int y coordinate of the upper left corner
- w optional int width of the rectangle
- h optional int height of the rectangle
Class util.MouseEvent
Represents a mouse event- util.mouseevent.button
-
Mouse button related to the event: 0 = left, 1 = middle, 2 = right
- button int
- util.mouseevent.type
-
Event type: 0 = mouse pressed, 1 = mouse released, 2 = mouse clicked,
3 = mouse enter, 4 = mouse exited, 5 = mouse moved, 6 = mouse wheel event,
7 = mouse double clicked
- type int
- util.mouseevent.x
-
Horizontal position of the mouse when event was triggered
- x int
- util.mouseevent.xrel
-
Relative horizontal position when event was triggered
- xrel int
- util.mouseevent.y
-
Horizontal position of the mouse when event was triggered
- y int
- util.mouseevent.yrel
-
Relative vertical position when event was triggered
- yrel int
Class util.Size
A UI Size.- util.Alignment
-
Alignment of the layout item
Fields:
- LEFT 0
- CENTER 1
- RIGHT 2
- util.Orientation
-
Orientation of the layout item
Fields:
- HORIZONTAL 0
- VERTICAL 1
- util.downcast(layout)
-
Properly set correct metatable of the object for most derived object
Parameters:
- layout layout.ILayout to downcast
Returns:
-
Object
representing item, but with the most derived metatable
- util.size.h
-
Height of the size element
- h int
- util.size.h
-
Height of the size
- h int
- util.size.w
-
Width of the size
- w int
- util.size.w
-
Width of the size element
- w int
- util.size:new(w, h)
-
Creates a new Size
Parameters:
- w int width of the size
- h int height of the size
Class comp.ILayoutItem
The base abstract class to all layouts and components.Internally, this is just a pointer to a C memory location. Since lua does not have a concept of ownership, a layout item is never owened by lua, and is just referenced by it.
The object might therefore become invalid if kept around. If you keep a layout item around, and you are not controlling the lifetime yourself, you can add a lifetime checker.
- comp.ilayoutitem:addHighPriorityProcessingComponent()
- Adds a component which will have priority in handling Input Actions
- comp.ilayoutitem:destroy()
- Destroys the item: the item cannot belong to a layout of component. This can not be used during a callback of the component itself or one of its children. To destroy a component from a callback, see util.destroyLater.
- comp.ilayoutitem:getBeginFrameTimes()
- Returns the rendering preparation time
- comp.ilayoutitem:getEventTimes()
- Returns the events processing time
- comp.ilayoutitem:getId()
-
Obtains the id of the ui item.
Returns:
-
string
the id of the ui item.
- comp.ilayoutitem:getRenderTimes()
- Returns the rendering time
- comp.ilayoutitem:getStepTimes()
- Returns the gui update time
- comp.ilayoutitem:getSwapTimes()
- Returns the rendering finish time
- comp.ilayoutitem:removeHighPriorityProcessingComponent()
- Remove a component which was added via addHighPriorityProcessingComponent
Class comp.Component
A very simple UI component with basic functionality. Inherits all functions from comp.ILayoutItem.Base class: comp.ILayoutItem.
- comp.component:addLifeTimeChecker()
-
Obtains an object from the component that can be used to check whether the component has been destroyed.
Especially useful if you do not have control over the lifetime of
the component and the component does not live for the entirety of the game.
You can keep around this object as long as you need.
Returns:
-
LifeTimeChecker
the object reference that can be used with api.gui.util.check(reference)
- comp.component:addStyleClass(class)
-
Assigns a style class to the component.
Parameters:
- class string Class to add
- comp.component:calcMinimumSize()
-
Gets minimum size taken by the component.
Returns:
-
Size
the minimum size that the component needs
- comp.component:getContentRect()
-
Gets Rect size for the component.
Returns:
-
Rect
the Rect representing the size of the component
- comp.component:getCore()
-
Returns the Core object for all Components
Returns:
-
Core
the core component
- comp.component:getLayout()
-
Returns layout of the component.
Returns:
-
Layout
the layout of the component
- comp.component:getName()
-
Receives the name of the component.
Returns:
-
string
the name of the component
- comp.component:getParent()
-
Gets parent of component (automatically downcasted).
Returns:
-
Component
the parent component
- comp.component:hasFocus()
-
Checks if component has focus.
Returns:
-
bool
true if the component has focus
- comp.component:insertMouseListener(func)
-
Prepends a mouse listener that will be called before all other listeners. Listeners can only be removed all at once
Parameters:
- func bool (MouseEvent) callback The function to call when an event is triggered on the component
Returns:
-
bool
Whether the event was handled or not
- comp.component:invokeLater(callback)
-
Invoke a stored function at the beginning of the next frame.
Parameters:
- callback func() A parameterless callback which will be invoked at the beginning of the next frame
- comp.component:isEnabled()
-
Checks if the object is interactable.
Returns:
-
bool
true if the object is interactable
- comp.component:isVisible()
-
Checks if the object is visible.
Returns:
-
bool
true if the object is visible
- comp.component:new(name, id)
-
Creates a new Component instance.
Parameters:
Returns:
-
Component
the new Component instance.
- comp.component:onDestroy(callback)
-
Adds a callback to be called when the item is destroyed.
Parameters:
- callback func() the parameterless function called when the component is destroyed
Returns:
-
type.Connection
to disconnect the callback if no longer needed
- comp.component:onStep(callback)
-
Adds a callback to be called each gui update.
Parameters:
- callback func(long,long) The function takes two numbers as input, specifying the frame time and the elapsed time
Returns:
-
type.Connection
to disconnect the callback if no longer needed
- comp.component:onVisibilityChange()
-
Adds a callback to be called when the visibility changes.
Returns:
-
type.Connection
to disconnect the callback if no longer needed
- comp.component:removeMouseListener()
- Removes the mouse listener attached to the component.
- comp.component:removeStyleClass(class)
-
Removes a style class to the component.
Parameters:
- class string Class to remove
- comp.component:setEnabled(enabled)
-
Makes the object (un)interactable.
Parameters:
- enabled bool true if should be interactable
- comp.component:setFocus()
- Sets a component to have focus.
- comp.component:setFocusable()
- Enables/disable focus on this component
- comp.component:setGravity(horizontal, vertical)
-
Sets the alignment of the component.
Both parameters can be set to 0.0 for left/top position, 0.5 for center positioning and 1.0 for right/bottom positioning.
If set to -1, the element will grow in that dimension to fill up space.
Parameters:
- horizontal float the horizontal gravity setting
- vertical float the vertical gravity setting
- comp.component:setHighlighted(highlighted)
-
Sets highlighted.
Parameters:
- highlighted bool true if the component should be highlighted (usually the yellow flashing)
- comp.component:setId(id)
-
Gives the component a unique identifier.
Parameters:
- id string the id for the component
- comp.component:setInputActionBubbleUpAcceptFilter(a, whether)
-
Sets a handler for a list of input actions and decide whether to enable those input actions or not
Parameters:
- a vector list of input actions
- whether bool to enable or disable the provided list of input actions
- comp.component:setInputActionForward(sourceIa, targetComp, targetIa)
-
Forwards an input action to a target component with a specified source and target action.
Parameters:
- comp.component:setInputActionHandler(ia, handlerFn, func)
-
Sets an handler for an input action, and another callback to determine whether it is enabled or not.
Parameters:
- ia string The name of the input action
- handlerFn func() A parameterless callback which will be invoked when the input action is triggered
- func bool () enabledFn A parameterless callback returning "bool" deciding whether the input action is enabled
- comp.component:setLayout(layout)
-
Sets a layout (the component takes ownership of the layout).
Parameters:
- layout Layout the layout that should be used for this component
- comp.component:setMaximumSize(size)
-
Set the maximum size that the components takes up.
Parameters:
- size util.Size the maximum size that the component may reach
- comp.component:setMinimumSize(size)
-
Set the minimum size that the components takes up.
Parameters:
- size util.Size the minimum size that the component may reach
- comp.component:setMouseListener(func)
-
Forwards mouse events to the component under the cursor. Listener is unique.
Parameters:
- func bool (MouseEvent) callback The function to call when an event is triggered on the component
Returns:
-
bool
Whether the event was handled or not
- comp.component:setName(name)
-
Gives the component a name, used to apply styles.
Parameters:
- name string the name for the component
- comp.component:setStyleClassList(list)
-
Assigns a style class to the component.
Parameters:
- list {string,...} the list of style classes that should be added
- comp.component:setTooltip(text)
-
Sets the tooltip of the component.
Parameters:
- text string the text that should be used for the tooltip
- comp.component:setTransparent(transparent)
-
Sets transparency.
Parameters:
- transparent bool true if the component should be transparent
- comp.component:setVisible(visible, emitSignal)
-
Sets visibility.
Parameters:
- visible bool true if component should be visible
- emitSignal bool true if "onVisibilityChanged" callback should be called
Util
- util.check(reference)
-
Checks if a component is still alive using the LifeTimeChecker.
Parameters:
- reference LifeTimeChecker The lifetime checker reference for the component
Returns:
-
bool
true if the component is still alive.
- util.destroyLater(comp)
-
Delete a gui element at the beginning of the next frame. The user must have obtained ownership of the item by removing from the layout.
Parameters:
- comp gui.Component the component to delete
- util.getById(id)
-
Returns the component with the given id.
Parameters:
- id string the id of the ui component with the given id
Returns:
-
Component
the component that was requested
- util.getCommandTimes()
-
Returns commands processing time
Available only within GUI State.
Returns:
-
The
commands processing time
- util.getGameUI()
-
Returns the GameUI.
Available only within GUI State.
Returns:
-
Component
the main game ui component
- util.getInputMode()
-
Returns the current InputMode.
Available only within GUI State.
Returns:
-
The
input mode
- util.getMouseScreenPos()
-
Returns the screet coordinate at the mouse position.
Returns:
-
type.Vec2i
the vector containing the x and y coordinate of the mouse pointer on the screen
- util.getReplicateTimes()
-
Returns the sync time between gui and simulation
Available only within GUI State.
Returns:
-
The
sync time between gui and simulation
- util.getStepTimes()
-
Returns the simulation update time
Available only within GUI State.
Returns:
-
The
simulation update time
Class comp.Window
A special component with window-like behaviour.Base class: comp.Component.
Available only within GUI State.
- comp.window:addHideOnCloseHandler()
-
Adds a default handler for "onClose" that hides the window when it is closed.
Without the callback, the close button does nothing.
- comp.window:close()
- Closes the window. Calls the onClose callback.
- comp.window:getContent()
-
Returns the window content.
Returns:
-
ILayoutItem
the current content of the window
- comp.window:isAttached()
-
Checks if window is attached.
Returns:
-
bool
true if the window is attached
- comp.window:isPinnable()
-
Checks if window is pinnable.
Returns:
-
bool
true if the pin button is visible
- comp.window:isPinned()
-
Checks if window is pinned.
Returns:
-
bool
true if the window is pinned
- comp.window:maximize()
-
Maximizes the window to its maximisedSize size.
Must have set the maximisedSize with setMaximisedSize
- comp.window:minimize()
-
Minimizes the window to its minimizedSize size.
Must have set the maximisedSize with setMaximisedSize
- comp.window:new(title, content)
-
Creates a new Window.
Parameters:
- title string the window title displayed in the top right corner
- content Component the component that holds the content of the window
Returns:
-
Window
the window component
- comp.window:onClose(callback)
-
Adds a parameterless callback, which is called when the window is closed.
Parameters:
- callback func() the callback function that should be called when close() is called
- comp.window:onMove(callback)
-
Adds a parameterless callback, which is called when the window is moved
Parameters:
- callback func() the callback function that should be called when the window is moved
- comp.window:remove(win)
-
Removes a window from the UI and returns it.
Parameters:
- win string the window to remove from the UI and return
Returns:
-
Window
the removed window
- comp.window:setAttached(b)
-
Sets the window to be attached.
Parameters:
- b bool true if the window should get the :attached pseudoclass
- comp.window:setContent(content)
-
Sets the window content.
Parameters:
- content ILayoutItem the component or layout that should be used as the window content
- comp.window:setIcon(icon)
-
Sets the window icon.
Parameters:
- icon string the reference to the icon that should be set
- comp.window:setLocateButtonVisible(b)
-
Adds a button to follow entities and other objects.
Parameters:
- b bool true if the locate button left to the title should be visible
- comp.window:setMaximiseSize()
- Set the size when maximised.
- comp.window:setMovable(b)
-
Sets the window to be movable.
Parameters:
- b bool true if the window should be movable
- comp.window:setPinButtonVisible(b)
-
Adds a button to pin the window. It automatically reflects the pin status of the window.
Parameters:
- b bool true if the pin button right to the title should be visible
- comp.window:setPinned(b)
-
Sets the window to be pinned. Then the window is not closed when
key is used.Parameters:
- b bool true if the window should be pinned
- comp.window:setPosition(x, y)
-
Sets the window position.
Parameters:
- x int
- y int
- comp.window:setResizable(b)
-
Sets the window to be resizable.
Parameters:
- b bool true if the window should be resizable
- comp.window:setSize(size)
-
Sets the window size.
Parameters:
- size util.Size the size for the window
- comp.window:setTitle(title)
-
Sets the window title.
Parameters:
- title string the title that should be set
Class comp.GameUI
A special component which is the root of many other in-game components, including the entire ingame menu and the windowing system. In particular, it displays the main 3d representation of the world, in the form of a RendererComponent.Base class: comp.Component.
Available only within GUI State.
- comp.gameui:getMainRendererComponent()
-
Obtains the main 3d scene.
Returns:
-
RenderComponent
the main render component for the game world
- comp.gameui:getViewManager()
-
Obtains the view manager.
Returns:
-
ViewManager
the view manager for entity windows
- comp.gameui:playCutscene(fileName)
-
Plays a cutscene.
Parameters:
- fileName string the reference to the cutscene keyframe definition that should be played
- comp.gameui:playSoundEffect(name)
-
Plays a single sound effect.
Parameters:
- name string the name of the sound effect
- comp.gameui:playTrack(filename, offset)
-
Plays a single track with the music player.
Parameters:
- filename string the reference to the soundtrack file that should be played
- offset float the start position of the track
- comp.gameui:setConstructionAngle(angle)
-
Sets the default construction angle for constructions.
Parameters:
- angle float the default construction angle
Class comp.RendererComponent
Contains the 3d scene and control most actions.Base class: comp.Component.
Available only within GUI State.
- comp.renderercomponent:getCameraController()
-
Gets the camera controller for the component.
Returns:
-
CameraController
the camera controller of the RendererComponent
- comp.renderercomponent:getTerrainPos()
-
Gets the terrain position pointed by the mouse.
Returns:
-
{float,float,float}
x, y and z coordinates of the terrain position
- comp.renderercomponent:stopAction()
- Stops the current Action (bulldoze, build construction, etc.)
Class util.CameraController
Controls the camera view.Available only within GUI State.
- util.cameracontroller:focus(entity)
-
Focuses the camera on an entity.
Parameters:
- entity Entity the id of the entity that should be focussed on
- util.cameracontroller:follow(entity, jump)
-
Sets camera to follow an Entity.
Parameters:
- entity Entity the id of the entity that should be followed
- jump bool true if the camera should directly jump to the entity and not slide there
- util.cameracontroller:getCameraData()
-
Obtains the current camera data.
Returns:
-
type.Vec5f
the current camera data
- util.cameracontroller:getFollowEntity()
- Gets the entity currently being followed.
- util.cameracontroller:setCameraData(center, dist, angle, pitch)
-
Sets the camera data with custom position and other information.
Parameters:
- center type.Vec2f position on the map where the camera should point
- dist float the distance from this position
- angle float the rotation angle
- pitch float the pitch angle
Class util.ViewManager
Controls the small entity windows.Available only within GUI State.
- util.viewmanager:closeAll()
- Closes all currently open entity windows.
- util.viewmanager:openWindow(entity, above, tabIndex)
-
Focuses the camera on an entity.
Parameters:
- entity Entity the id of the entity of which to open the window
- above bool whether the window should go on top
- tabIndex int the tab index on which to open the window
Returns:
-
Window
the opened window or nil
Class comp.TextInputField
A simple component for input of lines of text.Base class: comp.Component
- comp.textinputfield:OnFocusChange(callback)
-
Sets a callback that is called when the focus changes.
Parameters:
- callback func Function taking a boolean telling if focus was lost or gained.
- comp.textinputfield:getSelectedText()
- Gets selected text.
- comp.textinputfield:getText()
- Returns the text in the input field.
- comp.textinputfield:new()
- Creates a new text input field with placeholder text.
- comp.textinputfield:onCancel(callback)
-
Sets a callback that is called when enter is pressed.
Parameters:
- callback func Function.
- comp.textinputfield:onChange(callback)
-
Sets a callback that is called when the text changes.
Parameters:
- callback func Function with the new text.
- comp.textinputfield:onEnter(callback)
-
Sets a callback that is called when enter is pressed.
Parameters:
- callback func Function.
- comp.textinputfield:selectAll()
- Selects entire text
- comp.textinputfield:setDeselectOnFocusLost()
- Clear selection when focus is lost
- comp.textinputfield:setMaxLength()
- Sets the maximal length of the input text.
- comp.textinputfield:setText()
- Sets the text of the field to the given text.
Class comp.TextView
A simple component for displaying (large amounts) of text.Base class: comp.Component
- comp.textview:getSelectedText()
- Gets selected text.
- comp.textview:getText()
- Gets the entire text.
- comp.textview:getTextAlignment()
- Gets the alignment of the text
- comp.textview:getTextAlignment2()
-
Gets the alignment of the text
Returns:
-
{ horizontal, vertical }
- comp.textview:new()
- Creates a new text view with some text.
- comp.textview:setSelectable()
- Sets the text as selectable.
- comp.textview:setText()
- Sets the text
- comp.textview:setTextAlignment()
- Sets the alignment of the text
Class comp.CheckBox
A simple component for displaying (large amounts) of text.Base class: comp.Component.
- comp.checkbox:isSelected()
- Return selection status for the checkbox
- comp.checkbox:new()
- Gets the entire text.
- comp.checkbox:onToggle(callback)
-
Sets a callback that is called when the checkbox is selected
Parameters:
- callback func Function taking a boolean telling if box was selected or unselected.
- comp.checkbox:setSelected(value, emit)
-
Sets the checkbox as selected.
Parameters:
- value bool Whether the box is selected or not
- emit bool Signal When true, "onToggle" will be called
- comp.checkbox:setText()
- Sets the label text of the checkbox.
Class comp.ImageView
A simple component for displaying images.Base class: comp.Component.
- comp.imageview:setImage()
- Sets the image of the image view.
- comp.imageview:setText()
- Creates a new imageview with a texture.
Class comp.ContentView
The base classes for components containing a single component.Base class: comp.Component.
- comp.contentview:getContent()
- Returns the content
- comp.contentview:setContent()
- Sets the content (takes ownership of content)
- comp.contentview:setContentAlignment()
- Sets the alignment of the content
Class comp.ToggleButton
A simple button that can be toggled on and off.Base class: comp.ContentView.
- comp.togglebutton:isSelected()
- TReturns whether the toggle button is toggled
- comp.togglebutton:new(child)
-
Creates a toggle button with a child element.
Parameters:
- child ILayoutItem The content of the button
- comp.togglebutton:onToggle()
- Calls the callback when the button is toggled
- comp.togglebutton:setSelected()
- TReturns whether the toggle status of the button
- comp.togglebutton:toggle()
- TToggles the button
Class comp.Button
A simple button that can be clicked and triggers an event.Base class: comp.ContentView.
- comp.button:click()
- Triggers a button click
- comp.button:new(child, clickOnPress)
-
Creates a button with a child element.
Parameters:
- child ILayoutItem The content of the button
- clickOnPress bool Whether the button tirggers a "onClick" callback when released, instead as when pressed
- comp.button:onClick()
- Calls the callback when the button is clicked
Class comp.ToggleButtonGroup
A group of buttons that can be toggled exclusively.Base class: comp.Component.
- comp.togglebuttongroup:add()
- Adds a new toggle button to the group, takes ownership of the button
- comp.togglebuttongroup:getButton()
- Returns a button with the given index
- comp.togglebuttongroup:getNumButtons()
- Returns the number of buttons
- comp.togglebuttongroup:getSelectedIndex()
- Returns the index of the selected button
- comp.togglebuttongroup:new()
- Creates a toggle button group.
- comp.togglebuttongroup:onCurrentIndexChanged()
- Calls the callback when one button is toggled with the index of the button
- comp.togglebuttongroup:setEmitSignal()
- Sets the group to trigger a signal when pressed
- comp.togglebuttongroup:setOneButtonMustAlwaysBeSelected()
- Prevents deselecting all buttons
Class comp.Table
Creates a simple table which supports selection and has an header.Base class: comp.Component.
- comp.table:addRow(components)
-
Adds a new row of components
Parameters:
- components {gui.comp.Component,...} Header components
- comp.table:deleteAll()
- Remove all rows and all components
- comp.table:deleteRows()
- Remove all rows between first and last
- comp.table:getNumCols()
- Gets the number of columns of the table
- comp.table:getNumRows()
- Gets the number of rows of the cable
- comp.table:insertRow(components)
-
Adds a new row of components at the given index
Parameters:
- components {gui.comp.Component,...} Header components
- comp.table:new(numColumns, selectable)
-
Create a new table with a set number of columns and an optional selection policy.
Parameters:
- comp.table:setColWeight()
- Sets the column weight (affects the width)
- comp.table:setColWidth()
- Set the column default width.
- comp.table:setHeader(components)
-
Sets the header for the table
Parameters:
- components {gui.comp.Component,...} Header components
- comp.table:setMaxColWidth()
- Sets the column maximum width
- comp.table:setMinColWidth()
- Sets the column minimum width
- comp.table:setNumCols()
- Sets the number of columns.
- comp.table:setOrder()
- Sort the rows with a given order.
Class comp.ScrollArea
Creates an area with (optional) scrollbar to fit bigger components.Base class: comp.Component.
- comp.ScrollBarPolicy
-
The visibility policy for the ScrollBar
Fields:
- AS_NEEDED 0
- ALWAYS_OFF 1
- ALWAYS_ON 2
- SIMPLE 3
- comp.scrollarea:SetHorizontalScrollBarPolicy(policy)
-
Sets the policy for the horizontal scrollbar
Parameters:
- policy ScrollBarPolicy
- comp.scrollarea:ensureVisible()
- Ensures a child component is visible
- comp.scrollarea:getContent()
- Returns content of the scroll area.
- comp.scrollarea:getScrollOffset()
- Returns current scroll offset.
- comp.scrollarea:getViewportRect()
- Return the Rect of the visible portion
- comp.scrollarea:new()
- Makes a new scroll area with given component and names.
- comp.scrollarea:onScroll()
- Sets a callback for scrolling
- comp.scrollarea:setContent()
- Sets the content of the scroll area
- comp.scrollarea:setScrollOffset()
- Scrolls to given position.
- comp.scrollarea:setVerticalScrollBarPolicy(policy)
-
Sets the policy for the vertical scrollbar
Parameters:
- policy ScrollBarPolicy
Class comp.ComboBox
A combo box with dropdown menu for selecting entries.Base class: comp.Component.
- comp.combobox:addItem()
- Adds a new item at the bottom of the combo box
- comp.combobox:addItemFactory(callback)
-
Adds a new component at the bottom of the combo box, callback is called each time the combbox is open
Parameters:
- callback func A function returning a new Component
- comp.combobox:clear()
- Remove all entries from the combo box
- comp.combobox:getCurrentIndex()
- Gets currently selected index.
- comp.combobox:getNumItems()
- Returns the number of items in a layout.
- comp.combobox:new()
- Makes a new empty combo box.
- comp.combobox:onIndexChanged(callback)
-
Add callback that is called when the current index changes.
Parameters:
- callback func(int) Function to be called
Class comp.DoubleSpinBox
A spin box with input for floating point numbers.Base class: comp.Component
- comp.doublespinbox:getMaximum()
- Returns the current maximum possible value for the spinbox
- comp.doublespinbox:getMinimum()
- Returns the current minimum possible value for the spinbox
- comp.doublespinbox:getValue()
- Returns the current value of the spinbox
- comp.doublespinbox:new()
- Makes a new spin box with default values.
- comp.doublespinbox:onChange(callback)
-
Adds a callback for when the spinbox changes value.
Parameters:
- callback func(number) called each time the spinbox changes value
- comp.doublespinbox:setMaximum()
- Sets maximum selectable value for the spin box
- comp.doublespinbox:setMinimum()
- Sets minimum selectable value for the spin box
- comp.doublespinbox:setStep()
- Sets the interval between values of the spinbox
- comp.doublespinbox:setValue()
- Sets the current value of the spinbox
Class comp.SpinBox
A spin box with input for whole numbers.Base class: comp.Component
- comp.spinbox:getValue()
- Returns the current value of the spinbox
- comp.spinbox:new()
- Makes a new spin box with default values.
- comp.spinbox:onChange(callback)
-
Adds a callback for when the spinbox changes value.
Parameters:
- callback func(number) called each time the spinbox changes value
- comp.spinbox:setRange()
- Sets minimum and maximum selectable values for the spin box
- comp.spinbox:setValue()
- Sets the current value of the spinbox
Class comp.AbstractSlider
A base abstract class for all slider typesBase class: comp.Component
- comp.abstractslider:getPageStep()
- Gets the current page step of the slider
- comp.abstractslider:getPageStep()
- Gets the current minimum value of the slider
- comp.abstractslider:getPageStep()
- Gets the current maximum value of the slider
- comp.abstractslider:getStep()
- Gets the current step of the slider
- comp.abstractslider:getValue()
- Sets the current value of the slider
- comp.abstractslider:onValueChanged()
- Get called when the slider value changes.
- comp.abstractslider:setDefaultValue()
- Sets the default value of the slider
- comp.abstractslider:setMaximum()
- Sets the maximum value of the slider
- comp.abstractslider:setMinimum()
- Sets the minimum size of the slider
- comp.abstractslider:setPageStep()
- Sets the big increment size of the slider (controlled with page buttons)
- comp.abstractslider:setStep()
- Sets the increment size of the slider
- comp.abstractslider:setValue()
- Sets the value of the slider
Class comp.Slider
An slider that can be vertical of horizontal.Base class: comp.AbstractSlider
Class comp.Slider2
A 2d slider with 2 sets of valuesBase class: comp.Component
- comp.slider2:getValue()
- Sets the current value of the slider
- comp.slider2:new()
- Creates a new 2d slider
- comp.slider2:onValueChanged(callback)
-
Adds a callback for the slider, that is called when the slider value changes
Parameters:
- callback func(type.Vec2i) called when the value changes
- comp.slider2:setMaximum()
- Sets the maximum value for the slider
- comp.slider2:setMinimum()
- Sets the minimum value for the slider
- comp.slider2:setValue()
- Sets the default value for the slider
- comp.slider2:setValue()
- Sets the value of the slider to the given one
- comp.slider2:setValue()
- Sets the default step for the slider
Class comp.TabWidget
A component with multiple tabs to diplay the content.Base class: comp.Component
- comp.tabwidget:addSpace()
- Adds a space after the selected tab
- comp.tabwidget:addTab()
- Adds tab at the end, uses indicator to display the tab
- comp.tabwidget:addTabText()
- Adds tab at the end, uses text as indicator for the tab
- comp.tabwidget:getCurrentTab()
- (deprecated) Use getCurrentTabIndex instead
- comp.tabwidget:getCurrentTabIndex()
- Gets the tab index that is currently selected
- comp.tabwidget:getIndicator()
- Gets the indicator component at the given index
- comp.tabwidget:getNumTabs()
- Gets the numer of tabs
- comp.tabwidget:getTab()
- Gets the tab at specified index
- comp.tabwidget:insertTab()
- Inserts tab at given position, uses indicator to display the tab
- comp.tabwidget:new(orientation)
-
Creates a new tab widget with tabs on the given position
Parameters:
- orientation string One of "NORTH", "EAST", "SOUTH", "WEST"
- comp.tabwidget:onCurrentChanged(int)
-
Called when the tab changes,
Parameters:
- int func(int, ) callback Will be provided an index before and after the call
- comp.tabwidget:setCurrentTab()
- Sets the tab that is currently selected
- comp.tabwidget:setDeselectAllowed()
- Allow selecting no tab at all
Class comp.ProgressBar
A component that displays a progressBase class: comp.Component
- comp.progressbar:getProgress()
- Gets the current progress
- comp.progressbar:new()
- Creates a new progress bar
- comp.progressbar:setColor()
- Sets the color of the progress bar
- comp.progressbar:setProgress(The)
-
Sets the current progress
Parameters:
- The number progress (between 0 and 1)
- comp.progressbar:setTask()
- Adds some text to the bar
Class comp.Chart
A line or bar plot of values on a graph Base class: comp.Component- comp.chart:addSeries()
- Adds a new data series to the graph
- comp.chart:clear()
- Clears all data from the graph
- comp.chart:new()
- Creates a new chart
- comp.chart:setAxis()
- Sets the axis values and the range of the axis
- comp.chart:setColor()
- Sets the color of the bar
- comp.chart:setLabelFormatter(axis, callback)
-
Sets a function to be called to format axis numbers into labels
Parameters:
- axis Number The axis for which the callback will be used (0 = horizontal, 1 = vertical)
- callback func(Number) The callback to format numbers into strings
- comp.chart:setLineWidth()
- Sets the line with of the graph
- comp.chart:setSeriesLabels()
- Sets the labels for the series
- comp.chart:setType(type)
-
Sets the type of graph
Parameters:
- type string One of "LINE", "LINE_STEP" or "BAR"
Class comp.ColorChooserButton
A button that opens a color picker Base class: comp.Component- comp.colorchooserbutton:new()
-
Creates a new color picker button.
The reset color is
type.Vec3f(-1, -1, -1)
. - comp.colorchooserbutton:onSelect(callback)
-
Called when the color is selected
Parameters:
- callback func(type.Vec3f) The callback that is called
- comp.colorchooserbutton:setColor()
- Sets the currently selected color.
Class comp.ColorPicker
A color picker component Base class: comp.Component- comp.colorpicker:new()
- Creates a new color picker
- comp.colorpicker:onColorChanged(callback)
-
Called when the selected color changes
Parameters:
- callback func(type.Vec3f) The callback that is called
- comp.colorpicker:setColor()
- Sets the color of the color picker
Class comp.ColorChooser
A color chooser component Base class: comp.Component- comp.colorchooser:new()
- Creates a new color chooser
- comp.colorchooser:onSelect(callback)
-
Called when the color is selected.
Parameters:
- callback func(type.Vec3f) The callback that is called
Class comp.LineRenderView
Display lines Base class: comp.Component- comp.linerenderview:addLine(from, to)
-
Add a new displayed line from from to to
Parameters:
- from type.Vec2f Start point
- to type.Vec2f End point
- comp.linerenderview:clear()
- Clear all lines added so far.
- comp.linerenderview:new()
- Creates a new line render component
- comp.linerenderview:setColor(color)
-
Called to set the color of all lines added to this
Parameters:
- color type.Vec4f The color or all lines
- comp.linerenderview:setWidth(width)
-
Set the width of all lines of the component.
Parameters:
- width number Width, in pixels
Class comp.List
A list of components with automatic scroll area Base class: comp.ScrollArea- comp.list:addItem(item)
-
Adds an item to the list
Parameters:
- item type.Component The item to add
- comp.list:clear(emitSignal)
-
Clear items from list
Parameters:
- emitSignal bool
- comp.list:getItem(index)
-
Returns component at position index
Parameters:
- index number
Returns:
-
type.Component
Item at position index
- comp.list:getNumItems()
-
Returns number of items in the list
Returns:
-
int
Number of items
- comp.list:getSelectedIndex()
-
Returns currently selected item
Returns:
-
int
Currently selected index
- comp.list:new(drawBackground, orientation, autoDeselectDisabledItems)
-
Creates a new list component
Parameters:
- drawBackground bool
- orientation Orientation
- autoDeselectDisabledItems bool
- comp.list:onActivate(callback)
-
Called when an item is activated
Parameters:
- callback func(number) The callback that is called
Returns:
-
type.Connection
A connection that needs to be disconnected when the callback should be removed
- comp.list:onHover(callback)
-
Called when an item is hovered on
Parameters:
- callback func(number) The callback that is called
Returns:
-
type.Connection
A connection that needs to be disconnected when the callback should be removed
- comp.list:onSelect(callback)
-
Called when an item is selected
Parameters:
- callback func(number) The callback that is called
Returns:
-
type.Connection
A connection that needs to be disconnected when the callback should be removed
- comp.list:removeItem(index, emitSignal)
-
Removes an item from the list
Parameters:
- index int The index of the item to remove
- emitSignal bool Emit select signal for newly selected item
Returns:
-
type.ILayoutItem
item the removed item
- comp.list:select(index, emitSignal)
-
Selects an item in the list
Parameters:
- index int
- emitSignal bool
- comp.list:setDeselectAllowed(deselectAllowed)
-
Set policy to allow no selected item
Parameters:
- deselectAllowed bool
- comp.list:setEmitSignalOnReselect(emitSignal)
-
Set policy not to emit a signal when the same item is selected
Parameters:
- emitSignal bool
Class layout.ILayout
Base for all layouts, cannot be created and is used only as base class.Base class: comp.ILayoutItem.
- layout.ilayout:getItem()
- Get the item at the given index.
- layout.ilayout:getNumItems()
- Get the number of items in a layout
- layout.ilayout:removeItem()
- Removes an item from the layout, returns an object having ownership of the removed item.
Class layout.LayoutBase
Abstract layout with an id. Cannot be created and is used only as base class.Base class: layout.ILayout.
- layout.layoutbase:addItem()
- Adds an item to the layout. Gives ownership to the layout.
- layout.layoutbase:getComponent()
- Get the component stored in the layout.
- layout.layoutbase:insertItem()
- Adds an item to the layout at given position. Gives ownership to the layout.
- layout.layoutbase:setGravity()
- Sets the alignment of the component.
- layout.layoutbase:setId()
- Sets a name for the layout.
- layout.layoutbase:setId()
- Sets a unique id for the layout.
Class layout.BoxLayout
A layout that aligns it's childs in a stack.Base class: layout.AbstractLayout.
- layout.boxlayout:new(orientation)
-
Creates a new layout with the given orientation.
Parameters:
- orientation string One of "HORIZONTAL" or "VERTICAL".
Class layout.AbsoluteLayout
A layout that aligns it childs with an absolute position, independently of other siblings. Each item has an absolute position relative to the parent.Base class: layout.LayoutBase.
- layout.absolutelayout:addItem()
- Adds an item with the given geometry to the layout. Takes ownership of the item.
- layout.absolutelayout:deleteAll()
- Removes all childs and deletes them.
- layout.absolutelayout:getIndex()
- Get the index of the item at given position.
- layout.absolutelayout:new(orientation)
-
Creates a new layout with the given orientation.
Parameters:
- orientation string One of "HORIZONTAL" or "VERTICAL".
- layout.absolutelayout:setItemPosition()
- [Deprecated] Sets item at position. Use setPosition instead.
- layout.absolutelayout:setPosition()
- Sets the position of the item at given index at the given position.
Class layout.FloatingLayout
A layout that aligns it's childs if a position that is relative to the parent.Base class: layout.LayoutBase.
- layout.floatinglayout:addItem()
- Adds an item with the given alignments.
- layout.floatinglayout:deleteAll()
- Removes and deletes all elements in the layout.
- layout.floatinglayout:insertItem()
- Adds and items (and takes ownership), at the given position and with the given alignments.
- layout.floatinglayout:new()
- Creates a new layout
- layout.floatinglayout:setAlignment()
- Sets the alignment of the item at the position.