Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NoryiE committed May 8, 2024
1 parent 38720e6 commit a122331
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 8 deletions.
32 changes: 32 additions & 0 deletions docs/references/basalt.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Here is a list with all available methods for basalt.
|[basalt.getTerm](#basalt-getterm)|term|Returns the term used by basalt.
|[basalt.errorHandler](#basalt-errorhandler)|-|Handles all incoming errors.
|[basalt.create](#basalt-create)|object|Can create a new element.
|[basalt.requiredElement](#basalt-requiredelement)|-|Ensures that a specific element is available and loaded.
|[basalt.requiredExtension](#basalt-requiredextension)|-|Ensures that a specific extension is available and loaded.

## basalt.run <C content="basalt.run"/>

Expand Down Expand Up @@ -437,4 +439,34 @@ local main = basalt.getMainFrame()
local button = basalt.create("RandomId", nil, "Button")
button:setParent(main)
```
:::

## basalt.requiredElement <C content="basalt.requiredElement"/>

Ensures that a specific element is available and loaded. If the element is not available, it will attempt to download it from github.

### Parameters

1. `string` The name of the required element
2. `...` multiple entries possible

::: details Click to see example
```lua
basalt.requiredElement("Button") -- If the element button doesn't exist it will try to download it from github.
```
:::

## basalt.requiredExtension <C content="basalt.requiredExtension"/>

Ensures that a specific extension is available and loaded. If the extension is not available, it will attempt to download it from github.

### Parameters

1. `string` The name of the required extension
2. `...` multiple entries possible

::: details Click to see example
```lua
basalt.requiredExtension("dynamicValues") -- If the extension dynamicValues doesn't exist it will try to download it from github.
```
:::
21 changes: 21 additions & 0 deletions docs/references/betterbackgrounds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Better Backgrounds

The Better Backgrounds extension allows the use of characters or strings as backgrounds.

## Properties

|Property|Type|Description|
|---|---|---|
|backgroundSymbol|string|Specifies the symbol or string to use as the background of the element. It will be repeated to fill the entire background.
|backgroundSymbolColor|color|Specifies the color of the background symbol. Default: red

## Usage

To use the Better Backgrounds extension in Basalt, simply apply the desired background properties to your elements. For example:

```lua
local main = basalt.getMainFrame()
local frame = main:addFrame():setPosition(2, 2)

frame:setBackgroundSymbol("#"):setBackgroundSymbolColor(colors.blue)
```
31 changes: 31 additions & 0 deletions docs/references/borders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Borders

The Borders extension in Basalt adds customizable border properties to elements. This guide provides an overview of the properties available with the Borders extension and how to use them effectively.

## Properties

|Property|Type|Description|
|---|---|---|
|border|bool|Specifies whether the element has a border.
|borderClickable|bool|Specifies whether the border of the element is clickable (interactable).
|borderSides|table|Specifies which sides of the element have borders.
|borderType|string|Specifies the type of border to apply. Available options include "small" or "solid".
|borderColor|color|Specifies the color of the border.

## Methods

|Method|Returns|Description|
|---|---|---|
|setBorderSide|self|Sets the visibility of a specific border side for the element.
|getBorderSide|bool|Gets the visibility state of a specific border side for the element

## Usage

To use the Borders extension, simply apply the desired border properties to your elements. For example:

```lua
local main = basalt.getMainFrame()
local button = main:addButton()

button:setBorder(true):setBorderColor(colors.blue)
```
27 changes: 27 additions & 0 deletions docs/references/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Debug

The Debug extension is designed to facilitate the development of programs by providing tools for debugging and logging information. This guide provides an overview of the methods available with the Debug extension and how to use them effectively.

## Methods

|Method|Returns|Description|
|---|---|---|
|basalt.openDebugPanel|-|Opens or closes the debug panel, which displays debug information.
|basalt.debug|-|Logs the specified text to the debug panel for debugging purposes.

## Usage

To use the Debug extension in Basalt, simply call the provided methods in your code as needed. For example:

```lua
-- Open the debug panel
basalt.openDebugPanel(true)

-- Log debug information
basalt.debug("Initializing application...")

-- More code...

-- Log additional information
basalt.debug("Application initialized successfully.")
```
59 changes: 59 additions & 0 deletions docs/references/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ List inherit from [VisualElement](visualelement) and [Element](element)
|selectionBackground|color|The background color of the selected item in the list.
|selectionForeground|color|The foreground/text color of the selected item in the list.
|scrollIndex|number|The scrolling offset of the list.
|spacing|number|The spacing of the list.
|align|string|The alignment of items within the list (e.g., "left", "center", "right").
|connectedLists|table|A collection of other lists that are connected to this list, enabling synchronized scrolling or selection changes between them.

## Methods

Expand All @@ -32,6 +35,8 @@ List inherit from [VisualElement](visualelement) and [Element](element)
|[clear](#clear)|self|Removes all items from the list.
|[updateColor](#updatecolor)|self|Updates the color of a item.
|[getSelectionState](#getselectionstate)|boolean|Returns the selection state of the item at the given index.
|[connect](#connect)|self|Connects other lists to this list, enabling synchronized scrolling or selection changes between them.
|[disconnect](#disconnect)|self|Disconnects other lists from this list.

## Example

Expand Down Expand Up @@ -245,3 +250,57 @@ local selectionState = list:getSelectionState(1)
basalt.debug(selectionState)
```
:::

## connect <C content="connect"/>

Connects other lists to this list, enabling synchronized scrolling or selection changes between them. Make sure the lists always have the same amount of entries.

:::info
Connecting a list to another list also connects the other list to this list (it goes in both directions).
:::

### Parameters

1. `List` The other List element you want to connect.

### Returns

1. `self ` The List element itself

::: details Click to see example
```lua
local main = basalt.getMainFrame()
local list1 = main:addList()
local list2 = main:addList():setPosition(16, 1):setWidth(4):setAlign("right")
list1:connect(list2)

list1:addItem("Apple")
list2:addItem("12")
list1:addItem("Banana")
list2:addItem("8")
```
:::

## disconnect <C content="disconnect"/>

Disconnects a already connected list.

### Parameters

1. `List` The list you want to disconnect from this list.

### Returns

1. `self ` The List element itself

::: details Click to see example
```lua
local main = basalt.getMainFrame()
local list1 = main:addList()
local list2 = main:addList():setPosition(16, 1):setWidth(4):setAlign("right")
list1:connect(list2)

-- some logic
list1:disconnect(list2)
```
:::
11 changes: 11 additions & 0 deletions docs/references/main.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# References

Welcome to the Basalt API References! This section provides a guide to the elements and extensions available in Basalt.

## Elements

Elements in Basalt are the building blocks for creating user interfaces. Each element provides specific functionality and properties that can be customized.

## Extensions

Extensions in Basalt are additional features or functionalities that extend the capabilities of the framework beyond the built-in elements. These extensions provide tools and utilities to enhance the development experience and create more advanced UIs.
30 changes: 30 additions & 0 deletions docs/references/scrollbars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Scrollbars

The Scrollbars extension enhances the functionality of Container, TextField, and List elements by adding the ability to include scrollbars.

## Methods

|Method|Returns|Description|
|---|---|---|
|enableScrollbar|self|Enables the scrollbar for the element, allowing users to scroll through its content via a bar.
|disableScrollbar|self|Disables the scrollbar for the element.

## Usage

To use the Scrollbars extension in Basalt, simply call the provided methods on the supported elements. For example:

```lua
local main = basalt.getMainFrame()

local frame = main:addFrame()
local list = main:addList()
local textfield = main:addTextfield()

-- Enable scrollbar for a frame element
frame:enableScrollbar()

-- Enable scrollbar for a list element
list:enableScrollbar()

-- Enable scrollbar for a textfield element
textfield:enableScrollbar()
17 changes: 17 additions & 0 deletions docs/references/shadows.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Shadows

The Shadows extension in Basalt enhances the visual appearance of elements by adding shadows. This guide provides an overview of the properties available with the Shadows extension and how to use them effectively.

## Properties

|Property|Type|Description|
|---|---|---|
|shadow|bool|Specifies whether the element has a shadow.
|shadowDirection|bool|Specifies the direction of the shadow effect. Available options include "topLeft", "topRight", "bottomLeft", and "bottomRight".
|shadowColor|table|Specifies the color of the shadow.

To use the Shadows extension in Basalt, simply apply the desired shadow properties to your elements. For example:

```lua
local main = basalt.getMainFrame()
local frame = main:addFrame():setPosition(2, 2)

frame:setShadow(true):setShadowColor(colors.blue)
```
4 changes: 2 additions & 2 deletions docs/references/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ basalt.addTemplate({
Templates can be loaded from JSON-formatted files using the `basalt.loadTemplate()` function.

```lua
basalt.loadTemplate("myTemplate", "path/to/template.json")
basalt.loadTemplate("path/to/template.json")
```

### Customizing Colors

In addition to setting default property values for UI elements, templates in Basalt also allow you to define custom colors for use throughout your interface. The `colors` section in a template JSON or Lua table enables you to specify custom color values that can be referenced by name in the template.
In addition to setting default property values for UI elements, templates also allow you to define custom colors for use throughout your interface. The `colors` section in a template JSON or Lua table enables you to specify custom color values that can be referenced by name in the template.

```json
{
Expand Down
39 changes: 39 additions & 0 deletions docs/references/xml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# XML

Basalt provides a convenient way to create and load user interface (UI) elements using XML (eXtensible Markup Language). XML allows you to define the structure and properties of UI elements in a human-readable format, making it easier to manage complex UI layouts.

## Creating UI Elements in XML

In XML, each UI element is represented by a tag, and its properties are specified as attributes within the tag. Here's a basic example of how to create a button element in XML:

```xml
<button x="10" y="10" width="100" height="30" text="Click Me" />
```

You can add additional attributes to customize the appearance and behavior of UI elements further. Refer to the Basalt documentation for a list of supported attributes for each UI element.

## Creating Events for UI Elements in XML

In XML, you can also define event handlers for UI elements to specify actions to be performed when certain events occur. For example, to add an onClick event to a button element, you can include the event handler within the button tag as follows:

```xml
<button x="10" y="10" width="100" height="30" text="Click Me">
<onClick>
basalt.debug("Button got clicked")
</onClick>
</button>
```

## Loading XML Files in Basalt

Once you've created your UI elements in XML, you can load them into your Basalt application using the `element:loadXML()` method. This method parses the XML file and creates the corresponding UI element in your application.

```lua
local basalt = require("basalt")
local main = basalt.getMainFrame()

-- Load UI elements from XML file
main:loadXML("ui_layout.xml")

basalt.run()
```
36 changes: 30 additions & 6 deletions install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,25 @@ Press "Next" to continue.
end)

Label(settings, 2, 12, "Bundle"):onClick(function(self, button)
drawHint(settingsFrame, "This will bundle all the files into one file. Making it easier to use Basalt on your computer.")
drawHint(settingsFrame, "This will bundle all the files into one file. Making it easier to use Basalt on your computer. The bundled version is meant to be used for production. If you're developing a program, you should not use the bundled version.")
end)

Label(settings, 2, 14, "Annotations"):onClick(function(self, button)
drawHint(settingsFrame, "This will download the annotations file. It will make the developement with basalt easier, as you can see the documentation of the functions in your editor. Doesn't work with the bundled installation.")
end)

local path = Input(settings, 15, 4, "{parent.w - 21}", 1, "{self.focused ? black : lightGray}", "{self.focused ? white : black}", installer.getConfig("defaultSettings").path.default)

local cache = Checkbox(settings, "{parent.w - 7}", 6, colors.lightGray, colors.black, false)

local autoUpdate = Checkbox(settings, "{parent.w - 7}", 8, colors.lightGray, colors.black, false)
local autoUpdate = Checkbox(settings, "{parent.w - 7}", 8, colors.lightGray, colors.black, false):setEnabled(false)

local minify = Checkbox(settings, "{parent.w - 7}", 10, colors.lightGray, colors.black, false)

local bundle = Checkbox(settings, "{parent.w - 7}", 12, colors.lightGray, colors.black, false)

local annotations = Checkbox(settings, "{parent.w - 7}", 14, colors.lightGray, colors.black, false)

Button(settingsFrame, 2, "{parent.h - self.h + 1}", 10, 1, colors.white, colors.black, "Back", function()
basalt.switchFrame(installDescFrame)
end)
Expand Down Expand Up @@ -396,10 +402,17 @@ Press "Next" to continue.
basalt.switchFrame(loggingFrame)
basalt.thread(function()
installer.install(eleList:getSelectedItems(), extList:getSelectedItems())
local projPath = path:getValue()
if(minify:getChecked())then
log("Minifying files...")
installer.minifyProject(path:getValue())
log("Minifying complete!")
installer.minifyProject(projPath)
end
if(bundle:getChecked())then
installer.bundleProject(projPath)
fs.delete(projPath)
end

if(annotations:getChecked())and not(bundle:getChecked())then
downloadFile(fs.combine(projPath, "annotations.lua"), "https://raw.githubusercontent.com/Pyroxenium/basalt-docs/main/bundle.lua", "Annotations")
end

backBtn:setVisible(false)
Expand Down Expand Up @@ -446,8 +459,19 @@ end

if(args[1]=="source")then
installer.install()
elseif(args[1]=="package")then
if(args[2]=="true")then
installer.minifyProject(installer.getConfig("defaultSettings").path.default)
end
elseif(args[1]=="bundled")then
installer.install()
if(args[2]=="true")then
installer.minifyProject(installer.getConfig("defaultSettings").path.default)
end
installer.bundleProject(installer.getConfig("defaultSettings").path.default)
elseif(args[1]=="minify")then
installer.minifyProject(args[2])
elseif(args[1]=="bundle")then
installer.bundleProject(args[2] or "basalt")
else
installer.gui()
end

0 comments on commit a122331

Please sign in to comment.