-
Notifications
You must be signed in to change notification settings - Fork 1
Box
A box is a Rectangle that represents the building block of GNUI
Note
It is recommened to use GNUI.newBox() instead of requiring the class script, save yourself some space.
| Type | Field | Description | |
|---|---|---|---|
number |
AccumulatedScaleFactor | Scales the displayed sprites and its children based on the factor. | |
Vector4 |
Anchor | Determins where to attach to its parent, (0-1, left-right, up-down) |
|
string[] |
BakedText | The baked text to be displayed. | |
table |
cache | Contains data to optimize the process. | |
boolean |
canCaptureCursor | True when the box can capture the cursor. from its parent | |
GNUI.Canvas |
Canvas | The canvas that the box is attached to. | |
integer |
ChildIndex | the element's place order on its parent. | |
table<any,GNUI.any> |
Children | A list of the element's children. | |
boolean |
ClipOnParent | when true, the box will go invisible once touching outside the parent container. |
|
Vector3 |
Color | The tint applied to the sprite. | |
Vector4 |
ContainmentRect | The final output dimensions with anchors applied. incredibly handy piece of data. | |
boolean |
CursorHovering | True when the cursor is hovering over the container, compared with the parent container. | |
Vector2 |
CustomMinimumSize | Minimum size that the box will use. | |
string |
DefaultTextColor | The color to be used when the text color is not specified. | |
Vector4 |
Dimensions | Determins the offset of each side from the final output | |
number |
FontScale | The scale of the text. | |
Vector2 |
GrowDirection | The direction in which the box grows into when is too small for the parent container. | |
integer |
id | A unique integer for this element. (next-free based). | |
boolean |
isClipping |
true when the box is touching outside the parent's container. |
|
boolean |
isCursorHovering |
true when the cursor is hovering over the container. |
|
boolean |
isFreed | true when the element is being freed. | |
ModelPart |
ModelPart | The ModelPart used to handle where to display debug features and the sprite. |
|
string |
name | An optional property used to get the element by a name. | |
Nineslice |
Nineslice | the sprite that will be used for displaying textures. | |
Vector2 |
offsetChildren | Shifts the children. | |
GNUI.any |
Parent | the element's parents. | |
table |
PARENT_CHANGED | when the parent changes. | |
number |
ScaleFactor | Scales the displayed sprites and its children based on the factor. | |
Vector2 |
Size | The size of the container. | |
Vector2 |
SystemMinimumSize | The minimum size that the box can use, set by the box itself. | |
table |
Text | The text to be displayed. | |
Vector2 |
TextAlign | The alignment of the text within the box. | |
GNUI.TextBehavior |
TextBehavior | Tells the text what to do when out of bounds. | |
GNUI.TextEffect |
TextEffect | The effect to be applied to the text. | |
integer[] |
TextLengths | The length of each separated text | |
boolean |
TextLimitsHeight | If true, the text will clamp to the height of the box | |
Vector2 |
TextOffset | Specifies how much to offset the text from its final position. | |
ModelPart |
TextPart | The ModelPart used to display text. |
|
TextTask[] |
TextTasks | A list of tasks to be executed when the text is changed. | |
boolean |
Visible |
true to see. |
|
number |
Z | Offsets the box forward(+) or backward(-) if Z fighting is occuring, also affects its children. | |
number |
ZSquish | Multiplies how much the modelpart is positioned in the Z axis |
| Event | Description |
|---|---|
ANCHOR_CHANGED |
Triggered when the anchors applied to the box is changed. |
CANVAS_CHANGED |
Triggered when the canvas that the box is attached to has changed. first argument is the new, second is the old one. |
CHILDREN_ADDED |
when a child is added. first parameter is the child added. |
CHILDREN_CHANGED |
when the children list is changed. |
CHILDREN_REMOVED |
when a child is removed. first parameter is the child removed. |
DIMENSIONS_CHANGED |
Triggered when the final box dimensions has changed. |
INPUT |
Serves as the handler for all inputs within the boundaries of the container. |
MOUSE_ENTERED |
Triggered once the cursor is hovering over the container |
MOUSE_EXITED |
Triggered once the cursor leaves the confinement of this container. |
MOUSE_MOVED |
Triggered when the mouse position changes within this container. GNUI.InputEventMouseMotion being the first agument, containing data about the event. |
MOUSE_PRESSENCE_CHANGED |
Triggered when the state of the mouse to box interaction changes, arguments include: (hovering: boolean, pressed: boolean) |
ON_FREE |
when the element is wiped from history. |
SIZE_CHANGED |
Triggered when the size of the final box dimensions is different from the last tick. |
SPRITE_CHANGED |
Triggered when the sprite object set to this box has changed. |
TEXT_CHANGED |
Triggered when the text is changed. |
VISIBILITY_CHANGED |
on change of visibility. |
| Returns | Methods |
|---|---|
self |
Box.new(parent : GNUI.Box?) |
self |
Box:setVisible(visible : boolean) |
self |
Box:setColor(r : number|Vector3|string, g : number?, b : number?) |
| Box:_updateVisibility() | |
self |
Box:setName(name : string) |
string |
Box:getName() |
GNUI.any |
Box:getChild(name : string) |
| Box:getChildByIndex() | |
self |
Box:updateChildrenOrder(self : self) |
self |
Box:addChild(child : GNUI.any, index : integer?) |
self |
Box:removeChild(child : GNUI.Box) |
table<integer, |
Box:getChildren() |
self |
Box:updateChildrenIndex(self : self) |
| Box:setChildIndex(i : any) | |
| Box:free() | |
| Box:purgeAllChildren() | |
| Box:purgeChildrenRange(ifrom : any, ito : any) | |
self |
Box:setCanvas(canvas : GNUI.Canvas) |
self |
Box:setNineslice(self : self, nineslice : Nineslice?) |
self |
Box:setClipOnParent(self : self, clip : any) |
self |
Box:setDimensions(self : self, x : number|Vector4, y : number?, w : number?, t : number?) |
self |
Box:setPos(self : self, x : number|Vector2, y : number?) |
self |
Box:setEnd(self : self, x : number|Vector2, y : number?) |
self |
Box:setSize(x : number|Vector2, y : number?) |
Vector2 |
Box:getSize() |
boolean |
Box:isPosInside(x : number|Vector2, y : number?) |
self |
Box:setZMul(mul : number) |
self |
Box:setCanCaptureCursor(capture : boolean) |
self |
Box:setScaleFactor(factor : number?) |
self |
Box:setAnchorTop(units : number?) |
self |
Box:setAnchorLeft(units : number?) |
self |
Box:setAnchorDown(units : number?) |
self |
Box:setAnchorRight(units : number?) |
self |
Box:setAnchor(left : number|Vector4|Vector2, top : number|Vector2?, right : number?, bottom : number?) |
self |
Box:setIsCursorHovering(toggle : boolean) |
self |
Box:setCustomMinimumSize(x : number|Vector2, y : number?) |
self |
Box:setSystemMinimumSize(x : number|Vector2, y : number?) |
self |
Box:setGrowDirection(x : number|Vector2, y : number?) |
self |
Box:setChildrenOffset(x : number|Vector2, y : number?) |
| Box:getMinimumSize() | |
Vector2 |
Box:XYtoUV(x : number|Vector2, y : number?) |
Vector2 |
Box:UVtoXY(x : number|Vector2, y : number?) |
Vector2 |
Box:toGlobal(x : number|Vector2, y : number?) |
Vector2 |
Box:toLocal(x : number|Vector2, y : number?) |
self |
Box:update(self : self) |
self |
Box:updateTheming(self : self) |
| Box:_update() | |
| Box:updateSpriteTasks() | |
self |
Box:forceUpdate(self : self) |
| Box:_propagateUpdateToChildren() | |
self |
Box:rebuildTextTasks(self : self) |
| Box:repositionText() | |
self |
Box:setText(self : self, text : any) |
self |
Box:setFontScale(scale : number) |
self |
Box:setDefaultTextColor(color : Vector3|string) |
| Box:setTextAlign(h : number?, v : number?) | |
self |
Box:setTextBehavior(behavior : GNUI.TextBehavior) |
self |
Box:setTextEffect(self : self, effect : GNUI.TextEffect) |
self |
Box:setTextOffset(x : number|Vector2, y : number?) |
Creates a new container.
-
GNUI.Box?parent
Sets the visibility of the element and its children
-
booleanvisible
Sets the color of the element.
-
number|Vector3|stringr -
number?g -
number?b
Sets the name of the element. this is used to make it easier to find elements with getChild
-
stringname
Gets a child by username
-
stringname
Adopts an element as its child.
-
GNUI.anychild -
integer?index
Abandons the child into the street.
-
GNUI.Boxchild
Sets the Child Index of the element.
-
anyi
Frees all the data of the element. all thats left to do is to forget it ever existed.
Kills all the children, go startwars mode.
Kills all the children in the given number range.
-
anyifrom -
anyito
Sets the canvas of this box and its hierarchy.
-
GNUI.Canvascanvas
Sets the backdrop of the container.
Note: if the sprite given is already in use, it will overtake it.
-
Nineslice?nineslice
Sets the flag if this box should go invisible once touching outside of its parent.
-
anyclip
Sets the dimensions of this container.
x,y is top left
z,w is bottom right
if Z or W is missing, they will use X and Y instead
-
number|Vector4x -
number?y -
number?w -
number?t
Sets the position of this container.
check out Box:setEnd() for setting the position from the other end.
-
number|Vector2x -
number?y
Sets the position of this container.
check out Box:setPos() for setting the position from the other end.
-
number|Vector2x -
number?y
Sets the Size of this container.
-
number|Vector2x -
number?y
Gets the Size of this container.
Checks if the given position is inside the container, in local BBunits of this box with dimension offset considered.
-
number|Vector2x -
number?y
Multiplies the offset from its parent container, useful for making the future elements go behind the parent by setting this value to lower than 0.
-
numbermul
If this box should be able to capture the cursor from its parent if obstructed.
-
booleancapture
Sets the UI scale of its children, while still mentaining their original anchors and positions.
-
number?factor
Sets the top anchor.
0 = top part of the box is fully anchored to the top of its parent
1 = top part of the box is fully anchored to the bottom of its parent
-
number?units
Sets the left anchor.
0 = left part of the box is fully anchored to the left of its parent
1 = left part of the box is fully anchored to the right of its parent
-
number?units
Sets the down anchor.
0 = bottom part of the box is fully anchored to the top of its parent
1 = bottom part of the box is fully anchored to the bottom of its parent
-
number?units
Sets the right anchor.
0 = right part of the box is fully anchored to the left of its parent
1 = right part of the box is fully anchored to the right of its parent
-
number?units
Sets the anchor for all sides.
x 0 <-> 1 = left <-> right
y 0 <-> 1 = top <-> bottom
if right and bottom are not given, they will use left and top instead.
-
number|Vector4|Vector2left -
number|Vector2?top -
number?right -
number?bottom
-
booleantoggle
-
number|Vector2x -
number?y
-
number|Vector2x -
number?y
-
number|Vector2x -
number?y
Sets the shift of the children, useful for scrollbars.
-
number|Vector2x -
number?y
Gets the minimum size of the container.
Converts a point from BBunits to UV units.
-
number|Vector2x -
number?y
Converts a point from UV units to BB units.
-
number|Vector2x -
number?y
returns the global position of the given local position.
-
number|Vector2x -
number?y
returns the local position of the given global position.
-
number|Vector2x -
number?y
Flags this Container to be updated.
Calls the events that are most likely used by themes. ex. MOUSE_PRESSENCE_CHANGED
Forces an update of the box.
Sets the text to be displayed in the box. This supports raw json text
-
anytext
Sets the scale of the text being displayed.
-
numberscale
Sets the default text color
-
Vector3|stringcolor
Tells where to anchor the text at.
0 <-> 1, left <-> right
0 <-> 1, top <-> bottom
-
number?h -
number?v
Sets the flag if the text should wrap around when out of bounds.
-
GNUI.TextBehaviorbehavior
-
GNUI.TextEffecteffect
Sets the offset of the text.
-
number|Vector2x -
number?y