Class Widget
Base class for UI widgets.
Inherited Members
Namespace: Genesis.UI
Assembly: Genesis.dll
Syntax
public class Widget
Constructors
Widget()
Creates a new instance of the Widget class.
Declaration
public Widget()
Properties
Anchor
Gets or sets the anchor value for the widget
Declaration
public WidgetAnchor Anchor { get; set; }
Property Value
Type | Description |
---|---|
WidgetAnchor |
Children
Gets or sets the list of child widgets.
Declaration
public List<Widget> Children { get; set; }
Property Value
Type | Description |
---|---|
List<Widget> |
Debug
Gets or sets a value indicating whether debug mode is enabled for the widget.
Declaration
public bool Debug { get; set; }
Property Value
Type | Description |
---|---|
bool |
Enabled
Gets or sets a value indicating whether the widget is enabled.
Declaration
public bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
Location
Gets or sets the location of the widget in 3D space.
Declaration
public Vec3 Location { get; set; }
Property Value
Type | Description |
---|---|
Vec3 |
Name
Gets or sets the name of the widget.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Parent
Gets or sets the parent widget.
Declaration
public Widget Parent { get; set; }
Property Value
Type | Description |
---|---|
Widget |
Size
Gets or sets the size of the widget.
Declaration
public Vec3 Size { get; set; }
Property Value
Type | Description |
---|---|
Vec3 |
Methods
AddChildren(Widget)
Adds a child widget to the entity and sets the parent of the child entity.
Declaration
public void AddChildren(Widget widget)
Parameters
Type | Name | Description |
---|---|---|
Widget | widget | The child widget to be added. |
FindChildren(string)
Recursively finds a child widget with the given name.
Declaration
public Widget FindChildren(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name to search for. |
Returns
Type | Description |
---|---|
Widget | The widget with the specified name, or null if not found. |
GetChildren(string)
Returns the child widget with the specified name.
Declaration
public Widget GetChildren(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the child widget to find. |
Returns
Type | Description |
---|---|
Widget | The child widget with the specified name, or null if not found. |
GetRelativeBounds2D(Canvas)
Gets the relative bounds of the widget on the canvas.
Declaration
public Rect GetRelativeBounds2D(Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas used for rendering. |
Returns
Type | Description |
---|---|
Rect | The relative bounds of the widget. |
GetRelativePos(Canvas)
Gets the relative position of the widget on the screen.
Declaration
public Vec3 GetRelativePos(Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas used for rendering. |
Returns
Type | Description |
---|---|
Vec3 | The relative position of the widget. |
Hovered()
Checks if the widget is hovered
Declaration
public bool Hovered()
Returns
Type | Description |
---|---|
bool |
IsHover(Game, Scene, Canvas)
Checks if the mouse is hovering over the widget.
Declaration
public bool IsHover(Game game, Scene scene, Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
Scene | scene | The current scene. |
Canvas | canvas | The canvas used for rendering. |
Returns
Type | Description |
---|---|
bool | True if the mouse is hovering over the widget, otherwise false. |
OnClick(Game, Scene, Canvas)
Executes the click event for the current UI element.
Declaration
public virtual void OnClick(Game game, Scene scene, Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The current game instance. |
Scene | scene | The current scene instance. |
Canvas | canvas | The canvas where the UI element resides. |
OnDispose(Game, Scene, Canvas)
Disposes the widget.
Declaration
public virtual void OnDispose(Game game, Scene scene, Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
Scene | scene | The current scene. |
Canvas | canvas | The canvas used for rendering. |
OnInit(Game, Scene, Canvas)
Initializes the widget.
Declaration
public virtual void OnInit(Game game, Scene scene, Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
Scene | scene | The current scene. |
Canvas | canvas | The canvas used for rendering. |
OnRender(Game, IRenderDevice, Scene, Canvas)
Renders the widget.
Declaration
public virtual void OnRender(Game game, IRenderDevice renderDevice, Scene scene, Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
IRenderDevice | renderDevice | The render device used for rendering. |
Scene | scene | The current scene. |
Canvas | canvas | The canvas used for rendering. |
OnUpdate(Game, Scene, Canvas)
Updates the widget.
Declaration
public virtual void OnUpdate(Game game, Scene scene, Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
Scene | scene | The current scene. |
Canvas | canvas | The canvas used for rendering. |
TransformBounds(Rect, WidgetAnchor)
Transform the bounds from the bottom left point to any anchor position
Declaration
public static Rect TransformBounds(Rect source, WidgetAnchor anchor)
Parameters
Type | Name | Description |
---|---|---|
Rect | source | |
WidgetAnchor | anchor |
Returns
Type | Description |
---|---|
Rect |
Events
Click
Event triggered when the widget is clicked.
Declaration
public event UIEvent Click
Event Type
Type | Description |
---|---|
UIEvent |
MouseEnter
Event triggered when the mouse enters the widget.
Declaration
public event UIEvent MouseEnter
Event Type
Type | Description |
---|---|
UIEvent |
MouseLeave
Event triggered when the mouse leaves the widget.
Declaration
public event UIEvent MouseLeave
Event Type
Type | Description |
---|---|
UIEvent |