This commit is contained in:
Robert Jelic
2025-09-13 12:54:15 +02:00
42 changed files with 1582 additions and 2507 deletions

View File

@@ -1,175 +1,48 @@
# BaseElement
## Functions
|Method|Returns|Description|
|---|---|---|
|[BaseElement:BaseElement](#baseelement-baseelement-methodname)|BaseElement|Starts timing a method call|
|[BaseElement:BaseElement](#baseelement-baseelement-methodname)|BaseElement|Ends timing a method call and records statistics|
|[BaseElement:BaseElement](#baseelement-baseelement-methodname)|BaseElement|Enables performance measurement for a method|
|[BaseElement:BaseElement](#baseelement-baseelement-methodname)|BaseElement|Logs benchmark statistics for a method|
|[BaseElement:BaseElement](#baseelement-baseelement-methodname)|BaseElement|Disables performance measurement for a method|
|[BaseElement:BaseElement](#baseelement-baseelement-methodname)|stats|Retrieves benchmark statistics for a method|
## BaseElement:BaseElement(methodName)
Starts profiling a method
### Parameters
* `methodName` `string` The name of the method to profile
### Returns
* `BaseElement` `self` The element instance
## BaseElement:BaseElement(methodName)
Ends profiling a method
### Parameters
* `methodName` `string` The name of the method to stop profiling
### Returns
* `BaseElement` `self` The element instance
## BaseElement:BaseElement(methodName)
Enables benchmarking for a method
### Parameters
* `methodName` `string` The name of the method to benchmark
### Returns
* `BaseElement` `self` The element instance
### Usage
```lua
element:benchmark("render")
```
## BaseElement:BaseElement(methodName)
Logs benchmark statistics for a method
### Parameters
* `methodName` `string` The name of the method to log
### Returns
* `BaseElement` `self` The element instance
## BaseElement:BaseElement(methodName)
Stops benchmarking for a method
### Parameters
* `methodName` `string` The name of the method to stop benchmarking
### Returns
* `BaseElement` `self` The element instance
## BaseElement:BaseElement(methodName)
Gets benchmark statistics for a method
### Parameters
* `methodName` `string` The name of the method to get statistics for
### Returns
* `stats` `The` benchmark statistics or nil
# Container
Extends: `VisualElement`
## Functions
|Method|Returns|Description|
|---|---|---|
|[Container:Container](#container-container-methodname)|Container|Recursively enables benchmarking|
|[Container:Container](#container-container-methodname)|Container|Recursively logs benchmark statistics|
|[Container:Container](#container-container-methodname)|Container|Recursively stops benchmarking|
## Container:Container(methodName)
Enables benchmarking for a container and all its children
### Parameters
* `methodName` `string` The method to benchmark
### Returns
* `Container` `self` The container instance
### Usage
```lua
container:benchmarkContainer("render")
```
## Container:Container(methodName)
Logs benchmark statistics for a container and all its children
### Parameters
* `methodName` `string` The method to log
### Returns
* `Container` `self` The container instance
## Container:Container(methodName)
Stops benchmarking for a container and all its children
### Parameters
* `methodName` `string` The method to stop benchmarking
### Returns
* `Container` `self` The container instance
# Benchmark
_This is the benchmark plugin. It provides performance measurement tools for elements and methods,
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._
where performance is critical. It allows you to measure the time taken by specific methods and log the results.
## Functions
|Method|Returns|Description|
|---|---|---|
|[Benchmark.start](#benchmark-start-name-options)|-|Starts timing a custom operation|
|[Benchmark.stop](#benchmark-stop-name)|-|Stops timing and logs results|
|[Benchmark.getStats](#benchmark-getstats-name)|stats|Retrieves benchmark statistics|
|[Benchmark.clear](#benchmark-clear-name)|-|Removes a benchmark's data|
|[Benchmark.clearAll](#benchmark-clearall)|-|Removes all custom benchmark data|
|[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
## Benchmark.start(name, options?)
Starts a custom benchmark
## API.clear(name)
Clears a specific benchmark
### Parameters
* `name` `string` The name of the benchmark
* `options` *(optional)* `table` Optional configuration
* `name` `string` The name of the benchmark to clear
## Benchmark.stop(name)
Stops a custom benchmark
### Parameters
* `name` `string` The name of the benchmark to stop
## Benchmark.getStats(name)
## API.clearAll()
Clears all custom benchmarks
## API.getStats(name)
Gets statistics for a benchmark
### Parameters
* `name` `string` The name of the benchmark
### Returns
* `stats` `The` benchmark statistics or nil
* `table?` `stats` The benchmark statistics or nil
## Benchmark.clear(name)
Clears a specific benchmark
## API.start(name, options?)
Starts a custom benchmark
### Parameters
* `name` `string` The name of the benchmark to clear
* `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
## Benchmark.clearAll()
Clears all custom benchmarks

View File

@@ -1,15 +1,15 @@
# BaseElement
_No Description_
No Description
## Functions
|Method|Returns|Description|
|---|---|---|
|[BaseElement.debug](#baseelement-debug-self-level)|-|Enables debugging for this element|
|[BaseElement.dumpDebug](#baseelement-dumpdebug-self)|-|Dumps debug information|
|[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
@@ -17,55 +17,62 @@ Enables debugging for this element
* `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.openConsole](#baseframe-openconsole-self)|-|Shows the debug log frame|
|[BaseFrame.closeConsole](#baseframe-closeconsole-self)|-|Hides the debug log frame|
|[BaseFrame.toggleConsole](#baseframe-toggleconsole-self)|-|Toggles the debug log frame|
|[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.openConsole(self)
Shows the debug log frame
### Parameters
* `self` `BaseFrame` The frame to show debug log in
## BaseFrame.closeConsole(self)
Hides the debug log frame
### Parameters
* `self` `BaseFrame` The frame to hide debug log for
## BaseFrame.toggleConsole(self)
## 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-self-level)|-|Debug container and children|
|[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

View File

@@ -1,3 +1,15 @@
# 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._
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}")
```

View File

@@ -1,15 +1,92 @@
# BaseFrame
Extends: `Container`
# 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|
|---|---|---|
|[BaseFrame:BaseFrame](#baseframe-baseframe-self-name-default-persist-path)|BaseFrame|Initializes a new state|
|[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
## BaseFrame:BaseFrame(self, name, default, persist?, path?)
## 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
@@ -22,75 +99,4 @@ Initializes a new state for this element
### Returns
* `BaseFrame` `self` The element instance
# 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:BaseElement](#baseelement-baseelement-self-name-value)|BaseElement|Sets a state value|
|[BaseElement:BaseElement](#baseelement-baseelement-self-name)|any|Gets a state value|
|[BaseElement:BaseElement](#baseelement-baseelement-self-statename-callback)|BaseElement|Watches for state changes|
|[BaseElement:BaseElement](#baseelement-baseelement-self-statename-callback)|BaseElement|Removes a state change observer|
|[BaseElement:BaseElement](#baseelement-baseelement-self-propertyname-statename)|BaseElement|Binds a property to a state|
## BaseElement:BaseElement(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
## BaseElement:BaseElement(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:BaseElement(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:BaseElement(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:BaseElement(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

View File

@@ -1,29 +1,26 @@
# 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._
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.____getElementPath](#baseelement-----getelementpath)|-||
|[BaseElement:BaseElement](#baseelement-baseelement-self-applytochildren)|BaseElement|Applies theme styles to the element|
|[BaseElement:BaseElement](#baseelement-baseelement-self)|table|Gets theme properties for the element|
|[BaseElement:applyTheme](#baseelement-applytheme)|BaseElement|Applies theme styles to the element
|[BaseElement:getTheme](#baseelement-gettheme)|table|Gets theme properties for the element
## BaseElement.____getElementPath()
## BaseElement:BaseElement(self, applyToChildren)
## 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)
* `applyToChildren` `boolean?` Whether to apply theme to child elements (default: true)
### Returns
* `BaseElement` `self` The element instance
## BaseElement:BaseElement(self)
## BaseElement:getTheme(self)
Gets the theme properties for this element
### Parameters
@@ -32,34 +29,38 @@ Gets the theme properties for this element
### Returns
* `table` `styles` The theme properties
---
<br>
# ThemeAPI
_The Theme API provides methods for managing themes globally_
The Theme API provides methods for managing themes globally
## Functions
|Method|Returns|Description|
|---|---|---|
|[ThemeAPI.setTheme](#themeapi-settheme-newtheme)|-|Sets a new theme|
|[ThemeAPI.getTheme](#themeapi-gettheme)|table|Gets the current theme|
|[ThemeAPI.loadTheme](#themeapi-loadtheme-path)|-|Loads theme from JSON file|
|[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.setTheme(newTheme)
Sets the current theme
### Parameters
* `newTheme` `table` The theme configuration to set
## 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