From 01412b4c553c56d6da7d61be614080b9319035c1 Mon Sep 17 00:00:00 2001
From: Robert Jelic <36573031+NoryiE@users.noreply.github.com>
Date: Sun, 17 Jul 2022 22:37:32 +0200
Subject: [PATCH] docs
---
Basalt/objects/Textfield.lua | 52 +++++---
docs/objects/Button.md | 45 +++++--
docs/objects/Checkbox.md | 21 ++-
docs/objects/Dropdown.md | 139 +++++++++++---------
docs/objects/Frame.md | 248 +++++++++++++++++++++++++++++++----
docs/objects/Image.md | 16 ++-
docs/objects/Input.md | 32 +++--
docs/objects/Label.md | 26 ++++
docs/objects/Menubar.md | 112 +++++++++++-----
docs/objects/Object.md | 93 +++++++++----
docs/objects/Pane.md | 8 +-
docs/objects/Program.md | 5 +
docs/objects/Progressbar.md | 58 +++++---
docs/objects/Textfield.md | 75 ++++++++++-
docs/objects/Thread.md | 22 +++-
15 files changed, 731 insertions(+), 221 deletions(-)
diff --git a/Basalt/objects/Textfield.lua b/Basalt/objects/Textfield.lua
index bef156d..09f0715 100644
--- a/Basalt/objects/Textfield.lua
+++ b/Basalt/objects/Textfield.lua
@@ -34,9 +34,9 @@ return function(name)
return pos
end
- local function updateColors()
- local fgLine = tHex[base.fgColor]:rep(fgLines[textY]:len())
- local bgLine = tHex[base.bgColor]:rep(bgLines[textY]:len())
+ local function updateColors(self)
+ local fgLine = tHex[self.fgColor]:rep(fgLines[textY]:len())
+ local bgLine = tHex[self.bgColor]:rep(bgLines[textY]:len())
for k,v in pairs(rules)do
local pos = stringGetPositions(lines[textY], v[1])
if(#pos>0)then
@@ -68,8 +68,8 @@ return function(name)
local object = {
init = function(self)
- base.bgColor = self.parent:getTheme("TextfieldBG")
- base.fgColor = self.parent:getTheme("TextfieldText")
+ self.bgColor = self.parent:getTheme("TextfieldBG")
+ self.fgColor = self.parent:getTheme("TextfieldText")
end,
getType = function(self)
return objectType
@@ -78,8 +78,8 @@ return function(name)
setValuesByXMLData = function(self, data)
base.setValuesByXMLData(self, data)
if(data["lines"]~=nil)then
- for k,v in pairs(data["lines"])do
- self:addLine(xmlValue("line", v))
+ for k,v in pairs(data["lines"]["line"])do
+ self:addLine(v:value())
end
end
if(data["keywords"]~=nil)then
@@ -100,13 +100,13 @@ return function(name)
end
end
if(data["rules"]~=nil)then
- if(data["rules"]["item"]~=nil)then
- local tab = data["rules"]["item"]
- if(data["rules"]["item"].properties~=nil)then tab = {data["rules"]["item"]} end
+ if(data["rules"]["rule"]~=nil)then
+ local tab = data["rules"]["rule"]
+ if(data["rules"]["rule"].properties~=nil)then tab = {data["rules"]["rule"]} end
for k,v in pairs(tab)do
- if(xmlValue("rule", v)~=nil)then
- self:addRule(xmlValue("rule", v), colors[xmlValue("fg", v)], colors[xmlValue("bg", v)])
+ if(xmlValue("pattern", v)~=nil)then
+ self:addRule(xmlValue("pattern", v), colors[xmlValue("fg", v)], colors[xmlValue("bg", v)])
end
end
end
@@ -118,7 +118,7 @@ return function(name)
end;
getLine = function(self, index)
- return lines[index] or ""
+ return lines[index]
end;
editLine = function(self, index, text)
@@ -127,10 +127,22 @@ return function(name)
end;
addLine = function(self, text, index)
- if (index ~= nil) then
- table.insert(lines, index, text)
- else
- table.insert(lines, text)
+ if(text~=nil)then
+ if(#lines==1)and(lines[1]=="")then
+ lines[1] = text
+ bgLines[1] = tHex[self.bgColor]:rep(text:len())
+ fgLines[1] = tHex[self.fgColor]:rep(text:len())
+ return self
+ end
+ if (index ~= nil) then
+ table.insert(lines, index, text)
+ table.insert(bgLines, index, tHex[self.bgColor]:rep(text:len()))
+ table.insert(fgLines, tHex[self.fgColor]:rep(text:len()))
+ else
+ table.insert(lines, text)
+ table.insert(bgLines, tHex[self.bgColor]:rep(text:len()))
+ table.insert(fgLines, tHex[self.fgColor]:rep(text:len()))
+ end
end
return self
end;
@@ -253,7 +265,7 @@ return function(name)
if (textY < hIndex) then
hIndex = hIndex - 1
end
- updateColors()
+ updateColors(self)
self:setValue("")
end
@@ -271,7 +283,7 @@ return function(name)
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. fgLines[textY]:sub(textX + 1, fgLines[textY]:len())
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. bgLines[textY]:sub(textX + 1, bgLines[textY]:len())
end
- updateColors()
+ updateColors(self)
end
if (key == keys.enter) then
@@ -380,7 +392,7 @@ return function(name)
if (textX >= w + wIndex) then
wIndex = wIndex + 1
end
- updateColors()
+ updateColors(self)
self:setValue("")
end
diff --git a/docs/objects/Button.md b/docs/objects/Button.md
index d093a71..c4894b8 100644
--- a/docs/objects/Button.md
+++ b/docs/objects/Button.md
@@ -13,8 +13,12 @@ Sets the displayed button text
#### Usage:
* Creates a button with "Click me!" as text.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local button = mainFrame:addButton("myFirstButton"):setText("Click me!"):show()
+local mainFrame = basalt.createFrame()
+local button = mainFrame:addButton():setText("Click me!")
+```
+
+```xml
+
```
## setHorizontalAlign
@@ -29,11 +33,14 @@ Sets the horizontal align of the button text
#### Usage:
* Sets the button's horizontal text align to right.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local button = mainFrame:addButton("myFirstButton")
+local mainFrame = basalt.createFrame():show()
+local button = mainFrame:addButton()
:setText("Click me!")
:setHorizontalAlign("right")
- :show()
+```
+
+```xml
+
```
## setVerticalAlign
@@ -48,19 +55,22 @@ Sets the vertical align of the button text
#### Usage:
* Sets the button's horizontal text align to right and the vertical text align to bottom.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local button = mainFrame:addButton("myFirstButton")
+local mainFrame = basalt.createFrame():show()
+local button = mainFrame:addButton()
:setText("Click me!")
:setHorizontalAlign("right")
:setVerticalAlign("bottom")
- :show()
+```
+
+```xml
+
```
# Example
This is a example on how you would create a fully working button:
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show()
+local mainFrame = basalt.createFrame():show()
+local aButton = mainFrame:addButton():setText("Click"):show()
aButton:onClick(function(self,event,button,x,y)
if(event=="mouse_click")and(button==1)then
@@ -68,3 +78,18 @@ aButton:onClick(function(self,event,button,x,y)
end
end)
```
+
+## Lua and XML:
+```lua
+local mainFrame = basalt.createFrame():addLayout("example.xml")
+
+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)
+```
+
+```xml
+
+```
\ No newline at end of file
diff --git a/docs/objects/Checkbox.md b/docs/objects/Checkbox.md
index ae36ef2..e41f2b2 100644
--- a/docs/objects/Checkbox.md
+++ b/docs/objects/Checkbox.md
@@ -7,14 +7,27 @@ A checkbox does not have any custom methods. All required methods are provided b
# Example
This is how you would create a event which gets fired as soon as the value gets changed.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):show()
+local mainFrame = basalt.createFrame()
+local aCheckbox = mainFrame:addCheckbox()
local function checkboxChange(self)
local checked = self:getValue()
- basalt.debug("The value got changed into ", checked) end)
+ basalt.debug("The value got changed into ", checked)
end
aCheckbox:onChange(checkboxChange)
-
+```
+
+## Lua and XML:
+```lua
+local mainFrame = basalt.createFrame():addLayout("example.xml")
+
+basalt.setVariable("checkboxChange", function(self)
+ local checked = self:getValue()
+ basalt.debug("The value got changed into ", checked)
+end)
+```
+
+```xml
+
```
diff --git a/docs/objects/Dropdown.md b/docs/objects/Dropdown.md
index 98adaf8..81e74db 100644
--- a/docs/objects/Dropdown.md
+++ b/docs/objects/Dropdown.md
@@ -28,12 +28,17 @@ Adds a item into the dropdown
#### Usage:
* Creates a default dropdown with 3 entries
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
```
+
+ 1. Entry
+ 2. Entryyellow
+ 3. Entryyellowgreen
+
## removeItem
Removes a item from the dropdown
@@ -47,8 +52,8 @@ Removes a item from the dropdown
#### Usage:
* Creates a default dropdown with 3 entries and removes the second one.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -71,8 +76,8 @@ Edits a item from the dropdown
#### Usage:
* Creates a default dropdown with 3 entries and edits the second one.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -91,8 +96,8 @@ Returns a item by index
#### Usage:
* Creates a default dropdown with 3 entries and edits the second one.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -108,8 +113,8 @@ Returns the current item count
#### Usage:
* Creates a default dropdown with 3 entries and prints the current item count.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -125,34 +130,14 @@ Returns all items as table
#### Usage:
* Creates a default menubar with 3 entries and prints a table.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
basalt.debug(aDropdown:getAll())
```
-## setScrollable
-Makes the dropdown scrollable.
-
-#### Parameters:
-1. `boolean` if the dropdown should be scrollable or not
-
-#### Returns:
-1. `object` The object in use
-
-#### Usage:
-* Creates a default dropdown with 3 entries and makes it scrollable.
-```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
-aDropdown:addItem("1. Entry")
-aDropdown:addItem("2. Entry",colors.yellow)
-aDropdown:addItem("3. Entry",colors.yellow,colors.green)
-aDropdown:setScrollable(true)
-```
-
## selectItem
selects a item in the dropdown (same as a player would click on a item)
@@ -165,8 +150,8 @@ selects a item in the dropdown (same as a player would click on a item)
#### Usage:
* Creates a default dropdown with 3 entries and selects the second entry.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -182,8 +167,8 @@ Removes all items.
#### Usage:
* Creates a default dropdown with 3 entries and removes them immediatley. Which makes no sense.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -199,8 +184,8 @@ returns the item index of the currently selected item
#### Usage:
* Creates a default dropdown with 3 entries selects the second entry and prints the currently selected index.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
@@ -221,16 +206,24 @@ Sets the background and the foreground of the item which is currently selected
#### Usage:
* Creates a default dropdown with 4 entries and sets the selection background color to green.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("4. Entry")
-aDropdown:setSelectedItem(colors.green)
+aDropdown:setSelectedItem(colors.green, colors.red)
```
-## setIndexOffset
+```xml
+
+ 1. Entry
+ 2. Entryyellow
+ 2. Entryyellowgreen
+
+```
+
+## setOffset
Sets the offset of the dropdown (the same as you would scroll) - default is 0
#### Parameters:
@@ -242,19 +235,29 @@ Sets the offset of the dropdown (the same as you would scroll) - default is 0
#### Usage:
* Creates a default dropdown with 6 entries and sets the offset to 3.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
-aDropdown:addItem("1. Entry")
-aDropdown:addItem("2. Entry")
-aDropdown:addItem("3. Entry")
-aDropdown:addItem("4. Entry")
-aDropdown:addItem("5. Entry")
-aDropdown:addItem("6. Entry")
-aDropdown:setIndexOffset(3)
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
+ :addItem("1. Entry")
+ :addItem("2. Entry")
+ :addItem("3. Entry")
+ :addItem("4. Entry")
+ :addItem("5. Entry")
+ :addItem("6. Entry")
+ :setOffset(3)
```
+```xml
+
+ 1. Entry
+ 2. Entry
+ 3. Entry
+ 4. Entry
+ 5. Entry
+ 6. Entry
+
+```
-## getIndexOffset
+## getOffset
Returns the current index offset
#### Returns:
@@ -263,16 +266,16 @@ Returns the current index offset
#### Usage:
* Creates a default dropdown with 6 entries and sets the offset to 3, also prints the current offset.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
-aDropdown:addItem("1. Entry")
-aDropdown:addItem("2. Entry")
-aDropdown:addItem("3. Entry")
-aDropdown:addItem("4. Entry")
-aDropdown:addItem("5. Entry")
-aDropdown:addItem("6. Entry")
-aDropdown:setIndexOffset(3)
-basalt.debug(aDropdown:getIndexOffset())
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown()
+ :addItem("1. Entry")
+ :addItem("2. Entry")
+ :addItem("3. Entry")
+ :addItem("4. Entry")
+ :addItem("5. Entry")
+ :addItem("6. Entry")
+ :setOffset(3)
+basalt.debug(aDropdown:getOffset())
```
## setDropdownSize
@@ -288,10 +291,18 @@ Sets the size of the opened dropdown
#### Usage:
* Creates a default dropdown, adds 3 entries and sets the dropdown size to 15w, 8h
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aDropdown = mainFrame:addDropdown("myFirstDropdown"):setDropdownSize(15,8):show()
+local mainFrame = basalt.createFrame()
+local aDropdown = mainFrame:addDropdown():setDropdownSize(15,8)
aDropdown:addItem("1. Entry")
aDropdown:addItem("2. Entry")
aDropdown:addItem("3. Entry")
```
+```xml
+
+ 1. Entry
+ 2. Entry
+ 3. Entry
+
+```
+
diff --git a/docs/objects/Frame.md b/docs/objects/Frame.md
index 3c652fc..b8d268e 100644
--- a/docs/objects/Frame.md
+++ b/docs/objects/Frame.md
@@ -29,10 +29,14 @@ Creates a child frame on the frame, the same as [basalt.createFrame](https://git
1. `frame | nil` The frame created by addFrame, or `nil` if there is already a child frame with the given name.
#### Usage:
-* Create a frame with id "myFirstFrame" then create a child of that frame, named "myFirstSubFrame"
+* Create a new main frame and adds a child frame to it
```lua
-local mainFrame = basalt.createFrame("myFirstFrame")
-local myFrame = mainFrame:addFrame("myFirstSubFrame")
+local mainFrame = basalt.createFrame()
+local myFrame = mainFrame:addFrame()
+```
+
+```xml
+
```
## setBar
@@ -53,15 +57,18 @@ frame:setBar("My first Frame!", colors.black, colors.lightGray)
```
* Store the frame, use the named frame variable after assigning.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local myFrame = MainFrame:addFrame("myFirstSubFrame")
+local mainFrame = basalt.createFrame()
+local myFrame = MainFrame:addFrame()
myFrame:setBar("My first Frame!")
-myFrame:show()
```
* This abuses the call-chaining that Basalt uses.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local myFrame = mainFrame:addFrame("myFirstSubFrame"):setBar("My first Frame!"):show()
+local mainFrame = basalt.createFrame()
+local myFrame = mainFrame:addFrame():setBar("My first Frame!")
+```
+
+```xml
+
```
## setBarTextAlign
@@ -76,7 +83,11 @@ Sets the frame's bar-text alignment
#### Usage:
* Set the title of myFrame to "My first frame!", and align it to the right.
```lua
-local mainFrame = myFrame:setBar("My first Frame!"):setBarTextAlign("right")
+myFrame:setBar("My first Frame!"):setBarTextAlign("right")
+```
+
+```xml
+
```
## showBar
@@ -91,9 +102,14 @@ Toggles the frame's upper bar
#### Usage:
* Sets myFrame to have a bar titled "Hello World!" and subsequently displays it.
```lua
-local mainFrame = myFrame:setBar("Hello World!"):showBar()
+myFrame:setBar("Hello World!"):showBar()
```
+```xml
+
+```
+
+
## setMonitor
Sets this frame as a monitor frame
@@ -106,10 +122,34 @@ Sets this frame as a monitor frame
#### Usage:
* Creates a new monitor frame, you can use to show objects on a monitor.
```lua
-local mainFrame = basalt.createFrame("mainFrame"):show()
-local monitorFrame = basalt.createFrame("mainFrame"):setMonitor("right"):show()
+local mainFrame = basalt.createFrame()
+local monitorFrame = basalt.createFrame():setMonitor("right")
monitorFrame:setBar("Monitor 1"):showBar()
```
+
+```xml
+
+```
+
+## setMirror
+mirrors this frame to another peripheral monitor object.
+
+#### Parameters:
+1. `string` The monitor name ("right", "left",... "monitor_1", "monitor_2",...)
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates mirror of your main frame to a monitor on the left side.
+```lua
+local mainFrame = basalt.createFrame():setMirror("left")
+```
+
+```xml
+
+```
+
## getObject
Returns a child object of the frame
@@ -152,11 +192,12 @@ Sets the currently focused object
1. `frame` The frame being used
#### Usage:
-* Creates button with id "myFirstButton", sets the focused object to the previously mentioned button
+* Creates a new button, sets the focused object to the previously mentioned button
```lua
-local aButton = myFrame:addButton("myFirstButton")
+local aButton = myFrame:addButton()
myFrame:setFocusedObject(aButton)
```
+
## removeFocusedObject
Removes the focus of the supplied object
@@ -167,14 +208,16 @@ Removes the focus of the supplied object
1. `frame` The frame being used
#### Usage:
-* Creates a button with id "myFirstButton", then removes the focus from that button
+* Creates a new button then removes the focus from that button when clicking on it
```lua
-local aButton = myFrame:addButton("myFirstButton")
-myFrame:removeFocusedObject(aButton)
+local aButton = myFrame:addButton():setFocus():onClick(function()
+ myFrame:removeFocusedObject(aButton)
+end)
```
## getFocusedObject
Gets the currently focused object
+
#### Returns:
1. `object` The currently focused object
@@ -183,9 +226,10 @@ Gets the currently focused object
```lua
local focusedObject = myFrame:getFocusedObject()
```
-## setMovable
+## setMovable
Sets whether the frame can be moved. _In order to move the frame click and drag the upper bar of the frame_
+
#### Parameters:
1. `boolean` Whether the object is movable
@@ -195,14 +239,18 @@ Sets whether the frame can be moved. _In order to move the frame click and drag
#### Usage:
* Creates a frame with id "myFirstFrame" and makes it movable
```lua
-local myFrame = basalt.createFrame("myFirstFrame"):setMovable(true)
+local myFrame = basalt.createFrame():setMovable(true)
+```
+
+```xml
+
```
## setOffset
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)
-The function can be supplied negative offsets
+The function can also be supplied with negative values
#### Parameters:
1. `number` The x direction offset (+/-)
@@ -212,11 +260,163 @@ The function can be supplied negative offsets
1. `frame` The frame being used
#### Usage:
-* Creates "myFirstFrame" with an x offset of 5 and a y offset of 3
+* Creates a new base frame with x offset of 5 and a y offset of 3
```lua
-local myFrame = basalt.createFrame("myFirstFrame"):setOffset(5, 3)
+local myFrame = basalt.createFrame():setOffset(5, 3)
```
-* Creates "myFirstFrame" with an 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 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("myFirstFrame"):setOffset(5, -5)
+local myFrame = basalt.createFrame():setOffset(5, -5)
+```
+
+```xml
+
+```
+
+## addLayout
+Adds a new XML Layout into your frame.
+
+#### Parameters:
+1. `string` Path to your layout
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and adds the mainframe.xml layout
+```lua
+local myFrame = basalt.createFrame():addLayout("mainframe.xml")
+```
+
+```xml
+
+```
+
+## addLayoutFromString
+Adds a new XML Layout as string into your frame.
+
+#### Parameters:
+1. `string` xml
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and adds the mainframe.xml layout
+```lua
+local myFrame = basalt.createFrame():addLayoutFromString("")
+```
+
+## getLastLayout
+returns a table of all objects this frame has created via xml (useful if you'd like to access all of them for some reason)
+
+#### Returns:
+1. `table` table with objects
+
+## setTheme
+Sets the default theme of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt managers theme - which is sotred in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
+
+#### Parameters:
+1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and adds a new theme which only changes the default color of buttons.
+```lua
+local myFrame = basalt.createFrame():setTheme({
+ ButtonBG = colors.yellow,
+ ButtonText = colors.red,
+})
+```
+
+## setScrollable
+Makes the frame scrollable with mousewheel.
+
+#### Parameters:
+1. `bool` scrollable or not
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and makes it scrollable
+```lua
+local myFrame = basalt.createFrame():setScrollable()
+```
+
+```xml
+
+```
+
+## setMinScroll
+Sets the minimum offset it is allowed to scroll (default 0)
+
+#### Parameters:
+1. `number` minimum y offset
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and makes it scrollable and sets the minimum amount to -5
+```lua
+local myFrame = basalt.createFrame():setScrollable():setMinScroll(-5)
+```
+
+```xml
+
+```
+
+## setMaxScroll
+Sets the maximum offset it is allowed to scroll (default 10)
+
+#### Parameters:
+1. `number` maximum y offset
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and makes it scrollable and sets the maximum amount to 25
+```lua
+local myFrame = basalt.createFrame():setScrollable():setMaxScroll(25)
+```
+
+```xml
+
+```
+
+## setImportantScroll
+By default if you hovering your mouse over children objects, you wont scroll the frame, if you set this to true the frame scrolling becomes more important
+
+#### Parameters:
+1. `bool` important or not
+
+#### Returns:
+1. `frame` The frame being used
+
+#### Usage:
+* Creates a new base frame and makes it scrollable and defines it as important
+```lua
+local myFrame = basalt.createFrame():setScrollable():setImportantScroll(true)
+```
+
+```xml
+
+```
+
+# XML
+
+* A fully working example:
+```xml
+
+
+
+
+
+
+
+
```
diff --git a/docs/objects/Image.md b/docs/objects/Image.md
index 1ffd6a6..151778c 100644
--- a/docs/objects/Image.md
+++ b/docs/objects/Image.md
@@ -17,8 +17,12 @@ loads a default .nfp file into the object.
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aImage = mainFrame:addImage("myFirstImage"):loadImage("test.nfp"):show()
+local mainFrame = basalt.createFrame():show()
+local aImage = mainFrame:addImage():loadImage("test.nfp")
+```
+
+```xml
+
```
## shrink
@@ -30,6 +34,10 @@ Shrinks the current image into a blittle image.
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aImage = mainFrame:addImage("myFirstImage"):loadImage("test.nfp"):shrink():show()
+local mainFrame = basalt.createFrame()
+local aImage = mainFrame:addImage():loadImage("test.nfp"):shrink()
+```
+
+```xml
+
```
diff --git a/docs/objects/Input.md b/docs/objects/Input.md
index 6344524..d935094 100644
--- a/docs/objects/Input.md
+++ b/docs/objects/Input.md
@@ -15,8 +15,12 @@ Changes the input type. default: text
#### Usage:
* Creates a default input and sets it to numbers only.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aInput = mainFrame:addInput("myFirstInput"):setInputType("number"):show()
+local mainFrame = basalt.createFrame()
+local aInput = mainFrame:addInput():setInputType("number")
+```
+
+```xml
+
```
## getInputType
@@ -28,8 +32,8 @@ Gets the current input type
#### Usage:
* Creates a default input and sets it to numbers only. Also prints the current input type to log.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aInput = mainFrame:addInput("myFirstInput"):setInputType("number"):show()
+local mainFrame = basalt.createFrame()
+local aInput = mainFrame:addInput():setInputType("number")
basalt.debug(aInput:getInputType())
```
@@ -47,8 +51,12 @@ Sets the default text. This will only be displayed if there is no input set by t
#### Usage:
* Creates a default input and sets the default text to "...".
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aInput = mainFrame:addInput("myFirstInput"):setInputType("number"):setDefaultText(...):show()
+local mainFrame = basalt.createFrame()
+local aInput = mainFrame:addInput():setDefaultText("...")
+```
+
+```xml
+
```
## setInputLimit
@@ -63,8 +71,12 @@ Sets a character limit to the input.
#### Usage:
* Creates a default input and sets the character limit to 8.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aInput = mainFrame:addInput("myFirstInput"):setInputLimit(8):show()
+local mainFrame = basalt.createFrame()
+local aInput = mainFrame:addInput():setInputLimit(8)
+```
+
+```xml
+
```
## getInputLimit
@@ -76,7 +88,7 @@ Returns the input limit.
#### Usage:
* Creates a default input and sets the character limit to 8. Prints the current limit.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aInput = mainFrame:addInput("myFirstInput"):setInputLimit(8):show()
+local mainFrame = basalt.createFrame()
+local aInput = mainFrame:addInput():setInputLimit(8)
basalt.debug(aInput:getInputLimit())
```
diff --git a/docs/objects/Label.md b/docs/objects/Label.md
index 17998e5..f321bfd 100644
--- a/docs/objects/Label.md
+++ b/docs/objects/Label.md
@@ -23,6 +23,10 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Some random text"):show()
```
+```xml
+
+```
+
## setFontSize
Sets the font size, calculated by bigfonts. Default size is 1.
@@ -39,6 +43,10 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
```
+```xml
+
+```
+
## getFontSize
Returns the current font size
@@ -52,3 +60,21 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
basalt.debug(aLabel:getFontSize())
```
+
+## setTextAlign
+Changes the text align
+
+#### Returns:
+1. `string` horizontal ("left", "center", "right")
+1. `string` vertical ("top", "center", "bottom")
+
+#### Usage:
+* Creates a default label, sets the text to "Basalt!" changes the horizontal align to right
+```lua
+local mainFrame = basalt.createFrame()
+local aLabel = mainFrame:addLabel():setText("Basalt!"):setTextAlign("right")
+```
+
+```xml
+
+```
diff --git a/docs/objects/Menubar.md b/docs/objects/Menubar.md
index f270e76..98a9aeb 100644
--- a/docs/objects/Menubar.md
+++ b/docs/objects/Menubar.md
@@ -28,13 +28,21 @@ Adds a item into the menubar
#### Usage:
* Creates a default menubar with 3 entries
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
```
+```xml
+
+1. Entry
+2. Entryyellow
+3. Entryyellowgreen
+
+```
+
## removeItem
Removes a item from the menubar
@@ -47,8 +55,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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -71,8 +79,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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -91,8 +99,8 @@ Returns a item by index
#### Usage:
* Creates a default menubar with 3 entries and edits the second one.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -108,8 +116,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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -125,8 +133,8 @@ Returns all items as table
#### Usage:
* Creates a default menubar with 3 entries and prints a table.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -145,14 +153,22 @@ Sets the space between entries
#### Usage:
* Creates a default menubar with 3 entries and changes the space to 3.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
aMenubar:setSpace(3)
```
+```xml
+
+1. Entry
+2. Entryyellow
+3. Entryyellowgreen
+
+```
+
## setScrollable
@@ -167,14 +183,22 @@ Makes the menubar scrollable. The menubar will be scrollable as soon as the menu
#### Usage:
* Creates a default menubar with 3 entries and makes it scrollable.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
aMenubar:setScrollable(true)
```
+```xml
+
+1. Entry
+2. Entryyellow
+3. Entryyellowgreen
+
+```
+
## selectItem
selects a item in the list (same as a player would click on a item)
@@ -187,8 +211,8 @@ selects a item in the list (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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -205,8 +229,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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -222,8 +246,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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry",colors.yellow)
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
@@ -244,16 +268,25 @@ 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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry")
aMenubar:addItem("3. Entry")
aMenubar:addItem("4. Entry")
-aMenubar:setSelectedItem(colors.green)
+aMenubar:setSelectedItem(colors.green, colors.yellow)
```
-## setPositionOffset
+```xml
+
+1. Entry
+2. Entry
+3. Entry
+4. Entry
+
+```
+
+## setOffset
Sets the offset of the menubar (the same as you would scroll) - default is 0
#### Parameters:
@@ -265,18 +298,29 @@ 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("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry")
aMenubar:addItem("3. Entry")
aMenubar:addItem("4. Entry")
aMenubar:addItem("5. Entry")
aMenubar:addItem("6. Entry")
-aMenubar:setPositionOffset(3)
+aMenubar:setOffset(3)
```
-## getPositionOffset
+```xml
+
+1. Entry
+2. Entry
+3. Entry
+4. Entry
+5. Entry
+6. Entry
+
+```
+
+## getOffset
returns the current offset
#### Returns:
@@ -285,14 +329,14 @@ returns the current offset
#### Usage:
* Creates a default menubar with 6 entries and sets the offset to 3, prints the current offset.
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
+local mainFrame = basalt.createFrame()
+local aMenubar = mainFrame:addMenubar()
aMenubar:addItem("1. Entry")
aMenubar:addItem("2. Entry")
aMenubar:addItem("3. Entry")
aMenubar:addItem("4. Entry")
aMenubar:addItem("5. Entry")
aMenubar:addItem("6. Entry")
-aMenubar:setPositionOffset(3)
-basalt.debug(aMenubar:getPositionOffset())
+aMenubar:getOffset(3)
+basalt.debug(aMenubar:getOffset())
```
diff --git a/docs/objects/Object.md b/docs/objects/Object.md
index 46467f3..7605af0 100644
--- a/docs/objects/Object.md
+++ b/docs/objects/Object.md
@@ -13,6 +13,11 @@ local button = mainFrame:addButton("myFirstButton")
button:show()
```
+#### XML:
+```xml
+
+```
+
## hide
Hides the object
@@ -27,6 +32,11 @@ local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(fun
button:show()
```
+#### XML:
+```xml
+
+```
+
## setPosition
Changes the position relative to its parent frame
#### Parameters:
@@ -44,6 +54,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
mainFrame:addButton("myFirstButton"):setPosition(2,3)
```
+#### XML:
+```xml
+
+```
+
## setBackground
Changes the object background color, if you set the value to false the background wont be visible. For example you could see trough a frame.
#### Parameters:
@@ -58,6 +73,11 @@ Changes the object background color, if you set the value to false the backgroun
local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.gray)
```
+#### XML:
+```xml
+
+```
+
## setForeground
Changes the object text color
#### Parameters:
@@ -72,6 +92,11 @@ Changes the object text color
local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.green)
```
+#### XML:
+```xml
+
+```
+
## setSize
Changes the object size
#### Parameters:
@@ -88,6 +113,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
local subFrame = mainFrame:addFrame("myFirstSubFrame"):setSize(15,12):show()
```
+#### XML:
+```xml
+
+```
+
## setFocus
Sets the object to be the focused object.
If you click on an object, it's normally automatically the focused object. For example, if you call :show() on a frame, and you want this particular frame to be in
@@ -118,6 +148,12 @@ local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):setPosition(2,
local aLabel = mainFrame:addButton("myFirstLabel"):setZIndex(2):setPosition(2,2):setText("I am a label!"):show()
```
+#### XML:
+```xml
+
+
+```
+
## setParent
Sets the parent frame of the object
#### Parameters:
@@ -195,6 +231,11 @@ local aButton = mainFrame:addButton("myFirstButton")
:show()
```
+#### XML:
+```xml
+
+```
+
## getAbsolutePosition
Converts the relative coordinates into absolute coordinates
#### Parameters:
@@ -212,26 +253,6 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(8,1):setPosition(4,
basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
```
-## setTextAlign
-Sets the text align of the object (for example buttons)
-#### Parameters:
-1. `string` horizontal
-2. `string` vertical ("left", "center", "right")
-
-#### Returns:
-1. `object` The object in use
-
-#### Usage:
-* Creates a button with text aligned to `right, center`
-```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aButton = mainFrame:addButton("myFirstButton")
- :setSize(12,3)
- :setTextAlign("right", "center")
- :setText("Don't...")
- :show()
-```
-
## setValue
Sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
#### Parameters:
@@ -247,6 +268,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
```
+#### XML:
+```xml
+
+```
+
## getValue
Returns the currently saved value
#### Returns:
@@ -317,7 +343,11 @@ local subFrame = mainFrame:addFrame("mySubFrame")
:setSize(18,6)
:setShadow(colors.green)
:showShadow(true)
- :show()
+```
+
+#### XML:
+```xml
+
```
## showShadow
@@ -332,14 +362,19 @@ Shows or hides the shadow
#### Usage:
* Shows the shadow:
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local subFrame = mainFrame:addFrame("mySubFrame")
+local mainFrame = basalt.createFrame():show()
+local subFrame = mainFrame:addFrame()
:setMoveable()
:setSize(18,6)
:showShadow(true)
:show()
```
+#### XML:
+```xml
+
+```
+
## setBorder
Sets the border color - default: colors.black
@@ -361,6 +396,11 @@ local subFrame = mainFrame:addFrame("mySubFrame")
:show()
```
+#### XML:
+```xml
+
+```
+
## showBorder
Shows or hides the border
@@ -377,6 +417,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
local subFrame = mainFrame:addFrame("mySubFrame")
:setMoveable()
:setSize(18,6)
- :showBorder("left", "top", "right", "bottom")
+ :showBorder("left", "top", "bottom")
:show()
```
+
+#### XML:
+```xml
+
+```
\ No newline at end of file
diff --git a/docs/objects/Pane.md b/docs/objects/Pane.md
index d5928b4..7f94152 100644
--- a/docs/objects/Pane.md
+++ b/docs/objects/Pane.md
@@ -8,9 +8,13 @@ Pane doesn't have any custom functionallity. If you want to change the color/pos
## Example:
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aPane = mainFrame:addPane("myFirstBackground")
+local mainFrame = basalt.createFrame()
+local aPane = mainFrame:addPane()
aPane:setSize(30, 10)
aPane:setBackground(colors.yellow)
aPane:show()
+```
+
+```xml
+
```
\ No newline at end of file
diff --git a/docs/objects/Program.md b/docs/objects/Program.md
index 4cef915..d5d8b5e 100644
--- a/docs/objects/Program.md
+++ b/docs/objects/Program.md
@@ -35,6 +35,11 @@ local aProgram = mainFrame:addProgram("myFirstProgram"):show()
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
```
+#### XML:
+```xml
+
+```
+
## stop
Stops a currently running program
diff --git a/docs/objects/Progressbar.md b/docs/objects/Progressbar.md
index 82a8312..5a8e884 100644
--- a/docs/objects/Progressbar.md
+++ b/docs/objects/Progressbar.md
@@ -15,11 +15,15 @@ Sets the direction in which the bar should be expanding.
#### Usage:
* Creates a progressbar and sets the direction from bottom to top
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
+local mainFrame = basalt.createFrame():show()
+local aProgressbar = mainFrame:addProgressbar():show()
aProgressbar:setDirection(3)
```
+```xml
+
+```
+
## setProgress
This is the function you need to call if you want the progression to change.
@@ -32,23 +36,22 @@ This is the function you need to call if you want the progression to change.
#### Usage:
* Creates a progressbar and sets the current progress to 50
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
+local mainFrame = basalt.createFrame():show()
+local aProgressbar = mainFrame:addProgressbar():show()
aProgressbar:setProgress(50)
```
## getProgress
Returns the current progress status
-
#### Returns:
1. `number` progress (0-100)
#### Usage:
* Creates a progressbar, sets the current progress to 50 and prints the current progress
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
+local mainFrame = basalt.createFrame():show()
+local aProgressbar = mainFrame:addProgressbar():show()
aProgressbar:setProgress(50)
basalt.debug(aProgressbar:getProgress())
```
@@ -67,9 +70,13 @@ This function will change the visual display of your progress bar
#### Usage:
* Creates a progressbar and sets the progressbar color to green
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
-aProgressbar:setProgressBar(colors.green)
+local mainFrame = basalt.createFrame():show()
+local aProgressbar = mainFrame:addProgressbar():show()
+aProgressbar:setProgressBar(colors.green, colors.yellow, colors.red)
+```
+
+```xml
+
```
## setBackgroundSymbol
@@ -84,11 +91,15 @@ Will change the default background symbol (default is " " - space)
#### Usage:
* Creates a progressbar and sets the progressbar background symbol to X
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
+local mainFrame = basalt.createFrame():show()
+local aProgressbar = mainFrame:addProgressbar():show()
aProgressbar:setBackgroundSymbol("X")
```
+```xml
+
+```
+
# Events
# onProgressDone
@@ -98,13 +109,30 @@ A custom event which gets triggered as soon as the progress reaches 100.
Here is a example on how to add a onProgressDone event to your progressbar:
```lua
-local basalt = dofile("basalt.lua")
+local basalt = require("Basalt")
-local mainFrame = basalt.createFrame("myMainFrame"):show()
-local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
+local mainFrame = basalt.createFrame():show()
+local aProgressbar = mainFrame:addProgressbar():show()
function progressDone()
basalt.debug("The Progressbar reached 100%!")
end
aProgressbar:onProgressDone(progressDone)
```
+
+## XML Example
+
+```lua
+local basalt = require("Basalt")
+
+local mainFrame = basalt.createFrame()
+
+basalt.setVariable("progressDone", function()
+ basalt.debug("The Progressbar reached 100%!")
+end)
+```
+
+```xml
+
+```
+
diff --git a/docs/objects/Textfield.md b/docs/objects/Textfield.md
index 1933df6..bfe2cab 100644
--- a/docs/objects/Textfield.md
+++ b/docs/objects/Textfield.md
@@ -55,8 +55,8 @@ basalt.debug(aTextfield:editLine(1, "Hello!"))
Adds a line on index position
#### Parameteres:
-1. `number` index
-2. `string` text
+1. `string` text
+2. `number` index
#### Returns:
1. `object` The object in use
@@ -66,7 +66,15 @@ Adds a line on index position
```lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
-basalt.debug(aTextfield:addLine(1, "Hello!"))
+basalt.debug(aTextfield:addLine("Hello!", 1))
+```
+
+```xml
+
+
+ Hello!
+
+
```
## removeLine
@@ -93,3 +101,64 @@ Gets text cursor position
#### Returns:
1. `number` x position
2. `number` y position
+
+## addKeywords
+Adds keywords for special coloring
+
+#### Parameteres:
+1. `number|color` color of your choice
+2. `table` a list of keywords which should be colored example: {"if", "else", "then", "while", "do"}
+
+#### Returns:
+1. `object` The object in use
+
+#### Usage:
+* Changes the color of some words to purple
+```lua
+local mainFrame = basalt.createFrame()
+local aTextfield = mainFrame:addTextfield():addKeywords(colors.purple, {"if", "else", "then", "while", "do", "hello"})
+```
+
+```xml
+
+
+
+ if
+ else
+ then
+ while
+ do
+ hello
+
+
+
+```
+
+## addRule
+Adds a new rule for special coloring
+
+#### Parameteres:
+1. `string` a pattern - check out this page: (https://riptutorial.com/lua/example/20315/lua-pattern-matching)
+2. `number|color` text color
+3. `number|color` background color - optional
+
+#### Returns:
+1. `object` The object in use
+
+#### Usage:
+* Changes the color of all numbers
+```lua
+local mainFrame = basalt.createFrame()
+local aTextfield = mainFrame:addTextfield():addRule("%d", colors.lightBlue)
+```
+
+```xml
+
+
+
+ %d
+ lightBlue
+
+
+
+```
\ No newline at end of file
diff --git a/docs/objects/Thread.md b/docs/objects/Thread.md
index b41f3e0..3a8ab82 100644
--- a/docs/objects/Thread.md
+++ b/docs/objects/Thread.md
@@ -12,8 +12,8 @@ starts a new thread and executes the function
#### Usage:
* Starts a new thread
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aThread = mainFrame:addThread("myFirstThread"):show()
+local mainFrame = basalt.createFrame()
+local aThread = mainFrame:addThread()
local function randomThreadFunction()
while true do
basalt.debug("Thread is active")
@@ -21,6 +21,14 @@ local function randomThreadFunction()
end
end
aThread:start(randomThreadfunction)
+```
+```lua
+ basalt.setVariable("myThread", function() while true do os.sleep(1) end end)
+
+```
+```xml
+
+
```
## stop
@@ -32,8 +40,8 @@ stops the thread
#### Usage:
* Stops the current running thread by clicking on a button
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aThread = mainFrame:addThread("myFirstThread"):show()
+local mainFrame = basalt.createFrame()
+local aThread = mainFrame:addThread()
local function randomThreadFunction()
while true do
basalt.debug("Thread is active")
@@ -41,7 +49,7 @@ local function randomThreadFunction()
end
end
aThread:start(randomThreadfunction)
-local aButton = mainFrame:addButton("myFirstButton"):setText("Stop Thread"):onClick(function() aThread:stop() end):show()
+local aButton = mainFrame:addButton():setText("Stop Thread"):onClick(function() aThread:stop() end)
```
## getStatus
@@ -52,7 +60,7 @@ gets the current thread status
#### Usage:
```lua
-local mainFrame = basalt.createFrame("myFirstFrame"):show()
-local aThread = mainFrame:addThread("myFirstThread"):show()
+local mainFrame = basalt.createFrame()
+local aThread = mainFrame:addThread()
basalt.debug(aThread:getStatus())
```