diff --git a/docs/references/elementManager.md b/docs/references/elementManager.md index 8f759b0..4e0278d 100644 --- a/docs/references/elementManager.md +++ b/docs/references/elementManager.md @@ -6,10 +6,51 @@ _and then applies the plugins to the elements. It also provides a way to get ele |Method|Returns|Description| |---|---|---| +|[ElementManager.configure](#elementmanager-configure-config)|-|Configures the ElementManager| +|[ElementManager.registerDiskMount](#elementmanager-registerdiskmount-mountpath)|-|Registers a disk mount point for loading elements| +|[ElementManager.registerRemoteSource](#elementmanager-registerremotesource-elementname-url)|-|Registers a remote source for an element| +|[ElementManager.tryAutoLoad](#elementmanager-tryautoload-name)|boolean|Tries to load an element from any available source| |[ElementManager.loadElement](#elementmanager-loadelement-name)|-|Loads an element by name. This will load the element and apply any plugins to it.| |[ElementManager.getElement](#elementmanager-getelement-name)|table|Gets an element by name. If the element is not loaded, it will try to load it first.| |[ElementManager.getElementList](#elementmanager-getelementlist)|table|Gets a list of all elements| |[ElementManager.getAPI](#elementmanager-getapi-name)|table|Gets an Plugin API by name| +|[ElementManager.hasElement](#elementmanager-haselement-name)|boolean|Checks if an element exists (is registered)| +|[ElementManager.isElementLoaded](#elementmanager-iselementloaded-name)|boolean|Checks if an element is loaded| +|[ElementManager.clearGlobalCache](#elementmanager-clearglobalcache)|-|Clears the global cache (_G)| +|[ElementManager.getCacheStats](#elementmanager-getcachestats)|table|Gets cache statistics| +|[ElementManager.preloadElements](#elementmanager-preloadelements-elementnames)|-|Preloads elements into the global cache| + +## ElementManager.configure(config) + +Configures the ElementManager + +### Parameters +* `config` `table` Configuration options + +## ElementManager.registerDiskMount(mountPath) + +Registers a disk mount point for loading elements + +### Parameters +* `mountPath` `string` The path to the disk mount + +## ElementManager.registerRemoteSource(elementName, url) + +Registers a remote source for an element + +### Parameters +* `elementName` `string` The name of the element +* `url` `string` The URL to load the element from + +## ElementManager.tryAutoLoad(name) + +Tries to load an element from any available source + +### Parameters +* `name` `string` The element name + +### Returns +* `boolean` `success` Whether the element was loaded ## ElementManager.loadElement(name) @@ -49,3 +90,46 @@ Gets an Plugin API by name ### Returns * `table` `API` The API + +## ElementManager.hasElement(name) + +Checks if an element exists (is registered) + +### Parameters +* `name` `string` The element name + +### Returns +* `boolean` `exists` Whether the element exists + +## ElementManager.isElementLoaded(name) + +Checks if an element is loaded + +### Parameters +* `name` `string` The element name + +### Returns +* `boolean` `loaded` Whether the element is loaded + +## ElementManager.clearGlobalCache() + +Clears the global cache (_G) + +### Usage +```lua +ElementManager.clearGlobalCache() +``` + +## ElementManager.getCacheStats() + +Gets cache statistics + +### Returns +* `table` `stats` Cache statistics with size and element names + +## ElementManager.preloadElements(elementNames) + +Preloads elements into the global cache + +### Parameters +* `elementNames` `table` List of element names to preload diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index 68f7499..73ce16d 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -12,6 +12,7 @@ Extends: `PropertySystem` |name|string|BaseElement|User-defined name for the element| |eventCallbacks|table|BaseElement|Collection of registered event handler functions| |enabled|boolean|BaseElement|Controls event processing for this element| +|states|table|{}|Table of currently active states with their priorities| ## Functions @@ -22,6 +23,14 @@ Extends: `PropertySystem` |[BaseElement:isType](#baseelement-istype-type)|boolean|Tests if element is of or inherits given type| |[BaseElement:listenEvent](#baseelement-listenevent-eventname-enable)|table|Enables/disables event handling for this element| |[BaseElement:registerCallback](#baseelement-registercallback-event-callback)|table|Registers a function to handle specific events| +|[BaseElement:registerState](#baseelement-registerstate-statename-condition-priority)|BaseElement|Registers a state| +|[BaseElement:setState](#baseelement-setstate-statename-priority)|BaseElement|Activates a state| +|[BaseElement:unsetState](#baseelement-unsetstate-statename)|BaseElement|Deactivates a state| +|[BaseElement:hasState](#baseelement-hasstate-statename)|boolean|Checks if state is active| +|[BaseElement:getCurrentState](#baseelement-getcurrentstate)|string|nil|Gets current primary state| +|[BaseElement:getActiveStates](#baseelement-getactivestates)|table|Gets all active states| +|[BaseElement:updateConditionalStates](#baseelement-updateconditionalstates)|BaseElement|Updates conditional states| +|[BaseElement:unregisterState](#baseelement-unregisterstate-statename)|BaseElement|Removes state definition| |[BaseElement:fireEvent](#baseelement-fireevent-event-any)|table|Triggers event callbacks with provided arguments| |[BaseElement:onChange](#baseelement-onchange-property-callback)|table|Watches property changes with callback notification| |[BaseElement:getBaseFrame](#baseelement-getbaseframe)|BaseFrame|Retrieves the root frame of this element's tree| @@ -78,6 +87,80 @@ Adds an event handler function with automatic event registration ### Returns * `table` `self` The BaseElement instance +## BaseElement:registerState(stateName, condition?, priority?) + +Registers a new state with optional auto-condition + +### Parameters +* `stateName` `string` The name of the state +* `condition` *(optional)* `function` Optional: Function that returns true if state is active: function(element) return boolean end +* `priority` *(optional)* `number` Priority (higher = more important, default: 0) + +### Returns +* `BaseElement` `self` The BaseElement instance + +## BaseElement:setState(stateName, priority?) + +Manually activates a state + +### Parameters +* `stateName` `string` The state to activate +* `priority` *(optional)* `number` Optional priority override + +### Returns +* `BaseElement` self + +## BaseElement:unsetState(stateName) + +Manually deactivates a state + +### Parameters +* `stateName` `string` The state to deactivate + +### Returns +* `BaseElement` self + +## BaseElement:hasState(stateName) + +Checks if a state is currently active + +### Parameters +* `stateName` `string` The state to check + +### Returns +* `boolean` isActive + +## BaseElement:getCurrentState() + +Gets the highest priority active state + +### Returns +* `string|nil` `currentState` The state with highest priority + +## BaseElement:getActiveStates() + +Gets all currently active states sorted by priority + +### Returns +* `table` `states` Array of {name, priority} sorted by priority + +## BaseElement:updateConditionalStates() + +Updates all states that have auto-conditions + +### Returns +* `BaseElement` self + +## BaseElement:unregisterState(stateName) + +Removes a state from the registry + +### Parameters +* `stateName` `string` The state to remove + +### Returns +* `BaseElement` self + ## BaseElement:fireEvent(event, any) Executes all registered callbacks for the specified event diff --git a/docs/references/elements/Collection.md b/docs/references/elements/Collection.md new file mode 100644 index 0000000..725aae9 --- /dev/null +++ b/docs/references/elements/Collection.md @@ -0,0 +1,107 @@ +# Collection +_This is the Collection class. It provides a collection of items_ + +Extends: `VisualElement` + +## Properties + +|Property|Type|Default|Description| +|---|---|---|---| +|selectable|boolean|true|Whether items can be selected| +|multiSelection|boolean|false|Whether multiple items can be selected at once| +|selectedBackground|color|blue|Background color for selected items| +|selectedForeground|color|white|Text color for selected items| + +## Events + +|Event|Parameters|Description| +|---|---|---| +|onSelect|`index number, item table`|Fired when an item is selected| + +## Functions + +|Method|Returns|Description| +|---|---|---| +|[Collection:addItem](#collection-additem-text)|Collection|Adds an item to the Collection| +|[Collection:removeItem](#collection-removeitem-index)|Collection|Removes an item from the Collection| +|[Collection:clear](#collection-clear)|Collection|Clears all items from the Collection| +|[Collection:getSelectedItems](#collection-getselecteditems)|table|Gets the currently selected items| +|[Collection:getSelectedItem](#collection-getselecteditem)|selected|Gets first selected item| +|[Collection:onSelect](#collection-onselect-callback)|Collection|Registers a callback for the select event| + +## Collection:addItem(text) + +Adds an item to the Collection + +### Parameters +* `text` `string|table` The item to add (string or item table) + +### Returns +* `Collection` `self` The Collection instance + +### Usage +```lua +Collection:addItem("New Item") +Collection:addItem({text="Item", callback=function() end}) +``` + +## Collection:removeItem(index) + +Removes an item from the Collection + +### Parameters +* `index` `number` The index of the item to remove + +### Returns +* `Collection` `self` The Collection instance + +### Usage +```lua +Collection:removeItem(1) +``` + +## Collection:clear() + +Clears all items from the Collection + +### Returns +* `Collection` `self` The Collection instance + +### Usage +```lua +Collection:clear() +``` + +## Collection:getSelectedItems() + +Gets the currently selected items + +### Returns +* `table` `selected` Collection of selected items + +### Usage +```lua +local selected = Collection:getSelectedItems() +``` + +## Collection:getSelectedItem() + +Gets first selected item + +### Returns +* `selected` `The` first item + +## Collection:onSelect(callback) + +Registers a callback for the select event + +### Parameters +* `callback` `function` The callback function to register + +### Returns +* `Collection` `self` The Collection instance + +### Usage +```lua +Collection:onSelect(function(index, item) print("Selected item:", index, item) end) +``` diff --git a/docs/references/elements/ComboBox.md b/docs/references/elements/ComboBox.md index bce4d8e..28d087e 100644 --- a/docs/references/elements/ComboBox.md +++ b/docs/references/elements/ComboBox.md @@ -14,8 +14,6 @@ Extends: `DropDown` |viewOffset|number|0|Horizontal scroll position for viewing long text| |placeholder|string|"..."|Text shown when the input is empty| |placeholderColor|color|gray|Color used for placeholder text| -|focusedBackground|color|blue|Background color when input is focused| -|focusedForeground|color|white|Text color when input is focused| |autoComplete|boolean|false|Enables filtering dropdown items while typing| |manuallyOpened|boolean|false|Indicates if dropdown was opened by user action| @@ -24,14 +22,8 @@ Extends: `DropDown` |Method|Returns|Description| |---|---|---| |[ComboBox.new](#combobox-new)|ComboBox|Creates a new ComboBox instance| -|[ComboBox:setText](#combobox-settext-text)|ComboBox|Sets the text content| -|[ComboBox:getText](#combobox-gettext)|string|Gets the text content| -|[ComboBox:setEditable](#combobox-seteditable-editable)|ComboBox|Sets editable state| |[ComboBox:char](#combobox-char-char)|-|Handles character input| |[ComboBox:key](#combobox-key-key-held)|-|Handles key input| -|[ComboBox:render](#combobox-render)|-|Renders the ComboBox| -|[ComboBox:focus](#combobox-focus)|-|Called when gaining focus| -|[ComboBox:blur](#combobox-blur)|-|Called when losing focus| ## ComboBox.new() @@ -40,33 +32,6 @@ Creates a new ComboBox instance ### Returns * `ComboBox` `self` The newly created ComboBox instance -## ComboBox:setText(text) - -Sets the text content of the ComboBox - -### Parameters -* `text` `string` The text to set - -### Returns -* `ComboBox` self - -## ComboBox:getText() - -Gets the current text content - -### Returns -* `string` `text` The current text - -## ComboBox:setEditable(editable) - -Sets whether the ComboBox is editable - -### Parameters -* `editable` `boolean` Whether the ComboBox should be editable - -### Returns -* `ComboBox` self - ## ComboBox:char(char) Handles character input when editable @@ -81,15 +46,3 @@ Handles key input when editable ### Parameters * `key` `number` The key code that was pressed * `held` `boolean` Whether the key is being held - -## ComboBox:render() - -Renders the ComboBox - -## ComboBox:focus() - -Called when the ComboBox gains focus - -## ComboBox:blur() - -Called when the ComboBox loses focus diff --git a/docs/references/elements/DropDown.md b/docs/references/elements/DropDown.md index 4e5d180..8ba9cc8 100644 --- a/docs/references/elements/DropDown.md +++ b/docs/references/elements/DropDown.md @@ -7,7 +7,6 @@ Extends: `List` |Property|Type|Default|Description| |---|---|---|---| -|isOpen|boolean|false|Controls the expanded/collapsed state| |dropdownHeight|number|5|Maximum visible items when expanded| |selectedText|string|""|Text shown when no selection made| |dropSymbol|string|"\31"|Indicator for dropdown state| diff --git a/docs/references/elements/Input.md b/docs/references/elements/Input.md index f6b8051..657e59c 100644 --- a/docs/references/elements/Input.md +++ b/docs/references/elements/Input.md @@ -13,8 +13,6 @@ Extends: `VisualElement` |viewOffset|number|0|The horizontal scroll offset for viewing long text| |placeholder|string|...|Text to display when input is empty| |placeholderColor|color|gray|Color of the placeholder text| -|focusedBackground|color|blue|Background color when input is focused| -|focusedForeground|color|white|Foreground color when input is focused| |cursorColor|number|nil|Color of the cursor| |replaceChar|string|nil|Character to replace the input with (for password fields)| diff --git a/docs/references/elements/List.md b/docs/references/elements/List.md index 8be9e0d..4424c45 100644 --- a/docs/references/elements/List.md +++ b/docs/references/elements/List.md @@ -2,18 +2,13 @@ _This is the list class. It provides a scrollable list of selectable items with support for _ _custom item rendering, separators, and selection handling._ -Extends: `VisualElement` +Extends: `Collection` ## Properties |Property|Type|Default|Description| |---|---|---|---| -|items|table|{}|List of items to display. Items can be tables with properties including selected state| -|selectable|boolean|true|Whether items in the list can be selected| -|multiSelection|boolean|false|Whether multiple items can be selected at once| |offset|number|0|Current scroll offset for viewing long lists| -|selectedBackground|color|blue|Background color for selected items| -|selectedForeground|color|white|Text color for selected items| ## Events @@ -25,77 +20,10 @@ Extends: `VisualElement` |Method|Returns|Description| |---|---|---| -|[List:addItem](#list-additem-text)|List|Adds an item to the list| -|[List:removeItem](#list-removeitem-index)|List|Removes an item from the list| -|[List:clear](#list-clear)|List|Clears all items from the list| -|[List:getSelectedItems](#list-getselecteditems)|table|Gets the currently selected items| -|[List:getSelectedItem](#list-getselecteditem)|selected|Gets first selected item| |[List:onSelect](#list-onselect-callback)|List|Registers a callback for the select event| |[List:scrollToBottom](#list-scrolltobottom)|List|Scrolls the list to the bottom| |[List:scrollToTop](#list-scrolltotop)|List|Scrolls the list to the top| -## List:addItem(text) - -Adds an item to the list - -### Parameters -* `text` `string|table` The item to add (string or item table) - -### Returns -* `List` `self` The List instance - -### Usage -```lua -list:addItem("New Item") -list:addItem({text="Item", callback=function() end}) -``` - -## List:removeItem(index) - -Removes an item from the list - -### Parameters -* `index` `number` The index of the item to remove - -### Returns -* `List` `self` The List instance - -### Usage -```lua -list:removeItem(1) -``` - -## List:clear() - -Clears all items from the list - -### Returns -* `List` `self` The List instance - -### Usage -```lua -list:clear() -``` - -## List:getSelectedItems() - -Gets the currently selected items - -### Returns -* `table` `selected` List of selected items - -### Usage -```lua -local selected = list:getSelectedItems() -``` - -## List:getSelectedItem() - -Gets first selected item - -### Returns -* `selected` `The` first item - ## List:onSelect(callback) Registers a callback for the select event diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 4194944..7de9810 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -15,15 +15,12 @@ Extends: `BaseElement` |height|number|1|The height of the element| |background|color|black|The background color| |foreground|color|white|The text/foreground color| -|clicked|boolean|false|Whether the element is currently clicked| -|hover|boolean|false|Whether the mouse is currently hover over the element (Craftos-PC only)| |backgroundEnabled|boolean|true|Whether to render the background| |borderTop|boolean|false|Draw top border| |borderBottom|boolean|false|Draw bottom border| |borderLeft|boolean|false|Draw left border| |borderRight|boolean|false|Draw right border| |borderColor|color|white|Border color| -|focused|boolean|false|Whether the element has input focus| |visible|boolean|true|Whether the element is visible| |ignoreOffset|boolean|false|Whether to ignore the parent's offset| @@ -37,7 +34,40 @@ Extends: `BaseElement` |Method|Returns|Description| |---|---|---| +|[VisualElement:setConstraint](#visualelement-setconstraint-property-targetelement-targetproperty-offset)|VisualElement|Sets a constraint on a property relative to another element's property| +|[VisualElement:resolveAllConstraints](#visualelement-resolveallconstraints)|VisualElement|Resolves all constraints for the element| +|[VisualElement:removeConstraint](#visualelement-removeconstraint-property)|VisualElement|Removes a constraint from the element| +|[VisualElement:updateConstraints](#visualelement-updateconstraints)|VisualElement|Updates all constraints, recalculating positions and sizes| +|[VisualElement:alignRight](#visualelement-alignright-target-offset)|VisualElement|Aligns the element's right edge to the target's right edge with optional offset| +|[VisualElement:alignLeft](#visualelement-alignleft-target-offset)|VisualElement|Aligns the element's left edge to the target's left edge with optional offset| +|[VisualElement:alignTop](#visualelement-aligntop-target-offset)|VisualElement|Aligns the element's top edge to the target's top edge with optional offset| +|[VisualElement:alignBottom](#visualelement-alignbottom-target-offset)|VisualElement|Aligns the element's bottom edge to the target's bottom edge with optional offset| +|[VisualElement:centerHorizontal](#visualelement-centerhorizontal-target-offset)|VisualElement|Centers the element horizontally relative to the target with optional offset| +|[VisualElement:centerVertical](#visualelement-centervertical-target-offset)|VisualElement|Centers the element vertically relative to the target with optional offset| +|[VisualElement:centerIn](#visualelement-centerin-target)|VisualElement|Centers the element both horizontally and vertically relative to the target| +|[VisualElement:rightOf](#visualelement-rightof-target-gap)|VisualElement|Positions the element to the right of the target with optional gap| +|[VisualElement:leftOf](#visualelement-leftof-target-gap)|VisualElement|Positions the element to the left of the target with optional gap| +|[VisualElement:below](#visualelement-below-target-gap)|VisualElement|Positions the element below the target with optional gap| +|[VisualElement:above](#visualelement-above-target-gap)|VisualElement|Positions the element above the target with optional gap| +|[VisualElement:stretchWidth](#visualelement-stretchwidth-target-margin)|VisualElement|Stretches the element to match the target's width with optional margin| +|[VisualElement:stretchHeight](#visualelement-stretchheight-target-margin)|VisualElement|Stretches the element to match the target's height with optional margin| +|[VisualElement:stretch](#visualelement-stretch-target-margin)|VisualElement|Stretches the element to match the target's width and height with optional margin| +|[VisualElement:widthPercent](#visualelement-widthpercent-target-percent)|VisualElement|Sets the element's width as a percentage of the target's width| +|[VisualElement:heightPercent](#visualelement-heightpercent-target-percent)|VisualElement|Sets the element's height as a percentage of the target's height| +|[VisualElement:matchWidth](#visualelement-matchwidth-target-offset)|VisualElement|Matches the element's width to the target's width with optional offset| +|[VisualElement:matchHeight](#visualelement-matchheight-target-offset)|VisualElement|Matches the element's height to the target's height with optional offset| +|[VisualElement:fillParent](#visualelement-fillparent-margin)|VisualElement|Stretches the element to fill its parent's width and height with optional margin| +|[VisualElement:fillWidth](#visualelement-fillwidth-margin)|VisualElement|Stretches the element to fill its parent's width with optional margin| +|[VisualElement:fillHeight](#visualelement-fillheight-margin)|VisualElement|Stretches the element to fill its parent's height with optional margin| +|[VisualElement:center](#visualelement-center)|VisualElement|Centers the element within its parent both horizontally and vertically| +|[VisualElement:toRight](#visualelement-toright-gap)|VisualElement|Aligns the element's right edge to its parent's right edge with optional gap| +|[VisualElement:toLeft](#visualelement-toleft-gap)|VisualElement|Aligns the element's left edge to its parent's left edge with optional gap| +|[VisualElement:toTop](#visualelement-totop-gap)|VisualElement|Aligns the element's top edge to its parent's top edge with optional gap| +|[VisualElement:toBottom](#visualelement-tobottom-gap)|VisualElement|Aligns the element's bottom edge to its parent's bottom edge with optional gap| |[VisualElement:isInBounds](#visualelement-isinbounds-x-y)|boolean|Checks if point is within bounds| +|[VisualElement:setFocused](#visualelement-setfocused-focused-internal)|VisualElement|Sets focus state| +|[VisualElement:isFocused](#visualelement-isfocused)|boolean|Checks if element is focused| +|[VisualElement:isFocused](#visualelement-isfocused)|boolean|Checks if element is focused| |[VisualElement:addBorder](#visualelement-addborder-colororoptions)|VisualElement|Adds or updates a drawable character border around the element using the canvas plugin. The border will automatically adapt to size/background changes because the command reads current properties each render.| @@ -47,6 +77,317 @@ reads current properties each render.| |[VisualElement:getRelativePosition](#visualelement-getrelativeposition-x-y)|number, number|Returns the relative position of the element| |[VisualElement:prioritize](#visualelement-prioritize)|VisualElement|Prioritizes the element by moving it to the top of its parent's children| +## VisualElement:setConstraint(property, targetElement, targetProperty, offset) + +Sets a constraint on a property relative to another element's property + +### Parameters +* `property` `string` The property to constrain (x, y, width, height, left, right, top, bottom, centerX, centerY) +* `targetElement` `BaseElement|string` The target element or "parent" +* `targetProperty` `string` The target property to constrain to (left, right, top, bottom, centerX, centerY, width, height) +* `offset` `number` The offset to apply (negative = inside, positive = outside, fractional = percentage) + +### Returns +* `VisualElement` `self` The element instance + +## VisualElement:resolveAllConstraints() + +Resolves all constraints for the element + +### Returns +* `VisualElement` `self` The element instance + +## VisualElement:removeConstraint(property) + +Removes a constraint from the element + +### Parameters +* `property` `string` The property of the constraint to remove + +### Returns +* `VisualElement` `self` The element instance + +## VisualElement:updateConstraints() + +Updates all constraints, recalculating positions and sizes + +### Returns +* `VisualElement` `self` The element instance + +## VisualElement:alignRight(target, offset?) + +Aligns the element's right edge to the target's right edge with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Offset from the edge (negative = inside, positive = outside, default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:alignLeft(target, offset?) + +Aligns the element's left edge to the target's left edge with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Offset from the edge (negative = inside, positive = outside, default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:alignTop(target, offset?) + +Aligns the element's top edge to the target's top edge with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Offset from the edge (negative = inside, positive = outside, default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:alignBottom(target, offset?) + +Aligns the element's bottom edge to the target's bottom edge with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Offset from the edge (negative = inside, positive = outside, default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:centerHorizontal(target, offset?) + +Centers the element horizontally relative to the target with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Horizontal offset from center (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:centerVertical(target, offset?) + +Centers the element vertically relative to the target with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Vertical offset from center (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:centerIn(target) + +Centers the element both horizontally and vertically relative to the target + +### Parameters +* `target` `BaseElement|string` The target element or "parent" + +### Returns +* `VisualElement` self + +## VisualElement:rightOf(target, gap?) + +Positions the element to the right of the target with optional gap + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `gap` *(optional)* `number` Gap between elements (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:leftOf(target, gap?) + +Positions the element to the left of the target with optional gap + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `gap` *(optional)* `number` Gap between elements (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:below(target, gap?) + +Positions the element below the target with optional gap + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `gap` *(optional)* `number` Gap between elements (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:above(target, gap?) + +Positions the element above the target with optional gap + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `gap` *(optional)* `number` Gap between elements (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:stretchWidth(target, margin?) + +Stretches the element to match the target's width with optional margin + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `margin` *(optional)* `number` Margin on each side (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:stretchHeight(target, margin?) + +Stretches the element to match the target's height with optional margin + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `margin` *(optional)* `number` Margin on top and bottom (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:stretch(target, margin?) + +Stretches the element to match the target's width and height with optional margin + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `margin` *(optional)* `number` Margin on all sides (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:widthPercent(target, percent) + +Sets the element's width as a percentage of the target's width + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `percent` `number` Percentage of target's width (0-100) + +### Returns +* `VisualElement` self + +## VisualElement:heightPercent(target, percent) + +Sets the element's height as a percentage of the target's height + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `percent` `number` Percentage of target's height (0-100) + +### Returns +* `VisualElement` self + +## VisualElement:matchWidth(target, offset?) + +Matches the element's width to the target's width with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Offset to add to target's width (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:matchHeight(target, offset?) + +Matches the element's height to the target's height with optional offset + +### Parameters +* `target` `BaseElement|string` The target element or "parent" +* `offset` *(optional)* `number` Offset to add to target's height (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:fillParent(margin?) + +Stretches the element to fill its parent's width and height with optional margin + +### Parameters +* `margin` *(optional)* `number` Margin on all sides (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:fillWidth(margin?) + +Stretches the element to fill its parent's width with optional margin + +### Parameters +* `margin` *(optional)* `number` Margin on left and right (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:fillHeight(margin?) + +Stretches the element to fill its parent's height with optional margin + +### Parameters +* `margin` *(optional)* `number` Margin on top and bottom (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:center() + +Centers the element within its parent both horizontally and vertically + +### Returns +* `VisualElement` self + +## VisualElement:toRight(gap?) + +Aligns the element's right edge to its parent's right edge with optional gap + +### Parameters +* `gap` *(optional)* `number` Gap from the edge (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:toLeft(gap?) + +Aligns the element's left edge to its parent's left edge with optional gap + +### Parameters +* `gap` *(optional)* `number` Gap from the edge (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:toTop(gap?) + +Aligns the element's top edge to its parent's top edge with optional gap + +### Parameters +* `gap` *(optional)* `number` Gap from the edge (default: 0) + +### Returns +* `VisualElement` self + +## VisualElement:toBottom(gap?) + +Aligns the element's bottom edge to its parent's bottom edge with optional gap + +### Parameters +* `gap` *(optional)* `number` Gap from the edge (default: 0) + +### Returns +* `VisualElement` self + ## VisualElement:isInBounds(x, y) Checks if the specified coordinates are within the bounds of the element @@ -58,6 +399,31 @@ 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:setFocused(focused, internal?) + +Sets or removes focus from this element + +### Parameters +* `focused` `boolean` Whether to focus or blur +* `internal` *(optional)* `boolean` Internal flag to prevent parent notification + +### Returns +* `VisualElement` self + +## VisualElement:isFocused() + +Gets whether this element is focused + +### Returns +* `boolean` isFocused + +## VisualElement:isFocused() + +Gets whether this element is focused + +### Returns +* `boolean` isFocused + ## VisualElement:addBorder(colorOrOptions) Adds or updates a drawable character border around the element using the canvas plugin. diff --git a/docs/references/libraries/collectionentry.md b/docs/references/libraries/collectionentry.md new file mode 100644 index 0000000..84c33e9 --- /dev/null +++ b/docs/references/libraries/collectionentry.md @@ -0,0 +1 @@ +!! EMPTY MARKDOWN GENERATED !! diff --git a/docs/references/main.md b/docs/references/main.md index f4f8f8c..088f9a6 100644 --- a/docs/references/main.md +++ b/docs/references/main.md @@ -27,6 +27,10 @@ _What this code does is it loads basalt into the project, and you can access it |[basalt.onEvent](#basalt-onevent-eventname-callback)|-|Registers an event callback| |[basalt.removeEvent](#basalt-removeevent-eventname-callback)|boolean|Removes an event callback| |[basalt.triggerEvent](#basalt-triggerevent-eventname)|-|Triggers a custom event| +|[basalt.requireElements](#basalt-requireelements-elements-autoload)|-|Requires elements for the application| +|[basalt.loadManifest](#basalt-loadmanifest-path)|table|Loads an application manifest| +|[basalt.install](#basalt-install-elementname-source)|-|Installs an element| +|[basalt.configure](#basalt-configure-config)|-|Configures element loading behavior| ## basalt.create(type, properties?) @@ -194,3 +198,58 @@ Triggers a custom event and calls all registered callbacks ```lua basalt.triggerEvent("custom_event", "data1", "data2") ``` + +## basalt.requireElements(elements, autoLoad?) + +Requires specific elements and validates they are available + +### Parameters +* `elements` `table|string` List of element names or single element name +* `autoLoad` *(optional)* `boolean` Whether to automatically load missing elements (default: false) + +### Usage +```lua +basalt.requireElements({"Button", "Label", "Slider"}) +basalt.requireElements("Button", true) +``` + +## basalt.loadManifest(path) + +Loads a manifest file that describes element requirements and configuration + +### Parameters +* `path` `string` The path to the manifest file + +### Returns +* `table` `manifest` The loaded manifest data + +### Usage +```lua +basalt.loadManifest("myapp.manifest") +``` + +## basalt.install(elementName, source?) + +Installs an element interactively or from a specified source + +### Parameters +* `elementName` `string` The name of the element to install +* `source` *(optional)* `string` Optional source URL or path + +### Usage +```lua +basalt.install("Slider") +basalt.install("Slider", "https://example.com/slider.lua") +``` + +## basalt.configure(config) + +Configures the ElementManager (shortcut to elementManager.configure) + +### Parameters +* `config` `table` Configuration options + +### Usage +```lua +basalt.configure({allowRemoteLoading = true, useGlobalCache = true}) +```