deploy: 487409b31a
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
# ElementManager
|
||||
This class manages elements and plugins. It loads elements and plugins from the elements and plugins directories
|
||||
and then applies the plugins to the elements. It also provides a way to get elements and APIs.
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[ElementManager.getAPI](#elementmanager-getapi)|table|
|
||||
|[ElementManager.getElement](#elementmanager-getelement)|table|
|
||||
|[ElementManager.getElementList](#elementmanager-getelementlist)|table|
|
||||
|[ElementManager.loadElement](#elementmanager-loadelement)|-|
|
||||
|
||||
|
||||
## ElementManager.getAPI(name)
|
||||
Gets an Plugin API by name
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the API to get
|
||||
|
||||
### Returns
|
||||
* `table` `API` The API
|
||||
|
||||
## ElementManager.getElement(name)
|
||||
Gets an element by name. If the element is not loaded, it will try to load it first.
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the element to get
|
||||
|
||||
### Returns
|
||||
* `table` `Element` The element class
|
||||
|
||||
## ElementManager.getElementList()
|
||||
Gets a list of all elements
|
||||
|
||||
### Returns
|
||||
* `table` `ElementList` A list of all elements
|
||||
|
||||
## ElementManager.loadElement(name)
|
||||
Loads an element by name. This will load the element and apply any plugins to it.
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the element to load
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
ElementManager.loadElement("Button")
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# BarChart : Graph
|
||||
The Bar Chart element is designed for visualizing data series as vertical bars. It displays multiple values as side-by-side bars where each bar's height represents its value.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local chart = main:addBarChart()
|
||||
:addSeries("input", " ", colors.green, colors.green, 5)
|
||||
:addSeries("output", " ", colors.red, colors.red, 5)
|
||||
|
||||
basalt.schedule(function()
|
||||
while true do
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
sleep(2)
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|BarChart:init|BarChart|Initializes the BarChart instance
|
||||
|BarChart:render|-|Renders the BarChart
|
||||
|
||||
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
# BaseElement : PropertySystem
|
||||
The base class for all UI elements in Basalt. This class provides basic properties and event handling functionality.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|type|string|BaseElement|The type identifier of the element
|
||||
|id|string|BaseElement|The unique identifier for the element
|
||||
|name|string|BaseElement|The name of the element
|
||||
|eventCallbacks|table|BaseElement|The event callbacks for the element
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseElement.defineEvent](#baseelement-defineevent)|-|Registers a new event listener for the element (on class level)
|
||||
|[BaseElement.registerEventCallback](#baseelement-registereventcallback)|-|Registers a new event callback for the element (on class level)
|
||||
|[BaseElement:destroy](#baseelement-destroy)|-|Destroys the element and cleans up all references
|
||||
|[BaseElement:fireEvent](#baseelement-fireevent)|table|Triggers an event and calls all registered callbacks
|
||||
|[BaseElement:getBaseFrame](#baseelement-getbaseframe)|BaseFrame|Returns the base frame of the element
|
||||
|[BaseElement:isType](#baseelement-istype)|boolean|Checks if the element is a specific type
|
||||
|[BaseElement:listenEvent](#baseelement-listenevent)|table|Enables or disables event listening for a specific event
|
||||
|[BaseElement:onChange](#baseelement-onchange)|table|Observes a property and calls a callback when it changes
|
||||
|[BaseElement:registerCallback](#baseelement-registercallback)|table|Registers a callback function
|
||||
|[BaseElement:updateRender](#baseelement-updaterender)|table|Requests a render update for this element
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|BaseElement:dispatchEvent|boolean?|Handles all events
|
||||
|BaseElement:handleEvent|boolean?|The default event handler for all events
|
||||
|BaseElement:init|table|Initializes the BaseElement instance
|
||||
|BaseElement:postInit|table|Post initialization
|
||||
|
||||
## BaseElement.defineEvent(class, eventName, requiredEvent?)
|
||||
Registers a new event listener for the element (on class level)
|
||||
|
||||
### Parameters
|
||||
* `class` `table` The class to register
|
||||
* `eventName` `string` The name of the event to register
|
||||
* `requiredEvent` *(optional)* `string` The name of the required event (optional)
|
||||
|
||||
## BaseElement.registerEventCallback(class, callbackName, ...)
|
||||
Registers a new event callback for the element (on class level)
|
||||
|
||||
### Parameters
|
||||
* `class` `table` The class to register
|
||||
* `callbackName` `string` The name of the callback to register
|
||||
* `...` `string` The names of the events to register the callback for
|
||||
|
||||
## BaseElement:destroy()
|
||||
Destroys the element and cleans up all references
|
||||
|
||||
## BaseElement:fireEvent(event, ...)
|
||||
Triggers an event and calls all registered callbacks
|
||||
|
||||
### Parameters
|
||||
* `event` `string` The event to fire
|
||||
* `...` `any` Additional arguments to pass to the callbacks
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
## BaseElement:getBaseFrame()
|
||||
Returns the base frame of the element
|
||||
|
||||
### Returns
|
||||
* `BaseFrame` `BaseFrame` The base frame of the element
|
||||
|
||||
## BaseElement:isType(type)
|
||||
Checks if the element is a specific type
|
||||
|
||||
### Parameters
|
||||
* `type` `string` The type to check for
|
||||
|
||||
### Returns
|
||||
* `boolean` `isType` Whether the element is of the specified type
|
||||
|
||||
## BaseElement:listenEvent(eventName, enable?)
|
||||
Enables or disables event listening for a specific event
|
||||
|
||||
### Parameters
|
||||
* `eventName` `string` The name of the event to listen for
|
||||
* `enable` *(optional)* `boolean` Whether to enable or disable the event (default: true)
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
## BaseElement:onChange(property, callback)
|
||||
Observes a property and calls a callback when it changes
|
||||
|
||||
### Parameters
|
||||
* `property` `string` The property to observe
|
||||
* `callback` `function` The callback to call when the property changes
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
## BaseElement:registerCallback(event, callback)
|
||||
Registers a callback function for an event
|
||||
|
||||
### Parameters
|
||||
* `event` `string` The event to register the callback for
|
||||
* `callback` `function` The callback function to register
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
## BaseElement:updateRender()
|
||||
Requests a render update for this element
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
# BaseFrame : Container
|
||||
This is the base frame class. It is the root element of all elements and the only element without a parent.
|
||||
|
||||
## Fields
|
||||
|
||||
|Field|Type|Description|
|
||||
|---|---|---|
|
||||
|_render|`Render`|The render object|
|
||||
|_renderUpdate|`boolean`|Whether the render object needs to be updated|
|
||||
|_peripheralName|`string`|The name of a peripheral|
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|term|term|peripheral|term.current()|The terminal or (monitor) peripheral object to render to
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseFrame:dispatchEvent](#baseframe-dispatchevent)|-|
|
||||
|[BaseFrame:drawBg](#baseframe-drawbg)|-|
|
||||
|[BaseFrame:drawFg](#baseframe-drawfg)|-|
|
||||
|[BaseFrame:setCursor](#baseframe-setcursor)|-|Sets the cursor position
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|BaseFrame:blit|-|Renders a text with a foreground and background color to the render Object
|
||||
|BaseFrame:char|-|Handles character events
|
||||
|BaseFrame:drawText|-|Renders a text with a background color to the render Object
|
||||
|BaseFrame:init|table|Initializes the Frame instance
|
||||
|BaseFrame:key|-|Handles key events
|
||||
|BaseFrame:key_up|-|Handles key up events
|
||||
|BaseFrame:monitor_touch|-|Handles monitor touch events
|
||||
|BaseFrame:mouse_click|-|Handles mouse click events
|
||||
|BaseFrame:mouse_up|-|Handles mouse up events
|
||||
|BaseFrame:multiBlit|-|Renders a multiBlit to the render Object
|
||||
|BaseFrame:render|-|Renders the Frame
|
||||
|BaseFrame:term_resize|-|Resizes the Frame
|
||||
|BaseFrame:textBg|-|Renders a text with a background color to the render Object
|
||||
|BaseFrame:textFg|-|Renders a text with a foreground color to the render Object
|
||||
|
||||
## BaseFrame:dispatchEvent()
|
||||
|
||||
## BaseFrame:drawBg()
|
||||
|
||||
## BaseFrame:drawFg()
|
||||
|
||||
## BaseFrame:setCursor(x, y, blink)
|
||||
Sets the cursor position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to set the cursor to
|
||||
* `y` `number` The y position to set the cursor to
|
||||
* `blink` `boolean` Whether the cursor should blink
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# BigFont : VisualElement
|
||||
The BigFont element is a text element that displays larger text. It uses Wojbie's BigFont API to render the text in a larger font size. Credits to Wojbie for the original API.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local font = main:addBigFont()
|
||||
font:setText("Hello World!")
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|text|string|BigFont|BigFont text
|
||||
|fontSize|number|1|The font size of the BigFont
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|BigFont:init|-|Initializes the BigFont instance
|
||||
|BigFont:render|-|Renders the BigFont
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Button : VisualElement
|
||||
The Button is a standard button element with click handling and state management.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|text|string|Button|Button text
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Button:init|-|Initializes the Button instance
|
||||
|Button:render|-|Renders the Button
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# Checkbox : VisualElement
|
||||
The Checkbox is a visual element that can be checked.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|checked|boolean|Whether|checkbox is checked
|
||||
|text|string|empty|Text to display
|
||||
|checkedText|string|Text|when checked
|
||||
|autoSize|boolean|true|Whether to automatically size the checkbox
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Checkbox.new|Checkbox|Creates a new Checkbox instance
|
||||
|Checkbox:init|-|Initializes the Checkbox instance
|
||||
|Checkbox:mouse_click|boolean|Handles mouse click events
|
||||
|Checkbox:render|-|Renders the Checkbox
|
||||
|
||||
|
||||
|
||||
0
docs/references/elements/ComboBox.md
Normal file
0
docs/references/elements/ComboBox.md
Normal file
@@ -1,187 +0,0 @@
|
||||
# Container : VisualElement
|
||||
The Container class serves as a fundamental building block for organizing UI elements. It acts as a parent element that can hold and manage child elements.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local container = basalt.getMainFrame()
|
||||
container:addButton() -- Add a child element
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|children|table|{}|The children of the container
|
||||
|childrenSorted|boolean|true|Whether the children are sorted
|
||||
|childrenEventsSorted|boolean|true|Whether the children events are sorted
|
||||
|childrenEvents|table|{}|The children events of the container
|
||||
|eventListenerCount|table|{}|The event listener count of the container
|
||||
|focusedChild|table|nil|The focused child of the container
|
||||
|visibleChildren|table|{}|The visible children of the container
|
||||
|visibleChildrenEvents|table|{}|The visible children events of the container
|
||||
|offsetX|number|0|Horizontal content offset
|
||||
|offsetY|number|0|Vertical content offset
|
||||
|
||||
## Combined Properties
|
||||
|
||||
|Name|Properties|Description|
|
||||
|---|---|---|
|
||||
|offset|`offsetX number, offsetY number`|Combined property for offsetX and offsetY|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Container:addChild](#container-addchild)|Container|Adds a child to the container
|
||||
|[Container:callChildrenEvent](#container-callchildrenevent)|boolean|Calls a event on all children
|
||||
|[Container:clear](#container-clear)|Container|Clears the container
|
||||
|[Container:drawBg](#container-drawbg)|-|
|
||||
|[Container:drawFg](#container-drawfg)|-|
|
||||
|[Container:drawText](#container-drawtext)|-|
|
||||
|[Container:getChild](#container-getchild)|Container?|Removes a child from the container
|
||||
|[Container:isChildVisible](#container-ischildvisible)|boolean|Returns whether a child is visible
|
||||
|[Container:registerChildEvent](#container-registerchildevent)|Container|Registers the children events of the container
|
||||
|[Container:registerChildrenEvents](#container-registerchildrenevents)|Container|Registers the children events of the container
|
||||
|[Container:removeChild](#container-removechild)|Container|Removes a child from the container
|
||||
|[Container:removeChildrenEvents](#container-removechildrenevents)|Container|Unregisters the children events of the container
|
||||
|[Container:sortChildren](#container-sortchildren)|Container|Sorts the children of the container
|
||||
|[Container:sortChildrenEvents](#container-sortchildrenevents)|Container|Sorts the children events of the container
|
||||
|[Container:unregisterChildEvent](#container-unregisterchildevent)|Container|Unregisters the children events of the container
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Container:blit|Container|Draws a line of text and fg and bg as colors
|
||||
|Container:char|boolean|Handles char events
|
||||
|Container:handleEvent|boolean|Default handler for events
|
||||
|Container:init|-|Initializes the Container instance
|
||||
|Container:key|boolean|Handles key events
|
||||
|Container:key_up|boolean|Handles key up events
|
||||
|Container:mouse_click|boolean|Handles mouse click events
|
||||
|Container:mouse_drag|boolean|Handles mouse drag events
|
||||
|Container:mouse_move|boolean|Handles mouse move events
|
||||
|Container:mouse_release|-|Handles mouse release events
|
||||
|Container:mouse_scroll|boolean|Handles mouse scroll events
|
||||
|Container:mouse_up|boolean|Handles mouse up events
|
||||
|Container:multiBlit|Container|Draws multiple lines of text, fg and bg strings
|
||||
|Container:render|-|Renders the container
|
||||
|Container:textBg|Container|Draws a line of text and bg as color
|
||||
|Container:textFg|Container|Draws a line of text and fg as color
|
||||
|
||||
## Container:addChild(child)
|
||||
Adds a child to the container
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to add
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:callChildrenEvent(visibleOnly, event...)
|
||||
Calls a event on all children
|
||||
|
||||
### Parameters
|
||||
* `visibleOnly` `boolean` Whether to only call the event on visible children
|
||||
* `event` `string` The event to call
|
||||
* `...` *(vararg)* `any` The event arguments
|
||||
|
||||
### Returns
|
||||
* `boolean` `handled` Whether the event was handled
|
||||
* `table?` `child` The child that handled the event
|
||||
|
||||
## Container:clear()
|
||||
Clears the container
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:drawBg()
|
||||
|
||||
## Container:drawFg()
|
||||
|
||||
## Container:drawText()
|
||||
|
||||
## Container:getChild(path)
|
||||
Removes a child from the container
|
||||
|
||||
### Parameters
|
||||
* `path` `string` The path to the child to remove
|
||||
|
||||
### Returns
|
||||
* `Container?` `self` The container instance
|
||||
|
||||
## Container:isChildVisible(child)
|
||||
Returns whether a child is visible
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to check
|
||||
|
||||
### Returns
|
||||
* `boolean` `boolean` the child is visible
|
||||
|
||||
## Container:registerChildEvent(child, eventName)
|
||||
Registers the children events of the container
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to register events for
|
||||
* `eventName` `string` The event name to register
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:registerChildrenEvents(child)
|
||||
Registers the children events of the container
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to register events for
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:removeChild(child)
|
||||
Removes a child from the container
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to remove
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:removeChildrenEvents(child)
|
||||
Unregisters the children events of the container
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to unregister events for
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:sortChildren()
|
||||
Sorts the children of the container
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:sortChildrenEvents(eventName)
|
||||
Sorts the children events of the container
|
||||
|
||||
### Parameters
|
||||
* `eventName` `string` The event name to sort
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
## Container:unregisterChildEvent(child, eventName)
|
||||
Unregisters the children events of the container
|
||||
|
||||
### Parameters
|
||||
* `child` `table` The child to unregister events for
|
||||
* `eventName` `string` The event name to unregister
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# Display : VisualElement
|
||||
The Display is a special element where you can use the window (term) API to draw on the display, useful when you need to use external APIs.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local display = main:addDisplay() -- Create a display element
|
||||
local displayWindow = display:getWindow() -- Get the window object of the display
|
||||
displayWindow.write("Hello World!") -- Write "Hello World!" to the display
|
||||
```
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Display:getWindow](#display-getwindow)|table|Returns the current window object
|
||||
|[Display:write](#display-write)|Display|Writes text to the display
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Display:init|-|Initializes the Display instance
|
||||
|Display:render|-|Renders the Display
|
||||
|
||||
## Display:getWindow()
|
||||
Returns the current window object
|
||||
|
||||
### Returns
|
||||
* `table` `window` The current window object
|
||||
|
||||
## Display:write(x, y, text, fg?, bg?)
|
||||
Writes text to the display at the given position with the given foreground and background colors
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to write to
|
||||
* `y` `number` The y position to write to
|
||||
* `text` `string` The text to write
|
||||
* `fg` *(optional)* `colors` The foreground color (optional)
|
||||
* `bg` *(optional)* `colors` The background color (optional)
|
||||
|
||||
### Returns
|
||||
* `Display` `self` The display instance
|
||||
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
# Dropdown : List
|
||||
This is the dropdown class. It is a visual element that can show a list of selectable items in a dropdown menu.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local dropdown = main:addDropdown()
|
||||
dropdown:setItems({
|
||||
{text = "Item 1", callback = function() basalt.LOGGER.debug("Item 1 selected") end},
|
||||
{text = "Item 2", callback = function() basalt.LOGGER.debug("Item 2 selected") end},
|
||||
{text = "Item 3", callback = function() basalt.LOGGER.debug("Item 3 selected") end},
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|isOpen|boolean|false|Whether the dropdown menu is currently open
|
||||
|dropdownHeight|number|5|Maximum height of the dropdown menu when open
|
||||
|selectedText|string|""|The text to show when no item is selected
|
||||
|dropSymbol|string|"\31"|The symbol to show for dropdown indication
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Dropdown:init|Dropdown|Initializes the Dropdown instance
|
||||
|Dropdown:mouse_click|boolean|Handles mouse click events
|
||||
|Dropdown:render|-|Renders the Dropdown
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Flexbox : Container
|
||||
This is the Flexbox class. It is a container that arranges its children in a flexible layout.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local flex = main:addFlexbox({background=colors.black, width=30, height=10})
|
||||
flex:addButton():setFlexGrow(1)
|
||||
flex:addButton():setFlexGrow(1)
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
The flexbox element adds the following properties to its children:
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary.
|
||||
flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary.
|
||||
flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|flexDirection|string|"row"|The direction of the flexbox layout "row" or "column"
|
||||
|flexSpacing|number|1|The spacing between flex items
|
||||
|flexJustifyContent|string|"flex-start"|The alignment of flex items along the main axis
|
||||
|flexWrap|boolean|false|Whether to wrap flex items onto multiple lines
|
||||
|flexUpdateLayout|boolean|false|Whether to update the layout of the flexbox
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Flexbox:addChild](#flexbox-addchild)|Flexbox|Adds a child element to the flexbox
|
||||
|[Flexbox:addLineBreak](#flexbox-addlinebreak)|Flexbox|Adds a new line break to the flexbox.
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Flexbox:init|Flexbox|Initializes the Flexbox instance
|
||||
|Flexbox:removeChild|Flexbox|Removes a child element from the flexbox
|
||||
|Flexbox:render|-|Renders the flexbox and its children
|
||||
|
||||
## Flexbox:addChild(element)
|
||||
Adds a child element to the flexbox
|
||||
|
||||
### Parameters
|
||||
* `element` `Element` The child element to add
|
||||
|
||||
### Returns
|
||||
* `Flexbox` `self` The flexbox instance
|
||||
|
||||
## Flexbox:addLineBreak(self)
|
||||
Adds a new line break to the flexbox
|
||||
|
||||
### Parameters
|
||||
* `self` `Flexbox` The element itself
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# Frame : Container
|
||||
This is the frame class. It serves as a grouping container for other elements.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|draggable|boolean|false|Whether the frame is draggable
|
||||
|draggingMap|table|{}|The map of dragging positions
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Frame:init|Frame|Initializes the Frame instance
|
||||
|Frame:mouse_click|boolean|Handles mouse click events
|
||||
|Frame:mouse_drag|boolean|Handles mouse drag events
|
||||
|Frame:mouse_up|boolean|Handles mouse release events
|
||||
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
# Graph : VisualElement
|
||||
This is the base class for all graph elements. It is a point based graph.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local graph = main:addGraph()
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
|
||||
basalt.schedule(function()
|
||||
while true do
|
||||
graph:addPoint("input", math.random(1,100))
|
||||
graph:addPoint("output", math.random(1,100))
|
||||
sleep(2)
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|minValue|number|0|The minimum value of the graph
|
||||
|maxValue|number|100|The maximum value of the graph
|
||||
|series|table|{}|The series of the graph
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Graph:addPoint](#graph-addpoint)|Graph|Adds a point to a series
|
||||
|[Graph:addSeries](#graph-addseries)|Graph|Adds a series to the graph
|
||||
|[Graph:changeSeriesVisibility](#graph-changeseriesvisibility)|Graph|Changes the visibility of a series
|
||||
|[Graph:clear](#graph-clear)|Graph|Clears all points from a series
|
||||
|[Graph:focusSeries](#graph-focusseries)|Graph|Focuses a series
|
||||
|[Graph:getSeries](#graph-getseries)|table?|Gets a series from the graph
|
||||
|[Graph:removeSeries](#graph-removeseries)|Graph|Removes a series from the graph
|
||||
|[Graph:setSeriesPointCount](#graph-setseriespointcount)|Graph|Sets the point count of a series
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Graph:init|Graph|Initializes the Graph instance
|
||||
|Graph:render|-|Renders the graph
|
||||
|
||||
## Graph:addPoint(name, value)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
* `value` `number` The value of the point
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
## Graph:addSeries(name, symbol, bgCol, fgCol, pointCount)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
* `symbol` `string` The symbol of the series
|
||||
* `bgCol` `number` The background color of the series
|
||||
* `fgCol` `number` The foreground color of the series
|
||||
* `pointCount` `number` The number of points in the series
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
## Graph:changeSeriesVisibility(name, visible)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
* `visible` `boolean` Whether the series should be visible
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
## Graph:clear(name?)
|
||||
Clears all points from a series
|
||||
|
||||
### Parameters
|
||||
* `name` *(optional)* `string` The name of the series
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
## Graph:focusSeries(name)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
## Graph:getSeries(name)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
|
||||
### Returns
|
||||
* `table?` `series` The series
|
||||
|
||||
## Graph:removeSeries(name)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
## Graph:setSeriesPointCount(name, count)
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the series
|
||||
* `count` `number` The number of points in the series
|
||||
|
||||
### Returns
|
||||
* `Graph` `self` The graph instance
|
||||
|
||||
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
# Image : VisualElement
|
||||
This is the Image element class which can be used to display bimg formatted images.
|
||||
Bimg is a universal ComputerCraft image format.
|
||||
See: https://github.com/SkyTheCodeMaster/bimg
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|bimg|table|{}|The bimg image data
|
||||
|currentFrame|number|1|Current animation frame
|
||||
|autoResize|boolean|false|Whether to automatically resize the image when content exceeds bounds
|
||||
|offsetX|number|0|Horizontal offset for viewing larger images
|
||||
|offsetY|number|0|Vertical offset for viewing larger images
|
||||
|
||||
## Combined Properties
|
||||
|
||||
|Name|Properties|Description|
|
||||
|---|---|---|
|
||||
|offset|`offsetX offsetY`|Combined property for offsetX and offsetY|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Image:addFrame](#image-addframe)|Image|Adds a new frame to the image
|
||||
|[Image:getBg](#image-getbg)|string|Gets the background color at the specified position
|
||||
|[Image:getFg](#image-getfg)|string|Gets the foreground color at the specified position
|
||||
|[Image:getFrame](#image-getframe)|table|Gets the specified frame
|
||||
|[Image:getImageSize](#image-getimagesize)|number|Gets the size of the image
|
||||
|[Image:getMetadata](#image-getmetadata)|table|Gets the metadata of the image
|
||||
|[Image:getPixelData](#image-getpixeldata)|number?|Gets pixel information at position
|
||||
|[Image:getText](#image-gettext)|string|Gets the text at the specified position
|
||||
|[Image:nextFrame](#image-nextframe)|Image|Advances to the next frame in the animation
|
||||
|[Image:resizeImage](#image-resizeimage)|Image|Resizes the image to the specified width and height
|
||||
|[Image:setBg](#image-setbg)|Image|Sets the background color at the specified position
|
||||
|[Image:setFg](#image-setfg)|Image|Sets the foreground color at the specified position
|
||||
|[Image:setMetadata](#image-setmetadata)|Image|Sets the metadata of the image
|
||||
|[Image:setPixel](#image-setpixel)|Image|Sets the pixel at the specified position
|
||||
|[Image:setText](#image-settext)|Image|Sets the text at the specified position
|
||||
|[Image:updateFrame](#image-updateframe)|Image|Updates the specified frame with the provided data
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Image:init|Image|Initializes the Image instance
|
||||
|Image:render|-|Renders the Image
|
||||
|
||||
## Image:addFrame()
|
||||
Adds a new frame to the image
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:getBg(x, y, length)
|
||||
Gets the background color at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `length` `number` The length of the background color pattern to get
|
||||
|
||||
### Returns
|
||||
* `string` `bg` The background color pattern
|
||||
|
||||
## Image:getFg(x, y, length)
|
||||
Gets the foreground color at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `length` `number` The length of the foreground color pattern to get
|
||||
|
||||
### Returns
|
||||
* `string` `fg` The foreground color pattern
|
||||
|
||||
## Image:getFrame(frameIndex)
|
||||
Gets the specified frame
|
||||
|
||||
### Parameters
|
||||
* `frameIndex` `number` The index of the frame to get
|
||||
|
||||
### Returns
|
||||
* `table` `frame` The frame data
|
||||
|
||||
## Image:getImageSize()
|
||||
Gets the size of the image
|
||||
|
||||
### Returns
|
||||
* `number` `width` The width of the image
|
||||
* `number` `height` The height of the image
|
||||
|
||||
## Image:getMetadata()
|
||||
Gets the metadata of the image
|
||||
|
||||
### Returns
|
||||
* `table` `metadata` The metadata of the image
|
||||
|
||||
## Image:getPixelData(x, y)
|
||||
Gets pixel information at position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` X position
|
||||
* `y` `number` Y position
|
||||
|
||||
### Returns
|
||||
* `number?` `fg` Foreground color
|
||||
* `number?` `bg` Background color
|
||||
* `string?` `char` Character at position
|
||||
|
||||
## Image:getText(x, y, length)
|
||||
Gets the text at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `length` `number` The length of the text to get
|
||||
|
||||
### Returns
|
||||
* `string` `text` The text at the specified position
|
||||
|
||||
## Image:nextFrame()
|
||||
Advances to the next frame in the animation
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:resizeImage(width, height)
|
||||
Resizes the image to the specified width and height
|
||||
|
||||
### Parameters
|
||||
* `width` `number` The new width of the image
|
||||
* `height` `number` The new height of the image
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:setBg(x, y, pattern)
|
||||
Sets the background color at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `pattern` `string` The background color pattern
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:setFg(x, y, pattern)
|
||||
Sets the foreground color at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `pattern` `string` The foreground color pattern
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:setMetadata(key, value)
|
||||
Sets the metadata of the image
|
||||
|
||||
### Parameters
|
||||
* `key` `string` The key of the metadata to set
|
||||
* `value` `string` The value of the metadata to set
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:setPixel(x, y, char, fg, bg)
|
||||
Sets the pixel at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `char` `string` The character to set
|
||||
* `fg` `string` The foreground color pattern
|
||||
* `bg` `string` The background color pattern
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:setText(x, y, text)
|
||||
Sets the text at the specified position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `text` `string` The text to set
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
## Image:updateFrame(frameIndex, frame)
|
||||
Updates the specified frame with the provided data
|
||||
|
||||
### Parameters
|
||||
* `frameIndex` `number` The index of the frame to update
|
||||
* `frame` `table` The new frame data
|
||||
|
||||
### Returns
|
||||
* `Image` `self` The Image instance
|
||||
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
# Input : VisualElement
|
||||
This is the input class. It provides a text input field that can handle user input with various features like
|
||||
cursor movement, text manipulation, placeholder text, and input validation.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|text|string|-|The current text content of the input
|
||||
|cursorPos|number|1|The current cursor position in the text
|
||||
|viewOffset|number|0|The horizontal scroll offset for viewing long text
|
||||
|maxLength|number?|nil|Maximum length of input text (optional)
|
||||
|placeholder|string|...|Text to display when input is empty
|
||||
|placeholderColor|color|gray|Color of the placeholder text
|
||||
|focusedBackground|color|blue|Background color when input is focused
|
||||
|focusedForeground|color|white|Foreground color when input is focused
|
||||
|pattern|string?|nil|Regular expression pattern for input validation
|
||||
|cursorColor|number|nil|Color of the cursor
|
||||
|replaceChar|string|nil|Character to replace the input with (for password fields)
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Input:setCursor](#input-setcursor)|-|Sets the cursor position and color
|
||||
|[Input:updateViewport](#input-updateviewport)|Input|Updates the input's viewport
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Input:blur|-|Handles a blur event
|
||||
|Input:char|boolean|Handles char events
|
||||
|Input:focus|-|Handles a focus event
|
||||
|Input:init|Input|Initializes the Input instance
|
||||
|Input:key|boolean|Handles key events
|
||||
|Input:mouse_click|boolean|Handles mouse click events
|
||||
|Input:render|-|Renders the input element
|
||||
|
||||
## Input:setCursor(x, y, blink, color)
|
||||
Sets the cursor position and color
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position of the cursor
|
||||
* `y` `number` The y position of the cursor
|
||||
* `blink` `boolean` Whether the cursor should blink
|
||||
* `color` `number` The color of the cursor
|
||||
|
||||
## Input:updateViewport()
|
||||
Updates the input's viewport
|
||||
|
||||
### Returns
|
||||
* `Input` `self` The updated instance
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Label : VisualElement
|
||||
This is the label class. It provides a simple text display element that automatically
|
||||
resizes its width based on the text content.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|text|string|Label|The text content to display. Can be a string or a function that returns a string
|
||||
|autoSize|boolean|true|Whether the label should automatically resize its width based on the text content
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Label:getWrappedText](#label-getwrappedtext)|table|Gets the wrapped lines of the Label
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Label:init|Label|Initializes the Label instance
|
||||
|Label:render|-|Renders the Label by drawing its text content
|
||||
|
||||
## Label:getWrappedText()
|
||||
Gets the wrapped lines of the Label
|
||||
|
||||
### Returns
|
||||
* `table` `wrappedText` The wrapped lines of the Label
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# LineChart : Graph
|
||||
The Line Chart element visualizes data series as connected line graphs. It plots points on a coordinate system and connects them with lines.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local chart = main:addLineChart()
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
|
||||
basalt.schedule(function()
|
||||
while true do
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
sleep(2)
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|LineChart:init|LineChart|Initializes the LineChart instance
|
||||
|LineChart:render|-|Renders the LineChart
|
||||
|
||||
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
# List : VisualElement
|
||||
This is the list class. It provides a scrollable list of selectable items with support for
|
||||
custom item rendering, separators, and selection handling.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|items|table|{}|List of items to display. Items can be tables with properties including selected state
|
||||
|selectable|boolean|true|Whether items in the list can be selected
|
||||
|multiSelection|boolean|false|Whether multiple items can be selected at once
|
||||
|offset|number|0|Current scroll offset for viewing long lists
|
||||
|selectedBackground|color|blue|Background color for selected items
|
||||
|selectedForeground|color|white|Text color for selected items
|
||||
|
||||
## Events
|
||||
|
||||
|Event|Parameters|Description|
|
||||
|---|---|---|
|
||||
|onSelect|`index number, item table`|Fired when an item is selected|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[List:addItem](#list-additem)|List|Adds an item to the list
|
||||
|[List:clear](#list-clear)|List|Clears all items from the list
|
||||
|[List:getSelectedItem](#list-getselecteditem)|table?|Gets first selected item
|
||||
|[List:getSelectedItems](#list-getselecteditems)|table|Gets the currently selected items
|
||||
|[List:onSelect](#list-onselect)|List|Registers a callback for the select event
|
||||
|[List:removeItem](#list-removeitem)|List|Removes an item from the list
|
||||
|[List:scrollToBottom](#list-scrolltobottom)|List|Scrolls the list to the bottom
|
||||
|[List:scrollToTop](#list-scrolltotop)|List|Scrolls the list to the top
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|List:init|List|Initializes the List instance
|
||||
|List:mouse_click|boolean|Handles mouse click events
|
||||
|List:mouse_scroll|boolean|Handles mouse scroll events
|
||||
|List:render|-|Renders the list
|
||||
|
||||
## List:addItem(text)
|
||||
Adds an item to the list
|
||||
|
||||
### Parameters
|
||||
* `text` `string|table` The item to add (string or item table)
|
||||
|
||||
### Returns
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
list:addItem("New Item")
|
||||
list:addItem({text="Item", callback=function() end})
|
||||
```
|
||||
|
||||
## List:clear()
|
||||
Clears all items from the list
|
||||
|
||||
### Returns
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
list:clear()
|
||||
```
|
||||
|
||||
## List:getSelectedItem()
|
||||
Gets first selected item
|
||||
|
||||
### Returns
|
||||
* `table?` `selected` The first item
|
||||
|
||||
## List:getSelectedItems()
|
||||
Gets the currently selected items
|
||||
|
||||
### Returns
|
||||
* `table` `selected` List of selected items
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local selected = list:getSelectedItems()
|
||||
```
|
||||
|
||||
## List:onSelect(callback)
|
||||
Registers a callback for the select event
|
||||
|
||||
### Parameters
|
||||
* `callback` `function` The callback function to register
|
||||
|
||||
### Returns
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
list:onSelect(function(index, item) print("Selected item:", index, item) end)
|
||||
```
|
||||
|
||||
## List:removeItem(index)
|
||||
Removes an item from the list
|
||||
|
||||
### Parameters
|
||||
* `index` `number` The index of the item to remove
|
||||
|
||||
### Returns
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
list:removeItem(1)
|
||||
```
|
||||
|
||||
## List:scrollToBottom()
|
||||
Scrolls the list to the bottom
|
||||
|
||||
### Returns
|
||||
* `List` `self` The List instance
|
||||
|
||||
## List:scrollToTop()
|
||||
Scrolls the list to the top
|
||||
|
||||
### Returns
|
||||
* `List` `self` The List instance
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# Menu : List
|
||||
This is the menu class. It provides a horizontal menu bar with selectable items.
|
||||
Menu items are displayed in a single row and can have custom colors and callbacks.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|separatorColor|color|gray|The color used for separator items in the menu
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Menu:setItems](#menu-setitems)|Menu|Sets the menu items and calculates total width
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Menu:init|Menu|Initializes the Menu instance
|
||||
|Menu:mouse_click|boolean|Handles mouse click events and item selection
|
||||
|Menu:render|-|Renders the menu horizontally with proper spacing and colors
|
||||
|
||||
## Menu:setItems(items)
|
||||
Sets the menu items
|
||||
|
||||
### Parameters
|
||||
* `items` `table[]` List of items with {text, separator, callback, foreground, background} properties
|
||||
|
||||
### Returns
|
||||
* `Menu` `self` The Menu instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
menu:setItems({{text="File"}, {separator=true}, {text="Edit"}})
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Program : VisualElement
|
||||
This is the program class. It provides a program that runs in a window.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|program|table|nil|The program instance
|
||||
|path|string|""|The path to the program
|
||||
|running|boolean|false|Whether the program is running
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Program:execute](#program-execute)|Program|Executes a program
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Program:dispatchEvent|any|Handles all incomming events
|
||||
|Program:focus|-|Gets called when the element gets focused
|
||||
|Program:init|Program|Initializes the Program instance
|
||||
|Program:render|-|Renders the program
|
||||
|
||||
## Program:execute(path)
|
||||
Executes a program
|
||||
|
||||
### Parameters
|
||||
* `path` `string` The path to the program
|
||||
|
||||
### Returns
|
||||
* `Program` `self` The Program instance
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# ProgressBar : VisualElement
|
||||
This is the progress bar class. It provides a visual representation of progress
|
||||
with optional percentage display and customizable colors.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local progressBar = main:addProgressBar()
|
||||
progressBar:setDirection("up")
|
||||
progressBar:setProgress(50)
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|progress|number|0|Current progress value (0-100)
|
||||
|showPercentage|boolean|false|Whether to show the percentage text in the center
|
||||
|progressColor|color|lime|The color used for the filled portion of the progress bar
|
||||
|direction|string|right|The direction of the progress bar ("up", "down", "left", "right")
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|ProgressBar:init|ProgressBar|Initializes the ProgressBar instance
|
||||
|ProgressBar:render|-|Renders the progress bar with filled portion and optional percentage text
|
||||
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
# Scrollbar : VisualElement
|
||||
A scrollbar element that can be attached to other elements to control their scroll properties
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|value|number|0|Current scroll value
|
||||
|min|number|0|Minimum scroll value
|
||||
|max|number|100|Maximum scroll value
|
||||
|step|number|1|Step size for scroll operations
|
||||
|dragMultiplier|number|1|How fast the scrollbar moves when dragging
|
||||
|symbol|string|"|" Symbol used for the scrollbar handle
|
||||
|backgroundSymbol|string|"\127"|Symbol used for the scrollbar background
|
||||
|symbolBackgroundColor|color|black|Background color of the scrollbar handle
|
||||
|backgroundSymbol|string|"\127"|Symbol used for the scrollbar background
|
||||
|attachedElement|table?|nil|The element this scrollbar is attached to
|
||||
|attachedProperty|string?|nil|The property being controlled
|
||||
|minValue|number|function|0|Minimum value or function that returns it
|
||||
|maxValue|number|function|100|Maximum value or function that returns it
|
||||
|orientation|string|vertical|Orientation of the scrollbar ("vertical" or "horizontal")
|
||||
|handleSize|number|2|Size of the scrollbar handle in characters
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Scrollbar:attach](#scrollbar-attach)|Scrollbar|Attaches the scrollbar to an element's property
|
||||
|[Scrollbar:updateAttachedElement](#scrollbar-updateattachedelement)|Scrollbar|Updates the attached element's property based on the scrollbar value
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Scrollbar:init|Scrollbar|Initializes the Scrollbar instance
|
||||
|Scrollbar:mouse_click|boolean|Handles mouse click events
|
||||
|Scrollbar:mouse_drag|boolean|Handles mouse drag events
|
||||
|Scrollbar:mouse_scroll|boolean|Handles mouse scroll events
|
||||
|Scrollbar:render|-|Renders the scrollbar
|
||||
|
||||
## Scrollbar:attach(element, config)
|
||||
Attaches the scrollbar to an element's property
|
||||
|
||||
### Parameters
|
||||
* `element` `BaseElement` The element to attach to
|
||||
* `config` `table` Configuration {property = "propertyName", min = number|function, max = number|function}
|
||||
|
||||
### Returns
|
||||
* `Scrollbar` `self` The scrollbar instance
|
||||
|
||||
## Scrollbar:updateAttachedElement()
|
||||
Updates the attached element's property based on the scrollbar value
|
||||
|
||||
### Returns
|
||||
* `Scrollbar` `self` The scrollbar instance
|
||||
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
# Slider : VisualElement
|
||||
This is the slider class. It provides a draggable slider control that can be either horizontal or vertical,
|
||||
with customizable colors and value ranges.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|step|number|1|Current position of the slider handle (1 to width/height)
|
||||
|max|number|100|Maximum value for value conversion (maps slider position to this range)
|
||||
|horizontal|boolean|true|Whether the slider is horizontal (false for vertical)
|
||||
|barColor|color|gray|Color of the slider track
|
||||
|sliderColor|color|blue|Color of the slider handle
|
||||
|
||||
## Events
|
||||
|
||||
|Event|Parameters|Description|
|
||||
|---|---|---|
|
||||
|onChange|`value number`|Fired when the slider value changes|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Slider:getValue](#slider-getvalue)|number|Gets the current value mapped to the max range
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Slider:init|Slider|Initializes the Slider instance
|
||||
|Slider:mouse_click|boolean|Updates slider position on mouse click
|
||||
|Slider:mouse_scroll|boolean|Handles mouse release events
|
||||
|Slider:render|-|Renders the slider with track and handle
|
||||
|
||||
## Slider:getValue()
|
||||
Gets the current value of the slider
|
||||
|
||||
### Returns
|
||||
* `number` `value` The current value (0 to max)
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local value = slider:getValue()
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Switch : VisualElement
|
||||
The Switch is a standard Switch element with click handling and state management.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|checked|boolean|Whether|switch is checked
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Switch:init|-|Initializes the Switch instance
|
||||
|Switch:render|-|Renders the Switch
|
||||
|
||||
|
||||
|
||||
0
docs/references/elements/TabControl.md
Normal file
0
docs/references/elements/TabControl.md
Normal file
@@ -1,53 +0,0 @@
|
||||
# Table : VisualElement
|
||||
This is the table class. It provides a sortable data grid with customizable columns,
|
||||
row selection, and scrolling capabilities.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local people = container:addTable():setWidth(40)
|
||||
people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}})
|
||||
people:setData({{"Alice", 30, "USA"}, {"Bob", 25, "UK"}})
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|columns|table|{}|List of column definitions with {name, width} properties
|
||||
|data|table|{}|The table data as array of row arrays
|
||||
|selectedRow|number?|nil|Currently selected row index
|
||||
|headerColor|color|blue|Color of the column headers
|
||||
|selectedColor|color|lightBlue|Background color of selected row
|
||||
|gridColor|color|gray|Color of grid lines
|
||||
|sortColumn|number?|nil|Currently sorted column index
|
||||
|sortDirection|string|"asc"|Sort direction ("asc" or "desc")
|
||||
|scrollOffset|number|0|Current scroll position
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Table:sortData](#table-sortdata)|Table|Sorts the table data by the specified column
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Table:init|Table|Initializes the Table instance
|
||||
|Table:mouse_click|boolean|Handles header clicks for sorting and row selection
|
||||
|Table:mouse_scroll|boolean|Handles scrolling through the table data
|
||||
|Table:render|-|Renders the table with headers, data and scrollbar
|
||||
|
||||
## Table:sortData(columnIndex, fn)
|
||||
Sorts the table data by column
|
||||
|
||||
### Parameters
|
||||
* `columnIndex` `number` The index of the column to sort by
|
||||
* `fn` `function?` Optional custom sorting function
|
||||
|
||||
### Returns
|
||||
* `Table` `self` The Table instance
|
||||
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
# TextBox : VisualElement
|
||||
A multi-line text editor component with cursor support and text manipulation features
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|lines|table|{}|Array of text lines
|
||||
|cursorX|number|1|Cursor X position
|
||||
|cursorY|number|1|Cursor Y position (line number)
|
||||
|scrollX|number|0|Horizontal scroll offset
|
||||
|scrollY|number|0|Vertical scroll offset
|
||||
|editable|boolean|true|Whether text can be edited
|
||||
|syntaxPatterns|table|{}|Syntax highlighting patterns
|
||||
|cursorColor|number|nil|Color of the cursor
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[TextBox:addSyntaxPattern](#textbox-addsyntaxpattern)|TextBox|Adds a new syntax highlighting pattern
|
||||
|[TextBox:getText](#textbox-gettext)|string|Gets the text of the TextBox
|
||||
|[TextBox:setText](#textbox-settext)|TextBox|Sets the text of the TextBox
|
||||
|[TextBox:updateViewport](#textbox-updateviewport)|TextBox|Updates the viewport to keep the cursor in view
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|TextBox:char|boolean|Handles character input
|
||||
|TextBox:init|TextBox|Initializes the TextBox instance
|
||||
|TextBox:key|boolean|Handles key events
|
||||
|TextBox:mouse_click|boolean|Handles mouse click events
|
||||
|TextBox:mouse_scroll|boolean|Handles mouse scroll events
|
||||
|TextBox:render|-|Renders the TextBox with syntax highlighting
|
||||
|
||||
## TextBox:addSyntaxPattern(pattern, color)
|
||||
Adds a new syntax highlighting pattern
|
||||
|
||||
### Parameters
|
||||
* `pattern` `string` The regex pattern to match
|
||||
* `color` `colors` The color to apply
|
||||
|
||||
### Returns
|
||||
* `TextBox` `self` The TextBox instance
|
||||
|
||||
## TextBox:getText()
|
||||
Gets the text of the TextBox
|
||||
|
||||
### Returns
|
||||
* `string` `text` The text of the TextBox
|
||||
|
||||
## TextBox:setText(text)
|
||||
Sets the text of the TextBox
|
||||
|
||||
### Parameters
|
||||
* `text` `string` The text to set
|
||||
|
||||
### Returns
|
||||
* `TextBox` `self` The TextBox instance
|
||||
|
||||
## TextBox:updateViewport()
|
||||
Updates the viewport to keep the cursor in view
|
||||
|
||||
### Returns
|
||||
* `TextBox` `self` The TextBox instance
|
||||
|
||||
|
||||
|
||||
0
docs/references/elements/Timer.md
Normal file
0
docs/references/elements/Timer.md
Normal file
@@ -1,80 +0,0 @@
|
||||
# Tree : VisualElement
|
||||
This is the tree class. It provides a hierarchical view of nodes that can be expanded and collapsed,
|
||||
with support for selection and scrolling.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|nodes|table|{}|The tree structure containing node objects with {text, children} properties
|
||||
|selectedNode|table?|nil|Currently selected node
|
||||
|expandedNodes|table|{}|Table of nodes that are currently expanded
|
||||
|scrollOffset|number|0|Current vertical scroll position
|
||||
|horizontalOffset|number|0|Current horizontal scroll position
|
||||
|nodeColor|color|white|Color of unselected nodes
|
||||
|selectedColor|color|lightBlue|Background color of selected node
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Tree:collapseNode](#tree-collapsenode)|Tree|Collapses a node to hide its children
|
||||
|[Tree:expandNode](#tree-expandnode)|Tree|Expands a node to show its children
|
||||
|[Tree:getNodeSize](#tree-getnodesize)|number|Gets the size of the tree
|
||||
|[Tree:onSelect](#tree-onselect)|Tree|Registers a callback for when a node is selected
|
||||
|[Tree:toggleNode](#tree-togglenode)|Tree|Toggles between expanded and collapsed state
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|Tree:init|Tree|Initializes the Tree instance
|
||||
|Tree:mouse_click|boolean|Handles mouse click events for node selection and expansion
|
||||
|Tree:mouse_scroll|boolean|Handles mouse scroll events for vertical scrolling
|
||||
|Tree:render|-|Renders the tree with nodes, selection and scrolling
|
||||
|
||||
## Tree:collapseNode(node)
|
||||
Collapses a node
|
||||
|
||||
### Parameters
|
||||
* `node` `table` The node to collapse
|
||||
|
||||
### Returns
|
||||
* `Tree` `self` The Tree instance
|
||||
|
||||
## Tree:expandNode(node)
|
||||
Expands a node
|
||||
|
||||
### Parameters
|
||||
* `node` `table` The node to expand
|
||||
|
||||
### Returns
|
||||
* `Tree` `self` The Tree instance
|
||||
|
||||
## Tree:getNodeSize()
|
||||
Gets the size of the tree
|
||||
|
||||
### Returns
|
||||
* `number` `width` The width of the tree
|
||||
* `number` `height` The height of the tree
|
||||
|
||||
## Tree:onSelect(callback)
|
||||
Registers a callback for when a node is selected
|
||||
|
||||
### Parameters
|
||||
* `callback` `function` The callback function
|
||||
|
||||
### Returns
|
||||
* `Tree` `self` The Tree instance
|
||||
|
||||
## Tree:toggleNode(node)
|
||||
Toggles a node's expanded state
|
||||
|
||||
### Parameters
|
||||
* `node` `table` The node to toggle
|
||||
|
||||
### Returns
|
||||
* `Tree` `self` The Tree instance
|
||||
|
||||
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
# VisualElement : BaseElement
|
||||
This is the visual element class. It serves as the base class for all visual UI elements
|
||||
and provides core functionality for positioning, sizing, colors, and rendering.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|x|number|1|The horizontal position relative to parent
|
||||
|y|number|1|The vertical position relative to parent
|
||||
|z|number|1|The z-index for layering elements
|
||||
|width|number|1|The width of the element
|
||||
|height|number|1|The height of the element
|
||||
|background|color|black|The background color
|
||||
|foreground|color|white|The text/foreground color
|
||||
|clicked|boolean|false|Whether the element is currently clicked
|
||||
|hover|boolean|false|Whether the mouse is currently hover over the element (Craftos-PC only)
|
||||
|backgroundEnabled|boolean|true|Whether to render the background
|
||||
|focused|boolean|false|Whether the element has input focus
|
||||
|visible|boolean|true|Whether the element is visible
|
||||
|ignoreOffset|boolean|false|Whether to ignore the parent's offset
|
||||
|
||||
## Combined Properties
|
||||
|
||||
|Name|Properties|Description|
|
||||
|---|---|---|
|
||||
|position|`x number, y number`|Combined x, y position|
|
||||
|size|`width number, height number`|Combined width, height|
|
||||
|color|`foreground number, background number`|Combined foreground, background colors|
|
||||
|
||||
## Events
|
||||
|
||||
|Event|Parameters|Description|
|
||||
|---|---|---|
|
||||
|onClick|`button string, x number, y number`|Fired on mouse click|
|
||||
|onMouseUp|`button, x, y`|Fired on mouse button release|
|
||||
|onRelease|`button, x, y`|Fired when mouse leaves while clicked|
|
||||
|onDrag|`button, x, y`|Fired when mouse moves while clicked|
|
||||
|onScroll|`direction, x, y`|Fired on mouse scroll|
|
||||
|onEnter|`-`|Fired when mouse enters element|
|
||||
|onLeave|`-`|Fired when mouse leaves element|
|
||||
|onFocus|`-`|Fired when element receives focus|
|
||||
|onBlur|`-`|Fired when element loses focus|
|
||||
|onKey|`key`|Fired on key press|
|
||||
|onKeyUp|`key`|Fired on key release|
|
||||
|onChar|`char`|Fired on character input|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[VisualElement:calculatePosition](#visualelement-calculateposition)|number|Calculates the position of the element
|
||||
|[VisualElement:drawBg](#visualelement-drawbg)|-|
|
||||
|[VisualElement:drawFg](#visualelement-drawfg)|-|
|
||||
|[VisualElement:drawText](#visualelement-drawtext)|-|
|
||||
|[VisualElement:getAbsolutePosition](#visualelement-getabsoluteposition)|number|Returns the absolute position of the element
|
||||
|[VisualElement:getRelativePosition](#visualelement-getrelativeposition)|number|Returns the relative position of the element
|
||||
|[VisualElement:isInBounds](#visualelement-isinbounds)|boolean|Checks if point is within bounds
|
||||
|[VisualElement:prioritize](#visualelement-prioritize)|VisualElement|Prioritizes the element by moving it to the top of its parent's children
|
||||
|
||||
|
||||
## Protected Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|VisualElement:blit|-|Draws text with both colors
|
||||
|VisualElement:blur|-|Handles a blur event
|
||||
|VisualElement:char|-|Handles a character event
|
||||
|VisualElement:focus|-|Handles a focus event
|
||||
|VisualElement:init|-|Initializes a new visual element with properties
|
||||
|VisualElement:key|-|Handles a key event
|
||||
|VisualElement:key_up|-|Handles a key up event
|
||||
|VisualElement:mouse_click|boolean|Handles a mouse click event
|
||||
|VisualElement:mouse_drag|boolean|Handles a mouse drag event
|
||||
|VisualElement:mouse_move|boolean|Handles a mouse move event
|
||||
|VisualElement:mouse_release|-|Handles a mouse release event
|
||||
|VisualElement:mouse_scroll|boolean|Handles a mouse scroll event
|
||||
|VisualElement:mouse_up|boolean|Handles a mouse up event
|
||||
|VisualElement:multiBlit|-|Multi-character drawing with colors
|
||||
|VisualElement:postRender|-|Post-rendering function for the element
|
||||
|VisualElement:render|-|Renders the element
|
||||
|VisualElement:setCursor|VisualElement|Sets the cursor position
|
||||
|VisualElement:textBg|-|Draws text with background color
|
||||
|VisualElement:textFg|-|Draws text with foreground color
|
||||
|
||||
## VisualElement:calculatePosition()
|
||||
Calculates the position of the element relative to its parent
|
||||
|
||||
### Returns
|
||||
* `number` `x` The x position
|
||||
* `number` `y` The y position
|
||||
|
||||
## VisualElement:drawBg()
|
||||
|
||||
## VisualElement:drawFg()
|
||||
|
||||
## VisualElement:drawText()
|
||||
|
||||
## VisualElement:getAbsolutePosition(x?, y?)
|
||||
Returns the absolute position of the element or the given coordinates.
|
||||
|
||||
### Parameters
|
||||
* `x` *(optional)* `number` x position
|
||||
* `y` *(optional)* `number` y position
|
||||
|
||||
### Returns
|
||||
* `number` `x` The absolute x position
|
||||
* `number` `y` The absolute y position
|
||||
|
||||
## VisualElement:getRelativePosition(x?, y?)
|
||||
Returns the relative position of the element or the given coordinates.
|
||||
|
||||
### Parameters
|
||||
* `x` *(optional)* `number` x position
|
||||
* `y` *(optional)* `number` y position
|
||||
|
||||
### Returns
|
||||
* `number` `x` The relative x position
|
||||
* `number` `y` The relative y position
|
||||
|
||||
## VisualElement:isInBounds(x, y)
|
||||
Checks if the specified coordinates are within the bounds of the element
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to check
|
||||
* `y` `number` The y position to check
|
||||
|
||||
### Returns
|
||||
* `boolean` `isInBounds` Whether the coordinates are within the bounds of the element
|
||||
|
||||
## VisualElement:prioritize()
|
||||
This function is used to prioritize the element by moving it to the top of its parent's children. It removes the element from its parent and adds it back, effectively changing its order.
|
||||
|
||||
### Returns
|
||||
* `VisualElement` `self` The VisualElement instance
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# ErrorHandler
|
||||
This is Basalt's error handler. All the errors are handled by this module.
|
||||
|
||||
## Fields
|
||||
|
||||
|Field|Type|Description|
|
||||
|---|---|---|
|
||||
|tracebackEnabled|`boolean`|If the error handler should print a stack trace|
|
||||
|header|`string`|The header of the error message|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[errorHandler.error](#errorhandler-error)|-|
|
||||
|
||||
|
||||
## errorHandler.error(errMsg)
|
||||
Handles an error
|
||||
|
||||
### Parameters
|
||||
* `errMsg` `string` The error message
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
errorHandler.error("An error occurred")
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Simple type checking without stack traces
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
## utils.copy()
|
||||
|
||||
## utils.deepCopy()
|
||||
|
||||
## utils.getCenteredPosition()
|
||||
|
||||
## utils.reverse()
|
||||
|
||||
## utils.split()
|
||||
|
||||
## utils.uuid()
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
# Log
|
||||
Logger module for Basalt. Logs messages to the console and optionally to a file.
|
||||
|
||||
## Fields
|
||||
|
||||
|Field|Type|Description|
|
||||
|---|---|---|
|
||||
|_logs|`table`|The complete log history|
|
||||
|_enabled|`boolean`|If the logger is enabled|
|
||||
|_logToFile|`boolean`|If the logger should log to a file|
|
||||
|_logFile|`string`|The file to log to|
|
||||
|LEVEL|`table`|The log levels|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Log.debug](#log-debug)|-|Sends a debug message
|
||||
|[Log.error](#log-error)|-|Sends an error message
|
||||
|[Log.info](#log-info)|-|Sends an info message
|
||||
|[Log.setEnabled](#log-setenabled)|-|Sets if the logger should log
|
||||
|[Log.setLogToFile](#log-setlogtofile)|-|Sets if the logger should log to a file
|
||||
|[Log.warn](#log-warn)|-|Sends a warning message
|
||||
|
||||
|
||||
## Log.debug(...)
|
||||
Sends a debug message to the logger.
|
||||
|
||||
### Parameters
|
||||
* `...` *(vararg)* `string` The message to log
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
Log.debug("This is a debug message")
|
||||
```
|
||||
|
||||
## Log.error(...)
|
||||
Sends an error message to the logger.
|
||||
|
||||
### Parameters
|
||||
* `...` *(vararg)* `string` The message to log
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
Log.error("This is an error message")
|
||||
```
|
||||
|
||||
## Log.info(...)
|
||||
Sends an info message to the logger.
|
||||
|
||||
### Parameters
|
||||
* `...` *(vararg)* `string` The message to log
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
Log.info("This is an info message")
|
||||
```
|
||||
|
||||
## Log.setEnabled()
|
||||
Sets if the logger should log
|
||||
|
||||
## Log.setLogToFile()
|
||||
Sets if the logger should log to a file.
|
||||
|
||||
## Log.warn(...)
|
||||
Sends a warning message to the logger.
|
||||
|
||||
### Parameters
|
||||
* `...` *(vararg)* `string` The message to log
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
Log.warn("This is a warning message")
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
# basalt
|
||||
This is the UI Manager and the starting point for your project. The following functions allow you to influence the default behavior of Basalt.
|
||||
|
||||
Before you can access Basalt, you need to add the following code on top of your file:
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt".
|
||||
|
||||
## Fields
|
||||
|
||||
|Field|Type|Description|
|
||||
|---|---|---|
|
||||
|traceback|`boolean`|Whether to show a traceback on errors|
|
||||
|_events|`table`|A table of events and their callbacks|
|
||||
|_schedule|`function[]`|A table of scheduled functions|
|
||||
|_plugins|`table`|A table of plugins|
|
||||
|isRunning|`boolean`|Whether the Basalt runtime is active|
|
||||
|LOGGER|`Log`|The logger instance|
|
||||
|path|`string`|The path to the Basalt library|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[basalt.create](#basalt-create)|table|Creates a new UI element
|
||||
|[basalt.createFrame](#basalt-createframe)|BaseFrame|Creates a new BaseFrame
|
||||
|[basalt.getAPI](#basalt-getapi)|table|Returns a Plugin API
|
||||
|[basalt.getActiveFrame](#basalt-getactiveframe)|BaseFrame?|Returns the active frame
|
||||
|[basalt.getElementClass](#basalt-getelementclass)|table|Returns an element class
|
||||
|[basalt.getElementManager](#basalt-getelementmanager)|table|Returns the element manager
|
||||
|[basalt.getErrorManager](#basalt-geterrormanager)|table|Returns the error manager
|
||||
|[basalt.getFocus](#basalt-getfocus)|BaseFrame?|Returns the focused frame
|
||||
|[basalt.getMainFrame](#basalt-getmainframe)|BaseFrame|Gets or creates the main frame
|
||||
|[basalt.removeSchedule](#basalt-removeschedule)|boolean|Removes a scheduled update
|
||||
|[basalt.run](#basalt-run)|-|Starts the Basalt runtime
|
||||
|[basalt.schedule](#basalt-schedule)|thread|Schedules a function to run in a coroutine
|
||||
|[basalt.setActiveFrame](#basalt-setactiveframe)|-|Sets the active frame
|
||||
|[basalt.setFocus](#basalt-setfocus)|-|Sets a frame as focused
|
||||
|[basalt.stop](#basalt-stop)|-|Stops the Basalt runtime
|
||||
|[basalt.update](#basalt-update)|-|Runs basalt once
|
||||
|
||||
|
||||
## basalt.create(type, properties?)
|
||||
Creates and returns a new UI element of the specified type.
|
||||
|
||||
### Parameters
|
||||
* `type` `string` The type of element to create (e.g. "Button", "Label", "BaseFrame")
|
||||
* `properties` *(optional)* `string|table` Optional name for the element or a table with properties to initialize the element with
|
||||
|
||||
### Returns
|
||||
* `table` `element` The created element instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local button = basalt.create("Button")
|
||||
```
|
||||
|
||||
## basalt.createFrame()
|
||||
Creates and returns a new BaseFrame
|
||||
|
||||
### Returns
|
||||
* `BaseFrame` `BaseFrame` The created frame instance
|
||||
|
||||
## basalt.getAPI(name)
|
||||
Returns a Plugin API
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the plugin
|
||||
|
||||
### Returns
|
||||
* `table` `Plugin` The plugin API
|
||||
|
||||
## basalt.getActiveFrame(t?)
|
||||
Returns the active frame
|
||||
|
||||
### Parameters
|
||||
* `t` *(optional)* `term` The term to get the active frame for (default: current term)
|
||||
|
||||
### Returns
|
||||
* `BaseFrame?` `BaseFrame` The frame to set as active
|
||||
|
||||
## basalt.getElementClass(name)
|
||||
Returns an element's class without creating a instance
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the element
|
||||
|
||||
### Returns
|
||||
* `table` `Element` The element class
|
||||
|
||||
## basalt.getElementManager()
|
||||
Returns the element manager instance
|
||||
|
||||
### Returns
|
||||
* `table` `ElementManager` The element manager
|
||||
|
||||
## basalt.getErrorManager()
|
||||
Returns the error manager instance
|
||||
|
||||
### Returns
|
||||
* `table` `ErrorManager` The error manager
|
||||
|
||||
## basalt.getFocus()
|
||||
Returns the focused frame
|
||||
|
||||
### Returns
|
||||
* `BaseFrame?` `BaseFrame` The focused frame
|
||||
|
||||
## basalt.getMainFrame()
|
||||
Gets or creates the main frame
|
||||
|
||||
### Returns
|
||||
* `BaseFrame` `BaseFrame` The main frame instance
|
||||
|
||||
## basalt.removeSchedule(func)
|
||||
Removes a scheduled update
|
||||
|
||||
### Parameters
|
||||
* `func` `thread` The scheduled function to remove
|
||||
|
||||
### Returns
|
||||
* `boolean` `success` Whether the scheduled function was removed
|
||||
|
||||
## basalt.run(isActive?)
|
||||
Starts the Basalt runtime
|
||||
|
||||
### Parameters
|
||||
* `isActive` *(optional)* `boolean` Whether to start active (default: true)
|
||||
|
||||
## basalt.schedule(func)
|
||||
Schedules a function to run in a coroutine
|
||||
|
||||
### Parameters
|
||||
* `func` `function` The function to schedule
|
||||
|
||||
### Returns
|
||||
* `thread` `func` The scheduled function
|
||||
|
||||
## basalt.setActiveFrame(frame, setActive?)
|
||||
Sets the active frame
|
||||
|
||||
### Parameters
|
||||
* `frame` `BaseFrame` The frame to set as active
|
||||
* `setActive` *(optional)* `boolean` Whether to set the frame as active (default: true)
|
||||
|
||||
## basalt.setFocus(frame)
|
||||
Sets a frame as focused
|
||||
|
||||
### Parameters
|
||||
* `frame` `BaseFrame` The frame to set as focused
|
||||
|
||||
## basalt.stop()
|
||||
Stops the Basalt runtime
|
||||
|
||||
## basalt.update(...)
|
||||
Runs basalt once, can be used to update the UI manually, but you have to feed it the events
|
||||
|
||||
### Parameters
|
||||
* `...` *(vararg)* `any` The event to run with
|
||||
|
||||
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
# Animation
|
||||
This is the animation plugin. It provides a animation system for visual elements
|
||||
with support for sequences, easing functions, and multiple animation types.
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Animation.new](#animation-new)|Animation|Creates a new animation
|
||||
|[Animation.registerAnimation](#animation-registeranimation)|-|Registers a custom animation type
|
||||
|[Animation.registerEasing](#animation-registereasing)|-|Adds a custom easing function
|
||||
|[Animation:addAnimation](#animation-addanimation)|-|Adds a new animation to the sequence
|
||||
|[Animation:event](#animation-event)|-|The event handler for the animation
|
||||
|[Animation:onComplete](#animation-oncomplete)|Animation|Registers a callback for the complete event
|
||||
|[Animation:onStart](#animation-onstart)|-|Registers a callback for the start event
|
||||
|[Animation:onUpdate](#animation-onupdate)|Animation|Registers a callback for the update event
|
||||
|[Animation:sequence](#animation-sequence)|Animation|Creates a new sequence
|
||||
|[Animation:start](#animation-start)|Animation|Starts the animation
|
||||
|
||||
|
||||
## Animation.new(element)
|
||||
Creates a new Animation
|
||||
|
||||
### Parameters
|
||||
* `element` `VisualElement` The element to animate
|
||||
|
||||
### Returns
|
||||
* `Animation` `The` new animation
|
||||
|
||||
## Animation.registerAnimation(name, handlers)
|
||||
Registers a new animation type
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the animation
|
||||
* `handlers` `table` Table containing start, update and complete handlers
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
Animation.registerAnimation("fade", {start=function(anim) end, update=function(anim,progress) end})
|
||||
```
|
||||
|
||||
## Animation.registerEasing(name, func)
|
||||
Registers a new easing function
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the easing function
|
||||
* `func` `function` The easing function (takes progress 0-1, returns modified progress)
|
||||
|
||||
## Animation:addAnimation(type, args, duration, easing)
|
||||
Adds a new animation to the sequence
|
||||
|
||||
### Parameters
|
||||
* `type` `string` The type of animation
|
||||
* `args` `table` The animation arguments
|
||||
* `duration` `number` The duration in seconds
|
||||
* `easing` `string` The easing function name
|
||||
|
||||
## Animation:event(event, timerId)
|
||||
The event handler for the animation (listens to timer events)
|
||||
|
||||
### Parameters
|
||||
* `event` `string` The event type
|
||||
* `timerId` `number` The timer ID
|
||||
|
||||
## Animation:onComplete(callback)
|
||||
Registers a callback for the complete event
|
||||
|
||||
### Parameters
|
||||
* `callback` `function` The callback function to register
|
||||
|
||||
### Returns
|
||||
* `Animation` `self` The animation instance
|
||||
|
||||
## Animation:onStart(callback)
|
||||
Registers a callback for the start event
|
||||
|
||||
### Parameters
|
||||
* `callback` `function` The callback function to register
|
||||
|
||||
## Animation:onUpdate(callback)
|
||||
Registers a callback for the update event
|
||||
|
||||
### Parameters
|
||||
* `callback` `function` The callback function to register
|
||||
|
||||
### Returns
|
||||
* `Animation` `self` The animation instance
|
||||
|
||||
## Animation:sequence()
|
||||
Creates a new sequence
|
||||
|
||||
### Returns
|
||||
* `Animation` `self` The animation instance
|
||||
|
||||
## Animation:start()
|
||||
Starts the animation
|
||||
|
||||
### Returns
|
||||
* `Animation` `self` The animation instance
|
||||
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
# Benchmark
|
||||
This is the benchmark plugin. It provides performance measurement tools for elements and methods,
|
||||
with support for hierarchical profiling and detailed statistics. The plugin is meant to be used for very big projects
|
||||
where performance is critical. It allows you to measure the time taken by specific methods and log the results.
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[API.clear](#api-clear)|-|Removes a benchmark's data
|
||||
|[API.clearAll](#api-clearall)|-|Removes all custom benchmark data
|
||||
|[API.getStats](#api-getstats)|table?|Retrieves benchmark statistics
|
||||
|[API.start](#api-start)|-|Starts timing a custom operation
|
||||
|[API.stop](#api-stop)|-|Stops timing and logs results
|
||||
|
||||
|
||||
## API.clear(name)
|
||||
Clears a specific benchmark
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the benchmark to clear
|
||||
|
||||
## API.clearAll()
|
||||
Clears all custom benchmarks
|
||||
|
||||
## API.getStats(name)
|
||||
Gets statistics for a benchmark
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the benchmark
|
||||
|
||||
### Returns
|
||||
* `table?` `stats` The benchmark statistics or nil
|
||||
|
||||
## API.start(name, options?)
|
||||
Starts a custom benchmark
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the benchmark
|
||||
* `options` *(optional)* `table` Optional configuration
|
||||
|
||||
## API.stop(name)
|
||||
Stops a custom benchmark
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the benchmark to stop
|
||||
|
||||
|
||||
|
||||
0
docs/references/plugins/canvas.md
Normal file
0
docs/references/plugins/canvas.md
Normal file
@@ -1,78 +0,0 @@
|
||||
# BaseElement
|
||||
No Description
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseElement.debug](#baseelement-debug)|-|Enables debugging for this element
|
||||
|[BaseElement.dumpDebug](#baseelement-dumpdebug)|-|Dumps debug information
|
||||
|
||||
|
||||
## BaseElement.debug(self, level)
|
||||
Enables debugging for this element
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to debug
|
||||
* `level` `number` The debug level
|
||||
|
||||
## BaseElement.dumpDebug(self)
|
||||
Dumps debug information for this element
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to dump debug info for
|
||||
|
||||
|
||||
---
|
||||
<br>
|
||||
|
||||
# BaseFrame
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseFrame.closeConsole](#baseframe-closeconsole)|-|Hides the debug log frame
|
||||
|[BaseFrame.openConsole](#baseframe-openconsole)|-|Shows the debug log frame
|
||||
|[BaseFrame.toggleConsole](#baseframe-toggleconsole)|-|Toggles the debug log frame
|
||||
|
||||
|
||||
## BaseFrame.closeConsole(self)
|
||||
Hides the debug log frame
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseFrame` The frame to hide debug log for
|
||||
|
||||
## BaseFrame.openConsole(self)
|
||||
Shows the debug log frame
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseFrame` The frame to show debug log in
|
||||
|
||||
## BaseFrame.toggleConsole(self)
|
||||
Toggles the debug log frame
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseFrame` The frame to toggle debug log for
|
||||
|
||||
|
||||
---
|
||||
<br>
|
||||
|
||||
# Container
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Container.debugChildren](#container-debugchildren)|-|Debug container and children
|
||||
|
||||
|
||||
## Container.debugChildren(self, level)
|
||||
Enables debugging for this container and all its children
|
||||
|
||||
### Parameters
|
||||
* `self` `Container` The container to debug
|
||||
* `level` `number` The debug level
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# Reactive
|
||||
This module provides reactive functionality for elements, it adds no new functionality for elements.
|
||||
It is used to evaluate expressions in property values and update the element when the expression changes.
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local button = main:addButton({text="Exit"})
|
||||
button:setX("{parent.x - 12}")
|
||||
button:setBackground("{self.clicked and colors.red or colors.green}")
|
||||
button:setWidth("{self.text:len() + 2}")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
# BaseElement
|
||||
This is the state plugin. It provides a state management system for UI elements with support for
|
||||
persistent states, computed states, and state sharing between elements.
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseElement:bind](#baseelement-bind)|BaseElement|
|
||||
|[BaseElement:computed](#baseelement-computed)|-|
|
||||
|[BaseElement:getState](#baseelement-getstate)|any|Gets a state value
|
||||
|[BaseElement:onStateChange](#baseelement-onstatechange)|BaseElement|Watches for state changes
|
||||
|[BaseElement:removeStateChange](#baseelement-removestatechange)|BaseElement|Removes a state change observer
|
||||
|[BaseElement:setState](#baseelement-setstate)|BaseElement|Sets a state value
|
||||
|
||||
|
||||
## BaseElement:bind(self, propertyName, stateName)
|
||||
Binds a property to a state
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to bind
|
||||
* `propertyName` `string` The property to bind
|
||||
* `stateName` `string` The state to bind to (optional, uses propertyName if not provided)
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:computed()
|
||||
|
||||
## BaseElement:getState(self, name)
|
||||
Gets the value of a state
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to get state from
|
||||
* `name` `string` The name of the state
|
||||
|
||||
### Returns
|
||||
* `any` `value` The current state value
|
||||
|
||||
## BaseElement:onStateChange(self, stateName, callback)
|
||||
Registers a callback for state changes
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to watch
|
||||
* `stateName` `string` The state to watch
|
||||
* `callback` `function` Called with (element, newValue, oldValue)
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:removeStateChange(self, stateName, callback)
|
||||
Removes a state change observer
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to remove observer from
|
||||
* `stateName` `string` The state to remove observer from
|
||||
* `callback` `function` The callback function to remove
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:setState(self, name, value)
|
||||
Sets the value of a state
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to set state for
|
||||
* `name` `string` The name of the state
|
||||
* `value` `any` The new value for the state
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
|
||||
---
|
||||
<br>
|
||||
|
||||
# BaseFrame : Container
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseFrame.setup](#baseframe-setup)|-|
|
||||
|[BaseFrame:initializeState](#baseframe-initializestate)|BaseFrame|Initializes a new state
|
||||
|
||||
|
||||
## BaseFrame.setup()
|
||||
|
||||
## BaseFrame:initializeState(self, name, default, persist?, path?)
|
||||
Initializes a new state for this element
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseFrame` The element to initialize state for
|
||||
* `name` `string` The name of the state
|
||||
* `default` `any` The default value of the state
|
||||
* `persist` *(optional)* `boolean` Whether to persist the state to disk
|
||||
* `path` *(optional)* `string` Custom file path for persistence
|
||||
|
||||
### Returns
|
||||
* `BaseFrame` `self` The element instance
|
||||
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
# BaseElement
|
||||
This is the theme plugin. It provides a theming system that allows for consistent styling across elements
|
||||
with support for inheritance, named styles, and dynamic theme switching.
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseElement:applyTheme](#baseelement-applytheme)|BaseElement|Applies theme styles to the element
|
||||
|[BaseElement:getTheme](#baseelement-gettheme)|table|Gets theme properties for the element
|
||||
|
||||
|
||||
## BaseElement:applyTheme(self, applyToChildren)
|
||||
Applies the current theme to this element
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to apply theme to
|
||||
* `applyToChildren` `boolean?` Whether to apply theme to child elements (default: true)
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:getTheme(self)
|
||||
Gets the theme properties for this element
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to get theme for
|
||||
|
||||
### Returns
|
||||
* `table` `styles` The theme properties
|
||||
|
||||
|
||||
---
|
||||
<br>
|
||||
|
||||
# ThemeAPI
|
||||
The Theme API provides methods for managing themes globally
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[ThemeAPI.getTheme](#themeapi-gettheme)|table|Gets the current theme
|
||||
|[ThemeAPI.loadTheme](#themeapi-loadtheme)|-|Loads theme from JSON file
|
||||
|[ThemeAPI.setTheme](#themeapi-settheme)|-|Sets a new theme
|
||||
|
||||
|
||||
## ThemeAPI.getTheme()
|
||||
Gets the current theme configuration
|
||||
|
||||
### Returns
|
||||
* `table` `theme` The current theme configuration
|
||||
|
||||
## ThemeAPI.loadTheme(path)
|
||||
Loads a theme from a JSON file
|
||||
|
||||
### Parameters
|
||||
* `path` `string` Path to the theme JSON file
|
||||
|
||||
## ThemeAPI.setTheme(newTheme)
|
||||
Sets the current theme
|
||||
|
||||
### Parameters
|
||||
* `newTheme` `table` The theme configuration to set
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Container
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Container:loadXML](#Container:loadXML)|Container|Loads UI from XML string
|
||||
|
||||
|
||||
## Container:loadXML(self, content, scope?)
|
||||
Loads and creates UI elements from XML content
|
||||
local xml = [[
|
||||
<Frame>
|
||||
<Button name="myButton" x="5" y="5"/>
|
||||
</Frame>
|
||||
]]
|
||||
container:loadXML(xml)
|
||||
|
||||
### Parameters
|
||||
* `self` `Container` The container to load into
|
||||
* `content` `string` The XML content to parse
|
||||
* `scope` *(optional)* `table` Optional scope for variable resolution
|
||||
|
||||
### Returns
|
||||
* `Container` `self` The container instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
# PropertySystem
|
||||
PropertySystem is a class that allows Elements to have properties that can be observed and updated.
|
||||
It also allows for properties to have custom getters and setters. This is the base system for all Elements.
|
||||
|
||||
## Fields
|
||||
|
||||
|Field|Type|Description|
|
||||
|---|---|---|
|
||||
|_properties|`table`|A table containing all property configurations|
|
||||
|_values|`table`|A table containing all property values|
|
||||
|_observers|`table`|A table containing all property observers|
|
||||
|set|`function`|A function to set a property value|
|
||||
|get|`function`|A function to get a property value|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[PropertySystem.addSetterHook](#propertysystem-addsetterhook)|-|Adds a setter hook to the PropertySystem
|
||||
|[PropertySystem.blueprint](#propertysystem-blueprint)|table|Creates a blueprint of an element class
|
||||
|[PropertySystem.combineProperties](#propertysystem-combineproperties)|-|Combines multiple properties
|
||||
|[PropertySystem.createFromBlueprint](#propertysystem-createfromblueprint)|table|Creates an element from a blueprint
|
||||
|[PropertySystem.defineProperty](#propertysystem-defineproperty)|-|Defines a property for an element class
|
||||
|[PropertySystem:__init](#propertysystem-__init)|table|Initializes the PropertySystem
|
||||
|[PropertySystem:_updateProperty](#propertysystem-_updateproperty)|table|Update call for a property
|
||||
|[PropertySystem:getPropertyConfig](#propertysystem-getpropertyconfig)|table|Gets a property configuration
|
||||
|[PropertySystem:instanceProperty](#propertysystem-instanceproperty)|table|Adds a property to the PropertySystem on instance level
|
||||
|[PropertySystem:observe](#propertysystem-observe)|table|Observers a property
|
||||
|[PropertySystem:removeAllObservers](#propertysystem-removeallobservers)|table|Removes all observers from a property
|
||||
|[PropertySystem:removeObserver](#propertysystem-removeobserver)|table|Removes an observer from a property
|
||||
|[PropertySystem:removeProperty](#propertysystem-removeproperty)|table|Removes a property from the PropertySystem
|
||||
|
||||
|
||||
## PropertySystem.addSetterHook(hook)
|
||||
Adds a setter hook to the PropertySystem. Setter hooks are functions that are called before a property is set.
|
||||
|
||||
### Parameters
|
||||
* `hook` `function` The hook function to add
|
||||
|
||||
## PropertySystem.blueprint(elementClass)
|
||||
Creates a blueprint of an element class with all its properties
|
||||
|
||||
### Parameters
|
||||
* `elementClass` `table` The element class to create a blueprint from
|
||||
|
||||
### Returns
|
||||
* `table` `blueprint` A table containing all property definitions
|
||||
|
||||
## PropertySystem.combineProperties(class, name...)
|
||||
Combines multiple properties into a single getter and setter
|
||||
|
||||
### Parameters
|
||||
* `class` `table` The element class to combine the properties for
|
||||
* `name` `string` The name of the combined property
|
||||
* `...` *(vararg)* `string` The names of the properties to combine
|
||||
|
||||
## PropertySystem.createFromBlueprint(elementClass, blueprint)
|
||||
Creates an element from a blueprint
|
||||
|
||||
### Parameters
|
||||
* `elementClass` `table` The element class to create from the blueprint
|
||||
* `blueprint` `table` The blueprint to create the element from
|
||||
|
||||
### Returns
|
||||
* `table` `element` The created element
|
||||
|
||||
## PropertySystem.defineProperty(class, name, config)
|
||||
Defines a property for an element class
|
||||
|
||||
### Parameters
|
||||
* `class` `table` The element class to define the property for
|
||||
* `name` `string` The name of the property
|
||||
* `config` `table` The configuration of the property
|
||||
|
||||
## PropertySystem:__init()
|
||||
Initializes the PropertySystem IS USED INTERNALLY
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
## PropertySystem:_updateProperty(name, value)
|
||||
Update call for a property IS USED INTERNALLY
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
* `value` `any` The value of the property
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
## PropertySystem:getPropertyConfig(name)
|
||||
Gets a property configuration
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
|
||||
### Returns
|
||||
* `table` `config` The configuration of the property
|
||||
|
||||
## PropertySystem:instanceProperty(name, config)
|
||||
Adds a property to the PropertySystem on instance level
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
* `config` `table` The configuration of the property
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
## PropertySystem:observe(name, callback)
|
||||
Observers a property
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
* `callback` `function` The callback function to call when the property changes
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
## PropertySystem:removeAllObservers(name)
|
||||
Removes all observers from a property
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
## PropertySystem:removeObserver(name, callback)
|
||||
Removes an observer from a property
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
* `callback` `function` The callback function to remove
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
## PropertySystem:removeProperty(name)
|
||||
Removes a property from the PropertySystem on instance level
|
||||
|
||||
### Parameters
|
||||
* `name` `string` The name of the property
|
||||
|
||||
### Returns
|
||||
* `table` `self` The PropertySystem
|
||||
|
||||
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
# Render
|
||||
This is the render module for Basalt. It tries to mimic the functionality of the `term` API. but with additional
|
||||
functionality. It also has a buffer system to reduce the number of calls
|
||||
|
||||
## Fields
|
||||
|
||||
|Field|Type|Description|
|
||||
|---|---|---|
|
||||
|terminal|`table`|The terminal object to render to|
|
||||
|width|`number`|The width of the render|
|
||||
|height|`number`|The height of the render|
|
||||
|buffer|`table`|The buffer to render|
|
||||
|xCursor|`number`|The x position of the cursor|
|
||||
|yCursor|`number`|The y position of the cursor|
|
||||
|blink|`boolean`|Whether the cursor should blink|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[Render.new](#render-new)|Render|
|
||||
|[Render:addDirtyRect](#render-adddirtyrect)|Render|
|
||||
|[Render:bg](#render-bg)|Render|
|
||||
|[Render:bg](#render-bg)|Render|
|
||||
|[Render:blit](#render-blit)|Render|
|
||||
|[Render:clear](#render-clear)|Render|
|
||||
|[Render:clearArea](#render-cleararea)|Render|
|
||||
|[Render:fg](#render-fg)|Render|
|
||||
|[Render:fg](#render-fg)|Render|
|
||||
|[Render:getSize](#render-getsize)|number,|
|
||||
|[Render:mergeRects](#render-mergerects)|Render|
|
||||
|[Render:multiBlit](#render-multiblit)|Render|
|
||||
|[Render:rectOverlaps](#render-rectoverlaps)|boolean|
|
||||
|[Render:render](#render-render)|Render|
|
||||
|[Render:setCursor](#render-setcursor)|Render|
|
||||
|[Render:setSize](#render-setsize)|Render|
|
||||
|[Render:text](#render-text)|Render|
|
||||
|[Render:text](#render-text)|Render|
|
||||
|[Render:textBg](#render-textbg)|Render|
|
||||
|[Render:textFg](#render-textfg)|Render|
|
||||
|
||||
|
||||
## Render.new(terminal)
|
||||
Creates a new Render object
|
||||
|
||||
### Parameters
|
||||
* `terminal` `table` The terminal object to render to
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:addDirtyRect(x, y, width, height)
|
||||
Adds a dirty rectangle to the buffer
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position of the rectangle
|
||||
* `y` `number` The y position of the rectangle
|
||||
* `width` `number` The width of the rectangle
|
||||
* `height` `number` The height of the rectangle
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:bg(x, y, bg)
|
||||
Blits a background color to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `bg` `string` The background color to blit
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:bg(x, y, bg)
|
||||
Blits a background color to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `bg` `string` The background color to blit
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:blit(x, y, text, fg, bg)
|
||||
Blits text to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to blit to
|
||||
* `y` `number` The y position to blit to
|
||||
* `text` `string` The text to blit
|
||||
* `fg` `string` The foreground color of the text
|
||||
* `bg` `string` The background color of the text
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:clear(bg)
|
||||
Clears the screen
|
||||
|
||||
### Parameters
|
||||
* `bg` `colors` The background color to clear the screen with
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:clearArea(x, y, width, height, bg)
|
||||
Clears an area of the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position of the area
|
||||
* `y` `number` The y position of the area
|
||||
* `width` `number` The width of the area
|
||||
* `height` `number` The height of the area
|
||||
* `bg` `colors` The background color to clear the area with
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:fg(x, y, fg)
|
||||
Blits a foreground color to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `fg` `string` The foreground color to blit
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:fg(x, y, fg)
|
||||
Blits a foreground color to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position
|
||||
* `y` `number` The y position
|
||||
* `fg` `string` The foreground color to blit
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:getSize()
|
||||
Gets the size of the render
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:mergeRects(target, source)
|
||||
Merges two rectangles
|
||||
|
||||
### Parameters
|
||||
* `target` `table` The target rectangle
|
||||
* `source` `table` The source rectangle
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:multiBlit(x, y, width, height, text, fg, bg)
|
||||
Blits text to the screen with multiple lines
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to blit to
|
||||
* `y` `number` The y position to blit to
|
||||
* `width` `number` The width of the text
|
||||
* `height` `number` The height of the text
|
||||
* `text` `string` The text to blit
|
||||
* `fg` `colors` The foreground color of the text
|
||||
* `bg` `colors` The background color of the text
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:rectOverlaps(r1, r2)
|
||||
Checks if two rectangles overlap
|
||||
|
||||
### Parameters
|
||||
* `r1` `table` The first rectangle
|
||||
* `r2` `table` The second rectangle
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:render()
|
||||
Renders the buffer to the screen
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:setCursor(x, y, blink)
|
||||
Sets the cursor position
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position of the cursor
|
||||
* `y` `number` The y position of the cursor
|
||||
* `blink` `boolean` Whether the cursor should blink
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:setSize(width, height)
|
||||
Sets the size of the render
|
||||
|
||||
### Parameters
|
||||
* `width` `number` The width of the render
|
||||
* `height` `number` The height of the render
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:text(x, y, text)
|
||||
Blits text to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to blit to
|
||||
* `y` `number` The y position to blit to
|
||||
* `text` `string` The text to blit
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:text(x, y, text)
|
||||
Renders the text to the screen
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to blit to
|
||||
* `y` `number` The y position to blit to
|
||||
* `text` `string` The text to blit
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:textBg(x, y, text, bg)
|
||||
Blits text to the screen with a background color
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to blit to
|
||||
* `y` `number` The y position to blit to
|
||||
* `text` `string` The text to blit
|
||||
* `bg` `colors` The background color of the text
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## Render:textFg(x, y, text, fg)
|
||||
Blits text to the screen with a foreground color
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to blit to
|
||||
* `y` `number` The y position to blit to
|
||||
* `text` `string` The text to blit
|
||||
* `fg` `colors` The foreground color of the text
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user