This commit is contained in:
Robert Jelic
2025-09-13 12:50:01 +02:00
parent 179949c8b7
commit 3504d8a3aa
43 changed files with 2553 additions and 1719 deletions

View File

@@ -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

View File

@@ -1,48 +1,175 @@
# 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.
# BaseElement
## 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
|[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)
## API.clear(name)
Clears a specific benchmark
Starts profiling a method
### 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
* `methodName` `string` The name of the method to profile
### Returns
* `table?` `stats` The benchmark statistics or nil
* `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,
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|
|---|---|---|
|[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|
## Benchmark.start(name, options?)
## API.start(name, options?)
Starts a custom benchmark
### Parameters
* `name` `string` The name of the benchmark
* `options` *(optional)* `table` Optional configuration
## API.stop(name)
## Benchmark.stop(name)
Stops a custom benchmark
### Parameters
* `name` `string` The name of the benchmark to stop
## Benchmark.getStats(name)
Gets statistics for a benchmark
### Parameters
* `name` `string` The name of the benchmark
### Returns
* `stats` `The` benchmark statistics or nil
## Benchmark.clear(name)
Clears a specific benchmark
### Parameters
* `name` `string` The name of the benchmark to clear
## Benchmark.clearAll()
Clears all custom benchmarks

View File

View File

@@ -1,15 +1,15 @@
# BaseElement
No Description
_No Description_
## Functions
|Method|Returns|Description|
|---|---|---|
|[BaseElement.debug](#baseelement-debug)|-|Enables debugging for this element
|[BaseElement.dumpDebug](#baseelement-dumpdebug)|-|Dumps debug information
|[BaseElement.debug](#baseelement-debug-self-level)|-|Enables debugging for this element|
|[BaseElement.dumpDebug](#baseelement-dumpdebug-self)|-|Dumps debug information|
## BaseElement.debug(self, level)
Enables debugging for this element
### Parameters
@@ -17,62 +17,55 @@ 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.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](#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.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)
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](#container-debugchildren-self-level)|-|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,15 +1,3 @@
# 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}")
```
_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._

View File

@@ -1,92 +1,15 @@
# 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.
# BaseFrame
Extends: `Container`
## 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
|[BaseFrame:BaseFrame](#baseframe-baseframe-self-name-default-persist-path)|BaseFrame|Initializes a new state|
## 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
@@ -99,4 +22,75 @@ 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,26 +1,29 @@
# 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:applyTheme](#baseelement-applytheme)|BaseElement|Applies theme styles to the element
|[BaseElement:getTheme](#baseelement-gettheme)|table|Gets theme properties for the element
|[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.____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:getTheme(self)
## BaseElement:BaseElement(self)
Gets the theme properties for this element
### Parameters
@@ -29,38 +32,34 @@ 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.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](#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.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

View File

@@ -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
```