From 3107a7adb81fb9e66ee65c5e3edefa368a7be80c Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 17 Jul 2022 20:24:09 +0200 Subject: [PATCH] Update Frame.md --- docs/objects/Frame.md | 261 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 237 insertions(+), 24 deletions(-) diff --git a/docs/objects/Frame.md b/docs/objects/Frame.md index 3c652fc..9b509a0 100644 --- a/docs/objects/Frame.md +++ b/docs/objects/Frame.md @@ -29,10 +29,15 @@ 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: +```xml + ``` ## setBar @@ -53,15 +58,19 @@ 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: +```xml + ``` ## setBarTextAlign @@ -76,7 +85,12 @@ 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: +```xml + ``` ## showBar @@ -91,9 +105,15 @@ 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: +```xml + +``` + + ## setMonitor Sets this frame as a monitor frame @@ -106,10 +126,36 @@ 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: +```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: +```xml + +``` + ## getObject Returns a child object of the frame @@ -152,11 +198,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 +214,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 +232,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 +245,19 @@ 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: +```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 +267,169 @@ 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: +```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: +```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("