Some docs updates

This commit is contained in:
Robert Jelic
2022-08-30 20:49:25 +02:00
parent c977410a41
commit 2dd3bf648b
22 changed files with 181 additions and 131 deletions

View File

@@ -13,8 +13,8 @@ Adds a item into the list
#### Usage:
* Creates a default menubar with 3 entries
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -7,8 +7,8 @@ Removes all items.
#### Usage:
* Creates a default menubar with 3 entries and removes them immediatley. Which makes no sense.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -14,8 +14,8 @@ Edits a item from the menubar
#### Usage:
* Creates a default menubar with 3 entries and edits the second one.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -7,8 +7,8 @@ Returns all items as table
#### Usage:
* Creates a default menubar with 3 entries and prints a table.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -10,8 +10,8 @@ Returns a item by index
#### Usage:
* Creates a default menubar with 3 entries and edits the second one.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMeubar()
local main = basalt.createFrame()
local aMenubar = main:addMeubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -7,8 +7,8 @@ Returns the current item count
#### Usage:
* Creates a default menubar with 3 entries and prints the current item count.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -7,8 +7,8 @@ returns the item index of the currently selected item
#### Usage:
* Creates a default menubar with 3 entries selects the second entry and prints the currently selected index.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -7,8 +7,8 @@ Returns the current index offset
#### Usage:
* Creates a default menubar with 6 entries and sets the offset to 3, also prints the current offset.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry")
:addItem("3. Entry")

View File

@@ -10,8 +10,8 @@ Removes a item from the menubar
#### Usage:
* Creates a default menubar with 3 entries and removes the second one.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -10,8 +10,8 @@ selects a item in the menubar (same as a player would click on a item)
#### Usage:
* Creates a default menubar with 3 entries and selects the second entry.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -10,8 +10,8 @@ Sets the offset of the menubar (the same as you would scroll) - default is 0
#### Usage:
* Creates a default menubar with 6 entries and sets the offset to 3.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry")
:addItem("3. Entry")

View File

@@ -10,8 +10,8 @@ Makes it possible to scroll while the mouse is over the menubar
#### Usage:
* Creates a new menubar and makes it scrollable
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar():setScrollable(true)
local main = basalt.createFrame()
local aMenubar = main:addMenubar():setScrollable(true)
:addItem("1. Entry")
:addItem("2. Entry")
:addItem("3. Entry")

View File

@@ -11,8 +11,8 @@ Sets the background and the foreground of the item which is currently selected
#### Usage:
* Creates a default menubar with 4 entries and sets the selection background color to green.
```lua
local mainFrame = basalt.createFrame()
local aMenubar = mainFrame:addMenubar()
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)

View File

@@ -0,0 +1,27 @@
## setSpace
Sets the background and the foreground of the item which is currently selected
#### Parameters:
1. `number` The space you want between the entries
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default menubar with 4 entries and sets the space to 3.
```lua
local main = basalt.createFrame()
local aMenubar = main:addMenubar()
:addItem("1. Entry")
:addItem("2. Entry",colors.yellow)
:addItem("3. Entry",colors.yellow,colors.green)
:addItem("4. Entry")
:setSpace(3)
```
```xml
<menubar selectionBG="green" selectionFG="red" space="3">
<item><text>1. Entry</text></item>
<item><text>2. Entry</text><bg>yellow</bg></item>
<item><text>2. Entry</text><bg>yellow</bg><fg>green</fg></item>
</menubar>
```

View File

@@ -41,3 +41,24 @@ local button2 = main:addButton()
basalt.autoUpdate()
```
Also very interesting is a button where you are able to resize the frame just by dragging the button.
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
local sub = main:addFrame():setSize(30,12):setMovable()
sub:addLabel():setText("Example Frame"):setSize("parent.w", 1):setBackground(colors.black):setForeground(colors.lightGray)
local dragButton = sub:addButton()
:setAnchor("bottomRight")
:setPosition(1,1)
:setSize(1,1)
:setText("/")
:onDrag(function(self, button, x, y, xOffset, yOffset)
sub:setSize(-xOffset, -yOffset, true)
end)
basalt.autoUpdate()
```

View File

@@ -1,108 +1,12 @@
Scrollbars are objects, the user can scroll vertically or horizontally, this will change a value, which you can access by :getValue().<br>
Remember scrollbar also inherits from [Object](objects/Object.md)
## setSymbol
Changes the scrollbar symbol, default is " "
#### Parameters:
1. `string` symbol
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the symbol to X
```lua
local mainFrame = basalt.createFrame()
local scrollbar = mainFrame:addScrollbar():setSymbol("X")
```
```xml
<scrollbar symbol="X" />
```
## setBackgroundSymbol
Changes the symbol in the background, default is "\127"
#### Parameters:
1. `string` symbol
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the background symbol to X
```lua
local mainFrame = basalt.createFrame()
local scrollbar = mainFrame:addScrollbar():setBackgroundSymbol("X")
```
```xml
<scrollbar backgroundSymbol="X" />
```
## setBarType
Changes the scrollbar to be vertical or horizontal, default is vertical
#### Parameters:
1. `string` vertical or horizontal
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the bar type to horizontal
```lua
local mainFrame = basalt.createFrame()
local scrollbar = mainFrame:addScrollbar():setBarType("horizontal")
```
```xml
<scrollbar barType="horizontal" />
```
## setMaxValue
the default max value is always the width (if horizontal) or height (if vertical), if you change the max value the bar will always calculate the value based on its width or height - example: you set the max value to 100, the height is 10 and it is a vertical bar, this means if the bar is on top, the value is 10, if the bar goes one below, it is 20 and so on.
#### Parameters:
1. `number` maximum
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the max value to 20
```lua
local mainFrame = basalt.createFrame()
local scrollbar = mainFrame:addScrollbar():setMaxValue(20)
```
```xml
<scrollbar maxValue="20" />
```
## setIndex
Changes the current index to your choice, for example you could create a button which scrolls up to 1 by using :setIndex(1)
#### Parameters:
1. `number` the index
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the index to 1 as soon as the button got clicked
```lua
local mainFrame = basalt.createFrame()
local scrollbar = mainFrame:addScrollbar():setMaxValue(20)
local button = mainFrame:addButton(function()
scrollbar:setIndex(1)
end)
```
```xml
<scrollbar index="2" />
```
## getIndex
Returns the current index
#### Returns:
1. `number` index
[Object](objects/Object.md) methods also apply for scrollbars.
| | |
|---|---|
|[setSymbol](objects/Slider/setSymbol.md)|Sets the slider symbol
|[setBackgroundSymbol](objects/Slider/setBackgroundSymbol.md)|Sets the background symbol
|[setBarType](objects/Slider/setBarType.md)|Sets the bar type (vertical or horizontal)
|[setMaxValue](objects/Slider/setMaxValue.md)|Sets the maximum value
|[setIndex](objects/Slider/setIndex.md)|Sets the current index
|[getIndex](objects/Slider/getIndex.md)|Returns the index

View File

@@ -0,0 +1,5 @@
## getIndex
Returns the current index
#### Returns:
1. `number` index

View File

@@ -0,0 +1,18 @@
## setBackgroundSymbol
Changes the symbol in the background, default is "\127"
#### Parameters:
1. `string` symbol
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the background symbol to X
```lua
local main = basalt.createFrame()
local scrollbar = main:addScrollbar():setBackgroundSymbol("X")
```
```xml
<scrollbar backgroundSymbol="X" />
```

View File

@@ -0,0 +1,18 @@
## setBarType
Changes the scrollbar to be vertical or horizontal, default is vertical
#### Parameters:
1. `string` vertical or horizontal
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the bar type to horizontal
```lua
local main = basalt.createFrame()
local scrollbar = main:addScrollbar():setBarType("horizontal")
```
```xml
<scrollbar barType="horizontal" />
```

View File

@@ -0,0 +1,21 @@
## setIndex
Changes the current index to your choice, for example you could create a button which scrolls up to 1 by using :setIndex(1)
#### Parameters:
1. `number` the index
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the index to 1 as soon as the button got clicked
```lua
local main = basalt.createFrame()
local scrollbar = main:addScrollbar():setMaxValue(20)
local button = main:addButton(function()
scrollbar:setIndex(1)
end)
```
```xml
<scrollbar index="2" />
```

View File

@@ -0,0 +1,18 @@
## setMaxValue
the default max value is always the width (if horizontal) or height (if vertical), if you change the max value the bar will always calculate the value based on its width or height - example: you set the max value to 100, the height is 10 and it is a vertical bar, this means if the bar is on top, the value is 10, if the bar goes one below, it is 20 and so on.
#### Parameters:
1. `number` maximum
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new scrollbar and changes the max value to 20
```lua
local main = basalt.createFrame()
local scrollbar = main:addScrollbar():setMaxValue(20)
```
```xml
<scrollbar maxValue="20" />
```

View File

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