A node which represents a user interface element and is rendered in 2D.
Inheritance:
Get the screen space (pixels) rectangle that determines where the widget is rendered. This is computed on Tick().
Sig: rect = Widget:GetRect()
- Ret:
Rect rect
Screen space rect
Forcefully update this widget's screen space rect.
Sig: Widget:UpdateRect()
Set the X position of this widget in pixels.
Sig: Widget:SetX(x)
- Arg:
number x
X position in pixels
Set the Y position of this widget in pixels.
Sig: Widget:SetY(y)
- Arg:
number y
Y position in pixels
Set the width of this widget in pixels.
Sig: Widget:SetWidth(width)
- Arg:
number width
Width in pixels
Set the height of this widget in pixels.
Sig: Widget:SetHeight(height)
- Arg:
number height
Height in pixels
Set the X position of this widget as a ratio of the parent widget width.
Sig: Widget:SetXRatio(xRatio)
- Arg:
number xRatio
X as a ratio of parent width
Set the Y position of this widget as a ratio of the parent widget height.
Sig: Widget:SetYRatio(yRatio)
- Arg:
number yRatio
Y as a ratio of parent height
Set the width of this widget as a ratio of the parent widget width.
Sig: Widget:SetWidthRatio(widthRatio)
- Arg:
number widthRatio
Width as a ratio of parent width
Set the height of this widget as a ratio of the parent height.
Sig: Widget:SetHeightRatio(heightRatio)
- Arg:
number heightRatio
Height as a ratio of parent height
Set the left margin.
Sig: Widget:SetLeftMargin(margin)
- Arg:
number margin
Left margin
Set the top margin.
Sig: Widget:SetTopMargin(margin)
- Arg:
number margin
Top margin
Set the right margin.
Sig: Widget:SetRightMargin(margin)
- Arg:
number margin
Right margin
Set the bottom margin.
Sig: Widget:SetBottomMargin(margin)
- Arg:
number margin
Bottom margin
Set the position of this widget in pixels. A single Vector may be passed instead of the two separate arguments.
Sig: Widget:SetPosition(x, y)
- Arg:
number x
X position - Arg:
number y
Y position
Set the dimensions of this widget in pixels. A single Vector may be passed instead of the two separate arguments.
Sig: Widget:SetDimensions(width, height)
- Arg:
number width
Width - Arg:
number height
Height
Set position and dimensions. Note: this is not the same thing that GetRect() will return. GetRect() returns the final screen-space position/dimensions.
Sig: Widget:SetRect(rect)
- Arg:
Rect rect
Local rect (x, y, w, h)
Set the position/dimensions of this widget as ratios of the parent dimensions.
Sig: Widget:SetRatios(x, y, width, height)
- Arg:
number x
X ratio - Arg:
number y
Y ratio - Arg:
number width
Width ratio - Arg:
number height
Height ratio
Set the margins.
Sig: Widget:SetMargins(left, top, right, bottom)
- Arg:
number left
Left margin - Arg:
number top
Top margin - Arg:
number right
Right margin - Arg:
number bottom
Bottom margin
Explicitly set the widget's offset. The offset may be interpreted as either a pixel offset or a parent-ratio offset depending on the AnchorMode of the widget.
A single Vector may be passed instead of the two separate numbers.
Sig: Widget:SetOffset(x, y)
- Arg:
number x
X offset - Arg:
number y
Y offset
Get the widget's offset.
Sig: offset = Widget:GetOffset()
- Ret:
Vector offset
Offset (in .x and .y)
Set the widget's size. The size may be interpreted as either a pixel size or a parent-ratio size depending on the AnchorMode of the widget.
A single Vector may be passed instead of the two separate numbers.
Sig: Widget:SetSize(x, y)
- Arg:
number x
X size - Arg:
number y
Y size
Get the widget's size.
Sig: size = Widget:GetSize()
- Ret:
Vector size
Size (in .x and .y)
Get the widget's anchor mode. The anchor mode determines how a widget is positioned and sized relative to its parent.
See AnchorMode
Sig: anchorMode = Widget:GetAnchorMode()
- Ret:
AnchorMode(integer) anchorMode
Widget anchor mode
Set the widget's anchor mode. The anchor mode determines how a widget is positioned and sized relative to its parent.
See AnchorMode
Sig: Widget:SetAnchorMode(anchorMode)
- Arg:
AnchorMode(integer) anchorMode
Check if the widget should stretch along the X axis based on its anchor mode.
Sig: stretch = Widget:StretchX()
- Ret:
boolean stretch
Stretch along X
Check if the widget should stretch along the Y axis based on its anchor mode.
Sig: stretch = Widget:StretchY()
- Ret:
boolean stretch
Stretch along Y
Get the widget's relative X position in pixels.
Sig: x = Widget:GetX()
- Ret:
number x
Relative X in pixels
Get the widget's relative Y position in pixels.
Sig: y = Widget:GetY()
- Ret:
number y
Relative Y in pixels
Get the widget's relative width in pixels.
Sig: width = Widget:GetWidth()
- Ret:
number width
Relative width in pixels
Get the widget's relative height in pixels.
Sig: height = Widget:GetHeight()
- Ret:
number height
Relative height in pixels
Get the widget's relative position in pixels.
Sig: position = Widget:GetPosition()
- Ret:
Vector position
Relative position in pixels
Get the widget's relative dimensions in pixels.
Sig: dimensions = Widget:GetDimensions()
- Ret:
Vector dimensions
Relative dimensions in pixels
Get the parent widget's width.
Sig: width = Widget:GetParentWidth()
- Ret:
number width
Parent's width
Get the parent widget's height.
Sig: height = Widget:GetParentHeight()
- Ret:
number height
Parent's height
Set the widget's color.
Sig: Widget:SetColor(color)
- Arg:
Vector color
Widget color
Check if this widget should handle input.
Sig: handle = Widget:ShouldHandleInput()
- Ret:
boolean handle
Handle input
Mark this widget as dirty. When a widget is dirty, it will need to have its Rect updated on Tick(). Other data may be updated as well depending on the type of widget.
Sig: Widget:MarkDirty()
Check if the widget is marked as dirty.
Sig: dirty = Widget:IsDirty()
- Ret:
boolean dirty
Is widget dirty
Check if the mouse is contained within the area of the widget (inside the Rect). The mouse will not be considered inside the Rect if it is outside the scissor bounds.
Sig: contained = Widget:ContainsMouse()
- Ret:
boolean contained
Widget contains mouse
Check if a point is within the area of the widget (inside the Rect). Clamps within the scissor bounds if scissor is enabled.
Sig: contained = Widget:ContainsPoint(x, y)
- Arg:
number x
X screen position in pixels - Arg:
number y
Y screen position in pixels - Ret:
boolean contained
Widget contains point
Set the widget rotation in degrees.
Sig: Widget:SetRotation(rotation)
- Arg:
number rotation
Rotation in degrees
Get the widget rotation in degrees.
Sig: rotation = Widget:GetRotation()
- Ret:
number rotation
Rotation in degrees
Set the widget's pivot point which it will rotate around. A pivot of <0,0> is the top left corner. <0.5, 0.5> would be in the middle. <1, 1> would be the bottom right.
Sig: Widget:SetPivot(x, y)
- Arg:
number x
X pivot (should likely be between 0 and 1) - Arg:
number y
Y pivot (should likely be between 0 and 1)
Get the widget's pivot point which it will rotate around. A pivot of <0,0> is the top left corner. <0.5, 0.5> would be in the middle. <1, 1> would be the bottom right.
Sig: pivot = Widget:GetPivot()
- Ret:
Vector pivot
The pivot point (as a ratio in the range 0 to 1)
Set the widget's scale.
A single Vector argument can be used instead of the two number arguments.
Sig: Widget:SetScale(x, y)
- Arg:
number x
X scale - Arg:
number y
Y scale
Get the widget's scale.
Sig: scale = Widget:GetScale()
- Ret:
Vector scale
Widget scale
Check if the scissor is enabled. When the scissor is enabled, child widgets will be clipped to stay within the bounds of this widget.
Sig: scissor = Widget:IsScissorEnabled()
- Ret:
boolean scissor
Whether scissor is enabled
Set whether to enable the scissor. When the scissor is enabled, child widgets will be clipped to stay within the bounds of this widget.
Sig: Widget:EnableScissor(scissor)
- Arg:
boolean scissor
Whether to enable scissor
Set the widget's opacity as an integer between 0 and 255. When rendered, a widget's opacity is compounded with its parent opacity.
Sig: Widget:SetOpacity(opacity)
- Arg:
integer opacity
Widget opacity (0 to 255)
Set the widget's opacity as a floating point number between 0 and 1. When rendered, a widget's opacity is compounded with its parent opacity.
Sig: Widget:SetOpacityFloat(opacity)
- Arg:
number opacity
Widget opacity (0 to 1)
Get the widget's opacity as an integer between 0 and 255. When rendered, a widget's opacity is compounded with its parent opacity.
Sig: opacity = Widget:GetOpacity()
- Ret:
integer opacity
Widget opacity (0 to 255)
Get the widget's opacity as a floating point number between 0 and 1. When rendered, a widget's opacity is compounded with its parent opacity.
Sig: opacity = Widget:GetOpacityFloat()
- Ret:
number opacity
Widget opacity (0 to 1)