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:
Robert Jelic
2023-04-30 17:05:34 +02:00
parent e086c1abb2
commit bb1b1beb79
341 changed files with 15541 additions and 3862 deletions

View File

@@ -1,6 +1,5 @@
# Basalt
This is the UI Manager and the starting point for your project. The following functions allow you to influence the default behavior of Basalt.
This is the UI Manager and the first thing you want to access.
Before you can access Basalt, you need to add the following code on top of your file:
```lua
@@ -22,6 +21,7 @@ You are now able to access the following list of methods:
|[getVersion](objects/Basalt/getVersion.md)|Returns the Basalt version
|[isKeyDown](objects/Basalt/isKeyDown.md)|Returns if the key is held down
|[log](objects/Basalt/log.md)|Writes something into the log file
|[memory](objects/Basalt/log.md)|Returns the current memory usage of Basalt
|[onEvent](objects/Basalt/onEvent.md)|Event listener
|[removeFrame](objects/Basalt/removeFrame.md)|Removes a previously created base frame
|[schedule](objects/Basalt/schedule.md)|Schedules a new task
@@ -29,20 +29,21 @@ You are now able to access the following list of methods:
|[setTheme](objects/Basalt/setTheme.md)|Changes the base theme of basalt
|[setMouseDragThrottle](objects/Basalt/setMouseDragThrottle.md)|Changes the mouse drag throttle amount
|[setMouseMoveThrottle](objects/Basalt/setMouseMoveThrottle.md)|CraftOS-PC: Changes the mouse move throttle amount
|[setRenderingThrottle](objects/Basalt/setMouseMoveThrottle.md)|Sets the rendering throttle amount
|[setVariable](objects/Basalt/setVariable.md)|Sets a variable which you can access via XML
|[stopUpdate / stop](objects/Basalt/stopUpdate.md)|Stops the currently active event and draw listener
|[update](objects/Basalt/update.md)|Starts the event and draw listener once
## Examples
Here is a lua example on how to create a empty base frame and start basalt's listener.
Here is a Lua example on how to create an empty base frame and start Basalt's listener.
```lua
local basalt = require("basalt") -- Loads Basalt into our project
local main = basalt.createFrame() -- Creates a base frame. On that frame we are able to add object's
local main = basalt.createFrame() -- Creates a base frame. On that frame, we are able to add objects
-- Here we would add additional object's
-- Here we would add additional objects
basalt.autoUpdate() -- Starts listening to incoming events and draw stuff on the screen. This should nearly always be the last line.
```

View File

@@ -1,7 +1,7 @@
# Basalt
## autoUpdate
### Description
This starts the event and draw handler for you. The listeners will run until you stop them.
### Parameters
@@ -13,6 +13,12 @@ This starts the event and draw handler for you. The listeners will run until you
* Enables the basalt listeners, otherwise the screen will not continue to update
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
basalt.autoUpdate()
basalt.autoUpdate() -- Start the event and draw listeners
-- Some code here...
basalt.autoUpdate(false) -- Stop the event and draw listeners
```

View File

@@ -1,15 +1,14 @@
# Basalt
## createFrame
Creates a new base-frame, you can have as many base-frames as you want, but only 1 can be active (visible) at the same time.
You can always switch between your base frames.
### Description
Only the currently active base-frame listens to incoming events (except for some events like time-events and peripheral-events)
Creates a new base frame, which is essentially a frame without a parent. You can have as many base frames as you want, but only one can be active (visible) at a time. You can always switch between your base frames.
Only the currently active base frame listens to incoming events (except for some events like time-events and peripheral-events).
### Parameters
1. `string` id - optional (if you dont set a id it will automatically create a uuid for you)
1. `string` id - optional (if you don't set an ID, it will automatically create a UUID for you)
### Returns
@@ -24,7 +23,7 @@ local main1 = basalt.createFrame() -- Visible base frame on program start
local main2 = basalt.createFrame()
local main3 = basalt.createFrame()
main1:addButton()
:setPosition(2,2)
:setPosition(2, 2)
:setText("Switch")
:onClick(function()
main2:show() -- this function automatically "hides" the first one and shows the second one

View File

@@ -1,11 +1,10 @@
# Basalt
## debug
Creates a label with some information on the main frame on the bottom left. When you click on that label it will open a log view for you. See it as the new print for debugging
### Description
You can also edit the default debug Label (change position, change color or whatever you want) by accessing the variable `basalt.debugLabel`
which returns the debug Label.
Creates a label with some information on the main frame in the bottom left corner. When you click on that label, it will open a log view for you. Think of it as the new print for debugging.
You can also edit the default debug label (change position, change color, or whatever you want) by accessing the variable `basalt.debugLabel`, which returns the debug label.
`basalt.debugFrame` and `basalt.debugList` are also available.
@@ -19,11 +18,4 @@ which returns the debug Label.
```lua
basalt.debug("Hello! ", "^-^")
```
* Changes the debug label's anchor
```lua
basalt.debugLabel:setAnchor("topLeft") -- default anchor is bottomLeft
basalt.debug("Hello!")
```
```

View File

@@ -1,7 +1,7 @@
# Basalt
## getActiveFrame
### Description
Returns the currently active/visible base frame.
### Returns

View File

@@ -1,7 +1,7 @@
# Basalt
## getFrame
### Description
Returns a base frame by the given id.
### Parameters

View File

@@ -1,9 +1,8 @@
# Basalt
## getTheme
## basalt.getTheme
### Description
Returns the current base-theme. This base-theme can be set using setTheme.md.
A list of base-theme keys can be found [here](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua).
Returns the current base-theme. This base-theme can be set using setTheme.lua.
### Returns

View File

@@ -1,7 +1,7 @@
# Basalt
## getVariable
### Description
Returns a variable defined with [setVariable](objects/Basalt/setVariable)
### Returns

View File

@@ -1,7 +1,7 @@
# Basalt
## getVersion
### Description
Returns the currently active/visible base frame.
### Returns

View File

@@ -1,7 +1,7 @@
# Basalt
## isKeyDown
### Description
Checks if the user is currently holding a key
### Parameters

View File

@@ -1,13 +1,13 @@
# Basalt
## log
This writes something into a file. The main goal is to make debugging errors easier. Lets say you'r program is crashing and you don't know why, you could use basalt.log The log files will automatically removed after you start your program again.
### Description
Writes a message to the log file. This can be useful for debugging errors or keeping a record of events in your application. Log files are automatically removed when you start your program again.
### Parameters
1. `string` The text to write into the log file
2. `string` - optional (default: "Debug") - the type to write
2. `string` - The type or category of the log message
### Usage
@@ -17,12 +17,12 @@ This writes something into a file. The main goal is to make debugging errors eas
basalt.log("Hello!")
```
This should result in there beeing a file called `basaltLog.txt`. In the file it should say `[Basalt][Debug]: Hello!`.
This should result in a file called `basaltLog.txt`. In the file it should say `[Basalt][Debug]: Hello!`.
* Writes "Config file missing" into the log file, with warning as prefix.
* Writes "Config file missing" into the log file, with "WARNING" as the prefix.
```lua
basalt.log("Config file is missing", "WARNING")
```
This should result in there beeing a file called `basaltLog.txt`. In the file it should say `[Basalt][WARNING]: Config file is missing`.
This should result in a file called `basaltLog.txt`. In the file, it should say `[Basalt][WARNING]: Config file is missing`.

View File

@@ -0,0 +1,18 @@
## memory
### Description
Returns the amount of memory used by Basalt in bytes. This can be useful for monitoring your application's memory usage and performance.
### Returns
1. `number` The amount of memory used by Basalt in bytes.
### Usage
* Display the memory usage in the debug console
```lua
local memoryUsage = basalt.memory()
basalt.debug("Memory usage: ", memoryUsage, " bytes")
```

View File

@@ -1,8 +1,8 @@
# Basalt
## onEvent
This is the top-level method to intercept an event before sending it to the object event handlers. If you use return false, the event is not passed to the event handlers.
### Description
This is the top-level method to intercept an event before sending it to the object event handlers. If you use `return false`, the event is not passed to the event handlers.
### Parameters
@@ -10,6 +10,8 @@ This is the top-level method to intercept an event before sending it to the obje
### Usage
* Prevents the "terminate" event from stopping the program
```lua
local basalt = require("basalt")

View File

@@ -1,7 +1,7 @@
# Basalt
## removeFrame
### Description
Removes the base frame by it's id. **This only works for base-frames.**
### Parameters

View File

@@ -1,7 +1,7 @@
# Basalt
## schedule
### Description
Schedules a function which gets called in a coroutine. After the coroutine is finished it will get destroyed immediatly. It's something like threads, but with some limits.
**A guide can be found [here](/tips/logic).**

View File

@@ -1,8 +1,8 @@
# Basalt
## setActiveFrame
Sets what should be the active baseframe.
### Description
Sets the active base frame.
### Parameters
@@ -10,4 +10,23 @@ Sets what should be the active baseframe.
### Usage
TODO
```lua
local basalt = require("basalt")
local main1 = basalt.createFrame("firstBaseFrame")
local main2 = basalt.createFrame("secondBaseFrame")
main1:addButton()
:setText("Switch to main2")
:onClick(function()
basalt.setActiveFrame(main2)
end)
main2:addButton()
:setText("Switch to main1")
:onClick(function()
basalt.setActiveFrame(main1)
end)
basalt.autoUpdate()
```

View File

@@ -1,17 +1,19 @@
# Basalt
## setMouseDragThrottle
### Description
Changes the drag throttle of all drag events. Default value is 50ms - which is 0.05s.
Instead of sending all mouse_drag events to the :onDrag handlers basalt sends every 0.05s (while dragging) the most recent drag event to all
drag handlers. If you need all drag events - just change the value to 0.
### Parameters
1. `number` A number in miliseconds.
1. `number` throttle - A number in milliseconds representing the drag throttle.
### Usage
* Set the drag throttle to 0, which sends all drag events to the handlers
```lua
local basalt = require("basalt")
basalt.setMouseDragThrottle(0)

View File

@@ -1,19 +1,21 @@
# Basalt
## setMouseMoveThrottle
### Description
This feature is only available for [CraftOS-PC](https://www.craftos-pc.cc).
CraftOS-PC has a builtin mouse_move event, which is disabled by default. By using this method it will also enable the event for you. Remember - basalt does not disable the event after closing the program, which means the event stays active. If you want to disable the event please use config.set("mouse_move_throttle", -1) in your lua prompt or your program.
CraftOS-PC has a built-in `mouse_move` event, which is disabled by default. By using this method, it will also enable the event for you. Remember, Basalt does not disable the event after closing the program, which means the event stays active. If you want to disable the event, please use `config.set("mouse_move_throttle", -1)` in your Lua prompt or your program.
Sidenote: a very low amount can make the program laggy - because it litterally spams the mouse_move event. So use it carefully.
Sidenote: A very low amount can make the program laggy because it literally spams the `mouse_move` event. So, use it carefully.
### Parameters
1. `number` A number in miliseconds.
1. `number` throttle - A number in milliseconds representing the mouse move throttle.
### Usage
* Set the mouse move throttle to 50 milliseconds
```lua
local basalt = require("basalt")
basalt.setMouseMoveThrottle(50)

View File

@@ -0,0 +1,18 @@
## setRenderingThrottle
### Description
Sets the rendering throttle for Basalt's automatic update process. This determines how often the screen is updated during the auto-update loop. A higher value means the screen updates less frequently, potentially reducing CPU usage and improving performance, while a lower value results in more frequent updates, ensuring smoother animations and responsiveness.
### Parameters
1. `number` throttle - The throttle value in milliseconds. Default value is 50ms (0.05 seconds).
### Usage
* Sets the rendering throttle to 100ms (0.1 seconds).
```lua
local basalt = require("basalt")
basalt.setMouseMoveThrottle(100)
```

View File

@@ -1,16 +1,16 @@
# Basalt
## setTheme
Sets the base theme of the project! Make sure to cover all existing objects, otherwise it will result in errors. A good example is [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua). The theme can also be gotten with [`basalt.getTheme()`](objects/Basalt/getTheme)
### Description
Sets the base theme of the project! Make sure to cover all existing objects, otherwise it will result in errors. A good example is [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua). The theme can also be retrieved with [`basalt.getTheme()`](objects/Basalt/getTheme)
### Parameters
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
1. `table` theme - A table containing the theme layout. Look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for an example
### Usage
* Sets the default theme of basalt.
* Sets the default theme of Basalt.
```lua
basalt.setTheme({

View File

@@ -1,17 +1,17 @@
# Basalt
## setVariable
This stores a variable which you're able to access via xml. You are also able to add a function, which then gets called by object events created in XML.
### Description
This method stores a variable that you can access via XML. You can also add a function, which is then called by object events created in XML.
### Parameters
1. `string` a key name
2. `any` any variable
1. `string` key - A key name to store the variable.
2. `any` value - Any variable to store under the key.
### Usage
* Adds a function to basalt.
* Adds a reusable function to Basalt.
```lua
basalt.setVariable("clickMe", function()

View File

@@ -1,13 +1,13 @@
# Basalt
## stopUpdate / stop
Stops the automatic draw and event handler which got started by `basalt.autoUpdate()`.
`basalt.autoUpdate(false)` also does the same.
### Description
This method stops the automatic draw and event handler that was started by `basalt.autoUpdate()`.
`basalt.autoUpdate(false)` achieves the same result.
### Usage
* When the quit button is clicked, the button stops basalt's event listeners and draw handlers
* When the quit button is clicked, the button stops Basalt's event listeners and draw handlers.
```lua
local main = basalt.createFrame()

View File

@@ -1,5 +1,3 @@
# Basalt
## update
Calls the draw and event handler once - this gives more flexibility about which events basalt should process. For example you could filter the terminate event.

10
docs/objects/BaseFrame.md Normal file
View File

@@ -0,0 +1,10 @@
BaseFrame is a subclass of the Container class. It serves as the foundation for other frame types and provides additional functionality specific to the BaseFrame. The main difference between BaseFrame and other frame types is that BaseFrame does not have a parent.
If you want to create a BaseFrame, you will have to use [basalt.createFrame](objects/basalt/createFrame.md)
In addition to the Object, VisualObject and Container methods, baseframe also has the following methods:
| | |
|---|---|
|[getOffset](objects/BaseFrame/getOffset.md)|Returns the current offset of the BaseFrame object
|[setOffset](objects/BaseFrame/setOffset.md)|Sets a new offset for the BaseFrame object

View File

@@ -0,0 +1,21 @@
## getOffset
### Description
Returns the offset
### Returns
1. `number` x position
2. `number` y position
### Usage
* Prints the offset amount to the console
```lua
local main = basalt.createFrame()
local button = mainFrame:addButton()
basalt.debug(main:getOffset())
```

View File

@@ -0,0 +1,26 @@
## setOffset
### Description
Sets the frame's offset, this offset is beeing used to move all children object's by the offset's position
### Parameters
1. `number` x position
2. `number` y position
### Returns
1. `number` x position
2. `number` y position
### Usage
* Sets the baseframes offset by y5.
```lua
local main = basalt.createFrame()
local button = mainFrame:addButton()
main:setOffset(0, 5)
```

View File

@@ -1,6 +1,6 @@
The button object is for creating buttons If you click on them, they should execute something. You decide what should happen when clicking on them.
The Button object is derived from the VisualObject class and is used for creating interactive buttons in the Basalt framework. When a button is clicked, it can execute a predefined function, such as navigating to another screen or performing a specific action.
[Object](objects/Object.md) methods also apply for buttons.
In addition to the Object and VisualObject methods, buttons also have the following methods:
| | |
|---|---|
@@ -8,9 +8,10 @@ The button object is for creating buttons If you click on them, they should exec
|[setHorizontalAlign](objects/Button/setHorizontalAlign.md)|Changes the horizontal text position
|[setVerticalAlign](objects/Button/setVerticalAlign.md)|Changes the vertical text position
# Example
This is a example on how you would create a fully working button:
Here's an example of how to create a fully functional button using the Button object:
```lua
local main = basalt.createFrame()
local aButton = main:addButton():setText("Click")
@@ -22,16 +23,16 @@ aButton:onClick(function(self,event,button,x,y)
end)
```
and this would be the xml way:
```lua
basalt.setVariable("buttonClick", function(self,event,button,x,y)
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
end)
Alternatively, you can create a button using an XML layout:
local main = basalt.createFrame():addLayout("example.xml")
```
```xml
<button onClick="buttonClick" text="Click" />
```
<button onClick="buttonClick" text="Click">
<onClick>
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
</onClick>
</button>
```
In these examples, a button is created with the text "Click". When the left mouse button is clicked on the button, the message "Left mouse button got clicked!" is printed.

View File

@@ -1,20 +1,28 @@
## setHorizontalAlign
### Description
Sets the horizontal align of the button text
#### Parameters:
### Parameters
1. `string` the position as string ("left", "center", "right") - default is center.
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
* Sets the button's horizontal text align to right.
### Usage
* Sets the button's horizontal text align to right.
```lua
local mainFrame = basalt.createFrame()
local button = mainFrame:addButton()
:setText("Click me!")
:setHorizontalAlign("right")
```
```xml
<button text="Click me!" horizontalAlign="right" />
```
```

View File

@@ -1,17 +1,26 @@
## setText
### Description
Sets the displayed button text
#### Parameters:
### Parameters
1. `string` the text the button should show
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a button with "Click me!" as text.
```lua
local mainFrame = basalt.createFrame()
local button = mainFrame:addButton():setText("Click me!")
```
```xml
<button text="Click me!" />
```
```

View File

@@ -1,14 +1,21 @@
## setVerticalAlign
### Description
Sets the vertical align of the button text
#### Parameters:
### Parameters
1. `string` the position as string ("top", "center", "bottom") - default is center.
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Sets the button's horizontal text align to right and the vertical text align to bottom.
```lua
local mainFrame = basalt.createFrame()
local button = mainFrame:addButton()
@@ -16,6 +23,7 @@ local button = mainFrame:addButton()
:setHorizontalAlign("right")
:setVerticalAlign("bottom")
```
```xml
<button text="Click me!" horizontalAlign="right" verticalAlign="bottom" />
```
```

View File

@@ -0,0 +1,38 @@
The ChangeableObject class is a subclass of VisualObject and Object that provides additional methods for handling changes to objects.
In addition to the Object and VisualObject methods, changeableObjects also have the following methods:
| | |
|---|---|
|[setValue](objects/Button/setText.md)|Changes the button text
|[getValue](objects/Button/setHorizontalAlign.md)|Changes the horizontal text position
|[onChange](objects/Button/setVerticalAlign.md)|Changes the vertical text position
# Example
Here's an example of how to create a fully functional button using the Button object:
```lua
local main = basalt.createFrame()
local aButton = main:addButton():setText("Click")
aButton:onClick(function(self,event,button,x,y)
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
end)
```
Alternatively, you can create a button using an XML layout:
```xml
<button onClick="buttonClick" text="Click">
<onClick>
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
</onClick>
</button>
```
In these examples, a button is created with the text "Click". When the left mouse button is clicked on the button, the message "Left mouse button got clicked!" is printed.

View File

@@ -0,0 +1,21 @@
## getValue
### Description
Gets the value of your object
### Returns
1. `any` The current value of the object
### Usage
* Retrieves the value of a Slider.
```lua
local mainFrame = basalt.createFrame()
local slider = mainFrame:addSlider():setValue(50)
local currentValue = slider:getValue()
basalt.debug("The current value of the slider is:", currentValue)
```

View File

@@ -0,0 +1,33 @@
## onChange
### Description
`onChange(self, event, value)`
The onChange event is triggered when the value of a ChangeableObject, such as a Slider, is changed by the user.
### Returns
1. `object` The object in use
### Usage
* Add an onChange event to a Slider:
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
local slider = main:addSlider()
:setPosition(3,3)
:setSize(12,3)
:setValue(50)
function sliderOnChange(self, event, value)
basalt.debug("Slider value changed to", value)
end
slider:onChange(sliderOnChange)
basalt.autoUpdate()
```

View File

@@ -0,0 +1,22 @@
## setValue
### Description
Sets the value of your object
### Parameters
1. `any` new value
### Returns
1. `object` The object in use
### Usage
* Creates a Slider with a value of 50.
```lua
local mainFrame = basalt.createFrame()
local slider = mainFrame:addSlider():setValue(50)
```

View File

@@ -1,36 +1,34 @@
With checkboxes the user can set a boolean to true or false by clicking on them.
The Checkbox object is derived from the VisualObject class and allows users to set a boolean value to true or false by clicking on it. Checkboxes are commonly used in forms and settings to enable or disable specific options.
[Object](objects/Object.md) methods also apply for checkboxes.
In addition to the Object and VisualObject methods, checkboxes also have the following method:
| | |
|---|---|
|[setSymbol](objects/Checkbox/setSymbol.md)|Changes the symbol when checkbox is checked
# Example
This is how you would create a event which gets fired as soon as the value gets changed:
Here's an example of how to create a Checkbox object and attach an event that gets fired when the value changes:
```lua
local main = basalt.createFrame()
local aCheckbox = main:addCheckbox()
local function checkboxChange(self)
local checked = self:getValue()
basalt.debug("The value got changed into ", checked)
local checked = self:getValue()
basalt.debug("The value got changed into ", checked)
end
aCheckbox:onChange(checkboxChange)
```
also possible via xml:
```lua
local main = basalt.createFrame():addLayout("example.xml")
basalt.setVariable("checkboxChange", function(self)
local checked = self:getValue()
basalt.debug("The value got changed into ", checked)
end)
```
```xml
<checkbox onChange="checkboxChange" />
<checkbox onChange="checkboxChange">
<onChange>
local checked = self:getValue()
basalt.debug("The value got changed into ", checked)
</onChange>
</checkbox>
```
In these examples, a checkbox is created, and when the value changes, a debug message prints the new value of the checkbox.

View File

@@ -1,18 +1,26 @@
## setSymbol
### Description
Changes the checkbox symbol, default is "\42"
#### Parameters:
### Parameters
1. `string` symbol
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a new checkbox and changes the symbol to o
```lua
local main = basalt.createFrame()
local checkbox = main:addCheckbox():setSymbol("o")
```
```xml
<checkbox symbol="o" />
```
```

17
docs/objects/Container.md Normal file
View File

@@ -0,0 +1,17 @@
Container is the base class for all frame types. It provides the basic structure and functionality for all frame objects. Container objects can contain other container objects, thus forming the foundation for the hierarchy of frame objects.
In addition to the Object and VisualObject methods, container objects have the following methods:
| | |
|---|---|
|[addObject](objects/Container/addObject.md)|Adds a new object to the container
|[getObject](objects/Container/getObject.md)|Returns an object in the container by its ID
|[getDeepObject](objects/Container/getDeepObject.md)|Returns an object in the container or its sub-containers by its ID
|[removeObject](objects/Container/removeObject.md)|Removes an object from the container by its ID
|[updateZIndex](objects/Container/updateZIndex.md)|Updates the Z-index of an object in the container
|[setImportant](objects/Container/setImportant.md)|Marks an object as important, so it is displayed on top if needed
|[sortElementOrder](objects/Container/sortElementOrder.md)|Sorts the order of elements in the container based on their Z-indices
|[removeFocusedObject](objects/Container/removeFocusedObject.md)|Removes focus from an object in the container
|[setFocusedObject](objects/Container/setFocusedObject.md)|Sets focus on a specific object in the container
A Container Object inherits from VisualObject, but won't draw children objects.

View File

@@ -0,0 +1,13 @@
## addObject
### Description
Adds a object to the container
### Parameters
1. `object` any object
### Returns
1. `object` The object which got added

View File

@@ -0,0 +1,30 @@
## getDeepObject
### Description
Retrieves an object from the container or its descendants by its ID. This method searches recursively through all child containers to find the object.
### Parameters
1. `string` id - The ID of the object you want to retrieve.
### Returns
1. `object` The object with the specified ID, or nil if no object with that ID is found.
### Usage
```lua
local main = basalt.createFrame()
local container = main:addFrame("container")
local button = container:addButton("myButton")
:setPosition(2, 2)
:setText("My Button")
-- Get the button object by its ID, searching through all containers
local retrievedButton = main:getDeepObject("myButton")
if retrievedButton then
basalt.debug("Button found!")
end
basalt.autoUpdate()
```

View File

@@ -0,0 +1,30 @@
## getObject
### Description
Retrieves an object from the container by its ID.
### Parameters
1. `string` id - The ID of the object you want to retrieve.
### Returns
1. `object` The object with the specified ID, or nil if no object with that ID is found.
### Usage
```lua
local main = basalt.createFrame()
local button = main:addButton("myButton")
:setPosition(2, 2)
:setText("My Button")
-- Get the button object by its ID
local retrievedButton = main:getObject("myButton")
if retrievedButton then
basalt.debug("Button found!")
end
basalt.autoUpdate()
```

View File

@@ -0,0 +1,32 @@
## removeFocusedObject
### Description
Removes the focus from the currently focused object within the container. If no object is focused, this method has no effect.
### Returns
1. `object` The object in use
### Usage
```lua
local main = basalt.createFrame()
local container = main:addFrame()
local inputField1 = container:addInputField()
:setPosition(2, 2)
local inputField2 = container:addInputField()
:setPosition(2, 4)
container:setFocusedObject(inputField1)
main:addButton()
:setPosition(2, 6)
:setText("Remove focus from input fields")
:onClick(function()
container:removeFocusedObject()
basalt.debug("Focus removed from input fields!")
end)
basalt.autoUpdate()
```

View File

@@ -0,0 +1,37 @@
## removeObject
### Description
Removes an object from the container by its ID. If the object is not a direct child of the container, this method will not remove it.
### Parameters
1. `string` id - The ID of the object you want to retrieve.
### Returns
1. `boolean` true if the object was removed
### Usage
```lua
local main = basalt.createFrame()
local container = main:addFrame("container")
local button = container:addButton("removableButton")
:setPosition(2, 2)
:setText("Remove me")
main:addButton()
:setPosition(2, 4)
:setText("Remove the button above")
:onClick(function()
local removed = container:removeObject("removableButton")
if removed then
basalt.debug("Button removed!")
else
basalt.debug("Button not found!")
end
end)
basalt.autoUpdate()
```

View File

@@ -0,0 +1,38 @@
## setFocusedObject
### Description
Sets the focused object within the container. When an object is focused, it will receive keyboard events. Only one object can be focused at a time within a container.
### Parameters
1. `object` object - The object to set as the focused object.
### Returns
1. `object` The object in use
### Usage
```lua
local main = basalt.createFrame()
local container = main:addFrame()
local inputField1 = container:addInput("inputField1")
:setPosition(2, 2)
local inputField2 = container:addInput("inputField2")
:setPosition(2, 4)
main:addButton()
:setPosition(2, 6)
:setText("Focus on inputField1")
:onClick(function()
local focused = container:setFocusedObject(inputField1)
if focused then
basalt.debug("InputField1 is now focused!")
else
basalt.debug("Failed to set focus on InputField1!")
end
end)
basalt.autoUpdate()
```

View File

@@ -0,0 +1,36 @@
## setImportant
### Description
Sets the specified object as "important" within the container. This means the object will be reordered on the same z-index level, making it more important than other objects on the same level. This can be useful when you want to prioritize event handling or drawing order for specific objects.
### Parameters
1. `string` The object to set as important
### Returns
1. `object` the object in use
### Usage
```lua
local main = basalt.createFrame()
local container = main:addFrame()
local inputField1 = container:addInput()
:setPosition(2, 2)
local inputField2 = container:addInput()
:setPosition(2, 4)
inputField1:onKey(function(event, key)
basalt.debug("InputField1 received key press: ", key)
end)
inputField2:onKey(function(event, key)
basalt.debug("InputField2 received key press: ", key)
end)
container:setImportant(inputField1)
basalt.autoUpdate()
```

View File

@@ -0,0 +1,11 @@
## sortElementOrder
### Description
This function is called internally and automatically after objects are added or removed from the container. It sorts all objects by their z-index and the time they were added, ensuring the correct order is maintained. This is essential for proper event handling and drawing order of objects within the container.
As a user, you don't need to call this function directly, as it's automatically taken care of by the library.
### Usage
No direct usage example is provided since this function is called automatically by the library when needed.

View File

@@ -0,0 +1,25 @@
## setFocusedObject
### Description
Updates the z-index of a specified object within the container. This is useful when you need to change the z-index of an object after it has been added to the container.
### Parameters
1. `object` The object whose z-index you want to update.
2. `number` The new z-index value for the object.
### Returns
1. `object` The object in use
### Usage
```lua
local frame = basalt.createFrame()
local button1 = frame:addButton():setZIndex(1)
local button2 = frame:addButton():setZIndex(2)
-- Update button1's z-index to be above button2
frame:updateZIndex(button1, 3)
```

View File

@@ -1,24 +1,12 @@
Dropdowns are objects where the user can click on a button, this will open a list where the user can choose from.
Dropdowns are objects where the user can click on a button, which opens a list from which the user can choose an item.
[Object](objects/Object.md) methods also apply for dropdowns.
List Object methods also apply for dropdowns.
In addition to the Object, VisualObject and List methods, Dropdowns also have the following methods:
| | |
|---|---|
|[addItem](objects/Dropdown/addItem.md)|Adds a new item into the list
|[removeItem](objects/Dropdown/removeItem.md)|Removes a item from the list
|[editItem](objects/Dropdown/editItem.md)|Changes a already existing item in the list
|[getItem](objects/Dropdown/getItem.md)|Returns a item by its index
|[getItemCount](objects/Dropdown/getItemCount.md)|Returns the item count
|[getAll](objects/Dropdown/getAll.md)|Returns the entire list as a table
|[selectItem](objects/Dropdown/selectItem.md)|Selects a item
|[clear](objects/Dropdown/clear.md)|Makes the entire list empty
|[getItemIndex](objects/Dropdown/getItemIndex.md)|Returns the currently active item index
|[setSelectedItem](objects/Dropdown/setSelectedItem.md)|Changes the default bg and fg, when the user selects a item
|[setOffset](objects/Dropdown/setOffset.md)|Changes the list offset
|[getOffset](objects/Dropdown/getOffset.md)|Returns the current offset
|[setDropdownSize](objects/Dropdown/setDropdownSize.md)|Changes the dropdown size
A item-table in dropdowns looks like the following example:
```lua
@@ -28,4 +16,33 @@ item = {
fgCol=colors.white -- the foreground color
args = {} -- custom args you want to pass, which you will be able to access in for example onChange events
}
```
```
Here's an example of how to create a fully functional dropdown using the Dropdown object:
Lua:
```lua
local main = basalt.createFrame()
local aDropdown = main:addDropdown()
aDropdown:addItem("Item 1")
aDropdown:addItem("Item 2", colors.yellow)
aDropdown:addItem("Item 3", colors.yellow, colors.green)
aDropdown:onChange(function(self, item)
basalt.debug("Selected item: ", item.text)
end)
```
XML:
```xml
<dropdown>
<item><text>Item 1</text></item>
<item><text>Item 2</text><bg>yellow</bg></item>
<item><text>Item 3</text><bg>yellow</bg><fg>green</fg></item>
<onChange>
basalt.debug("Selected item: ", item.text)
</onChange>
</dropdown>
```

View File

@@ -1,26 +1,23 @@
## setDropdownSize
Sets the size of the opened dropdown
#### Parameters:
1. `number` The width value
2. `number` The height value
### Description
Sets the width and height of the dropdown menu for a Dropdown object.
### Parameters
1. `width`
2. `height`
### Returns
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default dropdown, adds 3 entries and sets the dropdown size to 15w, 8h
#### Usage
```lua
local mainFrame = basalt.createFrame()
local aDropdown = mainFrame:addDropdown():setDropdownSize(15,8)
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry")
aDropdown:addItem("3. Entry")
local main = basalt.createFrame()
local aDropdown = main:addDropdown()
aDropdown:setDropdownSize(10, 5)
```
```xml
<dropdown dropdownWidth="15" dropdownHeight="8">
<item><text>1. Entry</text></item>
<item><text>2. Entry</text></item>
<item><text>3. Entry</text></item>
</dropdown>
```

12
docs/objects/Flexbox.md Normal file
View File

@@ -0,0 +1,12 @@
A Flexbox is a layout container that is designed to make it easier to create flexible and responsive UI designs. It allows you to arrange and align its children (elements) within it in a more efficient way.
In addition to the methods inherited from Frame, Container, VisualObject and Object, Flexbox has the following methods:
| | |
|---|---|
|[setDirection](objects/BaseFrame/getOffset.md)|Sets the direction in which the children will be placed
|[getDirection](objects/BaseFrame/getOffset.md)|Returns the direction
|[setSpacing](objects/BaseFrame/setOffset.md)|Sets the space between objects
|[getSpacing](objects/BaseFrame/setOffset.md)|Returns the space
|[setJuustifyContent](objects/BaseFrame/getOffset.md)|Determines how the children are aligned along the main axis
|[getJuustifyContent](objects/BaseFrame/getOffset.md)|Returns the justify content

View File

@@ -1,334 +1,8 @@
Frames are like groups or windows. You can add objects on them and if you move the frame, all its children objects will also be moved. Frames also have
some special functionality to create very advanced programs.
Frame is a subclass of the Container class and inherits from VisualObject and Object classes. Frame objects are used for grouping and organizing other objects within a parent object, providing structure to your interface. The main difference between Frame and BaseFrame is that Frame must always have a parent.
[Object](objects/Object.md) methods also apply for frames.
In addition to the methods inherited from Container, VisualObject and Object, Frame has the following methods:
| | |
|---|---|
|[addObject](objects/Frame/addObject.md)|Adds a new object
|[setBar](objects/Frame/setBar.md)|Sets the top bar text and colors - deprecated
|[setBarTextAlign](objects/Frame/setBarTextAlign.md)|Sets the top bars text align - deprecated
|[showBar](objects/Frame/showBar.md)|Shows the top bar - deprecated
|[setMonitor](objects/Frame/setMonitor.md)|Sets the frame to be a monitor frame (only for base frames)
|[setMonitorScale](objects/Frame/setMonitorScale.md)|Sets the monitor scale (same as monitor.setTextScale)
|[setMirror](objects/Frame/setMirror.md)|Sets the frame to mirror onto a monitor (only for base frames)
|[getObject](objects/Frame/getObject.md)|Returns the object by its name (or id)
|[removeObject](objects/Frame/removeObject.md)|Removes the object by its name (or id)
|[setFocusedObject](objects/Frame/setFocusedObject.md)|Sets the currently focused object by this frame
|[removeFocusedObject](objects/Frame/removeFocusedObject.md)|Removes the currenlty focused object (it only removes beeing focused)
|[getFocusedObject](objects/Frame/getFocusedObject.md)|Returns the currently focused object
|[setMovable](objects/Frame/setMovable.md)|Makes the frame movable (only for sub frames)
|[setOffset](objects/Frame/setOffset.md)|Sets the frames offset (will be added to the childrens x and y positions)
|[getOffset](objects/Frame/getOffset.md)|Returns the current x and y offset
|[addLayout](objects/Frame/addLayout.md)|Adds a new XML Layout into the frame
|[addLayoutFromString](objects/Frame/addLayoutFromString.md)|Adds a new XML Layout via string into the frame
|[getLastLayout](objects/Frame/getLastLayout.md)|Returns a table of all objects generated by the last addLayout/FromString method
|[setTheme](objects/Frame/setTheme.md)|Sets the theme of that frame and all its childrens
|[setScrollable](objects/Frame/setScrollable.md)|Makes the frame scrollable via mousewheel (internally this uses setOffset)
|[setScrollAmount](objects/Frame/setScrollAmount.md)|Sets how far the user is allowed to scroll
This is how you would implement frames via xml:
```xml
<frame>
<frame width="parent.w * 0.5" bg="red">
<button x="2" y="2" width="17" text="Example Button!"/>
</frame>
<frame x="parent.w * 0.5 + 1" width="parent.w * 0.5 +1" bg="black">
<textfield bg="green" x="2" width="parent.w-2" />
</frame>
</frame>
```
## Examples
Here are some examples on how you can use frames to create very advanced programs. Because of the screen size limitation of CC:Tweaked frames can become very useful in almost every scenario. You will find some examples here on how you could implement them.
### Menubar for switching frames
This is a example on how you can create a menubar which switches your frames (without animation).
<details>
<summary>Click here to show code</summary>
```lua
local basalt = require("basalt") -- we need basalt here
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black}) -- we change the default bg and fg color for frames
local sub = { -- here we create a table where we gonna add some frames
main:addFrame():setPosition(1, 2):setSize("parent.w", "parent.h - 1"), -- obviously the first one should be shown on program start
main:addFrame():setPosition(1, 2):setSize("parent.w", "parent.h - 1"):hide(),
main:addFrame():setPosition(1, 2):setSize("parent.w", "parent.h - 1"):hide(),
}
local function openSubFrame(id) -- we create a function which switches the frame for us
if(sub[id]~=nil)then
for k,v in pairs(sub)do
v:hide()
end
sub[id]:show()
end
end
local menubar = main:addMenubar():setScrollable() -- we create a menubar in our main frame.
:setSize("parent.w")
:onChange(function(self, val)
openSubFrame(self:getItemIndex()) -- here we open the sub frame based on the table index
end)
:addItem("Example 1")
:addItem("Example 2")
:addItem("Example 3")
-- Now we can change our sub frames, if you want to access a sub frame just use sub[subid], some examples:
sub[1]:addButton():setPosition(2, 2)
sub[2]:addLabel():setText("Hello World!"):setPosition(2, 2)
sub[3]:addLabel():setText("Now we're on example 3!"):setPosition(2, 2)
sub[3]:addButton():setText("No functionality"):setPosition(2, 4):setSize(18, 3)
basalt.autoUpdate()
```
</details>
<br>
<video width="600" controls autoplay loop muted>
<source src="./_media/frames-with-menubars.mp4" type="video/mp4">
</video>
### Sidebar with buttons to switch frames
Here we will find out how to create a sidebar (which are also just frames) - the sidebar should have buttons to opens the frames for us.
<details>
<summary>Click here to show code</summary>
```lua
local basalt = require("basalt") -- we need basalt here
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
--[[
Here we create the sidebar, on focus it should change the position to parent.w - (self.w-1) which "opens the frame"
when the focus gets lost we simply change the position to "parent.w"
As you can see we add :setZIndex(25) - this makes sure the sidebar frame is always more important than our normal sub frames.
:setScrollable just makes the sidebar frame scrollable (in case you're adding more frames)
]]
local sidebar = main:addFrame():setBackground(colors.gray):setPosition("parent.w", 1):setSize(15, "parent.h"):setZIndex(25):setScrollable()
:onGetFocus(function(self)
self:setPosition("parent.w - (self.w-1)")
end)
:onLoseFocus(function(self)
self:setPosition("parent.w")
end)
-- Once again we add 3 frames, the first one should be immediatly visible
local sub = {
main:addFrame():setPosition(1, 1):setSize("parent.w", "parent.h"),
main:addFrame():setPosition(1, 1):setSize("parent.w", "parent.h"):hide(),
main:addFrame():setPosition(1, 1):setSize("parent.w", "parent.h"):hide(),
}
--This part of the code adds buttons based on the sub table.
local y = 2
for k,v in pairs(sub)do
sidebar:addButton():setText("Example "..k) -- creating the button and adding a name k is just the index
:setBackground(colors.black)
:setForeground(colors.lightGray)
:setSize("parent.w - 2", 3)
:setPosition(2, y)
:onClick(function() -- here we create a on click event which hides ALL sub frames and then shows the one which is linked to the button
for a, b in pairs(sub)do
b:hide()
v:show()
end
end)
y = y + 4
end
sub[1]:addButton():setPosition(2, 2)
sub[2]:addLabel():setText("Hello World!"):setPosition(2, 2)
sub[3]:addLabel():setText("Now we're on example 3!"):setPosition(2, 2)
sub[3]:addButton():setText("No functionality"):setPosition(2, 4):setSize(18, 3)
basalt.autoUpdate()
```
</details>
<br>
<video width="600" controls autoplay loop muted>
<source src="./_media/frames-with-sidebar.mp4" type="video/mp4">
</video>
### Movable frames with a program object
In this example you will see how you can add movable frames with a program object in it. It also shows you how you dynamically add new frames.
<details>
<summary>Click here to show code</summary>
```lua
local basalt = require("basalt")
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
local id = 1
local processes = {}
local function openProgram(path, title, x, y, w, h)
local pId = id
id = id + 1
local f = main:addFrame()
:setMovable()
:setSize(w or 30, h or 12)
:setPosition(x or math.random(2, 12), y or math.random(2, 8))
f:addLabel()
:setSize("parent.w", 1)
:setBackground(colors.black)
:setForeground(colors.lightGray)
:setText(title or "New Program")
f:addProgram()
:setSize("parent.w", "parent.h - 1")
:setPosition(1, 2)
:execute(path or "rom/programs/shell.lua")
f:addButton()
:setSize(1, 1)
:setText("X")
:setBackground(colors.black)
:setForeground(colors.red)
:setPosition("parent.w", 1)
:onClick(function()
f:remove()
processes[pId] = nil
end)
processes[pId] = f
return f
end
openProgram("rom/programs/fun/worm.lua")
main:addButton():setPosition("parent.w - 16", 2):setText("Open"):onClick(function()
openProgram()
end)
basalt.autoUpdate()
```
</details>
<br>
<video width="600" controls autoplay loop muted>
<source src="./_media/dynamic-frames.mp4" type="video/mp4">
</video>
### Resizable frames
If you want to make your frames resizeable, there is no way offered by basalt - so you would have to do it yourself. However such a implementation is very simple as you can see here.
<details>
<summary>Click here to show code</summary>
```lua
local basalt = require("basalt")
local main = basalt.createFrame():setTheme({FrameBG = colors.black, FrameFG = colors.lightGray})
local sub = main:addFrame():setSize(25, 12):setPosition(3, 3)
local function makeResizeable(frame, minW, minH, maxW, maxH)
minW = minW or 4
minH = minH or 4
maxW = maxW or 99
maxH = maxH or 99
local btn = frame:addButton()
:setPosition("parent.w", "parent.h")
:setSize(1, 1)
:setText("/")
:setForeground(colors.blue)
:setBackground(colors.black)
:onDrag(function(self, event, btn, xOffset, yOffset)
local w, h = frame:getSize()
local wOff, hOff = w, h
if(w+xOffset-1>=minW)and(w+xOffset-1<=maxW)then
wOff = w+xOffset-1
end
if(h+yOffset-1>=minH)and(h+yOffset-1<=maxH)then
hOff = h+yOffset-1
end
frame:setSize(wOff, hOff)
end)
end
makeResizeable(sub, 8, 4)
sub:addLabel():setText("Hello World")
basalt.autoUpdate()
```
</details>
<br>
<video width="600" controls autoplay loop muted>
<source src="./_media/resizable-frames.mp4" type="video/mp4">
</video>
### Scrollable frames
Another important feature of frames is the possibility to make them scrollable. Basalt only provides vertical scrolling for frames. If you want to make horizontal scrolling possible, you need to do it yourself. Also, if you're using :setScrollable() the amount to scroll is based on the object's y-position + height - you can change this by using :setScrollAmount(amount). Only count's for the basalt implementation of scrollable frames.
<details>
<summary>Click here to show code</summary>
```lua
local basalt = require("basalt")
local main = basalt.createFrame():setTheme({FrameBG = colors.black, FrameFG = colors.lightGray})
-- Vertical scrolling is pretty simple, as you can tell:
local sub1 = main:addFrame():setScrollable():setSize(20, 15):setPosition(2, 2)
sub1:addLabel():setPosition(3, 2):setText("Scrollable")
sub1:addLabel():setPosition(3, 12):setText("Inside")
sub1:addLabel():setPosition(3, 20):setText("Outside")
-- Here we create a custom scroll event as you can see we dont add a :setScrollable() method to our frame, instead we add a custom scroll event
local objects = {}
local sub2 = main:addFrame():setPosition(23, 2):setSize(25, 5):onScroll(function(self, event, dir)
local maxScroll = 0
for k,v in pairs(objects)do -- here we iterate trough every object and get their x position + width this way we can find out what's the maximum allowed value to scroll
local x = v:getX()
local w = v:getWidth()
maxScroll = x + w > maxScroll and x + w or maxScroll -- if you don't understand this line, http://lua-users.org/wiki/TernaryOperator
end
local xOffset = self:getOffset()
if(xOffset+dir>=0 and xOffset+dir<=maxScroll-self:getWidth())then
self:setOffset(xOffset+dir, 0)
end
end)
-- Because we need to iterate the objects, we add them into a table.
table.insert(objects, sub2:addButton():setPosition(2, 2):setText("Scrollable"))
table.insert(objects, sub2:addButton():setPosition(16, 2):setText("Inside"))
table.insert(objects, sub2:addButton():setPosition(30, 2):setText("Outside"))
basalt.autoUpdate()
```
</details>
<br>
<video width="600" controls autoplay loop muted>
<source src="./_media/scrollable-frames.mp4" type="video/mp4">
</video>
|[getOffset](objects/BaseFrame/getOffset.md)|Returns the current offset of the BaseFrame object
|[setOffset](objects/BaseFrame/setOffset.md)|Sets a new offset for the BaseFrame object

View File

@@ -0,0 +1,20 @@
## getOffset
### Description
Returns the current offset
### Returns
1. `x` the x coordinate
2. `y` the y coordinate
### Usage
* Returns the offset coordinates
```lua
local myFrame = basalt.createFrame():setOffset(5, 3)
basalt.debug(myFrame:getOffset())
```

View File

@@ -1,25 +1,36 @@
## setOffset
### Description
Sets the frame's coordinate offset. The frame's child objects will receive the frame's coordinate offset. For example, when using a scrollbar, if you use its value to add an offset to a frame, you will get a scrollable frame.
Objects are also able to ignore the offset by using :ignoreOffset() (For example, you may want to ignore the offset on the scrollbar itself)
Objects are also able to ignore the offset by using ':ignoreOffset()' (For example, you may want to ignore the offset on the scrollbar itself).
The function can also be supplied with negative values
The function can also be supplied with negative values.
### Parameters
#### Parameters:
1. `number` The x direction offset (+/-)
2. `number` The y direction offset (+/-)
#### Returns:
### Returns
1. `frame` The frame being used
#### Usage:
### Usage
* Creates a new base frame with x offset of 5 and a y offset of 3
```lua
local myFrame = basalt.createFrame():setOffset(5, 3)
```
* Creates with x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
* Creates a base frame with x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
```lua
local myFrame = basalt.createFrame():setOffset(5, -5)
```
```xml
<frame xOffset="5" yOffset="-5"></frame>
```
```

17
docs/objects/Graph.md Normal file
View File

@@ -0,0 +1,17 @@
Graph is a versatile object for visualizing data in various formats such as scatter, line, or bar graphs. It inherits from the ChangeableObject, VisualObject, and Object classes, which provide it with additional properties and methods. The Graph object allows you to customize its appearance, manage data points, and define the display range.
In addition to the methods inherited from the Object, VisualObject, and ChangeableObject classes, Graph objects have the following methods:
| | |
|---|---|
|[setGraphColor](objects/Graph/setGraphColor.md)|Sets the color of the graph
|[setGraphSymbol](objects/Graph/setGraphSymbol.md)|Sets the symbol used to represent data points in the graph
|[getGraphSymbol](objects/Graph/getGraphSymbol.md)|Returns the symbol used to represent data points in the graph
|[addDataPoint](objects/Graph/addDataPoint.md)|Adds a data point to the graph
|[setMaxValue](objects/Graph/setMaxValue.md)|Sets the maximum value displayed on the graph
|[getMaxValue](objects/Graph/getMaxValue.md)|Returns the maximum value displayed on the graph
|[setMinValue](objects/Graph/setMinValue.md)|Sets the minimum value displayed on the graph
|[getMinValue](objects/Graph/getMinValue.md)|Returns the minimum value displayed on the graph
|[setGraphType](objects/Graph/setGraphType.md)|Sets the type of the graph (scatter, line, or bar)
|[setMaxEntries](objects/Graph/setMaxEntries.md)|Sets the maximum number of data points displayed on the graph
|[getMaxEntries](objects/Graph/getMaxEntries.md)|Returns the maximum number of data points displayed on the graph

View File

@@ -0,0 +1,20 @@
## getMinValue
### Description
Returns the current minimum value of the graph.
### Returns
1. `number` minValue - The current minimum value of the graph.
### Usage
* Gets the minimum value of the graph
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph()
local minValue = aGraph:getMinValue()
basalt.debug("Min value:", minValue)
```

View File

@@ -0,0 +1,23 @@
## addDataPoint
### Description
Sets a data point in the graph with specified value.
### Parameters
1. `number` value - The value of the data point. (0-100)
### Returns
1. `object` The object in use
### Usage
* Sets a data point in the graph
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph()
aGraph:setDataPoint(13)
```

View File

@@ -0,0 +1,20 @@
## getGraphSymbol
### Description
Returns the current symbol used for the graph.
### Returns
1. `string` graphSymbol - The symbol used for the graph line.
### Usage
* Gets the graph symbol
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph()
local graphSymbol = aGraph:getGraphSymbol()
basalt.debug(graphSymbol)
```

View File

@@ -0,0 +1,20 @@
## getMaxEntries
### Description
Returns the maximum number of data points that can be stored in the graph.
### Returns
1. `number` maxEntries - The maximum number of data points
### Usage
* Gets the maximum number of data points in the graph
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph():setMaxEntries(100)
local maxEntries = aGraph:getMaxEntries()
basalt.debug(maxEntries)
```

View File

@@ -0,0 +1,20 @@
## getMaxValue
### Description
Returns the current maximum value of the graph.
### Returns
1. `number` maxValue - The current maximum value of the graph.
### Usage
* Gets the maximum value of the graph
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph()
local maxValue = aGraph:getMaxValue()
basalt.debug("Max value:", maxValue)
```

View File

@@ -0,0 +1,23 @@
## setGraphColor
### Description
Sets the color of the graph symbol.
### Parameters
1. `number` color - The color you want to set for the graph line.
### Returns
1. `object` The object in use
### Usage
* Sets the color of the graph line:
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph()
aGraph:setGraphColor(colors.blue)
```

View File

@@ -0,0 +1,22 @@
## setGraphSymbol
### Description
Sets the symbol used for the graph.
### Parameters
1. `string` symbol - The symbol to be used for the graph.
### Returns
1. `object` The object in use
### Usage
* Sets the graph symbol to "X"
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph():setGraphSymbol("X")
```

View File

@@ -0,0 +1,22 @@
## setGraphType
### Description
Sets the type of the graph to scatter, line, or bar. Default: line.
### Parameters
1. `number` graphType - The type of the graph ("scatter", "line", or "bar").
### Returns
1. `object` The object in use
### Usage
* Sets the graph type to a line graph
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph():setGraphType("scatter")
```

View File

@@ -0,0 +1,23 @@
## setMaxEntries
### Description
Sets the maximum number of data points that can be stored in the graph.
### Parameters
1. `number` maxEntries - The maximum number of data points
### Returns
1. `object` The object in use
### Usage
* Sets the maximum number of data points in the graph
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph()
aGraph:setMaxEntries(100)
```

View File

@@ -0,0 +1,22 @@
## setMaxValue
### Description
Sets the maximum value for the graph.
### Parameters
1. `number` maxValue - The maximum value for the graph.
### Returns
1. `object` The object in use
### Usage
* Sets the maximum value for the graph to 100
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph():setMaxValue(100)
```

View File

@@ -0,0 +1,22 @@
## setMinValue
### Description
Sets the minimum value for the graph.
### Parameters
1. `number` minValue - The minimum value for the graph.
### Returns
1. `object` The object in use
### Usage
* Sets the minimum value for the graph to 10
```lua
local mainFrame = basalt.createFrame()
local aGraph = mainFrame:addGraph():setMinValue(10)
```

View File

@@ -1,18 +1,50 @@
The image object is for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images.
The Image object is designed for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images, allowing for greater customization of your interface's appearance.
[Object](objects/Object.md) methods also apply for images.
In addition to the Object and VisualObject methods, Progressbar objects have the following methods:
| | |
|---|---|
|[loadImage](objects/Image/loadImage.md)|Loads an image from the specified file path
|[setImage](objects/Image/setImage.md)|Set's a new image
|[usePalette](objects/Image/usePalette.md)|Changes the used palette to the image prefered palette
|[usePalette](objects/Image/usePalette.md)|Changes the used palette to the image preferred palette
|[play](objects/Image/play.md)|Plays an animated image
|[selectFrame](objects/Image/selectFrame.md)|Selects a specific frame in an animated image
|[getMetadata](objects/Image/getMetadata.md)|Returns the metadata of the image
|[setImageSize](objects/Image/setImageSize.md)|Sets the size of the image
|[getImageSize](objects/Image/getImageSize.md)|Returns the width and height of the image
|[resizeImage](objects/Image/resizeImage.md)|Resizes the image to the specified dimensions
|[setOffset](objects/Image/setOffset.md)|Sets the offset of the image
|[getOffset](objects/Image/getOffset.md)|Returns the offset of the image
|[addFrame](objects/Image/addFrame.md)|Adds a new frame to the image
|[getFrame](objects/Image/getFrame.md)|Returns the specified frame
|[getFrameObject](objects/Image/getFrameObject.md)|Returns the Frame object of the specified frame
|[removeFrame](objects/Image/removeFrame.md)|Removes the specified frame
|[moveFrame](objects/Image/moveFrame.md)|Moves a frame to a new position
|[getFrames](objects/Image/getFrames.md)|Returns all frames of the image
|[getFrameCount](objects/Image/getFrameCount.md)|Returns the number of frames in the image
|[getActiveFrame](objects/Image/getActiveFrame.md)|Returns the currently active frame
|[clear](objects/Image/clear.md)|Clears the image
|[getImage](objects/Image/getImage.md)|Returns the image's data
|[blit](objects/Image/blit.md)|Writes text, foreground and background into the image
|[setText](objects/Image/setText.md)|Writes text into the image
|[setBg](objects/Image/setBg.md)|Writes background color into the image
|[setFg](objects/Image/setFg.md)|Writes text color into the image
# About Bimg
## About Bimg
Bimg is a custom image format that can be used in place of .nfp, it is a table which can store multiple frames and metadata. The frames can store text, background and foreground, which makes it possible to create any image you'd like. The image format is made by people from the Minecraft Computercraft Mods - Discord. Here's a Github page which explains how the Bimg format works: [bimg](https://github.com/SkyTheCodeMaster/bimg)
Bimg is a custom image format that can be used as an alternative to .nfp. It is a table that can store multiple frames and metadata. The frames can store text, background, and foreground colors, enabling the creation of a wide variety of images. The Bimg format was developed by members of the Minecraft Computercraft Mods Discord community. For more information on the Bimg format, visit the GitHub page: [bimg](https://github.com/SkyTheCodeMaster/bimg)
## Example
Here's an example of how to create and use an Image object:
```lua
-- Create a new Image object
local main = basalt.createFrame()
local myImage = main:addImage()
-- Load an image from a file
myImage:loadImage("/path/to/your/image.nfp")
```
This example demonstrates how to create an Image object, load an image from a file, and display the image on the interface.

View File

@@ -0,0 +1,29 @@
## addFrame
### Description
Adds a new frame to the image object. This is useful for creating animations with the image object by adding multiple frames that can be played in sequence.
### Parameters
1. `number` index - The index of the frame.
2. `table` frame - A table in bimg format representing a single frame of the animation.
### Returns
1. `object` The object in use
### Usage
* Adds a new frame to an existing image object's animation.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frameToAdd = {
{"Hello", "fffff", "33333"}
}
aImage:addFrame(2, frameToAdd)
```

View File

@@ -0,0 +1,19 @@
## clear
### Description
Clears all frames from the image object.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads a bimg image, and clears all frames.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
aImage:clear()
```

View File

@@ -0,0 +1,20 @@
## getActiveFrame
### Description
Returns the index of the currently active frame in the image object.
### Returns
1. `number` The index of the currently active frame in the image object.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the index of the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local activeFrame = aImage:getActiveFrame()
basalt.debug(activeFrame)
```

View File

@@ -0,0 +1,23 @@
## getFrame
### Description
Retrieves a frame from the image object at the specified index.
### Parameters
1. `number` index - The index of the frame to retrieve.
### Returns
1. `table` The frame at the specified index in bimg format.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the frame at index 2.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frame = aImage:getFrame(2)
```

View File

@@ -0,0 +1,20 @@
## getFrameCount
### Description
Returns the total number of frames in the image object.
### Returns
1. `number` The total number of frames in the image object.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the frame count
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frameCount = aImage:getFrameCount()
basalt.debug(frameCount)
```

View File

@@ -0,0 +1,23 @@
## getFrameObject
### Description
Retrieves a frame object from the image object at the specified index. This method works with bimg format images and can be used to access and manipulate individual frames.
### Parameters
1. `number` index - The index of the frame to retrieve.
### Returns
1. `object` The frame object at the specified index, with methods to interact and modify the frame.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the frame object at index 2.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frameObject = aImage:getFrameObject(2)
```

View File

@@ -0,0 +1,19 @@
## getFrames
### Description
Retrieves a table containing all the frames in the image object..
### Returns
1. `table` A table containing all the frames in the image object.
### Usage
* Creates a new image object, loads a bimg image, and retrieves all the frames.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frames = aImage:getFrames()
```

View File

@@ -0,0 +1,19 @@
## getImage
### Description
Returns the current image of the image object in its internal format. This is useful if you need to access the raw image data for manipulation or analysis purposes.
### Returns
1. `table` The current image in the image object
### Usage
* Creates a new image object, loads an image, and gets the current image
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local currentImage = aImage:getImage()
```

View File

@@ -1,6 +1,21 @@
## getImageSize
### Description
Returns the current image size
#### Returns:
1. `number` width
2. `number` height
### Returns
1. `number` width - The current width of the image
2. `number` height - The current height of the image object
### Usage
* Gets the size of an image and prints it
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp")
local width, height = aImage:getImageSize()
basalt.debug("Image width:", width, "Image height:", height)
```

View File

@@ -1,9 +1,23 @@
## getMetadata
### Description
Returns the metadata set in the image
#### Parameter:
### Parameter
1. `string` the metadata key (for example: title, description, author, creator, data, width, height,...)
#### Returns:
### Returns
1. `any` metadata value
### Usage
* Load an image and get the metadata for the "title" key
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local title = aImage:getMetadata("title")
```

View File

@@ -0,0 +1,23 @@
## getOffset
### Description
Gets the image's current coordinate offset. The offset values represent the distance the image has been moved relative to its original position.
### Returns
1. `number` offsetX - The x direction offset (+/-)
2. `number` offsetY - The y direction offset (+/-)
### Usage
* Creates a new image object, loads the image, sets an offset, and retrieves the current offset values.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):setOffset(5, 3)
local offsetX, offsetY = aImage:getOffset()
basalt.debug("Offset X: ", offsetX)
basalt.debug("Offset Y: ", offsetY)
```

View File

@@ -1,15 +1,18 @@
## loadImage
### Description
This method is used to load an image file into the image object.
#### Parameters:
### Parameters
1. `path` the absolute file path
1. `string` path - The absolute file path
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a default image and loads a test.nfp file

View File

@@ -0,0 +1,24 @@
## moveFrame
### Description
Moves a frame from one index to another within the image object. This method is useful when working with bimg format images and animations, allowing you to reorder frames in the animation sequence.
### Parameters
1. `number` fromIndex - The current index of the frame you want to move.
2. `number` toIndex - The new index where you want to move the frame.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads a bimg image, and moves the frame at index 1 to index 3.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
aImage:moveFrame(1, 3)
```

View File

@@ -1,10 +1,22 @@
## play
### Description
Plays a bimg animation. This can only work if the bimg has more than 1 frame.
#### Parameters:
### Parameters
1. `boolean` If the image animation should play
#### Returns:
### Returns
1. `object` The object in use
1. `object` The object in use
### Usage
* Creates an image and plays the animation.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("animated_bimg.bimg"):play(true)
```

View File

@@ -0,0 +1,23 @@
## removeFrame
### Description
Removes a frame from the image object at the specified index.
### Parameters
1. `number` index - The index of the frame to remove.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads a bimg image, and removes the frame at index 2.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
aImage:removeFrame(2)
```

View File

@@ -1,19 +1,23 @@
## resizeImage
This method is used to resize a bimg image. It takes two parameters: the new width, and the new height. It is important to note that resizing images can result in a loss of quality, as the original pixel data is being transformed and resampled to fit the new dimensions. This is especially noticeable when increasing the size of an image, as new pixels must be generated to fill in the gaps. As a result, it is generally recommended to use the original image at its full size whenever possible, rather than resizing it.
#### Parameters:
### Description
1. `number` the new width
2. `number` the new height
This method is used to resize the image. It takes two parameters: the new width, and the new height. It is important to note that resizing images can result in a loss of quality, as the original pixel data is being transformed and resampled to fit the new dimensions. This is especially noticeable when increasing the size of an image, as new pixels must be generated to fill in the gaps. As a result, it is generally recommended to use the original image at its full size whenever possible, rather than resizing it.
### Parameters
1. `number` width - The new width for the image
2. `number` height - The new height for the image
### Returns
#### Returns:
1. `object` The object in use
#### Usage:
### Usage
* Creates a new image object, loads the image and changes it's size.
* Creates a new image object, loads the image, and changes its size
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):resizeImage(40, 20)
local aImage = mainFrame:addImage():loadImage("resize_example.bimg"):resizeImage(40, 20)
```

View File

@@ -1,17 +1,20 @@
## selectFrame
### Description
The selectFrame method allows you to change the current frame of an image object. It takes a single parameter, the index of the frame you want to display.
#### Parameters:
### Parameters
1. `number` the frame index
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a default image and loads a test.nfp file
* Creates a default image and loads a test.bimg file, then selects the second frame
```lua
local mainFrame = basalt.createFrame()

View File

@@ -0,0 +1,24 @@
## setBg
### Description
Sets or modifies the background color of a specified position in the currently active frame of the image object.
### Parameters
1. `string` backgroundColor - The color of the background at the specified position.
2. `number` x - The x-coordinate of the text position.
3. `number` y - The y-coordinate of the text position.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, adds a frame, and sets the background color in the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():addFrame():setBg(1, 1, "000000")
```

View File

@@ -0,0 +1,24 @@
## setFg
### Description
Sets or modifies the foreground color of a specified position in the currently active frame of the image object.
### Parameters
1. `string` foregroundColor - The color of the foreground at the specified position.
2. `number` x - The x-coordinate of the text position.
3. `number` y - The y-coordinate of the text position.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, adds a frame, and sets the foreground color in the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():addFrame():setFg(1, 1, "ffffff")
```

View File

@@ -1,14 +1,17 @@
## setImage
### Description
Sets a new image
#### Parameter:
### Parameter
1. `table` A table in bimg or nfp format.
1. `string` The format in which the image should be loaded (nfp or bimg)
#### Usage:
### Usage
* Creates a default image and loads a test.nfp file
* Creates a default image and loads a test.nfp
```lua
local mainFrame = basalt.createFrame()

View File

@@ -0,0 +1,23 @@
## setImageSize
### Description
Sets the size of the image object. This can be useful when you need to scale an image to fit a specific area.
### Parameters
1. `number` width - The desired width of the image object
2. `number` height - The desired height of the image object
### Returns
1. `object` The object in use
### Usage
* Creates an image and sets its size to 10x5
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp"):setImageSize(10, 5)
```

View File

@@ -0,0 +1,23 @@
## setOffset
### Description
Sets the image's coordinate offset. The offset moves the image relative to its original position. It can be used to adjust the position of the image without affecting its layout within the container.
### Parameters
1. `number` offsetX - The x direction offset (+/-)
2. `number` offsetY - The y direction offset (+/-)
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads the image, and sets an offset of 5 in the x direction and 3 in the y direction.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):setOffset(5, 3)
```

View File

@@ -0,0 +1,25 @@
## setText
### Description
Sets or modifies the text at a specified position in the currently active frame of the image object. This allows you to create or modify text within an image directly.
### Parameters
1. `string` text - The text to be placed at the specified position
2. `number` x - The x-coordinate of the text position.
3. `number` y - The y-coordinate of the text position.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, adds a frame, and sets the text in the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():addFrame():setText("Hello", 1, 1)
```

View File

@@ -1,11 +1,22 @@
## usePalette
### Description
Changes the palette colors of the image, if the bimg image has palette metadata.
#### Parameter:
### Parameter
1. `boolean` if the image should change the palette
#### Returns:
### Returns
1. `object` The object in use
### Usage
* Creates an image and enables the use of the palette.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test_with_palette.bimg"):usePalette(true)
```

View File

@@ -1,12 +1,33 @@
With input's you are able to create a object where the user can type something in.<br>
Input objects allow you to create a field where the user can enter text.
[Object](objects/Object.md) methods also apply for input objects.
In addition to the Object and VisualObject methods, Input objects have the following methods:
| | |
|---|---|
|[setInputType](objects/Input/setInputType.md)|Sets the input type
|[getInputType](objects/Input/getInputType.md)|Returns the input type
|[setDefaultText](objects/Input/setDefaultText.md)|Sets the default text
|[setInputLimit](objects/Input/setInputLimit.md)|Sets a limit to be able to write
|[getInputLimit](objects/Input/getInputLimit.md)|Returns the limit
|[setInputLimit](objects/Input/setInputLimit.md)|Sets a limit to the number of characters that can be entered
|[getInputLimit](objects/Input/getInputLimit.md)|Returns the character limit
|[setOffset](objects/Input/setOffset.md)|Changes the offset inside the input
|[getOffset](objects/Input/getOffset.md)|Returns the input offset
|[setTextOffset](objects/Input/setTextOffset.md)|Changes the cursor position
|[getTextOffset](objects/Input/getTextOffset.md)|Returns the cursor position
Here's an example of how to create an Input object and set its properties:
Lua:
```lua
local main = basalt.createFrame()
local anInput = main:addInput()
anInput:setInputType("text")
anInput:setDefaultText("Username")
anInput:setInputLimit(20)
```
XML:
```xml
<input type="text" defaultText="Username" inputLimit="20" />
```

View File

@@ -1,11 +1,17 @@
## getInputLimit
Returns the input limit.
#### Returns:
### Description
Returns the character limit set for the Input object.
### Returns
1. `number` character limit
#### Usage:
### Usage
* Creates a default input and sets the character limit to 8. Prints the current limit.
```lua
local mainFrame = basalt.createFrame()
local aInput = mainFrame:addInput():setInputLimit(8)

View File

@@ -1,13 +1,19 @@
## getInputType
Gets the current input type
#### Returns:
1. `string` input type
### Description
Gets the current input type of the Input object.
### Returns
1. `string` inputType - The current input type.
### Usage
* Creates a default input, sets it to accept numbers only, and prints the current input type to the log.
#### Usage:
* Creates a default input and sets it to numbers only. Also prints the current input type to log.
```lua
local mainFrame = basalt.createFrame()
local aInput = mainFrame:addInput():setInputType("number")
basalt.debug(aInput:getInputType())
```
```

View File

@@ -1,20 +1,28 @@
## setDefaultText
Sets the default text. This will only be displayed if there is no input set by the user.
#### Parameters:
1. `string` input type ("text", "password", "number")
2. `number|color` default background color - optional
3. `number|color` default text color - optional
### Description
Sets the default text for the Input object. This will only be displayed if there is no input set by the user.
### Parameters
1. `string` default text
2. `number` default background color (optional)
3. `number` default text color (optional)
### Returns
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default input and sets the default text to "...".
### Usage
* Creates a default input and sets the default text to "..." with optional background and text colors.
```lua
local mainFrame = basalt.createFrame()
local aInput = mainFrame:addInput():setDefaultText("...")
local aInput = mainFrame:addInput():setDefaultText("...", colors.gray, colors.lightGray)
```
```xml
<input default="..." />
```
<input default="..." defaultBgColor="gray" defaultTextColor="lightGray" />
```

View File

@@ -1,18 +1,26 @@
## setInputLimit
Sets a character limit to the input.
#### Parameters:
1. `number` character limit
### Description
Sets a character limit for the Input object, restricting the number of characters that can be entered.
### Parameters
1. `number` characterLimit - The maximum number of characters allowed.
### Returns
#### Returns:
1. `object` The object in use
#### Usage:
### Usage
* Creates a default input and sets the character limit to 8.
```lua
local mainFrame = basalt.createFrame()
local aInput = mainFrame:addInput():setInputLimit(8)
```
```xml
<input limit="8" />
```
```

View File

@@ -1,18 +1,26 @@
## setInputType
Changes the input type. default: text
#### Parameters:
1. `string` input type ("text", "password", "number")
### Description
Changes the input type of the Input object. The default input type is "text".
### Parameters
1. `string` inputType - The input type to set. Accepted values are "text", "password", and "number".
### Returns
#### Returns:
1. `object` The object in use
#### Usage:
### Usage
* Creates a default input and sets it to numbers only.
```lua
local mainFrame = basalt.createFrame()
local aInput = mainFrame:addInput():setInputType("number")
```
```xml
<input type="number" />
```
```

View File

@@ -1,8 +1,6 @@
A label is for adding simple text.
A Label object is used to display simple text on the interface.
By default label's width is auto sizing based on the length of the text. If you change the size with setSize it will automatically stop autosizing the width.
The fontsize feature is calculated by bigfonts, a library made by Wojbie (http://www.computercraft.info/forums2/index.php?/topic/25367-bigfont-api-write-bigger-letters-v10/)
In addition to the Object and VisualObject methods, Label objects have the following methods:
[Object](objects/Object.md) methods also apply for labels.
@@ -11,3 +9,25 @@ The fontsize feature is calculated by bigfonts, a library made by Wojbie (http:/
|[setText](objects/Label/setText.md)|Sets the input type
|[setFontSize](objects/Label/setFontSize.md)|Returns the input type
|[getFontSize](objects/Label/getFontSize.md)|Sets the default text
|[setTextAlign](objects/Label/setTextAlign.md)|Changes the horizontal text align
By default, a label's width is auto-sized based on the length of the text. If you change the size with setSize, it will automatically stop auto-sizing the width.
The fontsize feature is calculated by bigfonts, a library made by Wojbie (http://www.computercraft.info/forums2/index.php?/topic/25367-bigfont-api-write-bigger-letters-v10/)
Here's an example of how to create a Label object and set its properties:
Lua:
```lua
local main = basalt.createFrame()
local aLabel = main:addLabel()
aLabel:setText("Hello, World!")
aLabel:setFontSize(2)
```
XML:
```xml
<label text="Hello World!" fontSize="2" />
```

View File

@@ -1,13 +1,19 @@
## getFontSize
### Description
Returns the current font size
#### Returns:
### Returns
1. `number` font size
#### Usage:
### Usage
* Creates a default label, sets the text to "Basalt!" and its font size to 2. Also prints the current fontsize.
```lua
local mainFrame = basalt.createFrame()
local aLabel = mainFrame:addLabel():setText("Basalt!"):setFontSize(2)
basalt.debug(aLabel:getFontSize())
```
```

View File

@@ -1,18 +1,26 @@
## setFontSize
Sets the font size, calculated by bigfonts. Default size is 1.
#### Parameters:
### Description
Sets the font size for the Label object, calculated by bigfonts. Default size is 1.
### Parameters
1. `number` The size (1, 2, 3, 4)
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a default label, sets the text to "Basalt!" and its font size to 2.
```lua
local mainFrame = basalt.createFrame()
local aLabel = mainFrame:addLabel():setText("Basalt!"):setFontSize(2)
```
```xml
<label font="2" />
```
<label text="Basalt!" fontSize="2" />
```

View File

@@ -1,18 +1,24 @@
## setText
Sets the text which gets displayed.
#### Parameters:
Sets the text which gets displayed in the Label object.
### Parameters
1. `string` The text which should be displayed
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a default label with text "Some random text".
```lua
local mainFrame = basalt.createFrame()
local aLabel = mainFrame:addLabel():setText("Some random text")
```
```xml
<label text="Some random text" />
```
```

View File

@@ -0,0 +1,24 @@
## setTextAlign
Sets the text alignment within the Label object. It can be left, center, or right aligned.
### Parameters
1. `string` The text alignment ("left", "center", "right")
### Returns
1. `object` The object in use
### Usage
* Creates a default label with text "Some random text" and sets the text alignment to "center".
```lua
local mainFrame = basalt.createFrame()
local aLabel = mainFrame:addLabel():setText("Some random text"):setTextAlign("center")
```
```xml
<label text="Some random text" align="center" />
```

Some files were not shown because too many files have changed in this diff Show More