mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-06 11:12:40 +01:00
Spelling and grammar fixes
parent
9007efaa39
commit
3597716f72
50
GUI-API.md
50
GUI-API.md
@ -87,12 +87,12 @@ Every created object and it's extended classes have several universal properties
|
||||
| *int* | .**height** | Object height |
|
||||
| *boolean* | .**hidden** | Whether the object is hidden. If the object is hidden, then its rendering and analysis of system events are ignored |
|
||||
| *boolean* | .**disabled** | Whether the object is disabled. If the object is disabled, then it can be rendered, but all system events are ignored |
|
||||
| *boolean* | .**passScreenEvents** | Optional variable that allows screen events to pass througs objects withount being processed |
|
||||
| *boolean* | .**passScreenEvents** | Optional variable that allows screen events to pass through objects without being processed |
|
||||
| *function* | :**draw**() | Main method that is called to render this object to the screen buffer. It can be defined by the user in any convenient way |
|
||||
|
||||
### Example
|
||||
|
||||
Let's implement the simple rectangle object. Don't worry if you don't understand what "workspace" or "container" means, it's just an template for copy-pasting, you can read two sections below and everything will be OK:
|
||||
Let's implement the simple rectangle object. Don't worry if you don't understand what "workspace" or "container" means, it's just a template for copy-pasting, you can read two sections below and everything will be OK:
|
||||
|
||||
```lua
|
||||
-- Import this library
|
||||
@ -225,7 +225,7 @@ The important detail of the event handlers is that if the event belongs to **scr
|
||||
|
||||
If you want to skip some event during event processing, call :**consumeEvent**() method. This will prevent all unprocessed child objects to handle current event data.
|
||||
|
||||
There is also an option to make any object **transparent** for screen events: just set .**passScreenEvents** = **true** variable for desired object. With this option it's event hanlder will be called as always, but event processing will continue for rest objects in container. This feature works with containers too.
|
||||
There is also an option to make any object **transparent** for screen events: just set .**passScreenEvents** = **true** variable for desired object. With this option it's event handler will be called as always, but event processing will continue for rest objects in container. This feature works with containers too.
|
||||
|
||||
And if the event does not belong to the screen, or the object **does not have** event handler method, the processing of the remaining child elements will continue as always. You can see the logic and the order of event processing in the following image:
|
||||
|
||||
@ -268,7 +268,7 @@ As a result, you will get an amusing output of event data to the terminal:
|
||||
|
||||
# Animations
|
||||
|
||||
The next feature of an objects is animations: every object can be animated. For more information about creating animations, see practical examples in end of this documentation. By the way, here is field of animated GUI.**switch** objects:
|
||||
The next feature of objects is animations: every object can be animated. For more information about creating animations, see practical examples in end of this documentation. By the way, here is field of animated GUI.**switch** objects:
|
||||
|
||||

|
||||
|
||||
@ -280,7 +280,7 @@ As described above, to add an animation to object, call <object>:**addAnimation*
|
||||
| *float* | .**position** | Current animation playback position. It is always in **[0.0; 1.0]** range, where **0.0** is animation starting and **1.0** is animation ending |
|
||||
| *function* | :**start**() | Start animation playback. Interesting detail: during animation playing an workspace which has some animated objects will temporary handle events with maximum available speed (i.e. like computer.**pullSignal**(0)). After finishing all animations, event handling delay will be the same it was in beginning |
|
||||
| *function* | :**stop**() | Stop animation playback |
|
||||
| *function* | :**remove**() | Remove animation from it's widget |
|
||||
| *function* | :**remove**() | Remove animation from its widget |
|
||||
| *callback-function* | .**frameHandler**(*table* animation) | An animation frame handler. It is called every frame before drawing stuff to screen buffer. A single parameter is a pointer to animation object |
|
||||
| *callback-function* | .**onFinish**() | This function is called after finishing animation playback. Important: calling :**stop**() will **not** call this function |
|
||||
|
||||
@ -394,7 +394,7 @@ Result:
|
||||
| *int* | textColor | Object text color |
|
||||
| *string* | text | Object text |
|
||||
|
||||
Another simpliest object is text. If you need to quickly display something in text form, then this widget is created for you. When you change the text, its width is automatically calculated to the desired value.
|
||||
Another simple object is text. If you need to quickly display something in text form, then this widget is created for you. When you change the text, its width is automatically calculated to the desired value.
|
||||
|
||||
###Example
|
||||
```lua
|
||||
@ -492,7 +492,7 @@ local workspace = GUI.workspace()
|
||||
workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
|
||||
|
||||
-- Load image, create widget from it and add it to workspace
|
||||
workspace:addChild(GUI.image(2, 2, image.load("/Furnance.pic")))
|
||||
workspace:addChild(GUI.image(2, 2, image.load("/Furnace.pic")))
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -663,7 +663,7 @@ This object has following properties:
|
||||
| Type | Property | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| *string* | .**text** | A variable that contains current displayed text of an object |
|
||||
| *boolean* | .**historyEnabled** | Optional property that allows widget to remember text that user inputs and to navigate through it's history via arrows buttons. Set to **false** by default |
|
||||
| *boolean* | .**historyEnabled** | Optional property that allows widget to remember text that user inputs and to navigate through its history via arrows buttons. Set to **false** by default |
|
||||
| *function* | :**startInput**() | Method for activation of text inputting |
|
||||
| *callback-function* | .**validator**(*string* text) | The function that is called after the text is entered in the input field. If it returns **true**, the text in the text field will be changed to the entered text, otherwise the entered data will be ignored |
|
||||
| *callback-function* | .**onInputFinished**() | The function that is called after entering data in the input field: it's a handy thing if you want to do something after entering text. If the object has .**validator** function, and if the text does not pass the check through it, then .**onInputFinished** will not be called |
|
||||
@ -1197,7 +1197,7 @@ This object has following properties:
|
||||
| *string* | .**workPath** | Current root directory |
|
||||
| *string* | .**selectedItem** | Current selected item path |
|
||||
| *function* | :**updateFileList**()| Update tree file list |
|
||||
| *function* | :**expandPath**(*string* path)| Recursuvely expands specified path and shows it's content |
|
||||
| *function* | :**expandPath**(*string* path)| Recursively expands specified path and shows it's content |
|
||||
| *function* | :**addExtensionFilter**( *string* extension )| Add a filter to the specified file extension. After that, only files witch specified extension well be able to be selected |
|
||||
| *callback-function* | .**onItemSelected**(*string* path) | This function is called when some item was selected |
|
||||
| *callback-function* | .**onItemExpanded**(*string* path) | This function is called when some directory was expanded |
|
||||
@ -1251,7 +1251,7 @@ Result:
|
||||
| *int* | textColor | Object text color |
|
||||
| *int* | tipBackgroundColor | Object "pipe" background color |
|
||||
| *int* | tipTextColor | Object "pipe" text color |
|
||||
| *string* | path | Initial path of and object. Can be also **nil** value, it it doesn't needed |
|
||||
| *string* | path | Initial path of and object. Can be also be **nil**, it is not required |
|
||||
| *string* | sumbitButtonText | Object submit button text |
|
||||
| *string* | cancelButtonText | Object cancel button text |
|
||||
| *string* | placeholderText | Text that is shown when no path was typed manually |
|
||||
@ -1338,7 +1338,7 @@ workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x0))
|
||||
-- Add codeView object to workspace
|
||||
local codeView = workspace:addChild(GUI.codeView(2, 2, 72, 22, 1, 1, 1, {}, {}, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, true, {}))
|
||||
|
||||
-- Open file and read it's lines
|
||||
-- Open file and read its lines
|
||||
local counter = 1
|
||||
for line in require("filesystem").lines("/Libraries/Number.lua") do
|
||||
-- Replace tab symbols to 2 whitespaces and Windows line endings to UNIX line endings
|
||||
@ -1600,7 +1600,7 @@ Result:
|
||||
| *int* | primaryColor | Primary indicator color in active state |
|
||||
| *int* | secondaryColor | Secondary indicator color in active state|
|
||||
|
||||
Progress indicator is a simple widget for giving users information when **something is happening**. It just nicely rolls around it's circle shape.
|
||||
Progress indicator is a simple widget for giving users information when **something is happening**. It just nicely rolls around its circle shape.
|
||||
|
||||
This object has following properties:
|
||||
|
||||
@ -1638,7 +1638,7 @@ workspace:addChild(GUI.adaptiveButton(3, 6, 2, 1, 0x2D2D2D, 0xD2D2D2, 0x5A5A5A,
|
||||
nil,
|
||||
-- Headers
|
||||
nil,
|
||||
-- Downloaded chunk hanlder
|
||||
-- Downloaded chunk handler
|
||||
function(chunk)
|
||||
downloadedData = downloadedData .. chunk
|
||||
|
||||
@ -1774,8 +1774,8 @@ This object has following properties:
|
||||
| *function* | :**setSpacing**(*int* column, *int* row, *int* spacing): *table* layout | Assign the specified grid cell distance in pixels between child objects. The default value is **1** |
|
||||
| *function* | :**setMargin**(*int* column, *int* row, *int* horizontalMargin, *int* verticalMargin): *table* layout | Assign the specified grid cell indents (margins) in pixels, depending on the current **alignment** of this cell |
|
||||
| *function* | :**getMargin**(*int* column, *int* row): *int* row, *int* horizontalMargin, *int* verticalMargin | Get current margins in pixels of specified cell |
|
||||
| *function* | :**setFitting**(*int* column, *int* row, *int* horizontalFitting, *int* verticalFitting[, *int* horizontalOffset, *int* verticalOffset] ): *table* layout | Assign the specified grid cell automatic resizing of child objects by horizonal, vertical or both directions. By default new child sizes will be equal the cell size. If optional parameters are specified, then it is possible to set an size reducing, i.e. the size of objects will be equal to **Cell size - Offset value** |
|
||||
| *function* | :**update**(): *table* layout | Forcibly recalculate child objects position. By default this function is being called automatically, but in some cases it can be helful |
|
||||
| *function* | :**setFitting**(*int* column, *int* row, *int* horizontalFitting, *int* verticalFitting[, *int* horizontalOffset, *int* verticalOffset] ): *table* layout | Assign the specified grid cell automatic resizing of child objects by horizontal, vertical or both directions. By default, new child sizes will be equal the cell size. If optional parameters are specified, then it is possible to set an size reducing, i.e. the size of objects will be equal to **Cell size - Offset value** |
|
||||
| *function* | :**update**(): *table* layout | Forcibly recalculate child objects position. By default, this function will be called automatically, but in some cases it can be helpful |
|
||||
|
||||
###Example
|
||||
|
||||
@ -1788,7 +1788,7 @@ local GUI = require("GUI")
|
||||
local workspace = GUI.workspace()
|
||||
workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
|
||||
|
||||
-- Add an layout with 5x1 grid size to workspace
|
||||
-- Add a layout with 5x1 grid size to workspace
|
||||
local layout = workspace:addChild(GUI.layout(1, 1, workspace.width, workspace.height, 5, 1))
|
||||
|
||||
-- Add 9 buttons to layout and assign specified grid position to them
|
||||
@ -2021,7 +2021,7 @@ The library has several methods that can simplify the development of programs. F
|
||||
| ------ | ------ | ------ |
|
||||
| *varargs* | ... | A lot of parameters having any type that need to be displayed in a window |
|
||||
|
||||
This method displays a debug window with text information. The line that is too long will be automatically wrapped. If parameter is a table, then it will be automatically serialized. To close the window, you must hit the Return key or click on the "OK" button
|
||||
This method displays a debug window with text information. The line that is too long will be automatically wrapped. If parameter is a table, then it will be automatically serialized. To close the window, you must hit the Return key or click on the "OK" button.
|
||||
|
||||
###Example
|
||||
|
||||
@ -2054,9 +2054,9 @@ Result:
|
||||
| [*float* [0.0; 1.0] | backgroundTransparency] | Optional background transparency |
|
||||
| [*float* [0.0; 1.0] | shadowTransparency] | Optional shadow transparency |
|
||||
|
||||
This is one of the most commonly used methods. It adds a context menu to the specified container and allows to work with it fantastically easy. All optional parameters of the method exist only for customization, and if they are not specified, pre-stored library constants will be used.
|
||||
This is one of the most commonly used methods. It adds a context menu to the specified container and makes working with it fantastically easy. All optional parameters of the method exist only for customization, and if they are not specified, pre-stored library constants will be used.
|
||||
|
||||
If the context menu contains too many items, scrolling buttons will appear and mouse wheel support will be enabled to navigate menu content. Also if you select an item and it's have callback function .**onTouch()**, it will be called
|
||||
If the context menu contains too many items, scrolling buttons will appear and mouse wheel support will be enabled to navigate menu content. Also if you select an item and it has a callback function, **onTouch()** will be called.
|
||||
|
||||
This object has following properties:
|
||||
|
||||
@ -2126,7 +2126,7 @@ Result:
|
||||
| *boolean* | addPanel | Necessity to add a semi-transparent dark background panel |
|
||||
| *varargs* | ... | Multiple parameters that comes to GUI.**filesystemDialog** starting from **width** |
|
||||
|
||||
This method creates a filesystem dialor in specified container with a nice drop-down animation and allows you to work with it in the same way as with a conventional JUI. It is useful for manual work with the file system, if there is no desire to work with GUI.**filesystemChooser**
|
||||
This method creates a filesystem dialer in specified container with a nice drop-down animation and allows you to work with it in the same way as with a conventional JUI. It is useful for manual work with the file system, if there is no desire to work with GUI.**filesystemChooser**
|
||||
|
||||
This object has following properties:
|
||||
|
||||
@ -2178,9 +2178,9 @@ This object has following properties:
|
||||
|
||||
| Type | Property | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| *table* | .**panel** | Pointer to background panel object. Doesn't exists if **addPanel** parameter is set to **false** |
|
||||
| *table* | .**layout** | Pointer to background layout object. Doesn't exists if **addLayout** parameter is set to **false** |
|
||||
| *table* | .**label** | Pointer to title label object. Doesn't exists if **title** parameter is **nil** |
|
||||
| *table* | .**panel** | Pointer to background panel object. Doesn't exist if **addPanel** parameter is set to **false** |
|
||||
| *table* | .**layout** | Pointer to background layout object. Doesn't exist if **addLayout** parameter is set to **false** |
|
||||
| *table* | .**label** | Pointer to title label object. Doesn't exist if **title** parameter is **nil** |
|
||||
|
||||
###Example
|
||||
|
||||
@ -2233,7 +2233,7 @@ local screen = require("Screen")
|
||||
|
||||
screen.clear(0x1E1E1E)
|
||||
|
||||
-- Open file and read it's lines
|
||||
-- Open file and read its lines
|
||||
local y = 1
|
||||
for line in require("filesystem").lines("/Libraries/Number.lua") do
|
||||
-- Replace tab symbols to 2 whitespaces and Windows line endings to UNIX line endings
|
||||
@ -2293,7 +2293,7 @@ local GUI = require("GUI")
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Create a function that will draw your switch to screen buffer
|
||||
-- It's recommended to use local function because it will exists in memory as single copy for each switch
|
||||
-- It's recommended to use local function because it will exist in memory as single copy for each switch
|
||||
local function switchDraw(switch)
|
||||
local bodyX = switch.x + switch.width - switch.bodyWidth
|
||||
-- Draw a switch text
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user