This commit is contained in:
NoryiE
2025-02-13 09:51:51 +00:00
parent 7dff4d2f1e
commit 346ded1c89
19 changed files with 336 additions and 35 deletions

View File

@@ -6,6 +6,8 @@ The base class for all UI elements in Basalt
|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|{}|Table containing all registered event callbacks
## Functions
@@ -14,8 +16,11 @@ The base class for all UI elements in Basalt
|---|---|---|
|[BaseElement.listenTo](#BaseElement.listenTo)|-|
|[BaseElement.new](#BaseElement.new)|table|
|[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?|
|[BaseElement:fireEvent](#BaseElement:fireEvent)|table|
|[BaseElement:handleEvent](#BaseElement:handleEvent)|boolean?|
|[BaseElement:init](#BaseElement:init)|table|
|[BaseElement:isType](#BaseElement:isType)|boolean|
|[BaseElement:listenEvent](#BaseElement:listenEvent)|table|
|[BaseElement:registerCallback](#BaseElement:registerCallback)|table|
|[BaseElement:updateRender](#BaseElement:updateRender)|-|
@@ -32,11 +37,11 @@ Registers an event that this class can listen to
BaseElement.listenTo(MyClass, "mouse_click")
```
## BaseElement.new(id, basalt)
## BaseElement.new(props, basalt)
Creates a new BaseElement instance
### Parameters
* `id` `string` The unique identifier for this element
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
@@ -47,6 +52,16 @@ Creates a new BaseElement instance
local element = BaseElement.new("myId", basalt)
```
## BaseElement:dispatchEvent(event)
Handles all events
@vararg any The arguments for the event
### Parameters
* `event` `string` The event to handle
### Returns
* `boolean?` `handled` Whether the event was handled
## BaseElement:fireEvent(event, ...)
Triggers an event and calls all registered callbacks
@@ -62,16 +77,35 @@ Triggers an event and calls all registered callbacks
element:fireEvent("mouse_click", 1, 2)
```
## BaseElement:init(id, basalt)
## BaseElement:handleEvent(event)
The default event handler for all events
@vararg any The arguments for the event
### Parameters
* `event` `string` The event to handle
### Returns
* `boolean?` `handled` Whether the event was handled
## BaseElement:init(props, basalt)
Initializes the BaseElement instance
### Parameters
* `id` `string` The unique identifier for this element
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `table` `self` The initialized instance
## BaseElement:isType(type)
Checks if the element is a specific type
### Parameters
* `type` `string` The type to check for
### Returns
* `boolean` `Whether` the element is of the specified type
## BaseElement:listenEvent(eventName, enable?)
Enables or disables event listening for a specific event

View File

@@ -1,21 +1,31 @@
# BaseFrame : Container
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|text|term|term|nil text
## Functions
|Method|Returns|Description|
|---|---|---|
|[BaseFrame.new](#BaseFrame.new)|-|
|[BaseFrame:init](#BaseFrame:init)|-|
|[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|
|[BaseFrame:render](#BaseFrame:render)|-|
|[BaseFrame:setCursor](#BaseFrame:setCursor)|-|
|[BaseFrame:textFg](#BaseFrame:textFg)|-|
## BaseFrame.new()
@diagnostic disable-next-line: duplicate-set-field
## BaseFrame:init()
## BaseFrame:multiBlit()
## BaseFrame:render()
@diagnostic disable-next-line: duplicate-set-field
## BaseFrame:setCursor()
## BaseFrame:textFg()

View File

@@ -11,12 +11,13 @@
|Method|Returns|Description|
|---|---|---|
|[Button.new](#Button.new)|-|
|[Button:init](#Button:init)|-|
|[Button:render](#Button:render)|-|
@event mouse_click The event that is triggered when the button is clicked
## Button.new()
@diagnostic disable-next-line: duplicate-set-field
## Button:init()
## Button:render()
@diagnostic disable-next-line: duplicate-set-field

View File

@@ -6,7 +6,14 @@
|---|---|---|
|[Container.new](#Container.new)|-|
|[Container:addChild](#Container:addChild)|-|
|[Container:char](#Container:char)|-|
|[Container:getChild](#Container:getChild)|-|
|[Container:handleEvent](#Container:handleEvent)|-|
|[Container:init](#Container:init)|-|
|[Container:isChildVisible](#Container:isChildVisible)|-|
|[Container:key](#Container:key)|-|
|[Container:key_up](#Container:key_up)|-|
|[Container:mouse_click](#Container:mouse_click)|-|
|[Container:multiBlit](#Container:multiBlit)|-|
|[Container:registerChildEvent](#Container:registerChildEvent)|-|
|[Container:registerChildrenEvents](#Container:registerChildrenEvents)|-|
@@ -19,12 +26,25 @@
|[Container:unregisterChildEvent](#Container:unregisterChildEvent)|-|
## Container.new()
@diagnostic disable-next-line: duplicate-set-field
## Container:addChild()
## Container:char()
## Container:getChild()
## Container:handleEvent()
## Container:init()
## Container:isChildVisible()
## Container:key()
## Container:key_up()
## Container:mouse_click()
## Container:multiBlit()
## Container:registerChildEvent()
@@ -36,7 +56,6 @@
## Container:removeChildrenEvents()
## Container:render()
@diagnostic disable-next-line: duplicate-set-field
## Container:sortChildren()

View File

@@ -0,0 +1,45 @@
# Flexbox : Container
## Functions
|Method|Returns|Description|
|---|---|---|
|[Flexbox.new](#Flexbox.new)|Flexbox|
|[Flexbox:addChild](#Flexbox:addChild)|-|
|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|
|[Flexbox:init](#Flexbox:init)|-|
|[Flexbox:removeChild](#Flexbox:removeChild)|-|
|[Flexbox:render](#Flexbox:render)|-|
## Flexbox.new(props, basalt)
Creates a new Flexbox instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Flexbox` `object` The newly created Flexbox instance
### Usage
```lua
local element = Flexbox.new("myId", basalt)
```
## Flexbox:addChild()
## Flexbox:addLineBreak(self)
Adds a new line break to the flexbox.
### Parameters
* `self` `Flexbox` The element itself
### Returns
* `nil` `nil` nil
## Flexbox:init()
## Flexbox:removeChild()
## Flexbox:render()

View File

@@ -4,7 +4,23 @@
|Method|Returns|Description|
|---|---|---|
|[Frame.new](#Frame.new)|-|
|[Frame.new](#Frame.new)|Frame|
|[Frame:init](#Frame:init)|-|
## Frame.new()
## Frame.new(props, basalt)
Creates a new Frame instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Frame` `object` The newly created Frame instance
### Usage
```lua
local element = Frame.new("myId", basalt)
```
## Frame:init()

52
docs/references/Input.md Normal file
View File

@@ -0,0 +1,52 @@
# Input : VisualElement
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|text|string|Input|- text to be displayed
|cursorPos|number|Input|- current cursor position
|viewOffset|number|Input|- offset für Text-Viewport
## Functions
|Method|Returns|Description|
|---|---|---|
|[Input.new](#Input.new)|Input|
|[Input:blur](#Input:blur)|-|
|[Input:char](#Input:char)|-|
|[Input:focus](#Input:focus)|-|
|[Input:init](#Input:init)|-|
|[Input:key](#Input:key)|-|
|[Input:render](#Input:render)|-|
|[Input:updateViewport](#Input:updateViewport)|-|
## Input.new(id, basalt)
Creates a new Input instance
### Parameters
* `id` `string` The unique identifier for this element
* `basalt` `table` The basalt instance
### Returns
* `Input` `object` The newly created Input instance
### Usage
```lua
local element = Input.new("myId", basalt)
```
## Input:blur()
## Input:char()
## Input:focus()
## Input:init()
## Input:key()
## Input:render()
## Input:updateViewport()

35
docs/references/Label.md Normal file
View File

@@ -0,0 +1,35 @@
# Label : VisualElement
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|text|string|Label|Label text to be displayed
## Functions
|Method|Returns|Description|
|---|---|---|
|[Label.new](#Label.new)|Label|
|[Label:init](#Label:init)|-|
|[Label:render](#Label:render)|-|
## Label.new(name, basalt)
Creates a new Label instance
### Parameters
* `name` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Label` `object` The newly created Label instance
### Usage
```lua
local element = Label.new("myId", basalt)
```
## Label:init()
## Label:render()

View File

@@ -12,29 +12,34 @@
|height|number|1|height of the element
|background|color|black|background color of the element
|foreground|color|white|foreground color of the element
|clicked|boolean|false|element is currently clicked
|clicked|boole|an|false element is currently clicked
|backgroundEnabled|boolean|true|whether the background is enabled
|focused|boolean|false|whether the element is focused
## Functions
|Method|Returns|Description|
|---|---|---|
|[VisualElement.new](#VisualElement.new)|VisualElement|
|[VisualElement:blur](#VisualElement:blur)|-|
|[VisualElement:focus](#VisualElement:focus)|-|
|[VisualElement:getAbsolutePosition](#VisualElement:getAbsolutePosition)|-|
|[VisualElement:getRelativePosition](#VisualElement:getRelativePosition)|number,|
|[VisualElement:handleEvent](#VisualElement:handleEvent)|boolean?|
|[VisualElement:init](#VisualElement:init)|-|
|[VisualElement:isInBounds](#VisualElement:isInBounds)|boolean|
|[VisualElement:mouse_click](#VisualElement:mouse_click)|boolean|
|[VisualElement:mouse_release](#VisualElement:mouse_release)|-|
|[VisualElement:mouse_up](#VisualElement:mouse_up)|-|
|[VisualElement:multiBlit](#VisualElement:multiBlit)|-|
|[VisualElement:render](#VisualElement:render)|-|
|[VisualElement:setCursor](#VisualElement:setCursor)|-|
|[VisualElement:textFg](#VisualElement:textFg)|-|
## VisualElement.new(id, basalt)
## VisualElement.new(props, basalt)
Creates a new VisualElement instance
### Parameters
* `id` `string` The unique identifier for this element
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
@@ -45,6 +50,10 @@ Creates a new VisualElement instance
local element = VisualElement.new("myId", basalt)
```
## VisualElement:blur()
## VisualElement:focus()
## VisualElement:getAbsolutePosition(x?, y?)
Returns the absolute position of the element or the given coordinates.
@@ -62,15 +71,7 @@ Returns the relative position of the element or the given coordinates.
### Returns
* `nil` `nil` nil
## VisualElement:handleEvent(event)
Handles all events
@vararg any The arguments for the event
### Parameters
* `event` `string` The event to handle
### Returns
* `boolean?` `handled` Whether the event was handled
## VisualElement:init()
## VisualElement:isInBounds(x, y)
Checks if the specified coordinates are within the bounds of the element
@@ -117,6 +118,8 @@ Renders the element
element:render()
```
## VisualElement:setCursor()
## VisualElement:textFg(x, y, text, fg)
Draws a text character at the specified position, used in the rendering system

View File

@@ -0,0 +1,34 @@
## Animation.new()
## Animation.registerAnimation()
## Animation.registerEasing()
## Animation:addAnimation()
## Animation:event()
## Animation:onComplete()
## Animation:onStart()
## Animation:onUpdate()
## Animation:sequence()
## Animation:start()
## AnimationInstance.new()
## AnimationInstance:complete()
## AnimationInstance:start()
## AnimationInstance:update()
## VisualElement.hooks.dispatchEvent()
## VisualElement.setup()
## VisualElement:animate()

View File

@@ -0,0 +1,7 @@
Will temporary exist while developing, maybe i will create a benchmark plugin in future
## Benchmark.start()
## Benchmark.stop()
## Benchmark.update()

View File

@@ -1,14 +1,6 @@
## ElementManager.extendMethod()
## ElementManager.generateId()
## ElementManager.getElement()
## ElementManager.getElementList()
## ElementManager.loadElement()
## ElementManager.loadPlugin()
## ElementManager.registerPlugin()

View File

@@ -25,12 +25,12 @@ What this code does is it loads basalt into the project, and you can access it b
|[basalt.stop](#basalt.stop)|-|
|[basalt.update](#basalt.update)|-|
## basalt.create(type, id?)
## 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")
* `id` *(optional)* `string` Optional unique identifier for the element
* `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

View File

@@ -0,0 +1,10 @@
Will temporary exist so that we don't lose track of how the plugin system works
## VisualElement.hooks.init()
Hooks into existing methods (you can also use init.pre or init.post)
## VisualElement.setup()
Called on Class level to define properties and setup before instance is created
## VisualElement:testFunc()
Adds a new method to the class

View File

@@ -4,10 +4,26 @@
|Method|Returns|Description|
|---|---|---|
|[PropertySystem.blueprint](#PropertySystem.blueprint)|table|
|[PropertySystem.createFromBlueprint](#PropertySystem.createFromBlueprint)|-|
|[PropertySystem.defineProperty](#PropertySystem.defineProperty)|-|
|[PropertySystem:__init](#PropertySystem:__init)|-|
|[PropertySystem:_updateProperty](#PropertySystem:_updateProperty)|-|
|[PropertySystem:getPropertyConfig](#PropertySystem:getPropertyConfig)|-|
|[PropertySystem:instanceProperty](#PropertySystem:instanceProperty)|-|
|[PropertySystem:observe](#PropertySystem:observe)|-|
|[PropertySystem:removeProperty](#PropertySystem:removeProperty)|-|
## 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.createFromBlueprint()
## PropertySystem.defineProperty()
@@ -15,5 +31,11 @@
## PropertySystem:_updateProperty()
## PropertySystem:getPropertyConfig()
## PropertySystem:instanceProperty()
## PropertySystem:observe()
## PropertySystem:removeProperty()

View File

@@ -0,0 +1,4 @@
## BaseElement:setReactive()
## BaseElement:setReactiveProperty()

View File

@@ -1,5 +1,7 @@
## Render.new()
## Render:addDirtyRect()
## Render:bg()
## Render:blit()
@@ -12,10 +14,17 @@
## Render:getSize()
## Render:mergeRects()
## Render:multiBlit()
## Render:rectOverlaps()
Hilfsfunktionen für Rectangle-Management
## Render:render()
## Render:setCursor()
## Render:text()
## Render:textFg()

View File

@@ -2,3 +2,7 @@
## utils.getCenteredPosition()
## utils.split()
## utils.uuid()

4
docs/references/xml.md Normal file
View File

@@ -0,0 +1,4 @@
## BaseElement:fromXML()
## Container:loadXML()