From ca2521d2370daeef163e14ea3e800ab95bdb876e Mon Sep 17 00:00:00 2001 From: NoryiE Date: Mon, 17 Feb 2025 08:37:58 +0000 Subject: [PATCH] deploy: cf49f69612b88cc049edc4b8b3552dc889aeaefe --- docs/references/elements/BaseElement.md | 14 ++++++- docs/references/elements/Button.md | 6 ++- docs/references/elements/Container.md | 3 ++ docs/references/elements/VisualElement.md | 44 ++++++++++---------- docs/references/log.md | 26 +++++++++++- docs/references/main.md | 50 ++++++++++++++--------- 6 files changed, 98 insertions(+), 45 deletions(-) diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index 9943de2..a57677e 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -19,7 +19,7 @@ The base class for all UI elements in Basalt |[BaseElement:destroy](#BaseElement:destroy)|-| |[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?| |[BaseElement:fireEvent](#BaseElement:fireEvent)|table| -|[BaseElement:getBaseFrame](#BaseElement:getBaseFrame)|-| +|[BaseElement:getBaseFrame](#BaseElement:getBaseFrame)|table| |[BaseElement:handleEvent](#BaseElement:handleEvent)|boolean?| |[BaseElement:init](#BaseElement:init)|table| |[BaseElement:isType](#BaseElement:isType)|boolean| @@ -56,6 +56,12 @@ local element = BaseElement.new("myId", basalt) ``` ## BaseElement:destroy() +Destroys the element and cleans up all references + +### Usage + ```lua +element:destroy() +``` ## BaseElement:dispatchEvent(event) Handles all events @@ -83,6 +89,10 @@ element:fireEvent("mouse_click", 1, 2) ``` ## BaseElement:getBaseFrame() +Returns the base frame of the element + +### Returns +* `table` `BaseFrame` The base frame of the element ## BaseElement:handleEvent(event) The default event handler for all events @@ -129,7 +139,7 @@ element:listenEvent("mouse_click", true) ``` ## BaseElement:postInit() -Post initialization hook +Post initialization ### Returns * `table` `self` The BaseElement instance diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index a1e9459..77621d1 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -6,6 +6,11 @@ |---|---|---|---| |text|string|Button|Button text +## Events + +|Event|Parameters|Description| +|---|---|---| + ## Functions |Method|Returns|Description| @@ -14,7 +19,6 @@ |[Button:init](#Button:init)|-| |[Button:render](#Button:render)|-| -@event mouse_click The event that is triggered when the button is clicked ## Button.new() Creates a new Button instance diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index 865c7c0..faf7185 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -22,6 +22,7 @@ |[Container:blit](#Container:blit)|Container| |[Container:char](#Container:char)|boolean| |[Container:clear](#Container:clear)|Container| +|[Container:destroy](#Container:destroy)|-| |[Container:getChild](#Container:getChild)|Container?| |[Container:handleEvent](#Container:handleEvent)|boolean| |[Container:init](#Container:init)|-| @@ -84,6 +85,8 @@ Clears the container ### Returns * `Container` `self` The container instance +## Container:destroy() + ## Container:getChild(path) Removes a child from the container diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 6f10515..00fa098 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -1,4 +1,3 @@ -@alias color number # VisualElement : BaseElement ## Properties @@ -17,6 +16,28 @@ |focused|boolean|false|whether the element is focused |visible|boolean|true|whether the element is visible +## Combined Properties + +|Name|Properties|Description| +|---|---|---| +|position|{x|y}|Position of the element +|size|{width|height}|Size of the element +|color|{foreground|background}|Color of the element + +## Events + +|Event|Parameters|Description| +|---|---|---| +|onMouseClick|`button number, x number, y number`|Fired when the element is clicked| +|onMouseUp|`button number, x number, y number`|Fired when the mouse is released| +|onMouseRelease|`button number, x number, y number`|Fired when the mouse is released| +|onMouseDrag|`button number, x number, y number`|Fired when the mouse is dragged| +|onFocus|`-`|Fired when the element is focused| +|onBlur|`-`|Fired when the element is blurred| +|onKey|`key number, code number, isRepeat boolean`|Fired when a key is pressed| +|onKeyUp|`key number, code number`|Fired when a key is released| +|onChar|`char string`|Fired when a key is pressed| + ## Functions |Method|Returns|Description| @@ -32,15 +53,11 @@ |[VisualElement:mouse_click](#VisualElement:mouse_click)|boolean| |[VisualElement:mouse_release](#VisualElement:mouse_release)|boolean| |[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean| -|[VisualElement:multiBlit](#VisualElement:multiBlit)|-| |[VisualElement:render](#VisualElement:render)|-| |[VisualElement:setCursor](#VisualElement:setCursor)|-| |[VisualElement:textBg](#VisualElement:textBg)|-| |[VisualElement:textFg](#VisualElement:textFg)|-| -@combinedProperty position x y -@combinedProperty size width height -@combinedProperty color foreground background ## VisualElement.new(props, basalt) Creates a new VisualElement instance @@ -135,26 +152,9 @@ Handles a mouse up event ### Returns * `boolean` `release` Whether the element was released on the element -## VisualElement:multiBlit(x, y, width, height, text, fg, bg) -Draws a text character/fg/bg at the specified position with a certain size, used in the rendering system - -### Parameters -* `x` `number` The x position to draw -* `y` `number` The y position to draw -* `width` `number` The width of the element -* `height` `number` The height of the element -* `text` `string` The text char to draw -* `fg` `color` The foreground color -* `bg` `color` The background color - ## VisualElement:render() Renders the element -### Usage - ```lua -element:render() -``` - ## VisualElement:setCursor(x, y, blink) Sets the cursor position diff --git a/docs/references/log.md b/docs/references/log.md index bb00a61..bed425c 100644 --- a/docs/references/log.md +++ b/docs/references/log.md @@ -1,7 +1,31 @@ -Log levels +# Log + +## Fields + +|Field|Type|Description| +|---|---|---| + +## Functions + +|Method|Returns|Description| +|---|---|---| +|[Log.error](#Log.error)|-| +|[Log.setEnabled](#Log.setEnabled)|-| +|[Log.setLogToFile](#Log.setLogToFile)|-| + ## Log.error() +Sends a debug message to the logger. +@vararg string The message to log +Sends an info message to the logger. +@vararg string The message to log +Sends a warning message to the logger. +@vararg string The message to log +Sends an error message to the logger. +@vararg string The message to log ## Log.setEnabled() +sets if the logger should log ## Log.setLogToFile() +Sets if the logger should log to a file. diff --git a/docs/references/main.md b/docs/references/main.md index dc8c985..1347c46 100644 --- a/docs/references/main.md +++ b/docs/references/main.md @@ -1,30 +1,35 @@ -# 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". +# 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| +|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)|table| -|[basalt.getAPI](#basalt.getAPI)|-| -|[basalt.getElementManager](#basalt.getElementManager)|table| -|[basalt.getMainFrame](#basalt.getMainFrame)|BaseFrame| -|[basalt.removeSchedule](#basalt.removeSchedule)|-| -|[basalt.run](#basalt.run)|-| -|[basalt.scheduleUpdate](#basalt.scheduleUpdate)|number| -|[basalt.setActiveFrame](#basalt.setActiveFrame)|-| -|[basalt.stop](#basalt.stop)|-| -|[basalt.update](#basalt.update)|-| +|[basalt.createFrame](#basalt.createFrame)|table|Creates a new BaseFrame +|[basalt.getAPI](#basalt.getAPI)|table|Returns a Plugin API +|[basalt.getElementManager](#basalt.getElementManager)|table|Returns the element manager +|[basalt.getMainFrame](#basalt.getMainFrame)|BaseFrame|Gets or creates the main frame +|[basalt.removeSchedule](#basalt.removeSchedule)|-|Removes a scheduled update +|[basalt.run](#basalt.run)|-|Starts the Basalt runtime +|[basalt.scheduleUpdate](#basalt.scheduleUpdate)|number|Schedules a function to be updated +|[basalt.setActiveFrame](#basalt.setActiveFrame)|-|Sets the active frame +|[basalt.stop](#basalt.stop)|-|Stops the Basalt runtime +|[basalt.update](#basalt.update)|-|Updates all scheduled functions ## basalt.create(type, properties?) Creates and returns a new UI element of the specified type. @@ -42,7 +47,7 @@ local button = basalt.create("Button") ``` ## basalt.createFrame() -Creates and returns a new frame +Creates and returns a new BaseFrame ### Returns * `table` `BaseFrame` The created frame instance @@ -52,7 +57,14 @@ Creates and returns a new frame local mainFrame = basalt.createFrame() ``` -## basalt.getAPI() +## basalt.getAPI(name) +Returns a Plugin API + +### Parameters +* `name` `string` The name of the plugin + +### Returns +* `table` `Plugin` The plugin API ## basalt.getElementManager() Returns the element manager instance