Class UIElementBase
Abstract base class for UI elements with hierarchical support
Inheritance
UIElementBase
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public abstract class UIElementBase : IUIElement
Fields
|
Edit this page
View Source
_children
Declaration
protected readonly List<IUIElement> _children
Field Value
Properties
|
Edit this page
View Source
Children
Declaration
public IReadOnlyList<IUIElement> Children { get; }
Property Value
|
Edit this page
View Source
Id
Declaration
public string Id { get; set; }
Property Value
|
Edit this page
View Source
Opacity
Declaration
public float Opacity { get; set; }
Property Value
|
Edit this page
View Source
Parent
Declaration
public IUIElement? Parent { get; set; }
Property Value
|
Edit this page
View Source
Position
Declaration
public Vector2 Position { get; set; }
Property Value
|
Edit this page
View Source
Size
Declaration
public Vector2 Size { get; set; }
Property Value
|
Edit this page
View Source
Declaration
protected string Tooltip { get; }
Property Value
|
Edit this page
View Source
TooltipFallbackText
Declaration
protected string TooltipFallbackText { get; }
Property Value
|
Edit this page
View Source
Declaration
protected string? TooltipLocalizationKey { get; }
Property Value
|
Edit this page
View Source
Visible
Declaration
public bool Visible { get; set; }
Property Value
Methods
|
Edit this page
View Source
AddChild(IUIElement)
Declaration
public virtual void AddChild(IUIElement child)
Parameters
|
Edit this page
View Source
Draw()
Draws this element and all children
Declaration
public virtual void Draw()
|
Edit this page
View Source
DrawSelf()
Override to implement element-specific drawing logic
Declaration
protected abstract void DrawSelf()
|
Edit this page
View Source
GetLocalPosition()
Gets the local position relative to the parent
Declaration
public virtual Vector2 GetLocalPosition()
Returns
|
Edit this page
View Source
GetWorldPosition()
Gets the world position by combining this element's position with all parent positions
Declaration
public virtual Vector2 GetWorldPosition()
Returns
|
Edit this page
View Source
IsMouseOver()
Checks if the mouse is currently over this UI element
Declaration
public virtual bool IsMouseOver()
Returns
| Type |
Description |
| bool |
True if mouse is over this element
|
|
Edit this page
View Source
RemoveChild(IUIElement)
Declaration
public virtual void RemoveChild(IUIElement child)
Parameters
|
Edit this page
View Source
RemoveFromParent()
Declaration
public virtual void RemoveFromParent()
|
Edit this page
View Source
SetLocalizationService(ILocalizationService?)
Sets the localization service to use for automatic font management.
Override this method in derived classes that display text to implement localization support.
Default implementation does nothing (for non-text UI elements).
Declaration
public virtual void SetLocalizationService(ILocalizationService? localizationService)
Parameters
| Type |
Name |
Description |
| ILocalizationService |
localizationService |
The localization service to use, or null to disable
|
|
Edit this page
View Source
Sets the tooltip text for this UI element
Declaration
public virtual void SetTooltip(string tooltipText)
Parameters
| Type |
Name |
Description |
| string |
tooltipText |
The tooltip text to display on hover
|
|
Edit this page
View Source
Sets the tooltip using a localization key for automatic updates when language changes.
Declaration
public virtual void SetTooltipLocalizationKey(string localizationKey, string? fallbackText = null)
Parameters
| Type |
Name |
Description |
| string |
localizationKey |
The localization key (e.g., "COMPLETE_TUTORIAL")
|
| string |
fallbackText |
Text to use if translation fails
|
|
Edit this page
View Source
SetTooltipText(string)
Protected method for derived classes to update the tooltip text.
Declaration
protected void SetTooltipText(string tooltipText)
Parameters
| Type |
Name |
Description |
| string |
tooltipText |
The new tooltip text
|
|
Edit this page
View Source
Update()
Updates this element and all children
Declaration
public virtual void Update()
|
Edit this page
View Source
UpdateSelf()
Override to implement element-specific update logic
Declaration
protected virtual void UpdateSelf()
|
Edit this page
View Source
Updates the tooltip text from the localization service using the stored localization key.
This method should be called by derived classes when they receive localization service updates.
Declaration
protected virtual void UpdateTooltipFromLocalization()
Implements