deploy: 8b6eaccd18
This commit is contained in:
@@ -1,62 +1,64 @@
|
||||
# VisualElement : BaseElement
|
||||
This is the visual element class. It serves as the base class for all visual UI elements
|
||||
and provides core functionality for positioning, sizing, colors, and rendering.
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|x|number|1|x position of the element
|
||||
|y|number|1|y position of the element
|
||||
|z|number|1|z position of the element
|
||||
|width|number|1|width of the element
|
||||
|height|number|1|height of the element
|
||||
|background|color|black|background color of the element
|
||||
|foreground|color|white|foreground color of the element
|
||||
|clicked|boolean|an|false element is currently clicked
|
||||
|backgroundEnabled|boolean|true|whether the background is enabled
|
||||
|focused|boolean|false|whether the element is focused
|
||||
|visible|boolean|true|whether the element is visible
|
||||
|x|number|1|The horizontal position relative to parent
|
||||
|y|number|1|The vertical position relative to parent
|
||||
|z|number|1|The z-index for layering elements
|
||||
|width|number|1|The width of the element
|
||||
|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
|
||||
|backgroundEnabled|boolean|true|Whether to render the background
|
||||
|focused|boolean|false|Whether the element has input focus
|
||||
|visible|boolean|true|Whether the element is visible
|
||||
|
||||
## Combined Properties
|
||||
|
||||
|Name|Properties|Description|
|
||||
|---|---|---|
|
||||
|position|{x|y}|Position of the element
|
||||
|size|{width|height}|Size of the element
|
||||
|color|{foreground|background}|Color of the element
|
||||
|position|`x y`|Combined x, y position|
|
||||
|size|`width height`|Combined width, height|
|
||||
|color|`foreground background`|Combined foreground, background colors|
|
||||
|
||||
## Events
|
||||
|
||||
|Event|Parameters|Description|
|
||||
|---|---|---|
|
||||
|onMouseClick|`button number, x number, y number`|Fired when the element is clicked|
|
||||
|onMouseUp|`button number, x number, y number`|Fired when the mouse is released|
|
||||
|onMouseRelease|`button number, x number, y number`|Fired when the mouse is released|
|
||||
|onMouseDrag|`button number, x number, y number`|Fired when the mouse is dragged|
|
||||
|onFocus|`-`|Fired when the element is focused|
|
||||
|onBlur|`-`|Fired when the element is blurred|
|
||||
|onKey|`key number, code number, isRepeat boolean`|Fired when a key is pressed|
|
||||
|onKeyUp|`key number, code number`|Fired when a key is released|
|
||||
|onChar|`char string`|Fired when a key is pressed|
|
||||
|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|
|
||||
|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|
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[VisualElement.new](#VisualElement.new)|VisualElement|
|
||||
|[VisualElement:blit](#VisualElement:blit)|-|
|
||||
|[VisualElement:blur](#VisualElement:blur)|-|
|
||||
|[VisualElement:focus](#VisualElement:focus)|-|
|
||||
|[VisualElement:getAbsolutePosition](#VisualElement:getAbsolutePosition)|-|
|
||||
|[VisualElement:getRelativePosition](#VisualElement:getRelativePosition)|number,|
|
||||
|[VisualElement:init](#VisualElement:init)|-|
|
||||
|[VisualElement:isInBounds](#VisualElement:isInBounds)|boolean|
|
||||
|[VisualElement:mouse_click](#VisualElement:mouse_click)|boolean|
|
||||
|[VisualElement:mouse_release](#VisualElement:mouse_release)|boolean|
|
||||
|[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean|
|
||||
|[VisualElement:render](#VisualElement:render)|-|
|
||||
|[VisualElement:setCursor](#VisualElement:setCursor)|-|
|
||||
|[VisualElement:textBg](#VisualElement:textBg)|-|
|
||||
|[VisualElement:textFg](#VisualElement:textFg)|-|
|
||||
|[VisualElement.new](#VisualElement.new)|VisualElement|Creates a new visual element
|
||||
|[VisualElement:blit](#VisualElement:blit)|-|Draws text with both colors
|
||||
|[VisualElement:blur](#VisualElement:blur)|-|Handles a blur event
|
||||
|[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_release](#VisualElement:mouse_release)|boolean|Handles a mouse release event
|
||||
|[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean|Handles a mouse up event
|
||||
|[VisualElement:render](#VisualElement:render)|-|Renders the element
|
||||
|[VisualElement:setCursor](#VisualElement:setCursor)|-|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
|
||||
@@ -74,7 +76,7 @@ local element = VisualElement.new("myId", basalt)
|
||||
```
|
||||
|
||||
## VisualElement:blit(x, y, text, fg, bg)
|
||||
Draws a text character with a foreground and background at the specified position, used in the rendering system
|
||||
Draws text with both foreground and background colors
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to draw
|
||||
@@ -106,9 +108,13 @@ Returns the relative position of the element or the given coordinates.
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## VisualElement:init()
|
||||
## VisualElement:init(props, basalt)
|
||||
Initializes the VisualElement instance
|
||||
|
||||
### Parameters
|
||||
* `props` `table` The properties to initialize the element with
|
||||
* `basalt` `table` The basalt instance
|
||||
|
||||
## VisualElement:isInBounds(x, y)
|
||||
Checks if the specified coordinates are within the bounds of the element
|
||||
|
||||
@@ -164,7 +170,7 @@ Sets the cursor position
|
||||
* `blink` `boolean` Whether the cursor should blink
|
||||
|
||||
## VisualElement:textBg(x, y, text, bg)
|
||||
Draws a text character with a background at the specified position, used in the rendering system
|
||||
Draws text with background color
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to draw
|
||||
@@ -173,7 +179,7 @@ Draws a text character with a background at the specified position, used in the
|
||||
* `bg` `color` The background color
|
||||
|
||||
## VisualElement:textFg(x, y, text, fg)
|
||||
Draws a text character at the specified position, used in the rendering system
|
||||
Draws text with foreground color
|
||||
|
||||
### Parameters
|
||||
* `x` `number` The x position to draw
|
||||
@@ -181,3 +187,4 @@ Draws a text character at the specified position, used in the rendering system
|
||||
* `text` `string` The text char to draw
|
||||
* `fg` `color` The foreground color
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user