Class Canvas
Represents a canvas for organizing and rendering UI widgets.
Inherited Members
Namespace: Genesis.UI
Assembly: Genesis.dll
Syntax
public class Canvas
Constructors
Canvas(string, Vec3, Vec3)
Creates a new instance of the Canvas class.
Declaration
public Canvas(string name, Vec3 location, Vec3 size)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the canvas. |
| Vec3 | location | The location of the canvas. |
| Vec3 | size | The size of the canvas. |
Properties
Enabled
Gets or sets a value indicating whether the canvas is enabled.
Declaration
public bool Enabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Location
Gets or sets the location of the canvas.
Declaration
public Vec3 Location { get; set; }
Property Value
| Type | Description |
|---|---|
| Vec3 |
Name
Gets or sets the name of the canvas.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Size
Gets or sets the size of the canvas.
Declaration
public Vec3 Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Vec3 |
Widgets
Gets or sets the list of widgets contained within the canvas.
Declaration
public List<Widget> Widgets { get; set; }
Property Value
| Type | Description |
|---|---|
| List<Widget> |
Methods
AddWidget(Widget)
Adds a widget to the canvas.
Declaration
public void AddWidget(Widget entity)
Parameters
| Type | Name | Description |
|---|---|---|
| Widget | entity |
CenterWidget(Canvas, Widget)
Centers the widget in the middle of the canvas.
Declaration
public static void CenterWidget(Canvas canvas, Widget widget)
Parameters
| Type | Name | Description |
|---|---|---|
| Canvas | canvas | The canvas instance. |
| Widget | widget | The widget to be centered. |
GetBounds()
Returns the bounds of the canvas.
Declaration
public Rect GetBounds()
Returns
| Type | Description |
|---|---|
| Rect | The bounds of the canvas. |
GetScreenBounds()
Returns the screen bounds of the canvas.
Declaration
public Rect GetScreenBounds()
Returns
| Type | Description |
|---|---|
| Rect | The screen bounds of the canvas. |
GetWidget(string)
Returns a widget with the specified name, searching within entities and their children.
Declaration
public Widget GetWidget(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. |
LoadCanvas(string, AssetManager, UIParser)
Loads a canvas from a specified JSON file using a UI parser and asset manager.
Declaration
public static Canvas LoadCanvas(string File, AssetManager assets, UIParser parser)
Parameters
| Type | Name | Description |
|---|---|---|
| string | File | Path to the JSON file containing canvas configuration. |
| AssetManager | assets | Asset manager for managing resources such as images, fonts, etc. |
| UIParser | parser | UI parser that contains the logic for parsing the JSON data. |
Returns
| Type | Description |
|---|---|
| Canvas | The created canvas based on the JSON configuration. |
LoadWidget(JObject, AssetManager, UIParser)
Loads a widget from provided JSON data using a UI parser and asset manager.
Declaration
public static Widget LoadWidget(JObject data, AssetManager assets, UIParser parser)
Parameters
| Type | Name | Description |
|---|---|---|
| JObject | data | JSON data containing the configuration of the widget to be created. |
| AssetManager | assets | Asset manager for managing resources such as images, fonts, etc. |
| UIParser | parser | UI parser that contains the logic for parsing the JSON data. |
Returns
| Type | Description |
|---|---|
| Widget | The created widget based on the JSON data. |
OnDispose(Game, Scene)
Disposes of the canvas.
Declaration
public void OnDispose(Game game, Scene scene)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
| Scene | scene | The scene instance. |
OnInit(Game, Scene)
Initializes the canvas.
Declaration
public void OnInit(Game game, Scene scene)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
| Scene | scene | The scene instance. |
OnRender(Game, IRenderDevice, Scene)
Renders the canvas.
Declaration
public void OnRender(Game game, IRenderDevice renderDevice, Scene scene)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
| IRenderDevice | renderDevice | The render device. |
| Scene | scene | The scene instance. |
OnUpdate(Game, Scene)
Updates the canvas.
Declaration
public void OnUpdate(Game game, Scene scene)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
| Scene | scene | The scene instance. |