Basalt 1.7 Update
- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
This commit is contained in:
31
docs/objects/VisualObject/addBG.md
Normal file
31
docs/objects/VisualObject/addBG.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## addBG
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom background to the object within the draw function. The background is displayed at the specified coordinates relative to the object.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `string` The background color as string
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomBackground(self)
|
||||
self:addBG(1, 1, "4444444")
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customBackground", drawCustomBackground)
|
||||
```
|
||||
|
||||
In this example, a custom draw function named `drawCustomBackground` is created. Within the function, `addBG` is used to add a background at the position (1, 1) relative to the object. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
33
docs/objects/VisualObject/addBackgroundBox.md
Normal file
33
docs/objects/VisualObject/addBackgroundBox.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## addBackgroundBox
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom background box to the object within the draw function. The box is displayed at the specified coordinates relative to the object and has the specified width and height.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `number` width
|
||||
4. `number` height
|
||||
5. `number|color` The background color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomBackgroundBox(self)
|
||||
self:addBackgroundBox(1, 1, 10, 5, colors.red)
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customBackgroundBox", drawCustomBackgroundBox)
|
||||
```
|
||||
|
||||
In this example, a custom draw function named `drawCustomBackgroundBox` is created. Within the function, `addBackgroundBox` is used to add a background box with a colors.red background color at the position (1, 1) relative to the object, with a width of 10 and a height of 5. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
33
docs/objects/VisualObject/addBlit.md
Normal file
33
docs/objects/VisualObject/addBlit.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## addBlit
|
||||
|
||||
### Description
|
||||
|
||||
Adds custom text, background, and foreground to the object within the draw function. The text, background, and foreground are displayed at the specified coordinates relative to the object.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `string` The text to display
|
||||
4. `string` The foreground color
|
||||
5. `string` The background color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomBlit(self)
|
||||
self:addBlit(1, 1, "Hello", "22222", "66666")
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customBlit", drawCustomBlit)
|
||||
```
|
||||
|
||||
In this example, a custom draw function named `drawCustomBlit` is created. Within the function, `addBlit` is used to add text "Hello", a background color, and a foreground color at the position (1, 1) relative to the object. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
33
docs/objects/VisualObject/addDraw.md
Normal file
33
docs/objects/VisualObject/addDraw.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## addDraw
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom drawing function to the object, allowing users to create their own graphical representations using code.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Name (ID) - must be unique
|
||||
2. `function` The function to be executed, containing the custom drawing code
|
||||
3. `number` Optional - Position, determines the order or priority of the drawing
|
||||
4. `number` Optional - Determines if the drawing should be added to the preDrawQueue, postDrawQueue, or drawQueue. `1` = drawQueue, `2` = preDrawQueue, `3` = postDrawQueue (default is drawQueue)
|
||||
5. `boolean` Optional - Whether the drawing should be rendered immediately or not, default is `true`
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function customDrawing()
|
||||
-- Custom drawing code goes here
|
||||
end
|
||||
|
||||
mainFrame:addDraw("uniqueID", customDrawing)
|
||||
```
|
||||
|
||||
In this example, a custom drawing function is added to the main frame. The custom drawing code should be placed inside the `customDrawing` function. The drawing is given a unique ID, a position of 1, added to the drawQueue, and rendered immediately.
|
||||
31
docs/objects/VisualObject/addFG.md
Normal file
31
docs/objects/VisualObject/addFG.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## addFG
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom foreground to the object within the draw function. The foreground is displayed at the specified coordinates relative to the object.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `string` The foreground color as string
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomForeground(self)
|
||||
self:addFG(1, 1, "777777")
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customForeground", drawCustomForeground)
|
||||
```
|
||||
|
||||
In this example, a custom draw function named `drawCustomForeground` is created. Within the function, `addFG` is used to add a foreground at the position (1, 1) relative to the object. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
33
docs/objects/VisualObject/addForegroundBox.md
Normal file
33
docs/objects/VisualObject/addForegroundBox.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## addForegroundBox
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom foreground box to the object within the draw function. The box is displayed at the specified coordinates relative to the object and has the specified width and height.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `number` width
|
||||
4. `number` height
|
||||
5. `number|color` The foreground color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomForegroundBox(self)
|
||||
self:addForegroundBox(1, 1, 10, 5, colors.blue)
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customForegroundBox", drawCustomForegroundBox)
|
||||
```
|
||||
|
||||
n this example, a custom draw function named `drawCustomForegroundBox` is created. Within the function, `addForegroundBox` is used to add a foreground box with a colors.blue foreground color at the position (1, 1) relative to the object, with a width of 10 and a height of 5. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
32
docs/objects/VisualObject/addPostDraw.md
Normal file
32
docs/objects/VisualObject/addPostDraw.md
Normal file
@@ -0,0 +1,32 @@
|
||||
## addPostDraw
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom drawing function to the object's postDrawQueue. Functions in the postDrawQueue are executed after the main drawing functions. This allows users to create custom graphical representations that will be drawn in front of the main elements.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Name (ID) - must be unique
|
||||
2. `function` The function to be executed, containing the custom drawing code
|
||||
3. `number` Optional - Position, determines the order or priority of the drawing
|
||||
4. `boolean` Optional - Whether the drawing should be rendered immediately or not, default is `true`
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function customPostDrawing()
|
||||
-- Custom drawing code goes here
|
||||
end
|
||||
|
||||
mainFrame:addPreDraw("uniqueID", customPostDrawing)
|
||||
```
|
||||
|
||||
In this example, a custom drawing function is added to the main frame's postDrawQueue. The custom drawing code should be placed inside the `customPostDrawing` function. The drawing is given a unique ID, a position of 1, and rendered immediately.
|
||||
32
docs/objects/VisualObject/addPreDraw.md
Normal file
32
docs/objects/VisualObject/addPreDraw.md
Normal file
@@ -0,0 +1,32 @@
|
||||
## addPreDraw
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom drawing function to the object's preDrawQueue. Functions in the preDrawQueue are executed before the main drawing functions. This allows users to create custom graphical representations that will be drawn behind the main elements.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Name (ID) - must be unique
|
||||
2. `function` The function to be executed, containing the custom drawing code
|
||||
3. `number` Optional - Position, determines the order or priority of the drawing
|
||||
4. `boolean` Optional - Whether the drawing should be rendered immediately or not, default is `true`
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function customPreDrawing()
|
||||
-- Custom drawing code goes here
|
||||
end
|
||||
|
||||
mainFrame:addPreDraw("uniqueID", customPreDrawing)
|
||||
```
|
||||
|
||||
In this example, a custom drawing function is added to the main frame's preDrawQueue. The custom drawing code should be placed inside the `customPreDrawing` function. The drawing is given a unique ID, a position of 1, and rendered immediately.
|
||||
31
docs/objects/VisualObject/addText.md
Normal file
31
docs/objects/VisualObject/addText.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## addText
|
||||
|
||||
### Description
|
||||
|
||||
Adds custom text to the object within the draw function. The text is displayed at the specified coordinates relative to the object.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `string` The text to be displayed
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomText(self)
|
||||
self:addText(2, 3, "Custom Text")
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customText", drawCustomText)
|
||||
```
|
||||
|
||||
In this example, a custom draw function named `drawCustomText` is created. Within the function, `addText` is used to add the text "Custom Text" at the position (2, 3) relative to the object. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
33
docs/objects/VisualObject/addTextBox.md
Normal file
33
docs/objects/VisualObject/addTextBox.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## addTextBox
|
||||
|
||||
### Description
|
||||
|
||||
Adds a custom text box to the object within the draw function. The text box is displayed at the specified coordinates relative to the object and has the specified width and height.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `number` width
|
||||
4. `number` height
|
||||
5. `string` The text to be displayed in the box
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function drawCustomTextBox(self)
|
||||
self:addTextBox(1, 1, 10, 5, "#")
|
||||
end
|
||||
|
||||
mainFrame:addDraw("customTextBox", drawCustomTextBox)
|
||||
```
|
||||
|
||||
In this example, a custom draw function named `drawCustomTextBox` is created. Within the function, `addTextBox` is used to add a text box with the text "#" at the position (1, 1) relative to the object, with a width of 10 and a height of 5. The `addDraw` function is then used to add the custom draw function to the main frame.
|
||||
26
docs/objects/VisualObject/addTexture.md
Normal file
26
docs/objects/VisualObject/addTexture.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## addTexture
|
||||
|
||||
### Description
|
||||
|
||||
Adds a texture to an object. A texture is a bimg image, stored on your computer.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Path to your bimg file
|
||||
2. `boolean` Optional - If the bimg image has animations, set this to true to be able to play it (default is false)
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Adds a texture to a frame:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
mainFrame:addTexture("path/to/texture.bimg", true)
|
||||
```
|
||||
33
docs/objects/VisualObject/animateOffset.md
Normal file
33
docs/objects/VisualObject/animateOffset.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## animateOffset
|
||||
|
||||
### Description
|
||||
|
||||
Animates the offset of an object within a specified time frame.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-offset
|
||||
2. `number` y-offset
|
||||
3. `number` Duration of the animation in seconds
|
||||
4. `number` Optional - offset in seconds
|
||||
5. `string` Optional - Animation mode
|
||||
6. `function` Optional - callback function, called when the animation is completed
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Animates the offset of a frame to an x-offset of 3 and a y-offset of 4 within 2 seconds:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aFrame = mainFrame:addFrame():setPosition(2, 3)
|
||||
|
||||
aFrame:animateOffset(3, 4, 2, 0, "linear", function()
|
||||
basalt.debug("Animation completed!")
|
||||
end)
|
||||
```
|
||||
33
docs/objects/VisualObject/animatePosition.md
Normal file
33
docs/objects/VisualObject/animatePosition.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## animatePosition
|
||||
|
||||
### Description
|
||||
|
||||
Animates the position of an object within a specified time frame.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` x-coordinate
|
||||
2. `number` y-coordinate
|
||||
3. `number` Duration of the animation in seconds
|
||||
4. `number` Optional - offset in seconds
|
||||
5. `string` Optional - Animation mode
|
||||
6. `function` Optional - callback function, called when the animation is completed
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Animates the position of a button within 2 seconds to the coordinates (5, 5):
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(2, 3)
|
||||
|
||||
aButton:animatePosition(5, 5, 2, 0, "linear", function()
|
||||
basalt.debug("Animation completed!")
|
||||
end)
|
||||
```
|
||||
33
docs/objects/VisualObject/animateSize.md
Normal file
33
docs/objects/VisualObject/animateSize.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## animateSize
|
||||
|
||||
### Description
|
||||
|
||||
Animates the size of an object within a specified time frame.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` Width
|
||||
2. `number` Height
|
||||
3. `number` Duration of the animation in seconds
|
||||
4. `number` Optional - offset in seconds
|
||||
5. `string` Optional - Animation mode
|
||||
6. `function` Optional - callback function, called when the animation is completed
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Animates the size of a button to a width of 10 and a height of 5 within 2 seconds
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setSize(5, 3)
|
||||
|
||||
aButton:animateSize(10, 5, 2, 0, "linear", function()
|
||||
basalt.debug("Animation completed!")
|
||||
end)
|
||||
```
|
||||
28
docs/objects/VisualObject/getAbsolutePosition.md
Normal file
28
docs/objects/VisualObject/getAbsolutePosition.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## getAbsolutePosition
|
||||
|
||||
### Description
|
||||
|
||||
Converts the relative coordinates into absolute coordinates
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|nil` x
|
||||
2. `number|nil` y
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` absolute x
|
||||
2. `number` absolute y
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a frame and a button and prints the button's absolute position to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame():setPosition(3,3)
|
||||
local aButton = mainFrame:addButton():setSize(8,1):setPosition(4,2)
|
||||
local absX, absY = aButton:getAbsolutePosition()
|
||||
basalt.debug("Absolute Position: " .. absX .. ", " .. absY) -- returns 7,5 (frame coords + own coords) instead of 4,2
|
||||
```
|
||||
21
docs/objects/VisualObject/getBackground.md
Normal file
21
docs/objects/VisualObject/getBackground.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## getBackground
|
||||
|
||||
### Description
|
||||
|
||||
Returns the current background color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number|false` color (returns false if the background is transparent)
|
||||
|
||||
### Usage
|
||||
|
||||
* Retrieves the background color of an object and prints it to the debug console:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame():setBackground(colors.gray)
|
||||
local bgColor = mainFrame:getBackground()
|
||||
basalt.debug(bgColor) -- prints colors.gray
|
||||
```
|
||||
32
docs/objects/VisualObject/getDrawId.md
Normal file
32
docs/objects/VisualObject/getDrawId.md
Normal file
@@ -0,0 +1,32 @@
|
||||
## getDrawId
|
||||
|
||||
### Description
|
||||
|
||||
Returns the ID of a custom drawing function.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Name (ID) of the drawing function
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` Index of the drawing function in the corresponding queue (drawQueue, preDrawQueue, or postDrawQueue)
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function customDrawing()
|
||||
-- Custom drawing code goes here
|
||||
end
|
||||
|
||||
mainFrame:addDraw("uniqueID", customDrawing, 1, true)
|
||||
local drawIndex = mainFrame:getDrawId("uniqueID")
|
||||
|
||||
basalt.debug("Custom drawing index: " .. drawIndex)
|
||||
```
|
||||
|
||||
In this example, a custom drawing function is added to the main frame's drawQueue. The `getDrawId` function is then used to retrieve the index of the drawing function in the corresponding queue. The index is then printed to the debug console.
|
||||
21
docs/objects/VisualObject/getForeground.md
Normal file
21
docs/objects/VisualObject/getForeground.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## getForeground
|
||||
|
||||
### Description
|
||||
|
||||
Returns the current foreground color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number|color` color
|
||||
|
||||
### Usage
|
||||
|
||||
* Retrieves the foreground color of an object and prints it to the debug console:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame():setForeground(colors.red)
|
||||
local fgColor = mainFrame:getForeground()
|
||||
basalt.debug(fgColor) -- prints colors.red
|
||||
```
|
||||
22
docs/objects/VisualObject/getHeight.md
Normal file
22
docs/objects/VisualObject/getHeight.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## getHeight
|
||||
|
||||
### Description
|
||||
|
||||
Returns the object's height.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` height
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the height of a button to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setSize(10, 3)
|
||||
local h = aButton:getHeight()
|
||||
basalt.debug("Button height: " .. h) -- prints "Button height: 3"
|
||||
```
|
||||
23
docs/objects/VisualObject/getPosition.md
Normal file
23
docs/objects/VisualObject/getPosition.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## getPosition
|
||||
|
||||
### Description
|
||||
|
||||
Returns the object's position
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` x position
|
||||
2. `number` y position
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the x and y coordinates of a button to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(5, 8)
|
||||
local x, y = aButton:getPosition()
|
||||
basalt.debug("Button position: x=" .. x .. ", y=" .. y) -- prints "Button position: x=5, y=8"
|
||||
```
|
||||
24
docs/objects/VisualObject/getShadow.md
Normal file
24
docs/objects/VisualObject/getShadow.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## getShadow
|
||||
|
||||
### Description
|
||||
|
||||
Returns the current shadow color of the object.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number|boolean` Shadow color or false if no shadow is set
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the shadow color of a frame to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local subFrame = mainFrame:addMovableFrame()
|
||||
:setSize(18,6)
|
||||
:setShadow(colors.green)
|
||||
|
||||
basalt.debug(subFrame:getShadow()) -- returns colors.green or false if no shadow is set
|
||||
```
|
||||
23
docs/objects/VisualObject/getSize.md
Normal file
23
docs/objects/VisualObject/getSize.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## getSize
|
||||
|
||||
### Description
|
||||
|
||||
Returns the object's size
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` width
|
||||
2. `number` height
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the width and height of a button to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setSize(10, 3)
|
||||
local w, h = aButton:getSize()
|
||||
basalt.debug("Button position: w=" .. w .. ", h=" .. h) -- prints "Button position: w=10, h=3"
|
||||
```
|
||||
22
docs/objects/VisualObject/getWidth.md
Normal file
22
docs/objects/VisualObject/getWidth.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## getWidth
|
||||
|
||||
### Description
|
||||
|
||||
Returns the object's width.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` width
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the width of a button to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setSize(10, 3)
|
||||
local w = aButton:getWidth()
|
||||
basalt.debug("Button width: " .. w) -- prints "Button width: 10"
|
||||
```
|
||||
22
docs/objects/VisualObject/getX.md
Normal file
22
docs/objects/VisualObject/getX.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## getX
|
||||
|
||||
### Description
|
||||
|
||||
Returns the object's x-coordinate.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` x position
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the x-coordinate of a button to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(5, 8)
|
||||
local x = aButton:getX()
|
||||
basalt.debug("Button x-coordinate: " .. x) -- prints "Button x-coordinate: 5"
|
||||
```
|
||||
22
docs/objects/VisualObject/getY.md
Normal file
22
docs/objects/VisualObject/getY.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## getY
|
||||
|
||||
### Description
|
||||
|
||||
Returns the object's y-coordinate.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` y position
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints the y-coordinate of a button to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(5, 8)
|
||||
local y = aButton:getY()
|
||||
basalt.debug("Button y-coordinate: " .. y) -- prints "Button y-coordinate: 5"
|
||||
```
|
||||
28
docs/objects/VisualObject/hide.md
Normal file
28
docs/objects/VisualObject/hide.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## hide
|
||||
|
||||
### Description
|
||||
|
||||
The `hide` method makes the object invisible, but it remains part of the parent frame. This can be useful for creating toggleable UI elements or hiding objects that should only be displayed under certain conditions.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage
|
||||
|
||||
* Hides a frame:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton():setText("Close"):onClick(function(self) mainFrame:hide() end)
|
||||
```
|
||||
|
||||
In this example, a button is added to the mainFrame with the text "Close". When clicked, the hide method is called on the mainFrame, making it invisible.
|
||||
|
||||
```xml
|
||||
<button visible="false" />
|
||||
```
|
||||
|
||||
The hide method allows you to control the visibility of the object within its parent frame.
|
||||
31
docs/objects/VisualObject/ignoreOffset.md
Normal file
31
docs/objects/VisualObject/ignoreOffset.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## ignoreOffset
|
||||
|
||||
### Description
|
||||
|
||||
Sets whether the object should ignore the offset of its parent frame. If set to `true`, the object's position will be absolute on the screen, disregarding any parent offset. By default, this value is set to `false`.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `boolean` ignore offset
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a frame with an offset and a button that ignores the offset
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame():setPosition(5, 5)
|
||||
local aButton = mainFrame:addButton():setSize(8, 1):setPosition(2, 2):ignoreOffset(true)
|
||||
|
||||
-- The button will be displayed at position (2,2) on the screen,
|
||||
-- ignoring the frame's offset of (5,5)
|
||||
```
|
||||
|
||||
```xml
|
||||
<button x="2" y="2" ignoreOffset="true" />
|
||||
```
|
||||
21
docs/objects/VisualObject/isFocused.md
Normal file
21
docs/objects/VisualObject/isFocused.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## isFocused
|
||||
|
||||
### Description
|
||||
|
||||
Returns whether the object is currently the focused object of the parent frame.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `boolean` Whether the object is focused
|
||||
|
||||
#### Usage
|
||||
|
||||
* Prints whether the button is focused to the debug console
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton()
|
||||
basalt.debug(aButton:isFocused()) -- shows true or false as a debug message
|
||||
```
|
||||
21
docs/objects/VisualObject/isVisible.md
Normal file
21
docs/objects/VisualObject/isVisible.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## isVisible
|
||||
|
||||
Returns whether the object is currently visible or not.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `boolean` The current visibility state of the object (true for visible, false for hidden)
|
||||
|
||||
#### Usage
|
||||
|
||||
* Prints the visibility state of an object to the debug console:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setSize(5, 8)
|
||||
basalt.debug(aButton:isVisible()) -- returns true
|
||||
```
|
||||
|
||||
In this example, the isVisible method is called on aButton, and its visibility state is printed to the debug console. Since the button is visible by default, the output will be true.
|
||||
28
docs/objects/VisualObject/onReposition.md
Normal file
28
docs/objects/VisualObject/onReposition.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## onReposition
|
||||
|
||||
### Description
|
||||
|
||||
`onReposition(self)`
|
||||
|
||||
The `onReposition` event is a custom event that gets triggered when the object is repositioned, such as when a dynamic value changes the object's position.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Add an onReposition event to a button:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local aButton = main:addButton():setPosition(3,3)
|
||||
|
||||
local function onButtonReposition(self)
|
||||
self:setSize(self:getWidth() - self:getX(), 3)
|
||||
end
|
||||
|
||||
aButton:onReposition(onButtonReposition)
|
||||
```
|
||||
29
docs/objects/VisualObject/onResize.md
Normal file
29
docs/objects/VisualObject/onResize.md
Normal file
@@ -0,0 +1,29 @@
|
||||
## onResize
|
||||
|
||||
### Description
|
||||
|
||||
`onResize(self)`
|
||||
|
||||
The `onResize` event is a custom event that gets triggered when the parent frame is resized.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Add an onResize event to a button:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local aButton = main:addButton():setPosition(3,3)
|
||||
|
||||
local function onButtonResize(self)
|
||||
local width = main:getWidth()
|
||||
self:setSize(width, 3)
|
||||
end
|
||||
|
||||
aButton:onResize(onButtonResize)
|
||||
```
|
||||
27
docs/objects/VisualObject/setBackground.md
Normal file
27
docs/objects/VisualObject/setBackground.md
Normal file
@@ -0,0 +1,27 @@
|
||||
## setBackground
|
||||
|
||||
### Description
|
||||
|
||||
Changes the object background color. If you set the value to `false`, the background won't be visible, allowing you to see through a frame, for example.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|color|false` Background color
|
||||
1. `char` (Optional) Background symbol you want to draw
|
||||
1. `number|color` (Optional) Background symbol color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` Creates a frame, and sets its background color to colors.gray, also sets a background symbol with color black.
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a frame, and sets its background color to `colors.gray`, also sets a background symbol with color black.
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():setBackground(colors.gray, "#", colors.black)
|
||||
```
|
||||
|
||||
```xml
|
||||
<button bg="gray" />
|
||||
```
|
||||
31
docs/objects/VisualObject/setBorder.md
Normal file
31
docs/objects/VisualObject/setBorder.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## setBorder
|
||||
|
||||
### Description
|
||||
|
||||
Sets the border of that objects, if false the border will be removed
|
||||
|
||||
Default: false
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|color` Border color
|
||||
2. `string` optional - sides. If you don't set sides, all 4 sides will have a border
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the border to green and shows it:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local subFrame = mainFrame:addMovableFrame()
|
||||
:setSize(18,6)
|
||||
:setBorder(colors.green, "left", "right", "bottom")
|
||||
```
|
||||
|
||||
```xml
|
||||
<movableFrame width="18" height="6" borderColor="green" />
|
||||
```
|
||||
31
docs/objects/VisualObject/setDrawState.md
Normal file
31
docs/objects/VisualObject/setDrawState.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## setDrawState
|
||||
|
||||
### Description
|
||||
|
||||
Sets the state of a custom drawing function, determining whether it should be rendered or not.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Name (ID) of the drawing function
|
||||
2. `boolean` State - `true` for rendering the drawing, `false` to disable rendering
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
local function customDrawing()
|
||||
-- Custom drawing code goes here
|
||||
end
|
||||
|
||||
mainFrame:addDraw("uniqueID", customDrawing, 1, true)
|
||||
mainFrame:setDrawState("uniqueID", false) -- Disables rendering of the custom drawing
|
||||
```
|
||||
|
||||
In this example, a custom drawing function is added to the main frame's drawQueue, and its state is then set to `false`, disabling its rendering. To enable rendering, set the state to `true`.
|
||||
20
docs/objects/VisualObject/setFocus.md
Normal file
20
docs/objects/VisualObject/setFocus.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Object
|
||||
|
||||
## setFocus
|
||||
|
||||
Sets the object to be the focused object.
|
||||
If you click on an object, it's normally automatically the focused object. For example, if you call :show() on a frame, and you want this particular frame to be in
|
||||
the foreground, you should also use :setFocus()
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the button to the focused object
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setFocus()
|
||||
```
|
||||
25
docs/objects/VisualObject/setForeground.md
Normal file
25
docs/objects/VisualObject/setForeground.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## setForeground
|
||||
|
||||
### Description
|
||||
|
||||
Changes the object text color
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|color` Foreground color
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a frame, and sets its foreground color to `colors.green`
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():setForeground(colors.green)
|
||||
```
|
||||
|
||||
```xml
|
||||
<frame fg="green" />
|
||||
```
|
||||
26
docs/objects/VisualObject/setInfinitePlay.md
Normal file
26
docs/objects/VisualObject/setInfinitePlay.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## setInfinitePlay
|
||||
|
||||
### Description
|
||||
|
||||
Sets whether the texture animation should play infinitely or not.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `boolean` Set to true to make the texture animation loop infinitely, false otherwise
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Set to true to make the texture animation loop infinitely, false otherwise
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
mainFrame:addTexture("path/to/animated_texture.bimg", true)
|
||||
mainFrame:setInfinitePlay(true)
|
||||
```
|
||||
65
docs/objects/VisualObject/setPosition.md
Normal file
65
docs/objects/VisualObject/setPosition.md
Normal file
@@ -0,0 +1,65 @@
|
||||
## setPosition
|
||||
|
||||
### Description
|
||||
|
||||
Changes the position relative to its parent frame
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|string` The x coordinate as a number or a dynamic value as a string
|
||||
2. `number|string` The y coordinate as a number or a dynamic value as a string
|
||||
3. `boolean` (optional) Whether to add/remove the given coordinates to the current position instead of setting them directly. Default is `false`.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Set the button's position to an x coordinate of 2 and a y coordinate of 3:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
mainFrame:addButton():setPosition(2, 3)
|
||||
```
|
||||
|
||||
```xml
|
||||
<button x="2" y="3" />
|
||||
```
|
||||
|
||||
* Use dynamic values for the button's position:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
mainFrame:addButton():setPosition("parent.w * 0.5", 23)
|
||||
```
|
||||
|
||||
```xml
|
||||
<button x="parent.w * 0.5" y="23" />
|
||||
```
|
||||
|
||||
In this example, the x coordinate is set to 50% of the parent frame's width.
|
||||
|
||||
### Dynamic Values
|
||||
|
||||
Dynamic values are special strings that allow you to set properties of an object based on calculations or the properties of other objects. These values are written as expressions inside double quotes (" "). The expressions can include arithmetic operations, functions, and references to other objects or their properties.
|
||||
|
||||
You can use parent, self, or an object's ID to reference other objects when creating dynamic values.
|
||||
|
||||
* `parent`: Refers to the object's parent.
|
||||
* `self`: Refers to the object itself.
|
||||
* `objectID`: Refers to an object with the given ID.
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local firstButton = mainFrame:addButton("objectID"):setPosition(2, 2)
|
||||
local secondButton = mainFrame:addButton():setPosition("objectID.w + objectID.x + 2", 2)
|
||||
```
|
||||
|
||||
In this example, the second button's x position is calculated based on the first button's (with the ID objectID) width and x position, with an additional offset of 2.
|
||||
30
docs/objects/VisualObject/setShadow.md
Normal file
30
docs/objects/VisualObject/setShadow.md
Normal file
@@ -0,0 +1,30 @@
|
||||
## setShadow
|
||||
|
||||
### Description
|
||||
|
||||
Sets the shadow color - default: false
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|color` Shadow color
|
||||
|
||||
#### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage
|
||||
|
||||
* Sets the shadow to green and shows it:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local subFrame = mainFrame:addMovableFrame()
|
||||
:setSize(18,6)
|
||||
:setShadow(colors.green)
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```xml
|
||||
<movableFrame width="18" height="6" shadowColor="green" />
|
||||
```
|
||||
37
docs/objects/VisualObject/setSize.md
Normal file
37
docs/objects/VisualObject/setSize.md
Normal file
@@ -0,0 +1,37 @@
|
||||
## setSize
|
||||
|
||||
Changes the object size
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number|string` width as number or dynamicvalue as string
|
||||
2. `number|string` height as number or dynamicvalue as string
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the frame to have a width of 15 and a height of 12
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local subFrame = mainFrame:addFrame():setSize(15,12)
|
||||
```
|
||||
|
||||
```xml
|
||||
<frame width="15" height="12" />
|
||||
```
|
||||
|
||||
### Dynamic Values
|
||||
|
||||
Dynamic values can be used to automatically calculate and set the size of an object based on expressions. They can include mathematical operations and reference the size or position of other objects or the object itself. Instead of using static numbers, you can use dynamic values as strings. Here's an example of using dynamic values with `setSize`:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton("objectID")
|
||||
local secondButton = mainFrame:addButton():setSize("objectID.w * 0.5", "parent.h * 0.25")
|
||||
```
|
||||
|
||||
In this example, the width of `secondButton` is set to half the width of `aButton`, and its height is set to one-quarter of its parent's height. You can use `parent`, `self`, or an object ID to reference different objects when using dynamic values.
|
||||
26
docs/objects/VisualObject/setTextureMode.md
Normal file
26
docs/objects/VisualObject/setTextureMode.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## setTextureMode
|
||||
|
||||
### Description
|
||||
|
||||
Sets the texture mode for an object. The texture mode determines how the texture is displayed on the object. Available modes are "default", "center", and "right".
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` Texture mode ("default", "center", or "right")
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the texture mode of a frame to "center":
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
|
||||
mainFrame:addTexture("path/to/texture.bimg", true)
|
||||
mainFrame:setTextureMode("center")
|
||||
```
|
||||
27
docs/objects/VisualObject/setTransparency.md
Normal file
27
docs/objects/VisualObject/setTransparency.md
Normal file
@@ -0,0 +1,27 @@
|
||||
## setTransparency
|
||||
|
||||
### Description
|
||||
|
||||
Enables or disables transparency for the object. This is useful for textures or custom drawings to skip spaces in color strings instead of using the standard background color. However, enabling transparency requires more processing power and is therefore disabled by default.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `boolean` Transparency state
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a frame, and enables transparency
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame():setTransparency(true)
|
||||
```
|
||||
|
||||
```xml
|
||||
<frame transparency="true" />
|
||||
```
|
||||
28
docs/objects/VisualObject/setVisible.md
Normal file
28
docs/objects/VisualObject/setVisible.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## setVisible
|
||||
|
||||
### Description
|
||||
|
||||
The `setVisible` method allows you to control the visibility of an object directly by passing a boolean value (true for visible, false for hidden).
|
||||
|
||||
### Returns
|
||||
|
||||
1. `boolean` The visibility state of the object (true for visible, false for hidden)
|
||||
|
||||
### Usage
|
||||
|
||||
* Toggle visibility of a button:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton():setText("Toggle")
|
||||
local anotherButton = mainFrame:addButton():setText("Another Button")
|
||||
|
||||
button:onClick(function()
|
||||
local currentState = anotherButton:isVisible()
|
||||
anotherButton:setVisible(not currentState)
|
||||
end)
|
||||
```
|
||||
|
||||
In this example, a button is added to the mainFrame with the text "Toggle". When clicked, the setVisible method is called on anotherButton, toggling its visibility between hidden and visible states.
|
||||
30
docs/objects/VisualObject/setZIndex.md
Normal file
30
docs/objects/VisualObject/setZIndex.md
Normal file
@@ -0,0 +1,30 @@
|
||||
## setZIndex
|
||||
|
||||
### Description
|
||||
|
||||
Sets the z-index for the object. A higher value means a higher draw and event priority. You can also add multiple objects to the same z-index; in this case, the last added object will have the highest priority.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` z-index
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the button's z-index to `1` and the label's z-index to `2`
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setZIndex(1):setPosition(2,2)
|
||||
local aLabel = mainFrame:addLabel():setZIndex(2):setPosition(2,2):setText("I am a label!")
|
||||
```
|
||||
|
||||
```xml
|
||||
<button x="2" y="2" zIndex="1" />
|
||||
<label x="2" y="2" text="I am a label!" zIndex="2" />
|
||||
```
|
||||
29
docs/objects/VisualObject/show.md
Normal file
29
docs/objects/VisualObject/show.md
Normal file
@@ -0,0 +1,29 @@
|
||||
## show
|
||||
|
||||
### Description
|
||||
|
||||
The `show` method makes the object visible if its parent frame is visible. If the parent frame is hidden, the object will not be displayed until the parent frame is shown.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Show a button:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton()
|
||||
button:show()
|
||||
```
|
||||
|
||||
In this example, a button is added to the mainFrame and the show method is called to make it visible.
|
||||
|
||||
```xml
|
||||
<button visible="true" />
|
||||
```
|
||||
|
||||
The show method allows you to control the visibility of the object within its parent frame.
|
||||
Reference in New Issue
Block a user