Class InteractiveUIElement
Base class for UI elements that support user interaction Extends UIElementBase with IsEnabled functionality and optional label support
Inheritance
Implements
Inherited Members
Namespace: PopcorningGuineaPig.Engine.UI
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public abstract class InteractiveUIElement : UIElementBase, IUIElement
Properties
| Edit this page View SourceHasLabel
Gets whether this element has a label
Declaration
public bool HasLabel { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsEnabled
Protected property that controls whether this element can be interacted with
Declaration
protected bool IsEnabled { get; }
Property Value
| Type | Description |
|---|---|
| bool |
LabelPosition
Gets the current label position for this interactive element
Declaration
public LabelPosition LabelPosition { get; }
Property Value
| Type | Description |
|---|---|
| LabelPosition |
LabelSpacing
Gets the label spacing
Declaration
public float LabelSpacing { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
| Edit this page View SourceDrawSelf()
Override DrawSelf to handle label drawing Derived classes should call base.DrawSelf() to ensure labels are drawn
Declaration
protected override void DrawSelf()
Overrides
| Edit this page View SourceGetEnabled()
Gets whether this interactive element is currently enabled
Declaration
public bool GetEnabled()
Returns
| Type | Description |
|---|---|
| bool | True if enabled, false if disabled |
GetLabelOffset()
Gets the offset that should be applied to the control position to account for label placement. This offset is the amount the control needs to move from the top-left of its bounding box.
Declaration
public Vector2 GetLabelOffset()
Returns
| Type | Description |
|---|---|
| Vector2 |
GetLabelText()
Gets the current label text, or null if no label is set
Declaration
public string? GetLabelText()
Returns
| Type | Description |
|---|---|
| string |
GetTotalSizeWithLabel()
Gets the total size of this element including its label (if any)
Declaration
public Vector2 GetTotalSizeWithLabel()
Returns
| Type | Description |
|---|---|
| Vector2 |
RemoveLabel()
Removes the label from this interactive element
Declaration
public virtual void RemoveLabel()
SetEnabled(bool)
Sets whether this interactive element is enabled for user interaction
Declaration
public virtual void SetEnabled(bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | enabled | True to enable interaction, false to disable |
SetLabel(string, LabelPosition, float)
Sets a label for this interactive element
Declaration
public virtual void SetLabel(string text, LabelPosition position = LabelPosition.Left, float spacing = 5)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The label text |
| LabelPosition | position | The position of the label relative to the control |
| float | spacing | Spacing between label and control |
SetLabelLocalization(ILocalizationService?, string, string?)
Sets localization on this element's label
Declaration
public void SetLabelLocalization(ILocalizationService? localizationService, string localizationKey, string? fallbackText = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ILocalizationService | localizationService | |
| string | localizationKey | |
| string | fallbackText |
UpdateSelf()
Override UpdateSelf to provide common interactive element functionality Derived classes should call base.UpdateSelf() before their own update logic
Declaration
protected override void UpdateSelf()