Ui - itb-community/ITB-ModLoader GitHub Wiki
This is a Preliminary description of the Ui class. Many methods remain to be described, and some fields and/or methods may need to be updated with verified information.
Table of Contents
- Ui
- Fields
- Methods
- add
- addTo
- detach
- setroot
- settooltip
- caption
- decorate
- setTranslucent
- show
- hide
- setfocus
- hacsfous
- pos
- posCentered
- setxpx
- setypx
- pospx
- width
- height
- size
- widthpx
- heightpx
- padding
- anchor
- anchorH
- anchorV
- crop
- clip
- wheel
- mousedown
- mouseup
- mousemove
- dragWheel
- startDrag
- stopDrag
- dragMove
- keydown
- keyup
- updateContainsMouse
- updateHoveredState
- updateTooltipState
- update
- relayout
- draw
- clicked
- mouseEntered
- mouseExited
- swapSiblings
- bringUp
- bringDown
- bringToTop
Ui
Ui is the base class of all ui elements. A ui element can be instances of derived classes of Ui, but must always be an instance of Ui.
Ui
| Argument name | Type | Description |
|---|
Returns a new ui element instance of class Ui with the following fields and functions:
Fields
root
The root element of this ui element. Normally all elements are attached to the same root, which is automatically updated and drawn by the mod loader.
parent
The direct parent of the ui element. Automatically set when using the methods add and addTo.
children
A list of children elements. Ui elements are added to children when using the methods add and addTo.
decorations
A list of decorations elements. Without decorations, an element will be completely invisible. Decorations are what describes the visual representation of the element.
animations
description_missing
ignoreMouse
If this field is set to true, then mouse events will be ignored; it can not be focused; and it can not contain the mouse. It becomes a purely visual element.
visible
If this field is set to true, then it will not be drawn; mouse events will be ignored; it can not be focused; and it can not contain the mouse. It is as if the element does not exist for all intents and purposes.
translucent
If this field is set to true, then it can not be hovered, focused. It will receive mouse events, but it will not consume them. It is if the mouse events pass through the element.
disabled
Setting this field to true doesn't do anything by default, but many derived classes of Ui as well as some decorations use it to change the functionality or appearance of the element.
x
If alignH is nil or "left": x coordinate of the ui element, measured from the parent's left padded edge.
If alignH is "right": x coordinate of the ui element's right edge, measured from the parent's right padded edge.
See padding
y
If alignV is nil or "top": y coordinate of the ui element, measured from the parent's top padded edge.
If alignV is "bottom": y coordinate of the ui element's bottom edge, measured from the parent's bottom padded edge.
See padding
w
Width in pixels of the ui element.
h
Height in pixels of the ui element.
dx
A variable used to horizontally shift all of its children by this amount. Defaults to 0, and is usually only used by scrolling Ui classes.
dy
A variable used to vertically shift all of its children by this amount. Defaults to 0, and is usually only used by scrolling Ui classes.
alignH
Horizontal alignment of the ui element. Tells the parent element how this element would like to be aligned by its parent. Accepted values are "left", "center" and "right". Defaults to left if not set.
alignV
Vertical alignment of the ui element. Tells the parent element how this element would like to be aligned by its parent. Accepted values are "top", "center" and "bottom". Defaults to top if not set.
padl
Left padding of the ui element. If a child's alignH is nil, "left" or "center" its x coordinate will be shifted to the right by this amount.
Certain ___Layout Ui classes will also use padding to contain its children elements within its area.
padt
Top padding of the ui element. If a child's alignV is nil, "top" or "center" its y coordinate will be shifted down by this amount.
Certain ___Layout Ui classes will also use padding to contain its children elements within its area.
padr
Right padding of the ui element. If a child's alignH is "right" its x coordinate will be shifted up by this amount.
Certain ___Layout Ui classes will also use padding to contain its children elements within its area.
padb
Bottom padding of the ui element. If a child's alignV is "bottom" its y coordinate will be shifted up by this amount.
Certain ___Layout Ui classes will also use padding to contain its children elements within its area.
screenx
The x coordinate relative to the screen of the ui element. Is automatically set by Ui.relayout.
screeny
The y coordinate relative to the screen of the ui element. Is automatically set by Ui.relayout.
innerWidth
The minimum width needed to contain all of its children. Automatically calculated in relayout
innerHeight
The minimum height needed to contain all of its children. Automatically calculated in relayout
hovered
Is true if the element is hovered by the mouse cursor; otherwise false. This field is automatically set in updateHoveredState, and should normally not be manually modified.
pressed
Is true if the element is pressed by the left mouse button; otherwise false. This field is automatically set by mouse down events, and should normally not be manually modified.
focused
Is true if the element was the hovered element on the last button down event; otherwise false. If this element is focused, then key events will be passed to it. This field is automatically set by mouse down events, and should normally not be manually modified (verification needed).
containsMouse
Is true if the element contains the mouse cursor; otherwise false. This field is automatically set in updateContainsMouse, and should normally not be manually modified.
Methods
setxpx
| Argument name | Type | Description |
|---|---|---|
x |
number | position x |
Sets the element's x coordinate relative to the parent's x coordinate (+padding) to the specified x coordinate.
Returns itself.
setypx
| Argument name | Type | Description |
|---|---|---|
y |
number | position y |
Sets the element's y coordinate relative to the parent's y coordinate (+padding) to the specified y coordinate.
Returns itself.
pospx
| Argument name | Type | Description |
|---|---|---|
x |
number | position x |
y |
number | position y |
Sets the element's position relative to the parent's position (+padding) to the specified coordinates.
Returns itself.
width
| Argument name | Type | Description |
|---|---|---|
width |
number | The width in percent of the parent element |
Sets the width of this element to a portion of the width of the parent element.
Returns itself.
height
| Argument name | Type | Description |
|---|---|---|
height |
number | The height in percent of the parent element |
Sets the height of this element to a portion of the height of the parent element.
Returns itself.
size
| Argument name | Type | Description |
|---|---|---|
width |
number | The width in percent of the parent element |
height |
number | The width in percent of the parent element |
Sets the width and height of this element to a portion of the width and height of the parent element.
Returns itself.
widthpx
| Argument name | Type | Description |
|---|---|---|
width |
number | Width in pixels |
Sets the width of this element to the specified width.
Returns itself.
heightpx
| Argument name | Type | Description |
|---|---|---|
height |
number | Height in pixels |
Sets the height of this element to the specified height.
Returns itself.
padding
| Argument name | Type | Description |
|---|---|---|
padding |
number | The amount of padding to add in all directions |
Adds an amount of padding to each side of the ui element.
Padding is used to reduce the available area for children.
If for example a child calls width(x), its width will be set to [x * (parent.w - parent.padl - parent.padr)]
Returns itself.
padt: top padding
padr: right padding
padb: bottom padding
padl: left padding
| <----------- Ui.w -------------> |
|---|
| padl | <- children -> | padr |
|---|
padding
| Argument name | Type | Description |
|---|---|---|
padding |
number | The amount of padding to add in all directions |
add
| Argument name | Type | Description |
|---|---|---|
child |
table | to_be_added |
index |
number | to_be_added |
description_missing
remove
| Argument name | Type | Description |
|---|---|---|
child |
table | to_be_added |
description_missing
addTo
| Argument name | Type | Description |
|---|---|---|
parent |
table | to_be_added |
index |
number | to_be_added |
description_missing
detach
| Argument name | Type | Description |
|---|
description_missing
setroot
| Argument name | Type | Description |
|---|---|---|
root |
table | to_be_added |
description_missing
settooltip
| Argument name | Type | Description |
|---|---|---|
text |
string | to_be_added |
title |
string | to_be_added |
static |
boolean | to_be_added |
description_missing
settooltip
| Argument name | Type | Description |
|---|---|---|
text |
string | to_be_added |
title |
string | to_be_added |
static |
boolean | to_be_added |
description_missing
show
| Argument name | Type | Description |
|---|
description_missing
hide
| Argument name | Type | Description |
|---|
description_missing
setfocus
| Argument name | Type | Description |
|---|
description_missing
hasfocus
| Argument name | Type | Description |
|---|
description_missing
decorate
| Argument name | Type | Description |
|---|---|---|
decorations |
table | to_be_added |
description_missing
pos
| Argument name | Type | Description |
|---|---|---|
x |
number | to_be_added |
y |
number | to_be_added |
description_missing
posCentered
| Argument name | Type | Description |
|---|---|---|
x |
number | to_be_added |
y |
number | to_be_added |
description_missing
caption
| Argument name | Type | Description |
|---|---|---|
text |
string | to_be_added |
description_missing
setTranslucent
| Argument name | Type | Description |
|---|---|---|
translucent |
string | to_be_added |
cascade |
string | to_be_added |
description_missing
anchor
| Argument name | Type | Description |
|---|---|---|
alignH |
string | to_be_added |
alignV |
string | to_be_added |
description_missing
anchorH
| Argument name | Type | Description |
|---|---|---|
alignH |
string | to_be_added |
description_missing
anchorV
| Argument name | Type | Description |
|---|---|---|
alignV |
string | to_be_added |
description_missing
crop
| Argument name | Type | Description |
|---|---|---|
crop |
string | to_be_added |
description_missing
clip
| Argument name | Type | Description |
|---|---|---|
clip |
string | to_be_added |
description_missing
wheel
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
y |
number | to_be_added |
description_missing
mousedown
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
button |
number | to_be_added |
description_missing
mouseup
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
button |
number | to_be_added |
description_missing
mousemove
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
description_missing
dragWheel
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
y |
number | to_be_added |
description_missing
startDrag
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
description_missing
stopDrag
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
button |
number | to_be_added |
description_missing
dragMove
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
description_missing
keydown
| Argument name | Type | Description |
|---|---|---|
keycode |
number | to_be_added |
description_missing
keyup
| Argument name | Type | Description |
|---|---|---|
keycode |
number | to_be_added |
description_missing
updateContainsMouse
| Argument name | Type | Description |
|---|---|---|
mx |
number | to_be_added |
my |
number | to_be_added |
description_missing
updateHoveredState
| Argument name | Type | Description |
|---|
description_missing
updateTooltipState
| Argument name | Type | Description |
|---|
description_missing
update
| Argument name | Type | Description |
|---|
description_missing
relayout
| Argument name | Type | Description |
|---|
description_missing
draw
| Argument name | Type | Description |
|---|---|---|
screen |
userdata | to_be_added |
description_missing
clicked
| Argument name | Type | Description |
|---|---|---|
button |
number | to_be_added |
description_missing
mouseEntered
| Argument name | Type | Description |
|---|
description_missing
mouseExited
| Argument name | Type | Description |
|---|
description_missing
swapSiblings
| Argument name | Type | Description |
|---|---|---|
destIndex |
number | to_be_added |
description_missing
bringUp
| Argument name | Type | Description |
|---|
description_missing
bringDown
| Argument name | Type | Description |
|---|
description_missing
bringToTop
| Argument name | Type | Description |
|---|
description_missing