mirror of
https://github.com/AR2000AR/openComputers_codes.git
synced 2025-09-08 14:41:14 +02:00
[libGUI-doc] documentation
This commit is contained in:
9
libGUIDoc/README.md
Normal file
9
libGUIDoc/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# libGUI
|
||||||
|
## Classes
|
||||||
|
- [Screen](Screen.md)
|
||||||
|
- [ImageFile](ImageFile.md)
|
||||||
|
- *[widget.Widget](widget/Widget.md)*
|
||||||
|
- [widget.Rectangle](widget/Rectangle.md)
|
||||||
|
- [widget.Text](widget/Text.md)
|
||||||
|
- [widget.Input](widget/Input.md)
|
||||||
|
- [widget.Image](widget/Image.md)
|
58
libGUIDoc/Screen.md
Normal file
58
libGUIDoc/Screen.md
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Screen
|
||||||
|
Group widgets together do draw them, hide or show, enable or disable them.
|
||||||
|
You should always put any widget in at least one Screen as it manage a [frame buffer](https://ocdoc.cil.li/component:gpu#video_ram_buffers) to speed up drawing
|
||||||
|
## Constructor
|
||||||
|
Take no arguments
|
||||||
|
|
||||||
|
## Public methods
|
||||||
|
### setVisible
|
||||||
|
Set the Screen's visibility. When hidden, no child widgets will be drawn.
|
||||||
|
#### Arguments
|
||||||
|
- visible : boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
### enable
|
||||||
|
Enable or disable the Screen. When disabled, the trigger event won't be propagated to the children.
|
||||||
|
#### Arguments
|
||||||
|
- enable : boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
### isVisible
|
||||||
|
Check if the Screen is visible.
|
||||||
|
#### Return
|
||||||
|
- boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
### isEnabled
|
||||||
|
Check if the Screen is enable.
|
||||||
|
#### Return
|
||||||
|
- boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
### addChild
|
||||||
|
Add a child to the Screen.
|
||||||
|
#### Arguments
|
||||||
|
- child : Widget|Screen
|
||||||
|
|
||||||
|
---
|
||||||
|
### trigger
|
||||||
|
Method to call to handle events. Most often a `touch` handler.
|
||||||
|
```lua
|
||||||
|
local gui = require "libGUI"
|
||||||
|
local event = require "event"
|
||||||
|
|
||||||
|
local screen = gui.Screen()
|
||||||
|
event.listen("touch",function(...) screen:trigger(...) end)
|
||||||
|
```
|
||||||
|
#### Arguments
|
||||||
|
- ... : any. The event infos
|
||||||
|
|
||||||
|
---
|
||||||
|
### draw
|
||||||
|
Draw the child widgets.
|
||||||
|
#### Arguments
|
||||||
|
- useBuffer : boolean. Should the Screen create a frame buffer to draw in. Default is true.
|
||||||
|
## Private methods
|
||||||
|
### clickHandler(eventName:string, uuid:string, x:int, y:int, button:int, playerName:string)
|
||||||
|
#### Parameter
|
||||||
|
`touch` event property.
|
@@ -13,7 +13,7 @@ class Screen {
|
|||||||
+ bool isEnabled()
|
+ bool isEnabled()
|
||||||
+ void addChild(Widget|Screen child)
|
+ void addChild(Widget|Screen child)
|
||||||
+ void trigger(...)
|
+ void trigger(...)
|
||||||
+ void draw()
|
+ void draw(bool useBuffer)
|
||||||
+ childs[] Widget
|
+ childs[] Widget
|
||||||
}
|
}
|
||||||
class ImageFile {
|
class ImageFile {
|
||||||
|
52
libGUIDoc/widget/Image.md
Normal file
52
libGUIDoc/widget/Image.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Image([Widget](Widget.md))
|
||||||
|
Display a image. Supported format are `.ppm` and `.pam` both in ASCII or RAW (binary) format.
|
||||||
|
|
||||||
|
## Constructor
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
- img : string|[ImageFile](ImageFile.md). The image file path
|
||||||
|
- drawMethod : int
|
||||||
|
|
||||||
|
## Inherited public methods
|
||||||
|
- [setX](Widget.md#setx)
|
||||||
|
- [setY](Widget.md#sety)
|
||||||
|
- [setPos](Widget.md#setpos)
|
||||||
|
- [getX](Widget.md#getx)
|
||||||
|
- [getY](Widget.md#gety)
|
||||||
|
- [getPos](Widget.md#getpos)
|
||||||
|
- [setCallback](Widget.md#setcallback)
|
||||||
|
- [draw](Widget.md#draw)
|
||||||
|
- [collide](Widget.md#collide)
|
||||||
|
|
||||||
|
## Public methods
|
||||||
|
### getWidth
|
||||||
|
#### Return
|
||||||
|
- width : int
|
||||||
|
---
|
||||||
|
### getHeight
|
||||||
|
#### Return
|
||||||
|
- height: int
|
||||||
|
|
||||||
|
---
|
||||||
|
### getSize
|
||||||
|
#### Return
|
||||||
|
- width : int
|
||||||
|
- height : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setDrawMethod
|
||||||
|
Define how a individual pixel is drawn :
|
||||||
|
- true : 2 pixels per character (square pixel)
|
||||||
|
- false : 1 pixel per character (rectangle pixel)
|
||||||
|
#### Argument
|
||||||
|
- drawMethod : boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
### getDrawMethod
|
||||||
|
How a individual pixel is drawn :
|
||||||
|
- true : 2 pixels per character (square pixel)
|
||||||
|
- false : 1 pixel per character (rectangle pixel)
|
||||||
|
#### Return
|
||||||
|
- drawMethod : boolean
|
||||||
|
|
||||||
|
---
|
57
libGUIDoc/widget/Input.md
Normal file
57
libGUIDoc/widget/Input.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Input([Text](Text.md))
|
||||||
|
Get text input from the user.
|
||||||
|
The widget must be able to
|
||||||
|
|
||||||
|
## Inherited public methods
|
||||||
|
- [setX](Widget.md#setx)
|
||||||
|
- [setY](Widget.md#sety)
|
||||||
|
- [setPos](Widget.md#setpos)
|
||||||
|
- [getX](Widget.md#getx)
|
||||||
|
- [getY](Widget.md#gety)
|
||||||
|
- [getPos](Widget.md#getpos)
|
||||||
|
- [draw](Widget.md#draw)
|
||||||
|
- [collide](Widget.md#collide)
|
||||||
|
- [setWidth](Rectangle.md#setwidth)
|
||||||
|
- [setHeight](Rectangle.mdsetHeight)
|
||||||
|
- [setSize](Rectangle.mdd#setsize)
|
||||||
|
- [setColor](Rectangle.md#setcolor)
|
||||||
|
- [getWidth](Rectangle.md#getwidth)
|
||||||
|
- [getHeight](Rectangle.md#getheight)
|
||||||
|
- [getSize](Rectangle.mdd#getsize)
|
||||||
|
- [getColor](Rectangle.md#getcolor)
|
||||||
|
- [getForeground](Text.md#getforeground)
|
||||||
|
- [getBackground](Text.md#getbackground)
|
||||||
|
- [setForeground](Text.md#setforeground)
|
||||||
|
- [setBackground](Text.md#setbackground)
|
||||||
|
|
||||||
|
Do not use :
|
||||||
|
- [setCallback](Widget.md#setcallback)
|
||||||
|
|
||||||
|
This methods are replaced by [getValue](#getvalue) and [setValue](#setvalue)
|
||||||
|
- [getText](Text.md#gettext)
|
||||||
|
- [setText](Text.md#settext)
|
||||||
|
|
||||||
|
## Public methods
|
||||||
|
### setPlaceholder
|
||||||
|
If set, the widget will show the placeholder character instead of the normal text. Useful for password prompts
|
||||||
|
#### Arguments
|
||||||
|
- char : string|nil
|
||||||
|
|
||||||
|
---
|
||||||
|
### getPlaceholder
|
||||||
|
Get the placeholder character.
|
||||||
|
#### Return
|
||||||
|
- char : string
|
||||||
|
|
||||||
|
---
|
||||||
|
### getValue
|
||||||
|
Get the inputted value. Return a different value than `getText`. Prefer this method.
|
||||||
|
#### Return
|
||||||
|
- value : string
|
||||||
|
---
|
||||||
|
### setValue
|
||||||
|
Get the inputted value. Should be used instead of `setText`
|
||||||
|
#### Arguments
|
||||||
|
#### Return
|
||||||
|
|
||||||
|
---
|
61
libGUIDoc/widget/Rectangle.md
Normal file
61
libGUIDoc/widget/Rectangle.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# Rectangle([Widget](Widget.md))
|
||||||
|
Basic rectangle shape.
|
||||||
|
|
||||||
|
## Constructor
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
- width : int
|
||||||
|
- height : int
|
||||||
|
- color : int
|
||||||
|
|
||||||
|
## Inherited public methods
|
||||||
|
- [setX](Widget.md#setx)
|
||||||
|
- [setY](Widget.md#sety)
|
||||||
|
- [setPos](Widget.md#setpos)
|
||||||
|
- [getX](Widget.md#getx)
|
||||||
|
- [getY](Widget.md#gety)
|
||||||
|
- [getPos](Widget.md#getpos)
|
||||||
|
- [setCallback](Widget.md#setcallback)
|
||||||
|
- [draw](Widget.md#draw)
|
||||||
|
- [collide](Widget.md#collide)
|
||||||
|
|
||||||
|
## Public methods
|
||||||
|
### setWidth
|
||||||
|
#### Arguments
|
||||||
|
- width : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setHeight
|
||||||
|
#### Arguments
|
||||||
|
- height : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setSize
|
||||||
|
#### Arguments
|
||||||
|
- width : int
|
||||||
|
- height : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setColor
|
||||||
|
#### Arguments
|
||||||
|
- color : int. RGB color
|
||||||
|
|
||||||
|
---
|
||||||
|
### getWidth
|
||||||
|
#### Return
|
||||||
|
- width : int
|
||||||
|
---
|
||||||
|
### getHeight
|
||||||
|
#### Return
|
||||||
|
- height: int
|
||||||
|
|
||||||
|
---
|
||||||
|
### getSize
|
||||||
|
#### Return
|
||||||
|
- width : int
|
||||||
|
- height : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### getColor
|
||||||
|
#### Return
|
||||||
|
- color : int. RGB color
|
59
libGUIDoc/widget/Text.md
Normal file
59
libGUIDoc/widget/Text.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Text([Rectangle](Rectangle.md))
|
||||||
|
Display text.
|
||||||
|
## Constructor
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
- width : int
|
||||||
|
- height : int
|
||||||
|
- backgroundColor : int
|
||||||
|
- text : string
|
||||||
|
|
||||||
|
## Inherited public methods
|
||||||
|
- [setX](Widget.md#setx)
|
||||||
|
- [setY](Widget.md#sety)
|
||||||
|
- [setPos](Widget.md#setpos)
|
||||||
|
- [getX](Widget.md#getx)
|
||||||
|
- [getY](Widget.md#gety)
|
||||||
|
- [getPos](Widget.md#getpos)
|
||||||
|
- [setCallback](Widget.md#setcallback)
|
||||||
|
- [draw](Widget.md#draw)
|
||||||
|
- [collide](Widget.md#collide)
|
||||||
|
- [setWidth](Rectangle.md#setwidth)
|
||||||
|
- [setHeight](Rectangle.md#setheight)
|
||||||
|
- [setSize](Rectangle.mdd#setsize)
|
||||||
|
- [setColor](Rectangle.md#setcolor)
|
||||||
|
- [getWidth](Rectangle.md#getwidth)
|
||||||
|
- [getHeight](Rectangle.md#getheight)
|
||||||
|
- [getSize](Rectangle.mdd#getsize)
|
||||||
|
- [getColor](Rectangle.md#getcolor)
|
||||||
|
|
||||||
|
## Public methods
|
||||||
|
### getText
|
||||||
|
#### Return
|
||||||
|
- text : string
|
||||||
|
|
||||||
|
---
|
||||||
|
### setText
|
||||||
|
#### Arguments
|
||||||
|
- text : string
|
||||||
|
|
||||||
|
---
|
||||||
|
### getForeground
|
||||||
|
#### Return
|
||||||
|
- color : int. RGB color
|
||||||
|
|
||||||
|
---
|
||||||
|
### getBackground
|
||||||
|
#### Return
|
||||||
|
- color : int. RGB color
|
||||||
|
|
||||||
|
---
|
||||||
|
### setForeground
|
||||||
|
#### Arguments
|
||||||
|
- color : int. RGB color
|
||||||
|
|
||||||
|
---
|
||||||
|
### setBackground
|
||||||
|
#### Arguments
|
||||||
|
- color : int. RGB color
|
||||||
|
|
64
libGUIDoc/widget/Widget.md
Normal file
64
libGUIDoc/widget/Widget.md
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# *Widget*
|
||||||
|
Abstract class. Define the basic information any widget need.
|
||||||
|
## Constructor
|
||||||
|
### Arguments
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
|
||||||
|
## Abstract public methods
|
||||||
|
|
||||||
|
### setPos
|
||||||
|
#### Arguments
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setX
|
||||||
|
#### Arguments
|
||||||
|
- x : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setY
|
||||||
|
#### Arguments
|
||||||
|
- y : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### setCallback
|
||||||
|
Set the function called when `trigger` is called. This usually happen when the widget is clicked.
|
||||||
|
#### Arguments
|
||||||
|
- callback : function
|
||||||
|
|
||||||
|
---
|
||||||
|
### getX
|
||||||
|
#### Return
|
||||||
|
- x : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### getY
|
||||||
|
#### Return
|
||||||
|
- y : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### getPos
|
||||||
|
#### Return
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### *collide*
|
||||||
|
Check if the position passed as arguments is on the widget
|
||||||
|
#### Arguments
|
||||||
|
- x : int
|
||||||
|
- y : int
|
||||||
|
|
||||||
|
---
|
||||||
|
### *draw*
|
||||||
|
Draw the widget.
|
||||||
|
|
||||||
|
---
|
||||||
|
## Public methods
|
||||||
|
|
||||||
|
### trigger
|
||||||
|
Call the callback method if the widget is enabled. Pass the widget and all arguments passed to it to the callback method.
|
||||||
|
### Arguments
|
||||||
|
- ... : any
|
Reference in New Issue
Block a user