diff --git a/docs/references/BaseElement.md b/docs/references/BaseElement.md index 6be9c42..5e1f3b1 100644 --- a/docs/references/BaseElement.md +++ b/docs/references/BaseElement.md @@ -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 diff --git a/docs/references/BaseFrame.md b/docs/references/BaseFrame.md index a96f631..e1acab9 100644 --- a/docs/references/BaseFrame.md +++ b/docs/references/BaseFrame.md @@ -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() diff --git a/docs/references/Button.md b/docs/references/Button.md index 05a23b3..16fa6d6 100644 --- a/docs/references/Button.md +++ b/docs/references/Button.md @@ -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 diff --git a/docs/references/Container.md b/docs/references/Container.md index b8d0e2d..2df845c 100644 --- a/docs/references/Container.md +++ b/docs/references/Container.md @@ -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() diff --git a/docs/references/Flexbox.md b/docs/references/Flexbox.md new file mode 100644 index 0000000..ba7219f --- /dev/null +++ b/docs/references/Flexbox.md @@ -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() + diff --git a/docs/references/Frame.md b/docs/references/Frame.md index 4eb1362..42d5cc9 100644 --- a/docs/references/Frame.md +++ b/docs/references/Frame.md @@ -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() diff --git a/docs/references/Input.md b/docs/references/Input.md new file mode 100644 index 0000000..d9457cd --- /dev/null +++ b/docs/references/Input.md @@ -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() + diff --git a/docs/references/Label.md b/docs/references/Label.md new file mode 100644 index 0000000..5cbba48 --- /dev/null +++ b/docs/references/Label.md @@ -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() + diff --git a/docs/references/VisualElement.md b/docs/references/VisualElement.md index a373d13..08e55d7 100644 --- a/docs/references/VisualElement.md +++ b/docs/references/VisualElement.md @@ -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 diff --git a/docs/references/animation.md b/docs/references/animation.md new file mode 100644 index 0000000..a39a254 --- /dev/null +++ b/docs/references/animation.md @@ -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() + diff --git a/docs/references/benchmark.md b/docs/references/benchmark.md new file mode 100644 index 0000000..5ddeb0f --- /dev/null +++ b/docs/references/benchmark.md @@ -0,0 +1,7 @@ +Will temporary exist while developing, maybe i will create a benchmark plugin in future +## Benchmark.start() + +## Benchmark.stop() + +## Benchmark.update() + diff --git a/docs/references/elementManager.md b/docs/references/elementManager.md index 8a96789..cc216d5 100644 --- a/docs/references/elementManager.md +++ b/docs/references/elementManager.md @@ -1,14 +1,6 @@ -## ElementManager.extendMethod() - -## ElementManager.generateId() - ## ElementManager.getElement() ## ElementManager.getElementList() ## ElementManager.loadElement() -## ElementManager.loadPlugin() - -## ElementManager.registerPlugin() - diff --git a/docs/references/main.md b/docs/references/main.md index f6053bf..239db74 100644 --- a/docs/references/main.md +++ b/docs/references/main.md @@ -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 diff --git a/docs/references/pluginTemplate.md b/docs/references/pluginTemplate.md new file mode 100644 index 0000000..888e90f --- /dev/null +++ b/docs/references/pluginTemplate.md @@ -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 + diff --git a/docs/references/propertySystem.md b/docs/references/propertySystem.md index b39b811..4faf96c 100644 --- a/docs/references/propertySystem.md +++ b/docs/references/propertySystem.md @@ -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() + diff --git a/docs/references/reactive.md b/docs/references/reactive.md new file mode 100644 index 0000000..79aa88b --- /dev/null +++ b/docs/references/reactive.md @@ -0,0 +1,4 @@ +## BaseElement:setReactive() + +## BaseElement:setReactiveProperty() + diff --git a/docs/references/render.md b/docs/references/render.md index 8a57035..5567a05 100644 --- a/docs/references/render.md +++ b/docs/references/render.md @@ -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() diff --git a/docs/references/utils.md b/docs/references/utils.md index ebfe343..d50af09 100644 --- a/docs/references/utils.md +++ b/docs/references/utils.md @@ -2,3 +2,7 @@ ## utils.getCenteredPosition() +## utils.split() + +## utils.uuid() + diff --git a/docs/references/xml.md b/docs/references/xml.md new file mode 100644 index 0000000..34c729f --- /dev/null +++ b/docs/references/xml.md @@ -0,0 +1,4 @@ +## BaseElement:fromXML() + +## Container:loadXML() +