From 5513bf4072d559dced5a14a9aa9d368f5e656e61 Mon Sep 17 00:00:00 2001 From: NoryiE Date: Mon, 24 Feb 2025 19:52:39 +0000 Subject: [PATCH 1/4] deploy: 13d3bbd461322d039058041a10e3a60bf0794fbe --- docs/references/elements/BaseElement.md | 2 +- docs/references/elements/BaseFrame.md | 6 -- docs/references/elements/Button.md | 2 +- docs/references/elements/Checkbox.md | 2 +- docs/references/elements/Container.md | 63 ++++++++++++--- docs/references/elements/Flexbox.md | 57 +++++++++++--- docs/references/elements/Image.md | 89 +++++++++++++++++++++ docs/references/elements/Program.md | 67 ++++++++++------ docs/references/elements/Scrollbar.md | 62 ++++++++++++--- docs/references/elements/Slider.md | 13 +++- docs/references/elements/Table.md | 30 -------- docs/references/elements/TextBox.md | 94 +++++++++++++++++++---- docs/references/elements/Tree.md | 43 ++++++----- docs/references/elements/VisualElement.md | 17 ++-- 14 files changed, 409 insertions(+), 138 deletions(-) create mode 100644 docs/references/elements/Image.md diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index 4f7d6bd..3acabb2 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -1,5 +1,5 @@ # BaseElement : PropertySystem -The base class for all UI elements in Basalt +The base class for all UI elements in Basalt. This class provides basic properties and event handling functionality. ## Properties diff --git a/docs/references/elements/BaseFrame.md b/docs/references/elements/BaseFrame.md index 6fc8e91..4fcbda5 100644 --- a/docs/references/elements/BaseFrame.md +++ b/docs/references/elements/BaseFrame.md @@ -21,11 +21,9 @@ This is the base frame class. It is the root element of all elements and the onl |[BaseFrame.new](#BaseFrame.new)|BaseFrame|Creates a new Frame instance |[BaseFrame:blit](#BaseFrame:blit)|-|Renders a text with a foreground and background color to the render Object |[BaseFrame:init](#BaseFrame:init)|table|Initializes the Frame instance -|[BaseFrame:mouse_up](#BaseFrame:mouse_up)|-| |[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|Renders a multiBlit to the render Object |[BaseFrame:render](#BaseFrame:render)|-|Renders the Frame |[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position -|[BaseFrame:term_resize](#BaseFrame:term_resize)|-| |[BaseFrame:textBg](#BaseFrame:textBg)|-|Renders a text with a background color to the render Object |[BaseFrame:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object @@ -60,8 +58,6 @@ Initializes the Frame instance ### Returns * `table` `self` The initialized instance -## BaseFrame:mouse_up() - ## BaseFrame:multiBlit(x, y, width, height, text, fg, bg) Renders a multiBlit to the render Object @@ -85,8 +81,6 @@ Sets the cursor position * `y` `number` The y position to set the cursor to * `blink` `boolean` Whether the cursor should blink -## BaseFrame:term_resize() - ## BaseFrame:textBg(x, y, text, bg) Renders a text with a background color to the render Object diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index 8e10c43..b2bf6b6 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -1,5 +1,5 @@ # Button : VisualElement -This is the button class. It is a visual element that can be clicked. +The Button is a standard button element with click handling and state management. @configDescription Standard button element with click handling and state management ## Properties diff --git a/docs/references/elements/Checkbox.md b/docs/references/elements/Checkbox.md index defd83c..f3f92c4 100644 --- a/docs/references/elements/Checkbox.md +++ b/docs/references/elements/Checkbox.md @@ -1,5 +1,5 @@ # Checkbox : VisualElement -This is the checkbox class. It is a visual element that can be checked. +The Checkbox is a visual element that can be checked. ## Properties diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index dfca931..76eb293 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -24,7 +24,7 @@ like Frames, BaseFrames, and more. |[Container.new](#Container.new)|Container|Creates a new Container instance |[Container:addChild](#Container:addChild)|Container|Adds a child to the container |[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors -|[Container:callChildrenEvents](#Container:callChildrenEvents)|-| +|[Container:callChildrenEvents](#Container:callChildrenEvents)|boolean|Calls a event on all children |[Container:char](#Container:char)|boolean|Handles char events |[Container:clear](#Container:clear)|Container|Clears the container |[Container:destroy](#Container:destroy)|Container|Destroys the container and its children @@ -35,10 +35,10 @@ like Frames, BaseFrames, and more. |[Container:key](#Container:key)|boolean|Handles key events |[Container:key_up](#Container:key_up)|boolean|Handles key up events |[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events -|[Container:mouse_drag](#Container:mouse_drag)|-| -|[Container:mouse_move](#Container:mouse_move)|-| -|[Container:mouse_release](#Container:mouse_release)|-| -|[Container:mouse_scroll](#Container:mouse_scroll)|-| +|[Container:mouse_drag](#Container:mouse_drag)|boolean|Handles mouse drag events +|[Container:mouse_move](#Container:mouse_move)|boolean|Handles mouse move events +|[Container:mouse_release](#Container:mouse_release)|-|Handles mouse release events +|[Container:mouse_scroll](#Container:mouse_scroll)|boolean|Handles mouse scroll events |[Container:mouse_up](#Container:mouse_up)|boolean|Handles mouse up events |[Container:multiBlit](#Container:multiBlit)|Container|Draws multiple lines of text, fg and bg strings |[Container:registerChildEvent](#Container:registerChildEvent)|Container|Registers the children events of the container @@ -80,7 +80,17 @@ Draws a line of text and fg and bg as colors, it is usually used in the render l ### Returns * `Container` `self` The container instance -## Container:callChildrenEvents() +## Container:callChildrenEvents(visibleOnly, event...) +Calls a event on all children + +### Parameters +* `visibleOnly` `boolean` Whether to only call the event on visible children +* `event` `string` The event to call +* `...` *(vararg)* `any` The event arguments + +### Returns +* `boolean` `handled` Whether the event was handled +* `table` `child?` The child that handled the event ## Container:char(char) Handles char events @@ -167,13 +177,46 @@ Handles mouse click events ### Returns * `boolean` `handled` Whether the event was handled -## Container:mouse_drag() +## Container:mouse_drag(button, x, y) +Handles mouse drag events -## Container:mouse_move() +### Parameters +* `button` `number` The button that was clicked +* `x` `number` The x position of the click +* `y` `number` The y position of the click -## Container:mouse_release() +### Returns +* `boolean` `handled` Whether the event was handled -## Container:mouse_scroll() +## Container:mouse_move(_, x, y) +Handles mouse move events + +### Parameters +* `_` `number` unknown +* `x` `number` The x position of the click +* `y` `number` The y position of the click + +### Returns +* `boolean` `handled` Whether the event was handled + +## Container:mouse_release(button, x, y) +Handles mouse release events + +### Parameters +* `button` `number` The button that was clicked +* `x` `number` The x position of the click +* `y` `number` The y position of the click + +## Container:mouse_scroll(direction, x, y) +Handles mouse scroll events + +### Parameters +* `direction` `number` The direction of the scroll +* `x` `number` The x position of the click +* `y` `number` The y position of the click + +### Returns +* `boolean` `handled` Whether the event was handled ## Container:mouse_up(button, x, y) Handles mouse up events diff --git a/docs/references/elements/Flexbox.md b/docs/references/elements/Flexbox.md index 0e7be8a..774e004 100644 --- a/docs/references/elements/Flexbox.md +++ b/docs/references/elements/Flexbox.md @@ -1,15 +1,26 @@ # Flexbox : Container +This is the Flexbox class. It is a container that arranges its children in a flexible layout. + +## Properties + +|Property|Type|Default|Description| +|---|---|---|---| +|flexDirection|string|"row"|The direction of the flexbox layout "row" or "column" +|flexSpacing|number|1|The spacing between flex items +|flexJustifyContent|string|"flex-start"|The alignment of flex items along the main axis +|flexWrap|boolean|false|Whether to wrap flex items onto multiple lines +|flexUpdateLayout|boolean|false|Whether to update the layout of the flexbox ## 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](#Flexbox.new)|Flexbox|Creates a new Flexbox instance +|[Flexbox:addChild](#Flexbox:addChild)|Flexbox|Adds a child element to the flexbox +|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|Adds a new line break to the flexbox. +|[Flexbox:init](#Flexbox:init)|Flexbox|Initializes the Flexbox instance +|[Flexbox:removeChild](#Flexbox:removeChild)|Flexbox|Removes a child element from the flexbox +|[Flexbox:render](#Flexbox:render)|Flexbox|Renders the flexbox and its children ## Flexbox.new() Creates a new Flexbox instance @@ -22,10 +33,17 @@ Creates a new Flexbox instance local element = Flexbox.new("myId", basalt) ``` -## Flexbox:addChild() +## Flexbox:addChild(element) +Adds a child element to the flexbox + +### Parameters +* `element` `Element` The child element to add + +### Returns +* `Flexbox` `self` The flexbox instance ## Flexbox:addLineBreak(self) -Adds a new line break to the flexbox. +Adds a new line break to the flexbox ### Parameters * `self` `Flexbox` The element itself @@ -33,10 +51,29 @@ Adds a new line break to the flexbox. ### Returns * `nil` `nil` nil -## Flexbox:init() +## Flexbox:init(props, basalt) +Initializes the Flexbox instance -## Flexbox:removeChild() +### Parameters +* `props` `table` The properties to initialize the element with +* `basalt` `table` The basalt instance + +### Returns +* `Flexbox` `self` The initialized instance + +## Flexbox:removeChild(element) +Removes a child element from the flexbox + +### Parameters +* `element` `Element` The child element to remove + +### Returns +* `Flexbox` `self` The flexbox instance ## Flexbox:render() +Renders the flexbox and its children + +### Returns +* `Flexbox` `self` The flexbox instance diff --git a/docs/references/elements/Image.md b/docs/references/elements/Image.md new file mode 100644 index 0000000..9b91d8b --- /dev/null +++ b/docs/references/elements/Image.md @@ -0,0 +1,89 @@ +# Image : VisualElement +This is the Image element class which can be used to display bimg format images. +The bimg format is a universal ComputerCraft image format. +See: https://github.com/SkyTheCodeMaster/bimg + +## Properties + +|Property|Type|Default|Description| +|---|---|---|---| +|bimg|table|{}|The bimg image data +|currentFrame|number|1|Current animation frame +|metadata|table|{}|Image metadata (version, palette, etc) + +## Functions + +|Method|Returns|Description| +|---|---|---| +|[Image.new](#Image.new)|-| +|[Image:getPixelData](#Image:getPixelData)|number?| +|[Image:init](#Image:init)|-| +|[Image:loadBimg](#Image:loadBimg)|-| +|[Image:nextFrame](#Image:nextFrame)|-| +|[Image:render](#Image:render)|-| +|[Image:setBg](#Image:setBg)|-| +|[Image:setChar](#Image:setChar)|-| +|[Image:setFg](#Image:setFg)|-| +|[Image:setPixel](#Image:setPixel)|-| + +## Image.new() + +## Image:getPixelData(x, y) +Gets pixel information at position + +### Parameters +* `x` `number` X position +* `y` `number` Y position + +### Returns +* `number?` `fg` Foreground color +* `number?` `bg` Background color +* `string?` `char` Character at position + +## Image:init() + +## Image:loadBimg(bimgData) +Loads a bimg format image + +### Parameters +* `bimgData` `table` The bimg image data + +## Image:nextFrame() + +## Image:render() + +## Image:setBg(x, y, color) +Sets background color at position + +### Parameters +* `x` `number` X position +* `y` `number` Y position +* `color` `number` Color value (0-15) + +## Image:setChar(x, y, char) +Sets character at position + +### Parameters +* `x` `number` X position +* `y` `number` Y position +* `char` `string` Single character to set + +## Image:setFg(x, y, color) +Sets foreground color at position + +### Parameters +* `x` `number` X position +* `y` `number` Y position +* `color` `number` Color value (0-15) + +## Image:setPixel(x, y, char, fg, bg) +Sets all properties at position + +### Parameters +* `x` `number` X position +* `y` `number` Y position +* `char` `string?` Character to set (optional) +* `fg` `number?` Foreground color (optional) +* `bg` `number?` Background color (optional) + + diff --git a/docs/references/elements/Program.md b/docs/references/elements/Program.md index ab6fae7..b43bc74 100644 --- a/docs/references/elements/Program.md +++ b/docs/references/elements/Program.md @@ -1,30 +1,24 @@ # Program : VisualElement +This is the program class. It provides a program that runs in a window. + +## Properties + +|Property|Type|Default|Description| +|---|---|---|---| +|program|table|nil|The program instance +|path|string|""|The path to the program +|running|boolean|false|Whether the program is running ## Functions |Method|Returns|Description| |---|---|---| -|[BasaltProgram.new](#BasaltProgram.new)|-| -|[BasaltProgram:resize](#BasaltProgram:resize)|-| -|[BasaltProgram:resume](#BasaltProgram:resume)|-| -|[BasaltProgram:run](#BasaltProgram:run)|-| -|[BasaltProgram:stop](#BasaltProgram:stop)|-| -|[Program.new](#Program.new)|Program| -|[Program:dispatchEvent](#Program:dispatchEvent)|-| -|[Program:execute](#Program:execute)|-| -|[Program:focus](#Program:focus)|-| -|[Program:init](#Program:init)|-| -|[Program:render](#Program:render)|-| - -## BasaltProgram.new() - -## BasaltProgram:resize() - -## BasaltProgram:resume() - -## BasaltProgram:run() - -## BasaltProgram:stop() +|[Program.new](#Program.new)|Program|Creates a new Program instance +|[Program:dispatchEvent](#Program:dispatchEvent)|any|Handles all incomming events +|[Program:execute](#Program:execute)|Program|Executes a program +|[Program:focus](#Program:focus)|-|Gets called when the element gets focused +|[Program:init](#Program:init)|Program|Initializes the Program instance +|[Program:render](#Program:render)|-|Renders the program ## Program.new() Creates a new Program instance @@ -37,14 +31,39 @@ Creates a new Program instance local element = Program.new("myId", basalt) ``` -## Program:dispatchEvent() +## Program:dispatchEvent(event, ...) +Handles all incomming events -## Program:execute() +### Parameters +* `event` `string` The event to handle +* `...` `any` The event arguments + +### Returns +* `any` `result` The event result + +## Program:execute(path) +Executes a program + +### Parameters +* `path` `string` The path to the program + +### Returns +* `Program` `self` The Program instance ## Program:focus() +Gets called when the element gets focused -## Program:init() +## Program:init(props, basalt) +Initializes the Program instanceProperty + +### Parameters +* `props` `table` The properties to initialize the element with +* `basalt` `table` The basalt instance + +### Returns +* `Program` `self` The initialized instance ## Program:render() +Renders the program diff --git a/docs/references/elements/Scrollbar.md b/docs/references/elements/Scrollbar.md index 49eb965..cec5f6f 100644 --- a/docs/references/elements/Scrollbar.md +++ b/docs/references/elements/Scrollbar.md @@ -26,13 +26,13 @@ A scrollbar element that can be attached to other elements to control their scro |Method|Returns|Description| |---|---|---| |[Scrollbar.new](#Scrollbar.new)|Scrollbar|Creates a new Scrollbar instance -|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar| -|[Scrollbar:init](#Scrollbar:init)|-| -|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|-| -|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|-| -|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|-| -|[Scrollbar:render](#Scrollbar:render)|-| -|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|-| +|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar|Attaches the scrollbar to an element's property +|[Scrollbar:init](#Scrollbar:init)|Scrollbar|Initializes the Scrollbar instance +|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|boolean|Handles mouse click events +|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|boolean|Handles mouse drag events +|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|boolean|Handles mouse scroll events +|[Scrollbar:render](#Scrollbar:render)|-|Renders the scrollbar +|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value ## Scrollbar.new() Creates a new Scrollbar instance @@ -55,16 +55,56 @@ Attaches the scrollbar to an element's property ### Returns * `Scrollbar` `self` The scrollbar instance -## Scrollbar:init() +## Scrollbar:init(props, basalt) +Initializes the Scrollbar instance -## Scrollbar:mouse_click() +### Parameters +* `props` `table` The properties to initialize the element with +* `basalt` `table` The basalt instance -## Scrollbar:mouse_drag() +### Returns +* `Scrollbar` `self` The initialized instance -## Scrollbar:mouse_scroll() +## Scrollbar:mouse_click(button, x, y) +Handles mouse click events + +### Parameters +* `button` `number` The mouse button clicked +* `x` `number` The x position of the click +* `y` `number` The y position of the click + +### Returns +* `boolean` `Whether` the event was handled + +## Scrollbar:mouse_drag(button, x, y) +Handles mouse drag events + +### Parameters +* `button` `number` The mouse button being dragged +* `x` `number` The x position of the drag +* `y` `number` The y position of the drag + +### Returns +* `boolean` `Whether` the event was handled + +## Scrollbar:mouse_scroll(direction, x, y) +Handles mouse scroll events + +### Parameters +* `direction` `number` The scroll direction (1 for up, -1 for down) +* `x` `number` The x position of the scroll +* `y` `number` The y position of the scroll + +### Returns +* `boolean` `Whether` the event was handled ## Scrollbar:render() +Renders the Scrollbar ## Scrollbar:updateAttachedElement() +Updates the attached element's property based on the scrollbar value + +### Returns +* `Scrollbar` `self` The scrollbar instance diff --git a/docs/references/elements/Slider.md b/docs/references/elements/Slider.md index c1560fd..05fb1cb 100644 --- a/docs/references/elements/Slider.md +++ b/docs/references/elements/Slider.md @@ -26,7 +26,7 @@ with customizable colors and value ranges. |[Slider:getValue](#Slider:getValue)|number|Gets the current value mapped to the max range |[Slider:init](#Slider:init)|Slider|Initializes the Slider instance |[Slider:mouse_click](#Slider:mouse_click)|boolean|Updates slider position on mouse click -|[Slider:mouse_scroll](#Slider:mouse_scroll)|-| +|[Slider:mouse_scroll](#Slider:mouse_scroll)|boolean|Handles mouse release events |[Slider:render](#Slider:render)|-|Renders the slider with track and handle ## Slider.new() @@ -72,7 +72,16 @@ Handles mouse click events ### Returns * `boolean` `handled` Whether the event was handled -## Slider:mouse_scroll() +## Slider:mouse_scroll(button, x, y) +Handles mouse release events + +### Parameters +* `button` `number` The mouse button that was released +* `x` `number` The x position of the release +* `y` `number` The y position of the release + +### Returns +* `boolean` `handled` Whether the event was handled ## Slider:render() Renders the slider diff --git a/docs/references/elements/Table.md b/docs/references/elements/Table.md index 5284222..2bd0672 100644 --- a/docs/references/elements/Table.md +++ b/docs/references/elements/Table.md @@ -25,8 +25,6 @@ row selection, and scrolling capabilities. |[Table:mouse_click](#Table:mouse_click)|boolean|Handles header clicks for sorting and row selection |[Table:mouse_scroll](#Table:mouse_scroll)|boolean|Handles scrolling through the table data |[Table:render](#Table:render)|-|Renders the table with headers, data and scrollbar -|[Table:setColumns](#Table:setColumns)|Table|Sets the table columns configuration -|[Table:setData](#Table:setData)|Table|Sets the table data |[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column ## Table.new() @@ -75,34 +73,6 @@ Handles mouse scroll events ## Table:render() Renders the table -## Table:setColumns(columns) -Sets the table columns - -### Parameters -* `columns` `table[]` Array of column definitions {name="Name", width=10} - -### Returns -* `Table` `self` The Table instance - -### Usage - ```lua -table:setColumns({{name="ID", width=4}, {name="Name", width=10}}) -``` - -## Table:setData(data) -Sets the table data - -### Parameters -* `data` `table[]` Array of row data arrays - -### Returns -* `Table` `self` The Table instance - -### Usage - ```lua -table:setData({{"1", "Item One"}, {"2", "Item Two"}}) -``` - ## Table:sortData(columnIndex) Sorts the table data by column diff --git a/docs/references/elements/TextBox.md b/docs/references/elements/TextBox.md index 9dbbadf..9ed4280 100644 --- a/docs/references/elements/TextBox.md +++ b/docs/references/elements/TextBox.md @@ -18,19 +18,23 @@ A multi-line text editor component with cursor support and text manipulation fea |Method|Returns|Description| |---|---|---| -|[TextBox.new](#TextBox.new)|-| -|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-| -|[TextBox:char](#TextBox:char)|-| -|[TextBox:getText](#TextBox:getText)|-| -|[TextBox:init](#TextBox:init)|-| -|[TextBox:key](#TextBox:key)|-| -|[TextBox:mouse_click](#TextBox:mouse_click)|-| -|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|-| -|[TextBox:render](#TextBox:render)|-| -|[TextBox:setText](#TextBox:setText)|-| -|[TextBox:updateViewport](#TextBox:updateViewport)|-| +|[TextBox.new](#TextBox.new)|TextBox|Creates a new TextBox instance +|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-|Adds a new syntax highlighting pattern +|[TextBox:char](#TextBox:char)|boolean|Handles character input +|[TextBox:getText](#TextBox:getText)|string|Gets the text of the TextBox +|[TextBox:init](#TextBox:init)|TextBox|Initializes the TextBox instance +|[TextBox:key](#TextBox:key)|boolean|Handles key events +|[TextBox:mouse_click](#TextBox:mouse_click)|boolean|Handles mouse click events +|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|boolean|Handles mouse scroll events +|[TextBox:render](#TextBox:render)|-|Renders the TextBox with syntax highlighting +|[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox +|[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view ## TextBox.new() +Creates a new TextBox instance + +### Returns +* `TextBox` `self` The newly created TextBox instance ## TextBox:addSyntaxPattern(pattern, color) Adds a new syntax highlighting pattern @@ -39,22 +43,78 @@ Adds a new syntax highlighting pattern * `pattern` `string` The regex pattern to match * `color` `colors` The color to apply -## TextBox:char() +## TextBox:char(char) +Handles character input + +### Parameters +* `char` `string` The character that was typed + +### Returns +* `boolean` `handled` Whether the event was handled ## TextBox:getText() +Gets the text of the TextBox -## TextBox:init() +### Returns +* `string` `text` The text of the TextBox -## TextBox:key() +## TextBox:init(props, basalt) +Initializes the TextBox instance -## TextBox:mouse_click() +### Parameters +* `props` `table` The properties to initialize the element with +* `basalt` `table` The basalt instance -## TextBox:mouse_scroll() +### Returns +* `TextBox` `self` The initialized instance + +## TextBox:key(key) +Handles key events + +### Parameters +* `key` `number` The key that was pressed + +### Returns +* `boolean` `handled` Whether the event was handled + +## TextBox:mouse_click(button, x, y) +Handles mouse click events + +### Parameters +* `button` `number` The button that was clicked +* `x` `number` The x position of the click +* `y` `number` The y position of the click + +### Returns +* `boolean` `handled` Whether the event was handled + +## TextBox:mouse_scroll(direction, x, y) +Handles mouse scroll events + +### Parameters +* `direction` `number` The scroll direction +* `x` `number` The x position of the scroll +* `y` `number` The y position of the scroll + +### Returns +* `boolean` `handled` Whether the event was handled ## TextBox:render() +Renders the TextBox -## TextBox:setText() +## TextBox:setText(text) +Sets the text of the TextBox + +### Parameters +* `text` `string` The text to set + +### Returns +* `TextBox` `self` The TextBox instance ## TextBox:updateViewport() +Updates the viewport to keep the cursor in view + +### Returns +* `TextBox` `self` The TextBox instance diff --git a/docs/references/elements/Tree.md b/docs/references/elements/Tree.md index e06c6a8..b40d113 100644 --- a/docs/references/elements/Tree.md +++ b/docs/references/elements/Tree.md @@ -23,10 +23,10 @@ with support for selection and scrolling. |[Tree:expandNode](#Tree:expandNode)|Tree|Expands a node to show its children |[Tree:getNodeSize](#Tree:getNodeSize)|number|Gets the size of the tree |[Tree:init](#Tree:init)|Tree|Initializes the Tree instance -|[Tree:mouse_click](#Tree:mouse_click)|-| +|[Tree:mouse_click](#Tree:mouse_click)|boolean|Handles mouse click events for node selection and expansion +|[Tree:mouse_scroll](#Tree:mouse_scroll)|boolean|Handles mouse scroll events for vertical scrolling |[Tree:onSelect](#Tree:onSelect)|Tree|Registers a callback for when a node is selected -|[Tree:render](#Tree:render)|-| -|[Tree:setNodes](#Tree:setNodes)|Tree|Sets the tree nodes and expands the root node +|[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling |[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state ## Tree.new() @@ -75,7 +75,27 @@ Initializes the Tree instance ### Returns * `Tree` `self` The initialized instance -## Tree:mouse_click() +## Tree:mouse_click(button, x, y) +Handles mouse click events + +### Parameters +* `button` `number` The button that was clicked +* `x` `number` The x position of the click +* `y` `number` The y position of the click + +### Returns +* `boolean` `handled` Whether the event was handled + +## Tree:mouse_scroll(direction, x, y) +Handles mouse scroll events + +### Parameters +* `direction` `number` The scroll direction (1 for up, -1 for down) +* `x` `number` The x position of the scroll +* `y` `number` The y position of the scroll + +### Returns +* `boolean` `handled` Whether the event was handled ## Tree:onSelect(callback) Registers a callback for when a node is selected @@ -87,20 +107,7 @@ Registers a callback for when a node is selected * `Tree` `self` The Tree instance ## Tree:render() - -## Tree:setNodes(nodes) -Sets the tree nodes - -### Parameters -* `nodes` `table[]` Array of node objects - -### Returns -* `Tree` `self` The Tree instance - -### Usage - ```lua -tree:setNodes({{text="Root", children={{text="Child"}}}}) -``` +Renders the tree ## Tree:toggleNode(node) Toggles a node's expanded state diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 277f7b0..6ddc500 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -32,15 +32,18 @@ and provides core functionality for positioning, sizing, colors, and rendering. |Event|Parameters|Description| |---|---|---| -|onMouseClick|`button number, x number, y number`|Fired on mouse click| -|onMouseUp|`button number, x number, y number`|Fired on mouse button release| -|onMouseRelease|`button number, x number, y number`|Fired when mouse leaves while clicked| -|onMouseDrag|`button number, x number, y number`|Fired when mouse moves while clicked| +|onClick|`button, x, y`|Fired on mouse click| +|onMouseUp|`button, x, y`|Fired on mouse button release| +|onRelease|`button, x, y`|Fired when mouse leaves while clicked| +|onDrag|`button, x, y`|Fired when mouse moves while clicked| +|onScroll|`direction, x, y`|Fired on mouse scroll| +|onEnter|`-`|Fired when mouse enters element| +|onLeave|`-`|Fired when mouse leaves element| |onFocus|`-`|Fired when element receives focus| |onBlur|`-`|Fired when element loses focus| -|onKey|`key number, code number, isRepeat boolean`|Fired on key press| -|onKeyUp|`key number, code number`|Fired on key release| -|onChar|`char string`|Fired on character input| +|onKey|`key`|Fired on key press| +|onKeyUp|`key`|Fired on key release| +|onChar|`char`|Fired on character input| ## Functions From c3f9dfa735406c203d5c10ccc5cb5d82807fbbf0 Mon Sep 17 00:00:00 2001 From: NoryiE Date: Mon, 24 Feb 2025 22:13:57 +0000 Subject: [PATCH 2/4] deploy: 189d642e7c0beb6dd358734d08a1823db613385a --- docs/references/elementManager.md | 1 + docs/references/elements/BaseElement.md | 1 + docs/references/elements/BaseFrame.md | 1 + docs/references/elements/Button.md | 1 + docs/references/elements/Checkbox.md | 1 + docs/references/elements/Container.md | 1 + docs/references/elements/Dropdown.md | 1 + docs/references/elements/Flexbox.md | 1 + docs/references/elements/Frame.md | 1 + docs/references/elements/Image.md | 1 + docs/references/elements/Input.md | 1 + docs/references/elements/Label.md | 1 + docs/references/elements/List.md | 1 + docs/references/elements/Menu.md | 1 + docs/references/elements/Program.md | 1 + docs/references/elements/ProgressBar.md | 1 + docs/references/elements/Scrollbar.md | 1 + docs/references/elements/Slider.md | 1 + docs/references/elements/Table.md | 1 + docs/references/elements/TextBox.md | 1 + docs/references/elements/Tree.md | 1 + docs/references/elements/VisualElement.md | 1 + docs/references/errorManager.md | 1 + docs/references/log.md | 1 + docs/references/main.md | 1 + docs/references/plugins/animation.md | 1 + docs/references/plugins/animation_AnimationInstance.md | 1 + docs/references/plugins/animation_VisualElement.md | 1 + docs/references/plugins/benchmark.md | 1 + docs/references/plugins/benchmark_BaseElement.md | 1 + docs/references/plugins/benchmark_Container.md | 1 + docs/references/plugins/debug.md | 3 +++ docs/references/plugins/reactive.md | 1 + docs/references/plugins/state.md | 1 + docs/references/plugins/theme.md | 2 ++ docs/references/plugins/xml.md | 2 ++ docs/references/propertySystem.md | 1 + docs/references/render.md | 1 + 38 files changed, 42 insertions(+) diff --git a/docs/references/elementManager.md b/docs/references/elementManager.md index 9f02420..e124d42 100644 --- a/docs/references/elementManager.md +++ b/docs/references/elementManager.md @@ -11,6 +11,7 @@ and then applies the plugins to the elements. It also provides a way to get elem |[ElementManager.getElementList](#ElementManager.getElementList)|table| |[ElementManager.loadElement](#ElementManager.loadElement)|-| + ## ElementManager.getAPI(name) Gets an Plugin API by name diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index 3acabb2..e06735a 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -29,6 +29,7 @@ The base class for all UI elements in Basalt. This class provides basic properti |[BaseElement:registerCallback](#BaseElement:registerCallback)|table|Registers a callback function |[BaseElement:updateRender](#BaseElement:updateRender)|-|Requests a render update for this element + ## BaseElement.defineEvent() ## BaseElement.new(props, basalt) diff --git a/docs/references/elements/BaseFrame.md b/docs/references/elements/BaseFrame.md index 4fcbda5..7cbdc8d 100644 --- a/docs/references/elements/BaseFrame.md +++ b/docs/references/elements/BaseFrame.md @@ -27,6 +27,7 @@ This is the base frame class. It is the root element of all elements and the onl |[BaseFrame:textBg](#BaseFrame:textBg)|-|Renders a text with a background color to the render Object |[BaseFrame:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object + ## BaseFrame.new() Creates a new Frame instance diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index b2bf6b6..8eecbd3 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -21,6 +21,7 @@ The Button is a standard button element with click handling and state management |[Button:init](#Button:init)|-|Initializes the Button instance |[Button:render](#Button:render)|-|Renders the Button + ## Button.new() Creates a new Button instance diff --git a/docs/references/elements/Checkbox.md b/docs/references/elements/Checkbox.md index f3f92c4..6c7345c 100644 --- a/docs/references/elements/Checkbox.md +++ b/docs/references/elements/Checkbox.md @@ -19,6 +19,7 @@ The Checkbox is a visual element that can be checked. |[Checkbox:mouse_click](#Checkbox:mouse_click)|boolean|Handles mouse click events |[Checkbox:render](#Checkbox:render)|-|Renders the Checkbox + ## Checkbox.new() Creates a new Checkbox instance diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index 76eb293..71e6b5c 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -52,6 +52,7 @@ like Frames, BaseFrames, and more. |[Container:textFg](#Container:textFg)|Container|Draws a line of text and fg as color |[Container:unregisterChildEvent](#Container:unregisterChildEvent)|Container|Unregisters the children events of the container + ## Container.new() Creates a new Container instance diff --git a/docs/references/elements/Dropdown.md b/docs/references/elements/Dropdown.md index e5ef42c..bdaea07 100644 --- a/docs/references/elements/Dropdown.md +++ b/docs/references/elements/Dropdown.md @@ -19,6 +19,7 @@ This is the dropdown class. It is a visual element that can show a list of selec |[Dropdown:mouse_click](#Dropdown:mouse_click)|boolean|Handles mouse click events |[Dropdown:render](#Dropdown:render)|-|Renders the Dropdown + ## Dropdown.new() Creates a new Dropdown instance diff --git a/docs/references/elements/Flexbox.md b/docs/references/elements/Flexbox.md index 774e004..e66d54a 100644 --- a/docs/references/elements/Flexbox.md +++ b/docs/references/elements/Flexbox.md @@ -22,6 +22,7 @@ This is the Flexbox class. It is a container that arranges its children in a fle |[Flexbox:removeChild](#Flexbox:removeChild)|Flexbox|Removes a child element from the flexbox |[Flexbox:render](#Flexbox:render)|Flexbox|Renders the flexbox and its children + ## Flexbox.new() Creates a new Flexbox instance diff --git a/docs/references/elements/Frame.md b/docs/references/elements/Frame.md index 118e4d5..81718ff 100644 --- a/docs/references/elements/Frame.md +++ b/docs/references/elements/Frame.md @@ -8,6 +8,7 @@ This is the frame class. It serves as a grouping container for other elements. |[Frame.new](#Frame.new)|Frame|Creates a new Frame instance |[Frame:init](#Frame:init)|Frame|Initializes the Frame instance + ## Frame.new() Creates a new Frame instance diff --git a/docs/references/elements/Image.md b/docs/references/elements/Image.md index 9b91d8b..e73468e 100644 --- a/docs/references/elements/Image.md +++ b/docs/references/elements/Image.md @@ -26,6 +26,7 @@ See: https://github.com/SkyTheCodeMaster/bimg |[Image:setFg](#Image:setFg)|-| |[Image:setPixel](#Image:setPixel)|-| + ## Image.new() ## Image:getPixelData(x, y) diff --git a/docs/references/elements/Input.md b/docs/references/elements/Input.md index d572889..322a627 100644 --- a/docs/references/elements/Input.md +++ b/docs/references/elements/Input.md @@ -30,6 +30,7 @@ cursor movement, text manipulation, placeholder text, and input validation. |[Input:render](#Input:render)|-|Renders the input element |[Input:updateViewport](#Input:updateViewport)|-|Updates the input's viewport + ## Input.new() Creates a new Input instance diff --git a/docs/references/elements/Label.md b/docs/references/elements/Label.md index 3bc9614..8665127 100644 --- a/docs/references/elements/Label.md +++ b/docs/references/elements/Label.md @@ -18,6 +18,7 @@ resizes its width based on the text content. |[Label:init](#Label:init)|Label|Initializes the Label instance |[Label:render](#Label:render)|-|Renders the Label by drawing its text content + ## Label.new() Creates a new Label instance diff --git a/docs/references/elements/List.md b/docs/references/elements/List.md index 34b3883..c6db771 100644 --- a/docs/references/elements/List.md +++ b/docs/references/elements/List.md @@ -36,6 +36,7 @@ custom item rendering, separators, and selection handling. |[List:scrollToBottom](#List:scrollToBottom)|List|Scrolls the list to the bottom |[List:scrollToTop](#List:scrollToTop)|List|Scrolls the list to the top + ## List.new() Creates a new List instance diff --git a/docs/references/elements/Menu.md b/docs/references/elements/Menu.md index e2ebe49..b4c57ab 100644 --- a/docs/references/elements/Menu.md +++ b/docs/references/elements/Menu.md @@ -18,6 +18,7 @@ Menu items are displayed in a single row and can have custom colors and callback |[Menu:render](#Menu:render)|-|Renders the menu horizontally with proper spacing and colors |[Menu:setItems](#Menu:setItems)|Menu|Sets the menu items and calculates total width + ## Menu.new() Creates a new Menu instance diff --git a/docs/references/elements/Program.md b/docs/references/elements/Program.md index b43bc74..f0cf482 100644 --- a/docs/references/elements/Program.md +++ b/docs/references/elements/Program.md @@ -20,6 +20,7 @@ This is the program class. It provides a program that runs in a window. |[Program:init](#Program:init)|Program|Initializes the Program instance |[Program:render](#Program:render)|-|Renders the program + ## Program.new() Creates a new Program instance diff --git a/docs/references/elements/ProgressBar.md b/docs/references/elements/ProgressBar.md index f28a618..b785527 100644 --- a/docs/references/elements/ProgressBar.md +++ b/docs/references/elements/ProgressBar.md @@ -18,6 +18,7 @@ with optional percentage display and customizable colors. |[ProgressBar:init](#ProgressBar:init)|ProgressBar|Initializes the ProgressBar instance |[ProgressBar:render](#ProgressBar:render)|-|Renders the progress bar with filled portion and optional percentage text + ## ProgressBar.new() Creates a new ProgressBar instance diff --git a/docs/references/elements/Scrollbar.md b/docs/references/elements/Scrollbar.md index cec5f6f..ebcecb5 100644 --- a/docs/references/elements/Scrollbar.md +++ b/docs/references/elements/Scrollbar.md @@ -34,6 +34,7 @@ A scrollbar element that can be attached to other elements to control their scro |[Scrollbar:render](#Scrollbar:render)|-|Renders the scrollbar |[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value + ## Scrollbar.new() Creates a new Scrollbar instance diff --git a/docs/references/elements/Slider.md b/docs/references/elements/Slider.md index 05fb1cb..1d92a9c 100644 --- a/docs/references/elements/Slider.md +++ b/docs/references/elements/Slider.md @@ -29,6 +29,7 @@ with customizable colors and value ranges. |[Slider:mouse_scroll](#Slider:mouse_scroll)|boolean|Handles mouse release events |[Slider:render](#Slider:render)|-|Renders the slider with track and handle + ## Slider.new() Creates a new Slider instance diff --git a/docs/references/elements/Table.md b/docs/references/elements/Table.md index 2bd0672..c0d7578 100644 --- a/docs/references/elements/Table.md +++ b/docs/references/elements/Table.md @@ -27,6 +27,7 @@ row selection, and scrolling capabilities. |[Table:render](#Table:render)|-|Renders the table with headers, data and scrollbar |[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column + ## Table.new() Creates a new Table instance diff --git a/docs/references/elements/TextBox.md b/docs/references/elements/TextBox.md index 9ed4280..dfa87b1 100644 --- a/docs/references/elements/TextBox.md +++ b/docs/references/elements/TextBox.md @@ -30,6 +30,7 @@ A multi-line text editor component with cursor support and text manipulation fea |[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox |[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view + ## TextBox.new() Creates a new TextBox instance diff --git a/docs/references/elements/Tree.md b/docs/references/elements/Tree.md index b40d113..69dd327 100644 --- a/docs/references/elements/Tree.md +++ b/docs/references/elements/Tree.md @@ -29,6 +29,7 @@ with support for selection and scrolling. |[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling |[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state + ## Tree.new() Creates a new Tree instance diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 6ddc500..04f486c 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -70,6 +70,7 @@ and provides core functionality for positioning, sizing, colors, and rendering. |[VisualElement:textBg](#VisualElement:textBg)|-|Draws text with background color |[VisualElement:textFg](#VisualElement:textFg)|-|Draws text with foreground color + ## VisualElement.new(props, basalt) Creates a new VisualElement instance diff --git a/docs/references/errorManager.md b/docs/references/errorManager.md index 0a72f7d..b27bc0c 100644 --- a/docs/references/errorManager.md +++ b/docs/references/errorManager.md @@ -14,6 +14,7 @@ This is Basalt's error handler. All the errors are handled by this module. |---|---|---| |[errorHandler.error](#errorHandler.error)|-| + ## errorHandler.error(errMsg) Handles an error diff --git a/docs/references/log.md b/docs/references/log.md index c78d88d..2178f4c 100644 --- a/docs/references/log.md +++ b/docs/references/log.md @@ -22,6 +22,7 @@ Logger module for Basalt. Logs messages to the console and optionally to a file. |[Log.setLogToFile](#Log.setLogToFile)|-|Sets if the logger should log to a file |[Log.warn](#Log.warn)|-|Sends a warning message + ## Log.debug(...) Sends a debug message to the logger. diff --git a/docs/references/main.md b/docs/references/main.md index 15a72b8..159baa0 100644 --- a/docs/references/main.md +++ b/docs/references/main.md @@ -37,6 +37,7 @@ What this code does is it loads basalt into the project, and you can access it b |[basalt.stop](#basalt.stop)|-|Stops the Basalt runtime |[basalt.update](#basalt.update)|-|Runs basalt once + ## basalt.create(type, properties?) Creates and returns a new UI element of the specified type. diff --git a/docs/references/plugins/animation.md b/docs/references/plugins/animation.md index 0714771..9bbdadb 100644 --- a/docs/references/plugins/animation.md +++ b/docs/references/plugins/animation.md @@ -17,6 +17,7 @@ with support for sequences, easing functions, and multiple animation types. |[Animation:sequence](#Animation:sequence)|Animation|Creates a new sequence |[Animation:start](#Animation:start)|Animation|Starts the animation + ## Animation.new(element) Creates a new Animation diff --git a/docs/references/plugins/animation_AnimationInstance.md b/docs/references/plugins/animation_AnimationInstance.md index df00ed7..22f0222 100644 --- a/docs/references/plugins/animation_AnimationInstance.md +++ b/docs/references/plugins/animation_AnimationInstance.md @@ -23,6 +23,7 @@ This is the AnimationInstance class. It represents a single animation instance |[AnimationInstance:start](#AnimationInstance:start)|AnimationInstance|Starts the animation |[AnimationInstance:update](#AnimationInstance:update)|boolean|Updates the animation + ## AnimationInstance.new(element, animType, args, duration, easing) Creates a new AnimationInstance diff --git a/docs/references/plugins/animation_VisualElement.md b/docs/references/plugins/animation_VisualElement.md index 4d2ae2c..550cf77 100644 --- a/docs/references/plugins/animation_VisualElement.md +++ b/docs/references/plugins/animation_VisualElement.md @@ -7,6 +7,7 @@ Adds additional methods for VisualElement when adding animation plugin |---|---|---| |[VisualElement:animate](#VisualElement:animate)|Animation|Creates a new animation + ## VisualElement:animate() Creates a new Animation Object diff --git a/docs/references/plugins/benchmark.md b/docs/references/plugins/benchmark.md index dabd471..c075aa8 100644 --- a/docs/references/plugins/benchmark.md +++ b/docs/references/plugins/benchmark.md @@ -11,6 +11,7 @@ Benchmark API methods |[API.start](#API.start)|-|Starts timing a custom operation |[API.stop](#API.stop)|-|Stops timing and logs results + ## API.clear(name) Clears a specific benchmark diff --git a/docs/references/plugins/benchmark_BaseElement.md b/docs/references/plugins/benchmark_BaseElement.md index 31e8c0b..7e40a60 100644 --- a/docs/references/plugins/benchmark_BaseElement.md +++ b/docs/references/plugins/benchmark_BaseElement.md @@ -14,6 +14,7 @@ The following methods are available for BaseElement |[BaseElement:startProfile](#BaseElement:startProfile)|BaseElement|Starts timing a method call |[BaseElement:stopBenchmark](#BaseElement:stopBenchmark)|BaseElement|Disables performance measurement for a method + ## BaseElement:benchmark(methodName) Enables benchmarking for a method diff --git a/docs/references/plugins/benchmark_Container.md b/docs/references/plugins/benchmark_Container.md index 2f91981..6657f65 100644 --- a/docs/references/plugins/benchmark_Container.md +++ b/docs/references/plugins/benchmark_Container.md @@ -9,6 +9,7 @@ Container benchmarking methods |[Container:logContainerBenchmarks](#Container:logContainerBenchmarks)|Container|Recursively logs benchmark statistics |[Container:stopContainerBenchmark](#Container:stopContainerBenchmark)|Container|Recursively stops benchmarking + ## Container:benchmarkContainer(methodName) Enables benchmarking for a container and all its children diff --git a/docs/references/plugins/debug.md b/docs/references/plugins/debug.md index 729cae6..d2cdf27 100644 --- a/docs/references/plugins/debug.md +++ b/docs/references/plugins/debug.md @@ -8,6 +8,7 @@ No Description |[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 @@ -35,6 +36,7 @@ Dumps debug information for this element |[BaseFrame.showDebugLog](#BaseFrame.showDebugLog)|-|Shows the debug log frame |[BaseFrame.toggleDebugLog](#BaseFrame.toggleDebugLog)|-|Toggles the debug log frame + ## BaseFrame.hideDebugLog(self) Hides the debug log frame @@ -65,6 +67,7 @@ Toggles the debug log frame |---|---|---| |[Container.debugChildren](#Container.debugChildren)|-|Debug container and children + ## Container.debugChildren(self, level) Enables debugging for this container and all its children diff --git a/docs/references/plugins/reactive.md b/docs/references/plugins/reactive.md index f8eabdc..e46a0d2 100644 --- a/docs/references/plugins/reactive.md +++ b/docs/references/plugins/reactive.md @@ -8,3 +8,4 @@ It is used to evaluate expressions in property values and update the element whe |---|---|---| + diff --git a/docs/references/plugins/state.md b/docs/references/plugins/state.md index 433a26f..29d64bb 100644 --- a/docs/references/plugins/state.md +++ b/docs/references/plugins/state.md @@ -13,6 +13,7 @@ persistent states, computed states, and state sharing between elements. |[BaseElement:setState](#BaseElement:setState)|BaseElement|Sets a state value |[BaseElement:shareState](#BaseElement:shareState)|BaseElement|Shares state between elements + ## BaseElement:computed(self, key, computeFn) Creates a computed state that derives its value from other states diff --git a/docs/references/plugins/theme.md b/docs/references/plugins/theme.md index 676a867..79d8357 100644 --- a/docs/references/plugins/theme.md +++ b/docs/references/plugins/theme.md @@ -9,6 +9,7 @@ with support for inheritance, named styles, and dynamic theme switching. |[BaseElement:applyTheme](#BaseElement:applyTheme)|BaseElement|Applies theme styles to the element |[BaseElement:getTheme](#BaseElement:getTheme)|table|Gets theme properties for the element + ## BaseElement:applyTheme(self) Applies the current theme to this element @@ -42,6 +43,7 @@ The Theme API provides methods for managing themes globally |[themeAPI.loadTheme](#themeAPI.loadTheme)|-|Loads theme from JSON file |[themeAPI.setTheme](#themeAPI.setTheme)|-|Sets a new theme + ## themeAPI.getTheme() Gets the current theme configuration diff --git a/docs/references/plugins/xml.md b/docs/references/plugins/xml.md index 40e036f..a61b550 100644 --- a/docs/references/plugins/xml.md +++ b/docs/references/plugins/xml.md @@ -7,6 +7,7 @@ The XML plugin provides XML parsing and UI creation from XML markup |---|---|---| |[BaseElement:fromXML](#BaseElement:fromXML)|BaseElement|Creates element from XML node + ## BaseElement:fromXML(self, node) Creates an element from an XML node @@ -29,6 +30,7 @@ Creates an element from an XML node |---|---|---| |[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 = [[ diff --git a/docs/references/propertySystem.md b/docs/references/propertySystem.md index f6ab236..03364e3 100644 --- a/docs/references/propertySystem.md +++ b/docs/references/propertySystem.md @@ -30,6 +30,7 @@ It also allows for properties to have custom getters and setters. This is the ba |[PropertySystem:removeObserver](#PropertySystem:removeObserver)|table| |[PropertySystem:removeProperty](#PropertySystem:removeProperty)|table|Removes a property from the PropertySystem + ## PropertySystem.addSetterHook(hook) Adds a setter hook to the PropertySystem. Setter hooks are functions that are called before a property is set. diff --git a/docs/references/render.md b/docs/references/render.md index 5cd76d8..6876da9 100644 --- a/docs/references/render.md +++ b/docs/references/render.md @@ -36,6 +36,7 @@ functionality. It also has a buffer system to reduce the number of calls |[Render:textBg](#Render:textBg)|Render| |[Render:textFg](#Render:textFg)|Render| + ## Render.new(terminal) Creates a new Render object From 47fef51a0c9bbf65a89b3d38aecda8c9fa033438 Mon Sep 17 00:00:00 2001 From: NoryiE Date: Mon, 24 Feb 2025 22:54:38 +0000 Subject: [PATCH 3/4] deploy: a3cc685620e4fb7b790a963dce6d715a302dbe44 --- docs/references/elements/BaseElement.md | 67 +------ docs/references/elements/BaseFrame.md | 76 +------- docs/references/elements/Button.md | 29 +-- docs/references/elements/Checkbox.md | 34 +--- docs/references/elements/Container.md | 207 ++-------------------- docs/references/elements/Dropdown.md | 43 +---- docs/references/elements/Flexbox.md | 44 +---- docs/references/elements/Frame.md | 29 +-- docs/references/elements/Image.md | 35 ++-- docs/references/elements/Input.md | 72 ++------ docs/references/elements/Label.md | 32 +--- docs/references/elements/List.md | 56 +----- docs/references/elements/Menu.md | 43 +---- docs/references/elements/Program.md | 47 +---- docs/references/elements/ProgressBar.md | 32 +--- docs/references/elements/Scrollbar.md | 67 +------ docs/references/elements/Slider.md | 54 +----- docs/references/elements/Table.md | 56 +----- docs/references/elements/TextBox.md | 74 ++------ docs/references/elements/Tree.md | 56 +----- docs/references/elements/VisualElement.md | 149 +++------------- 21 files changed, 188 insertions(+), 1114 deletions(-) diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index e06735a..3e33996 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -14,40 +14,23 @@ The base class for all UI elements in Basalt. This class provides basic properti |Method|Returns|Description| |---|---|---| -|[BaseElement.defineEvent](#BaseElement.defineEvent)|-| -|[BaseElement.new](#BaseElement.new)|table|Creates a new BaseElement instance -|[BaseElement.registerEventCallback](#BaseElement.registerEventCallback)|-| |[BaseElement:destroy](#BaseElement:destroy)|-|Destroys the element and cleans up all references -|[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?|Handles all events |[BaseElement:fireEvent](#BaseElement:fireEvent)|table|Triggers an event and calls all registered callbacks |[BaseElement:getBaseFrame](#BaseElement:getBaseFrame)|table|Returns the base frame of the element -|[BaseElement:handleEvent](#BaseElement:handleEvent)|boolean?|The default event handler for all events -|[BaseElement:init](#BaseElement:init)|table|Initializes the BaseElement instance |[BaseElement:isType](#BaseElement:isType)|boolean|Checks if the element is a specific type |[BaseElement:listenEvent](#BaseElement:listenEvent)|table|Enables or disables event listening for a specific event -|[BaseElement:postInit](#BaseElement:postInit)|table|Post initialization |[BaseElement:registerCallback](#BaseElement:registerCallback)|table|Registers a callback function |[BaseElement:updateRender](#BaseElement:updateRender)|-|Requests a render update for this element -## BaseElement.defineEvent() +## Protected Functions -## BaseElement.new(props, basalt) -Creates a new BaseElement instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `table` `The` newly created BaseElement instance - -### Usage - ```lua -local element = BaseElement.new() -``` - -## BaseElement.registerEventCallback() +|Method|Returns|Description| +|---|---|---| +|[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?|Handles all events +|[BaseElement:handleEvent](#BaseElement:handleEvent)|boolean?|The default event handler for all events +|[BaseElement:init](#BaseElement:init)|table|Initializes the BaseElement instance +|[BaseElement:postInit](#BaseElement:postInit)|table|Post initialization ## BaseElement:destroy() Destroys the element and cleans up all references @@ -57,16 +40,6 @@ Destroys the element and cleans up all references element:destroy() ``` -## BaseElement:dispatchEvent(event...) -Handles all events - -### Parameters -* `event` `string` The event to handle -* `...` *(vararg)* `any` The arguments for the event - -### Returns -* `boolean?` `handled` Whether the event was handled - ## BaseElement:fireEvent(event, ...) Triggers an event and calls all registered callbacks @@ -88,26 +61,6 @@ 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 - -### Parameters -* `event` `string` The event to handle -* `...` *(vararg)* `any` The arguments for the event - -### Returns -* `boolean?` `handled` Whether the event was handled - -## BaseElement:init(props, basalt) -Initializes the BaseElement instance - -### Parameters -* `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 @@ -132,12 +85,6 @@ Enables or disables event listening for a specific event element:listenEvent("mouse_click", true) ``` -## BaseElement:postInit() -Post initialization - -### Returns -* `table` `self` The BaseElement instance - ## BaseElement:registerCallback(event, callback) Registers a callback function for an event diff --git a/docs/references/elements/BaseFrame.md b/docs/references/elements/BaseFrame.md index 7cbdc8d..ca3f78f 100644 --- a/docs/references/elements/BaseFrame.md +++ b/docs/references/elements/BaseFrame.md @@ -18,62 +18,22 @@ This is the base frame class. It is the root element of all elements and the onl |Method|Returns|Description| |---|---|---| -|[BaseFrame.new](#BaseFrame.new)|BaseFrame|Creates a new Frame instance +|[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[BaseFrame:blit](#BaseFrame:blit)|-|Renders a text with a foreground and background color to the render Object |[BaseFrame:init](#BaseFrame:init)|table|Initializes the Frame instance +|[BaseFrame:mouse_up](#BaseFrame:mouse_up)|-|Handles mouse up events |[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|Renders a multiBlit to the render Object |[BaseFrame:render](#BaseFrame:render)|-|Renders the Frame -|[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position +|[BaseFrame:term_resize](#BaseFrame:term_resize)|-|Resizes the Frame |[BaseFrame:textBg](#BaseFrame:textBg)|-|Renders a text with a background color to the render Object |[BaseFrame:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object - -## BaseFrame.new() -Creates a new Frame instance - -### Returns -* `BaseFrame` `object` The newly created Frame instance - -### Usage - ```lua -local element = BaseFrame.new() -``` - -## BaseFrame:blit(x, y, text, fg, bg) -Renders a text with a foreground and background color to the render Object - -### Parameters -* `x` `number` The x position to render to -* `y` `number` The y position to render to -* `text` `string` The text to render -* `fg` `string` The foreground color -* `bg` `string` The background color - -## BaseFrame:init(props, basalt) -Initializes the Frame instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `table` `self` The initialized instance - -## BaseFrame:multiBlit(x, y, width, height, text, fg, bg) -Renders a multiBlit to the render Object - -### Parameters -* `x` `number` The x position to render to -* `y` `number` The y position to render to -* `width` `number` The width of the text -* `height` `number` The height of the text -* `text` `string` The text to render -* `fg` `string` The foreground color -* `bg` `string` The background color - -## BaseFrame:render() -Renders the Frame - ## BaseFrame:setCursor(x, y, blink) Sets the cursor position @@ -82,22 +42,4 @@ Sets the cursor position * `y` `number` The y position to set the cursor to * `blink` `boolean` Whether the cursor should blink -## BaseFrame:textBg(x, y, text, bg) -Renders a text with a background color to the render Object - -### Parameters -* `x` `number` The x position to render to -* `y` `number` The y position to render to -* `text` `string` The text to render -* `bg` `colors` The background color - -## BaseFrame:textFg(x, y, text, fg) -Renders a text with a foreground color to the render Object - -### Parameters -* `x` `number` The x position to render to -* `y` `number` The y position to render to -* `text` `string` The text to render -* `fg` `colors` The foreground color - diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index 8eecbd3..73fc711 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -8,34 +8,17 @@ The Button is a standard button element with click handling and state management |---|---|---|---| |text|string|Button|Button text -## Events - -|Event|Parameters|Description| -|---|---|---| - ## Functions |Method|Returns|Description| |---|---|---| -|[Button.new](#Button.new)|table|Creates a new Button instance + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Button:init](#Button:init)|-|Initializes the Button instance |[Button:render](#Button:render)|-|Renders the Button -## Button.new() -Creates a new Button instance - -### Returns -* `table` `self` The created instance - -## Button:init(props, basalt) -Initializes the Button instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -## Button:render() -Renders the Button - - diff --git a/docs/references/elements/Checkbox.md b/docs/references/elements/Checkbox.md index 6c7345c..848cee8 100644 --- a/docs/references/elements/Checkbox.md +++ b/docs/references/elements/Checkbox.md @@ -12,6 +12,12 @@ The Checkbox is a visual element that can be checked. ## Functions +|Method|Returns|Description| +|---|---|---| + + +## Protected Functions + |Method|Returns|Description| |---|---|---| |[Checkbox.new](#Checkbox.new)|Checkbox|Creates a new Checkbox instance @@ -20,31 +26,3 @@ The Checkbox is a visual element that can be checked. |[Checkbox:render](#Checkbox:render)|-|Renders the Checkbox -## Checkbox.new() -Creates a new Checkbox instance - -### Returns -* `Checkbox` `self` The created instance - -## Checkbox:init(props, basalt) -Initializes the Checkbox instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -## Checkbox:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `Clicked` Whether the event was handled - -## Checkbox:render() -Renders the Checkbox - - diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index 71e6b5c..6cc8e00 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -21,17 +21,28 @@ like Frames, BaseFrames, and more. |Method|Returns|Description| |---|---|---| -|[Container.new](#Container.new)|Container|Creates a new Container instance |[Container:addChild](#Container:addChild)|Container|Adds a child to the container -|[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors -|[Container:callChildrenEvents](#Container:callChildrenEvents)|boolean|Calls a event on all children -|[Container:char](#Container:char)|boolean|Handles char events +|[Container:callChildrenEvent](#Container:callChildrenEvent)|boolean|Calls a event on all children |[Container:clear](#Container:clear)|Container|Clears the container -|[Container:destroy](#Container:destroy)|Container|Destroys the container and its children |[Container:getChild](#Container:getChild)|Container?|Removes a child from the container +|[Container:isChildVisible](#Container:isChildVisible)|boolean|Returns whether a child is visible +|[Container:registerChildEvent](#Container:registerChildEvent)|Container|Registers the children events of the container +|[Container:registerChildrenEvents](#Container:registerChildrenEvents)|Container|Registers the children events of the container +|[Container:removeChild](#Container:removeChild)|Container|Removes a child from the container +|[Container:removeChildrenEvents](#Container:removeChildrenEvents)|Container|Unregisters the children events of the container +|[Container:sortChildren](#Container:sortChildren)|Container|Sorts the children of the container +|[Container:sortChildrenEvents](#Container:sortChildrenEvents)|Container|Sorts the children events of the container +|[Container:unregisterChildEvent](#Container:unregisterChildEvent)|Container|Unregisters the children events of the container + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| +|[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors +|[Container:char](#Container:char)|boolean|Handles char events |[Container:handleEvent](#Container:handleEvent)|boolean|Default handler for events |[Container:init](#Container:init)|-|Initializes the Container instance -|[Container:isChildVisible](#Container:isChildVisible)|boolean|Returns whether a child is visible |[Container:key](#Container:key)|boolean|Handles key events |[Container:key_up](#Container:key_up)|boolean|Handles key up events |[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events @@ -41,23 +52,9 @@ like Frames, BaseFrames, and more. |[Container:mouse_scroll](#Container:mouse_scroll)|boolean|Handles mouse scroll events |[Container:mouse_up](#Container:mouse_up)|boolean|Handles mouse up events |[Container:multiBlit](#Container:multiBlit)|Container|Draws multiple lines of text, fg and bg strings -|[Container:registerChildEvent](#Container:registerChildEvent)|Container|Registers the children events of the container -|[Container:registerChildrenEvents](#Container:registerChildrenEvents)|Container|Registers the children events of the container -|[Container:removeChild](#Container:removeChild)|Container|Removes a child from the container -|[Container:removeChildrenEvents](#Container:removeChildrenEvents)|Container|Unregisters the children events of the container |[Container:render](#Container:render)|-|Renders the container -|[Container:sortChildren](#Container:sortChildren)|Container|Sorts the children of the container -|[Container:sortChildrenEvents](#Container:sortChildrenEvents)|Container|Sorts the children events of the container |[Container:textBg](#Container:textBg)|Container|Draws a line of text and bg as color |[Container:textFg](#Container:textFg)|Container|Draws a line of text and fg as color -|[Container:unregisterChildEvent](#Container:unregisterChildEvent)|Container|Unregisters the children events of the container - - -## Container.new() -Creates a new Container instance - -### Returns -* `Container` `self` The new container instance ## Container:addChild(child) Adds a child to the container @@ -68,20 +65,7 @@ Adds a child to the container ### Returns * `Container` `self` The container instance -## Container:blit(x, y, text, fg, bg) -Draws a line of text and fg and bg as colors, it is usually used in the render loop - -### Parameters -* `x` `number` The x position to draw the text -* `y` `number` The y position to draw the text -* `text` `string` The text to draw -* `fg` `string` The foreground color of the text -* `bg` `string` The background color of the text - -### Returns -* `Container` `self` The container instance - -## Container:callChildrenEvents(visibleOnly, event...) +## Container:callChildrenEvent(visibleOnly, event...) Calls a event on all children ### Parameters @@ -93,27 +77,12 @@ Calls a event on all children * `boolean` `handled` Whether the event was handled * `table` `child?` The child that handled the event -## Container:char(char) -Handles char events - -### Parameters -* `char` `string` The character that was pressed - -### Returns -* `boolean` `handled` Whether the event was handled - ## Container:clear() Clears the container ### Returns * `Container` `self` The container instance -## Container:destroy() -Destroys the container and its children - -### Returns -* `Container` `self` The container instance - ## Container:getChild(path) Removes a child from the container @@ -123,23 +92,6 @@ Removes a child from the container ### Returns * `Container?` `self` The container instance -## Container:handleEvent(event...) -Default handler for events - -### Parameters -* `event` `string` The event to handle -* `...` *(vararg)* `any` The event arguments - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:init(props, basalt) -Initializes the Container instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - ## Container:isChildVisible(child) Returns whether a child is visible @@ -149,102 +101,6 @@ Returns whether a child is visible ### Returns * `boolean` `boolean` the child is visible -## Container:key(key) -Handles key events - -### Parameters -* `key` `number` The key that was pressed - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:key_up(key) -Handles key up events - -### Parameters -* `key` `number` The key that was released - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:mouse_drag(button, x, y) -Handles mouse drag events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:mouse_move(_, x, y) -Handles mouse move events - -### Parameters -* `_` `number` unknown -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:mouse_release(button, x, y) -Handles mouse release events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -## Container:mouse_scroll(direction, x, y) -Handles mouse scroll events - -### Parameters -* `direction` `number` The direction of the scroll -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:mouse_up(button, x, y) -Handles mouse up events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Container:multiBlit(x, y, width, height, text, fg, bg) -Draws multiple lines of text, fg and bg strings, it is usually used in the render loop - -### Parameters -* `x` `number` The x position to draw the text -* `y` `number` The y position to draw the text -* `width` `number` The width of the text -* `height` `number` The height of the text -* `text` `string` The text to draw -* `fg` `string` The foreground color of the text -* `bg` `string` The background color of the text - -### Returns -* `Container` `self` The container instance - ## Container:registerChildEvent(child, eventName) Registers the children events of the container @@ -282,9 +138,6 @@ Unregisters the children events of the container ### Returns * `Container` `self` The container instance -## Container:render() -Renders the container - ## Container:sortChildren() Sorts the children of the container @@ -300,30 +153,6 @@ Sorts the children events of the container ### Returns * `Container` `self` The container instance -## Container:textBg(x, y, text, bg) -Draws a line of text and bg as color, it is usually used in the render loop - -### Parameters -* `x` `number` The x position to draw the text -* `y` `number` The y position to draw the text -* `text` `string` The text to draw -* `bg` `color` The background color of the text - -### Returns -* `Container` `self` The container instance - -## Container:textFg(x, y, text, fg) -Draws a line of text and fg as color, it is usually used in the render loop - -### Parameters -* `x` `number` The x position to draw the text -* `y` `number` The y position to draw the text -* `text` `string` The text to draw -* `fg` `color` The foreground color of the text - -### Returns -* `Container` `self` The container instance - ## Container:unregisterChildEvent(child, eventName) Unregisters the children events of the container diff --git a/docs/references/elements/Dropdown.md b/docs/references/elements/Dropdown.md index bdaea07..9096da9 100644 --- a/docs/references/elements/Dropdown.md +++ b/docs/references/elements/Dropdown.md @@ -14,45 +14,14 @@ This is the dropdown class. It is a visual element that can show a list of selec |Method|Returns|Description| |---|---|---| -|[Dropdown.new](#Dropdown.new)|Dropdown|Creates a new Dropdown instance + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Dropdown:init](#Dropdown:init)|Dropdown|Initializes the Dropdown instance |[Dropdown:mouse_click](#Dropdown:mouse_click)|boolean|Handles mouse click events |[Dropdown:render](#Dropdown:render)|-|Renders the Dropdown -## Dropdown.new() -Creates a new Dropdown instance - -### Returns -* `Dropdown` `self` The newly created Dropdown instance - -### Usage - ```lua -local dropdown = Dropdown.new() -``` - -## Dropdown:init(props, basalt) -Initializes the Dropdown instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Dropdown` `self` The initialized instance - -## Dropdown:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Dropdown:render() -Renders the Dropdown - - diff --git a/docs/references/elements/Flexbox.md b/docs/references/elements/Flexbox.md index e66d54a..8aa5a6b 100644 --- a/docs/references/elements/Flexbox.md +++ b/docs/references/elements/Flexbox.md @@ -15,25 +15,18 @@ This is the Flexbox class. It is a container that arranges its children in a fle |Method|Returns|Description| |---|---|---| -|[Flexbox.new](#Flexbox.new)|Flexbox|Creates a new Flexbox instance |[Flexbox:addChild](#Flexbox:addChild)|Flexbox|Adds a child element to the flexbox |[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|Adds a new line break to the flexbox. + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Flexbox:init](#Flexbox:init)|Flexbox|Initializes the Flexbox instance |[Flexbox:removeChild](#Flexbox:removeChild)|Flexbox|Removes a child element from the flexbox |[Flexbox:render](#Flexbox:render)|Flexbox|Renders the flexbox and its children - -## Flexbox.new() -Creates a new Flexbox instance - -### Returns -* `Flexbox` `object` The newly created Flexbox instance - -### Usage - ```lua -local element = Flexbox.new("myId", basalt) -``` - ## Flexbox:addChild(element) Adds a child element to the flexbox @@ -52,29 +45,4 @@ Adds a new line break to the flexbox ### Returns * `nil` `nil` nil -## Flexbox:init(props, basalt) -Initializes the Flexbox instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Flexbox` `self` The initialized instance - -## Flexbox:removeChild(element) -Removes a child element from the flexbox - -### Parameters -* `element` `Element` The child element to remove - -### Returns -* `Flexbox` `self` The flexbox instance - -## Flexbox:render() -Renders the flexbox and its children - -### Returns -* `Flexbox` `self` The flexbox instance - diff --git a/docs/references/elements/Frame.md b/docs/references/elements/Frame.md index 81718ff..ab359c7 100644 --- a/docs/references/elements/Frame.md +++ b/docs/references/elements/Frame.md @@ -5,29 +5,12 @@ This is the frame class. It serves as a grouping container for other elements. |Method|Returns|Description| |---|---|---| -|[Frame.new](#Frame.new)|Frame|Creates a new Frame instance + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Frame:init](#Frame:init)|Frame|Initializes the Frame instance -## Frame.new() -Creates a new Frame instance - -### Returns -* `Frame` `self` The newly created Frame instance - -### Usage - ```lua -local frame = Frame.new() -``` - -## Frame:init(props, basalt) -Initializes the Frame instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Frame` `self` The initialized instance - - diff --git a/docs/references/elements/Image.md b/docs/references/elements/Image.md index e73468e..602e5e0 100644 --- a/docs/references/elements/Image.md +++ b/docs/references/elements/Image.md @@ -15,19 +15,21 @@ See: https://github.com/SkyTheCodeMaster/bimg |Method|Returns|Description| |---|---|---| -|[Image.new](#Image.new)|-| -|[Image:getPixelData](#Image:getPixelData)|number?| -|[Image:init](#Image:init)|-| -|[Image:loadBimg](#Image:loadBimg)|-| -|[Image:nextFrame](#Image:nextFrame)|-| -|[Image:render](#Image:render)|-| -|[Image:setBg](#Image:setBg)|-| -|[Image:setChar](#Image:setChar)|-| -|[Image:setFg](#Image:setFg)|-| -|[Image:setPixel](#Image:setPixel)|-| +|[Image:getPixelData](#Image:getPixelData)|number?|Gets pixel information at position +|[Image:loadBimg](#Image:loadBimg)|Image|Loads a bimg format image +|[Image:nextFrame](#Image:nextFrame)|Image|Advances to the next frame in the animation +|[Image:setBg](#Image:setBg)|-|Sets background color at position +|[Image:setChar](#Image:setChar)|-|Sets character at position +|[Image:setFg](#Image:setFg)|-|Sets foreground color at position +|[Image:setPixel](#Image:setPixel)|-|Sets all properties at position -## Image.new() +## Protected Functions + +|Method|Returns|Description| +|---|---|---| +|[Image:init](#Image:init)|Image|Initializes the Image instance +|[Image:render](#Image:render)|-|Renders the Image ## Image:getPixelData(x, y) Gets pixel information at position @@ -41,17 +43,20 @@ Gets pixel information at position * `number?` `bg` Background color * `string?` `char` Character at position -## Image:init() - ## Image:loadBimg(bimgData) Loads a bimg format image ### Parameters * `bimgData` `table` The bimg image data -## Image:nextFrame() +### Returns +* `Image` `self` The Image instance -## Image:render() +## Image:nextFrame() +Advances to the next frame in the animation + +### Returns +* `Image` `self` The Image instance ## Image:setBg(x, y, color) Sets background color at position diff --git a/docs/references/elements/Input.md b/docs/references/elements/Input.md index 322a627..ff97e96 100644 --- a/docs/references/elements/Input.md +++ b/docs/references/elements/Input.md @@ -20,7 +20,13 @@ cursor movement, text manipulation, placeholder text, and input validation. |Method|Returns|Description| |---|---|---| -|[Input.new](#Input.new)|Input|Creates a new Input instance +|[Input:updateViewport](#Input:updateViewport)|Input|Updates the input's viewport + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Input:blur](#Input:blur)|-|Handles blur events |[Input:char](#Input:char)|boolean|Handles char events |[Input:focus](#Input:focus)|-|Handles focus events @@ -28,69 +34,11 @@ cursor movement, text manipulation, placeholder text, and input validation. |[Input:key](#Input:key)|boolean|Handles key events |[Input:mouse_click](#Input:mouse_click)|boolean|Handles mouse click events |[Input:render](#Input:render)|-|Renders the input element -|[Input:updateViewport](#Input:updateViewport)|-|Updates the input's viewport - - -## Input.new() -Creates a new Input instance - -### Returns -* `Input` `object` The newly created Input instance - -### Usage - ```lua -local element = Input.new("myId", basalt) -``` - -## Input:blur() -Handles blur events - -## Input:char(char) -Handles char events - -### Parameters -* `char` `string` The character that was typed - -### Returns -* `boolean` `handled` Whether the event was handled - -## Input:focus() -Handles focus events - -## Input:init(props, basalt) -Initializes the Input instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Input` `self` The initialized instance - -## Input:key(key) -Handles key events - -### Parameters -* `key` `number` The key that was pressed - -### Returns -* `boolean` `handled` Whether the event was handled - -## Input:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Input:render() -Renders the input element ## Input:updateViewport() Updates the input's viewport +### Returns +* `Input` `self` The updated instance + diff --git a/docs/references/elements/Label.md b/docs/references/elements/Label.md index 8665127..e909b1c 100644 --- a/docs/references/elements/Label.md +++ b/docs/references/elements/Label.md @@ -13,40 +13,20 @@ resizes its width based on the text content. |Method|Returns|Description| |---|---|---| -|[Label.new](#Label.new)|Label|Creates a new Label instance |[Label:getWrappedText](#Label:getWrappedText)|table|Gets the wrapped lines of the Label + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Label:init](#Label:init)|Label|Initializes the Label instance |[Label:render](#Label:render)|-|Renders the Label by drawing its text content - -## Label.new() -Creates a new Label instance - -### Returns -* `Label` `self` The newly created Label instance - -### Usage - ```lua -local label = Label.new() -``` - ## Label:getWrappedText() Gets the wrapped lines of the Label ### Returns * `table` `wrappedText` The wrapped lines of the Label -## Label:init(props, basalt) -Initializes the Label instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Label` `self` The initialized instance - -## Label:render() -Renders the Label - diff --git a/docs/references/elements/List.md b/docs/references/elements/List.md index c6db771..82e18e5 100644 --- a/docs/references/elements/List.md +++ b/docs/references/elements/List.md @@ -23,30 +23,23 @@ custom item rendering, separators, and selection handling. |Method|Returns|Description| |---|---|---| -|[List.new](#List.new)|List|Creates a new List instance |[List:addItem](#List:addItem)|List|Adds an item to the list |[List:clear](#List:clear)|List|Clears all items from the list |[List:getSelectedItems](#List:getSelectedItems)|table|Gets the currently selected items -|[List:init](#List:init)|List|Initializes the List instance -|[List:mouse_click](#List:mouse_click)|boolean|Handles mouse click events -|[List:mouse_scroll](#List:mouse_scroll)|boolean|Handles mouse scroll events |[List:onSelect](#List:onSelect)|List|Registers a callback for the select event |[List:removeItem](#List:removeItem)|List|Removes an item from the list -|[List:render](#List:render)|-|Renders the list |[List:scrollToBottom](#List:scrollToBottom)|List|Scrolls the list to the bottom |[List:scrollToTop](#List:scrollToTop)|List|Scrolls the list to the top -## List.new() -Creates a new List instance +## Protected Functions -### Returns -* `List` `self` The newly created List instance - -### Usage - ```lua -local list = List.new() -``` +|Method|Returns|Description| +|---|---|---| +|[List:init](#List:init)|List|Initializes the List instance +|[List:mouse_click](#List:mouse_click)|boolean|Handles mouse click events +|[List:mouse_scroll](#List:mouse_scroll)|boolean|Handles mouse scroll events +|[List:render](#List:render)|-|Renders the list ## List:addItem(text) Adds an item to the list @@ -85,38 +78,6 @@ Gets the currently selected items local selected = list:getSelectedItems() ``` -## List:init(props, basalt) -Initializes the List instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `List` `self` The initialized instance - -## List:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The mouse button that was clicked -* `x` `number` The x-coordinate of the click -* `y` `number` The y-coordinate of the click - -### Returns -* `boolean` `Whether` the event was handled - -## List:mouse_scroll(direction, x, y) -Handles mouse scroll events - -### Parameters -* `direction` `number` The direction of the scroll (1 for down, -1 for up) -* `x` `number` The x-coordinate of the scroll -* `y` `number` The y-coordinate of the scroll - -### Returns -* `boolean` `Whether` the event was handled - ## List:onSelect(callback) Registers a callback for the select event @@ -145,9 +106,6 @@ Removes an item from the list list:removeItem(1) ``` -## List:render() -Renders the list - ## List:scrollToBottom() Scrolls the list to the bottom diff --git a/docs/references/elements/Menu.md b/docs/references/elements/Menu.md index b4c57ab..90dfc9e 100644 --- a/docs/references/elements/Menu.md +++ b/docs/references/elements/Menu.md @@ -12,47 +12,16 @@ Menu items are displayed in a single row and can have custom colors and callback |Method|Returns|Description| |---|---|---| -|[Menu.new](#Menu.new)|Menu|Creates a new Menu instance -|[Menu:init](#Menu:init)|Menu|Initializes the Menu instance -|[Menu:mouse_click](#Menu:mouse_click)|boolean|Handles mouse click events and item selection -|[Menu:render](#Menu:render)|-|Renders the menu horizontally with proper spacing and colors |[Menu:setItems](#Menu:setItems)|Menu|Sets the menu items and calculates total width -## Menu.new() -Creates a new Menu instance +## Protected Functions -### Returns -* `Menu` `self` The newly created Menu instance - -### Usage - ```lua -local menu = Menu.new() -``` - -## Menu:init(props, basalt) -Initializes the Menu instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Menu` `self` The initialized instance - -## Menu:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `Whether` the event was handled - -## Menu:render() -Renders the menu +|Method|Returns|Description| +|---|---|---| +|[Menu:init](#Menu:init)|Menu|Initializes the Menu instance +|[Menu:mouse_click](#Menu:mouse_click)|boolean|Handles mouse click events and item selection +|[Menu:render](#Menu:render)|-|Renders the menu horizontally with proper spacing and colors ## Menu:setItems(items) Sets the menu items diff --git a/docs/references/elements/Program.md b/docs/references/elements/Program.md index f0cf482..b7e2941 100644 --- a/docs/references/elements/Program.md +++ b/docs/references/elements/Program.md @@ -13,35 +13,18 @@ This is the program class. It provides a program that runs in a window. |Method|Returns|Description| |---|---|---| -|[Program.new](#Program.new)|Program|Creates a new Program instance -|[Program:dispatchEvent](#Program:dispatchEvent)|any|Handles all incomming events |[Program:execute](#Program:execute)|Program|Executes a program + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| +|[Program:dispatchEvent](#Program:dispatchEvent)|any|Handles all incomming events |[Program:focus](#Program:focus)|-|Gets called when the element gets focused |[Program:init](#Program:init)|Program|Initializes the Program instance |[Program:render](#Program:render)|-|Renders the program - -## Program.new() -Creates a new Program instance - -### Returns -* `Program` `object` The newly created Program instance - -### Usage - ```lua -local element = Program.new("myId", basalt) -``` - -## Program:dispatchEvent(event, ...) -Handles all incomming events - -### Parameters -* `event` `string` The event to handle -* `...` `any` The event arguments - -### Returns -* `any` `result` The event result - ## Program:execute(path) Executes a program @@ -51,20 +34,4 @@ Executes a program ### Returns * `Program` `self` The Program instance -## Program:focus() -Gets called when the element gets focused - -## Program:init(props, basalt) -Initializes the Program instanceProperty - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Program` `self` The initialized instance - -## Program:render() -Renders the program - diff --git a/docs/references/elements/ProgressBar.md b/docs/references/elements/ProgressBar.md index b785527..286b674 100644 --- a/docs/references/elements/ProgressBar.md +++ b/docs/references/elements/ProgressBar.md @@ -14,33 +14,13 @@ with optional percentage display and customizable colors. |Method|Returns|Description| |---|---|---| -|[ProgressBar.new](#ProgressBar.new)|ProgressBar|Creates a new ProgressBar instance + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[ProgressBar:init](#ProgressBar:init)|ProgressBar|Initializes the ProgressBar instance |[ProgressBar:render](#ProgressBar:render)|-|Renders the progress bar with filled portion and optional percentage text -## ProgressBar.new() -Creates a new ProgressBar instance - -### Returns -* `ProgressBar` `self` The newly created ProgressBar instance - -### Usage - ```lua -local progressBar = ProgressBar.new() -``` - -## ProgressBar:init(props, basalt) -Initializes the ProgressBar instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `ProgressBar` `self` The initialized instance - -## ProgressBar:render() -Renders the ProgressBar - - diff --git a/docs/references/elements/Scrollbar.md b/docs/references/elements/Scrollbar.md index ebcecb5..0f0c7f1 100644 --- a/docs/references/elements/Scrollbar.md +++ b/docs/references/elements/Scrollbar.md @@ -25,26 +25,19 @@ A scrollbar element that can be attached to other elements to control their scro |Method|Returns|Description| |---|---|---| -|[Scrollbar.new](#Scrollbar.new)|Scrollbar|Creates a new Scrollbar instance |[Scrollbar:attach](#Scrollbar:attach)|Scrollbar|Attaches the scrollbar to an element's property +|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Scrollbar:init](#Scrollbar:init)|Scrollbar|Initializes the Scrollbar instance |[Scrollbar:mouse_click](#Scrollbar:mouse_click)|boolean|Handles mouse click events |[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|boolean|Handles mouse drag events |[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|boolean|Handles mouse scroll events |[Scrollbar:render](#Scrollbar:render)|-|Renders the scrollbar -|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value - - -## Scrollbar.new() -Creates a new Scrollbar instance - -### Returns -* `Scrollbar` `self` The newly created Scrollbar instance - -### Usage - ```lua -local scrollbar = Scrollbar.new() -``` ## Scrollbar:attach(element, config) Attaches the scrollbar to an element's property @@ -56,52 +49,6 @@ Attaches the scrollbar to an element's property ### Returns * `Scrollbar` `self` The scrollbar instance -## Scrollbar:init(props, basalt) -Initializes the Scrollbar instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Scrollbar` `self` The initialized instance - -## Scrollbar:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The mouse button clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `Whether` the event was handled - -## Scrollbar:mouse_drag(button, x, y) -Handles mouse drag events - -### Parameters -* `button` `number` The mouse button being dragged -* `x` `number` The x position of the drag -* `y` `number` The y position of the drag - -### Returns -* `boolean` `Whether` the event was handled - -## Scrollbar:mouse_scroll(direction, x, y) -Handles mouse scroll events - -### Parameters -* `direction` `number` The scroll direction (1 for up, -1 for down) -* `x` `number` The x position of the scroll -* `y` `number` The y position of the scroll - -### Returns -* `boolean` `Whether` the event was handled - -## Scrollbar:render() -Renders the Scrollbar - ## Scrollbar:updateAttachedElement() Updates the attached element's property based on the scrollbar value diff --git a/docs/references/elements/Slider.md b/docs/references/elements/Slider.md index 1d92a9c..206f82a 100644 --- a/docs/references/elements/Slider.md +++ b/docs/references/elements/Slider.md @@ -22,25 +22,18 @@ with customizable colors and value ranges. |Method|Returns|Description| |---|---|---| -|[Slider.new](#Slider.new)|Slider|Creates a new Slider instance |[Slider:getValue](#Slider:getValue)|number|Gets the current value mapped to the max range + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Slider:init](#Slider:init)|Slider|Initializes the Slider instance |[Slider:mouse_click](#Slider:mouse_click)|boolean|Updates slider position on mouse click |[Slider:mouse_scroll](#Slider:mouse_scroll)|boolean|Handles mouse release events |[Slider:render](#Slider:render)|-|Renders the slider with track and handle - -## Slider.new() -Creates a new Slider instance - -### Returns -* `Slider` `self` The newly created Slider instance - -### Usage - ```lua -local slider = Slider.new() -``` - ## Slider:getValue() Gets the current value of the slider @@ -52,39 +45,4 @@ Gets the current value of the slider local value = slider:getValue() ``` -## Slider:init(props, basalt) -Initializes the Slider instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Slider` `self` The initialized instance - -## Slider:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The mouse button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Slider:mouse_scroll(button, x, y) -Handles mouse release events - -### Parameters -* `button` `number` The mouse button that was released -* `x` `number` The x position of the release -* `y` `number` The y position of the release - -### Returns -* `boolean` `handled` Whether the event was handled - -## Slider:render() -Renders the slider - diff --git a/docs/references/elements/Table.md b/docs/references/elements/Table.md index c0d7578..3e21330 100644 --- a/docs/references/elements/Table.md +++ b/docs/references/elements/Table.md @@ -20,59 +20,17 @@ row selection, and scrolling capabilities. |Method|Returns|Description| |---|---|---| -|[Table.new](#Table.new)|Table|Creates a new Table instance +|[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[Table:init](#Table:init)|Table|Initializes the Table instance |[Table:mouse_click](#Table:mouse_click)|boolean|Handles header clicks for sorting and row selection |[Table:mouse_scroll](#Table:mouse_scroll)|boolean|Handles scrolling through the table data |[Table:render](#Table:render)|-|Renders the table with headers, data and scrollbar -|[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column - - -## Table.new() -Creates a new Table instance - -### Returns -* `Table` `self` The newly created Table instance - -### Usage - ```lua -local table = Table.new() -``` - -## Table:init(props, basalt) -Initializes the Table instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Table` `self` The initialized instance - -## Table:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Table:mouse_scroll(direction, x, y) -Handles mouse scroll events - -### Parameters -* `direction` `number` The scroll direction (-1 up, 1 down) -* `x` `number` The x position of the scroll -* `y` `number` The y position of the scroll - -### Returns -* `boolean` `handled` Whether the event was handled - -## Table:render() -Renders the table ## Table:sortData(columnIndex) Sorts the table data by column diff --git a/docs/references/elements/TextBox.md b/docs/references/elements/TextBox.md index dfa87b1..1374429 100644 --- a/docs/references/elements/TextBox.md +++ b/docs/references/elements/TextBox.md @@ -18,24 +18,22 @@ A multi-line text editor component with cursor support and text manipulation fea |Method|Returns|Description| |---|---|---| -|[TextBox.new](#TextBox.new)|TextBox|Creates a new TextBox instance -|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-|Adds a new syntax highlighting pattern -|[TextBox:char](#TextBox:char)|boolean|Handles character input +|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|TextBox|Adds a new syntax highlighting pattern |[TextBox:getText](#TextBox:getText)|string|Gets the text of the TextBox +|[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox +|[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| +|[TextBox:char](#TextBox:char)|boolean|Handles character input |[TextBox:init](#TextBox:init)|TextBox|Initializes the TextBox instance |[TextBox:key](#TextBox:key)|boolean|Handles key events |[TextBox:mouse_click](#TextBox:mouse_click)|boolean|Handles mouse click events |[TextBox:mouse_scroll](#TextBox:mouse_scroll)|boolean|Handles mouse scroll events |[TextBox:render](#TextBox:render)|-|Renders the TextBox with syntax highlighting -|[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox -|[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view - - -## TextBox.new() -Creates a new TextBox instance - -### Returns -* `TextBox` `self` The newly created TextBox instance ## TextBox:addSyntaxPattern(pattern, color) Adds a new syntax highlighting pattern @@ -44,14 +42,8 @@ Adds a new syntax highlighting pattern * `pattern` `string` The regex pattern to match * `color` `colors` The color to apply -## TextBox:char(char) -Handles character input - -### Parameters -* `char` `string` The character that was typed - ### Returns -* `boolean` `handled` Whether the event was handled +* `TextBox` `self` The TextBox instance ## TextBox:getText() Gets the text of the TextBox @@ -59,50 +51,6 @@ Gets the text of the TextBox ### Returns * `string` `text` The text of the TextBox -## TextBox:init(props, basalt) -Initializes the TextBox instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `TextBox` `self` The initialized instance - -## TextBox:key(key) -Handles key events - -### Parameters -* `key` `number` The key that was pressed - -### Returns -* `boolean` `handled` Whether the event was handled - -## TextBox:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## TextBox:mouse_scroll(direction, x, y) -Handles mouse scroll events - -### Parameters -* `direction` `number` The scroll direction -* `x` `number` The x position of the scroll -* `y` `number` The y position of the scroll - -### Returns -* `boolean` `handled` Whether the event was handled - -## TextBox:render() -Renders the TextBox - ## TextBox:setText(text) Sets the text of the TextBox diff --git a/docs/references/elements/Tree.md b/docs/references/elements/Tree.md index 69dd327..13bc4ea 100644 --- a/docs/references/elements/Tree.md +++ b/docs/references/elements/Tree.md @@ -18,28 +18,21 @@ with support for selection and scrolling. |Method|Returns|Description| |---|---|---| -|[Tree.new](#Tree.new)|Tree|Creates a new Tree instance |[Tree:collapseNode](#Tree:collapseNode)|Tree|Collapses a node to hide its children |[Tree:expandNode](#Tree:expandNode)|Tree|Expands a node to show its children |[Tree:getNodeSize](#Tree:getNodeSize)|number|Gets the size of the tree -|[Tree:init](#Tree:init)|Tree|Initializes the Tree instance -|[Tree:mouse_click](#Tree:mouse_click)|boolean|Handles mouse click events for node selection and expansion -|[Tree:mouse_scroll](#Tree:mouse_scroll)|boolean|Handles mouse scroll events for vertical scrolling |[Tree:onSelect](#Tree:onSelect)|Tree|Registers a callback for when a node is selected -|[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling |[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state -## Tree.new() -Creates a new Tree instance +## Protected Functions -### Returns -* `Tree` `self` The newly created Tree instance - -### Usage - ```lua -local tree = Tree.new() -``` +|Method|Returns|Description| +|---|---|---| +|[Tree:init](#Tree:init)|Tree|Initializes the Tree instance +|[Tree:mouse_click](#Tree:mouse_click)|boolean|Handles mouse click events for node selection and expansion +|[Tree:mouse_scroll](#Tree:mouse_scroll)|boolean|Handles mouse scroll events for vertical scrolling +|[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling ## Tree:collapseNode(node) Collapses a node @@ -66,38 +59,6 @@ Gets the size of the tree * `number` `width` The width of the tree * `number` `height` The height of the tree -## Tree:init(props, basalt) -Initializes the Tree instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance - -### Returns -* `Tree` `self` The initialized instance - -## Tree:mouse_click(button, x, y) -Handles mouse click events - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `handled` Whether the event was handled - -## Tree:mouse_scroll(direction, x, y) -Handles mouse scroll events - -### Parameters -* `direction` `number` The scroll direction (1 for up, -1 for down) -* `x` `number` The x position of the scroll -* `y` `number` The y position of the scroll - -### Returns -* `boolean` `handled` Whether the event was handled - ## Tree:onSelect(callback) Registers a callback for when a node is selected @@ -107,9 +68,6 @@ Registers a callback for when a node is selected ### Returns * `Tree` `self` The Tree instance -## Tree:render() -Renders the tree - ## Tree:toggleNode(node) Toggles a node's expanded state diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 04f486c..923ff0e 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -49,60 +49,38 @@ and provides core functionality for positioning, sizing, colors, and rendering. |Method|Returns|Description| |---|---|---| -|[VisualElement.new](#VisualElement.new)|VisualElement|Creates a new visual element +|[VisualElement:calculatePosition](#VisualElement:calculatePosition)|number|Calculates the position of the element +|[VisualElement:getAbsolutePosition](#VisualElement:getAbsolutePosition)|number|Returns the absolute position of the element +|[VisualElement:getRelativePosition](#VisualElement:getRelativePosition)|number|Returns the relative position of the element +|[VisualElement:isInBounds](#VisualElement:isInBounds)|boolean|Checks if point is within bounds + + +## Protected Functions + +|Method|Returns|Description| +|---|---|---| |[VisualElement:blit](#VisualElement:blit)|-|Draws text with both colors |[VisualElement:blur](#VisualElement:blur)|-|Handles a blur event -|[VisualElement:calculatePosition](#VisualElement:calculatePosition)|-| |[VisualElement:focus](#VisualElement:focus)|-|Handles a focus event -|[VisualElement:getAbsolutePosition](#VisualElement:getAbsolutePosition)|-|Returns the absolute position of the element -|[VisualElement:getRelativePosition](#VisualElement:getRelativePosition)|number,|Returns the relative position of the element |[VisualElement:init](#VisualElement:init)|-|Initializes a new visual element with properties -|[VisualElement:isInBounds](#VisualElement:isInBounds)|boolean|Checks if point is within bounds |[VisualElement:mouse_click](#VisualElement:mouse_click)|boolean|Handles a mouse click event -|[VisualElement:mouse_drag](#VisualElement:mouse_drag)|-| -|[VisualElement:mouse_move](#VisualElement:mouse_move)|-| +|[VisualElement:mouse_drag](#VisualElement:mouse_drag)|boolean|Handles a mouse drag event +|[VisualElement:mouse_move](#VisualElement:mouse_move)|boolean|Handles a mouse move event |[VisualElement:mouse_release](#VisualElement:mouse_release)|-|Handles a mouse release event -|[VisualElement:mouse_scroll](#VisualElement:mouse_scroll)|-| +|[VisualElement:mouse_scroll](#VisualElement:mouse_scroll)|boolean|Handles a mouse scroll event |[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean|Handles a mouse up event |[VisualElement:multiBlit](#VisualElement:multiBlit)|-|Multi-character drawing with colors |[VisualElement:render](#VisualElement:render)|-|Renders the element -|[VisualElement:setCursor](#VisualElement:setCursor)|-|Sets the cursor position +|[VisualElement:setCursor](#VisualElement:setCursor)|VisualElement|Sets the cursor position |[VisualElement:textBg](#VisualElement:textBg)|-|Draws text with background color |[VisualElement:textFg](#VisualElement:textFg)|-|Draws text with foreground color - -## VisualElement.new(props, basalt) -Creates a new VisualElement instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance +## VisualElement:calculatePosition() +Calculates the position of the element relative to its parent ### Returns -* `VisualElement` `object` The newly created VisualElement instance - -### Usage - ```lua -local element = VisualElement.new("myId", basalt) -``` - -## VisualElement:blit(x, y, text, fg, bg) -Draws text with both foreground and background colors - -### Parameters -* `x` `number` The x position to draw -* `y` `number` The y position to draw -* `text` `string` The text char to draw -* `fg` `string` The foreground color -* `bg` `string` The background color - -## VisualElement:blur() -Handles a blur event - -## VisualElement:calculatePosition() - -## VisualElement:focus() -Handles a focus event +* `number` `x` The x position +* `number` `y` The y position ## VisualElement:getAbsolutePosition(x?, y?) Returns the absolute position of the element or the given coordinates. @@ -111,6 +89,10 @@ Returns the absolute position of the element or the given coordinates. * `x` *(optional)* `number` x position * `y` *(optional)* `number` y position +### Returns +* `number` `x` The absolute x position +* `number` `y` The absolute y position + ## VisualElement:getRelativePosition(x?, y?) Returns the relative position of the element or the given coordinates. @@ -119,14 +101,8 @@ Returns the relative position of the element or the given coordinates. * `y` *(optional)* `number` y position ### Returns -* `nil` `nil` nil - -## VisualElement:init(props, basalt) -Initializes the VisualElement instance - -### Parameters -* `props` `table` The properties to initialize the element with -* `basalt` `table` The basalt instance +* `number` `x` The relative x position +* `number` `y` The relative y position ## VisualElement:isInBounds(x, y) Checks if the specified coordinates are within the bounds of the element @@ -138,81 +114,4 @@ Checks if the specified coordinates are within the bounds of the element ### Returns * `boolean` `isInBounds` Whether the coordinates are within the bounds of the element -## VisualElement:mouse_click(button, x, y) -Handles a mouse click event - -### Parameters -* `button` `number` The button that was clicked -* `x` `number` The x position of the click -* `y` `number` The y position of the click - -### Returns -* `boolean` `clicked` Whether the element was clicked - -## VisualElement:mouse_drag() - -## VisualElement:mouse_move() - -## VisualElement:mouse_release(button, x, y) -Handles a mouse release event - -### Parameters -* `button` `number` The button that was released -* `x` `number` The x position of the release -* `y` `number` The y position of the release - -## VisualElement:mouse_scroll() - -## VisualElement:mouse_up(button, x, y) -Handles a mouse up event - -### Parameters -* `button` `number` The button that was released -* `x` `number` The x position of the release -* `y` `number` The y position of the release - -### Returns -* `boolean` `release` Whether the element was released on the element - -## VisualElement:multiBlit(x, y, width, height, text, fg, bg) -Draws multiple characters at once with colors - -### Parameters -* `x` `number` The x position to draw -* `y` `number` The y position to draw -* `width` `number` The width of the area to draw -* `height` `number` The height of the area to draw -* `text` `string` The text to draw -* `fg` `string` The foreground color -* `bg` `string` The background color - -## VisualElement:render() -Renders the element - -## VisualElement:setCursor(x, y, blink) -Sets the cursor position - -### Parameters -* `x` `number` The x position of the cursor -* `y` `number` The y position of the cursor -* `blink` `boolean` Whether the cursor should blink - -## VisualElement:textBg(x, y, text, bg) -Draws text with background color - -### Parameters -* `x` `number` The x position to draw -* `y` `number` The y position to draw -* `text` `string` The text char to draw -* `bg` `color` The background color - -## VisualElement:textFg(x, y, text, fg) -Draws text with foreground color - -### Parameters -* `x` `number` The x position to draw -* `y` `number` The y position to draw -* `text` `string` The text char to draw -* `fg` `color` The foreground color - From 15a60812c7e97e883887d28c459c63ed5fc06d62 Mon Sep 17 00:00:00 2001 From: NoryiE Date: Mon, 24 Feb 2025 23:13:34 +0000 Subject: [PATCH 4/4] deploy: 8b3dd38dfa069279883fc5eea4618f448104010e --- docs/references/elements/Button.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index 73fc711..6358e61 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -1,6 +1,5 @@ # Button : VisualElement The Button is a standard button element with click handling and state management. -@configDescription Standard button element with click handling and state management ## Properties