Class Control
- Namespace
- Forma
- Assembly
- Forma.dll
Retained-mode UI element modelled after Godot's Control. Coordinates are relative to the parent; anchors and offsets are resolved during layout.
public class Control : IAddChild<Control>, IAddChild, INotifyPropertyChanged
- Inheritance
-
Control
- Implements
- Derived
- Inherited Members
Constructors
Control()
public Control()
Properties
AccessibilityActions
public virtual AccessibilityActions AccessibilityActions { get; }
Property Value
AccessibilityBounds
public Rectangle AccessibilityBounds { get; }
Property Value
- Rectangle
AccessibilityLabel
public string AccessibilityLabel { get; set; }
Property Value
AccessibilityName
public virtual string AccessibilityName { get; }
Property Value
AccessibilityPeer
public AccessibilityPeer AccessibilityPeer { get; }
Property Value
AccessibilityRole
public virtual AccessibilityRole AccessibilityRole { get; }
Property Value
AccessibilityStates
public virtual AccessibilityStates AccessibilityStates { get; }
Property Value
AccessibilityValue
public virtual string AccessibilityValue { get; }
Property Value
AnchorBottom
public float AnchorBottom { get; }
Property Value
AnchorLeft
public float AnchorLeft { get; }
Property Value
AnchorRight
public float AnchorRight { get; }
Property Value
AnchorTop
public float AnchorTop { get; }
Property Value
AspectRatio
public float AspectRatio { get; set; }
Property Value
Bounds
public Rectangle Bounds { get; }
Property Value
- Rectangle
Children
public ReadOnlyCollection<Control> Children { get; }
Property Value
Classes
public ControlClassList Classes { get; }
Property Value
Clip
public Geometry Clip { get; set; }
Property Value
ClipContents
public bool ClipContents { get; set; }
Property Value
ClipToBounds
public bool ClipToBounds { get; set; }
Property Value
Context
public UIContext Context { get; }
Property Value
Cursor
public Cursor Cursor { get; set; }
Property Value
CustomMaximumSize
public Vector2 CustomMaximumSize { get; set; }
Property Value
- Vector2
CustomMinimumSize
public Vector2 CustomMinimumSize { get; set; }
Property Value
- Vector2
DataContext
public object DataContext { get; set; }
Property Value
Effect
public VisualEffect Effect { get; set; }
Property Value
EffectiveCursor
public Cursor EffectiveCursor { get; }
Property Value
EffectiveLayoutDirection
public LayoutDirection EffectiveLayoutDirection { get; }
Property Value
Enabled
public bool Enabled { get; set; }
Property Value
FocusBounds
public Rectangle FocusBounds { get; }
Property Value
- Rectangle
FocusMode
public FocusMode FocusMode { get; set; }
Property Value
FocusNeighborBottom
Optional directional focus neighbor.
public Control FocusNeighborBottom { get; set; }
Property Value
FocusNeighborLeft
Optional directional focus neighbor.
public Control FocusNeighborLeft { get; set; }
Property Value
FocusNeighborRight
Optional directional focus neighbor.
public Control FocusNeighborRight { get; set; }
Property Value
FocusNeighborTop
Optional directional focus neighbor.
public Control FocusNeighborTop { get; set; }
Property Value
FocusNext
Optional explicit focus order used before tree traversal.
public Control FocusNext { get; set; }
Property Value
FocusPrevious
Optional reverse focus order used before tree traversal.
public Control FocusPrevious { get; set; }
Property Value
FontFamily
public UIFontFamily FontFamily { get; set; }
Property Value
FontSize
public float FontSize { get; set; }
Property Value
FontStretch
public UIFontStretch FontStretch { get; set; }
Property Value
FontStyle
public UIFontStyle FontStyle { get; set; }
Property Value
FontWeight
public UIFontWeight FontWeight { get; set; }
Property Value
Foreground
public Color? Foreground { get; set; }
Property Value
- Color?
GlobalPosition
public Vector2 GlobalPosition { get; }
Property Value
- Vector2
HGrowDirection
Matches Godot's Control.GrowHorizontal (default GROW_DIRECTION_END): how the horizontal position compensates when the anchor-resolved width is clamped up to the minimum size.
public GrowDirection HGrowDirection { get; set; }
Property Value
HasLocalDataContext
public bool HasLocalDataContext { get; }
Property Value
Height
public float Height { get; set; }
Property Value
HorizontalAlignment
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
HorizontalSizeFlags
public SizeFlags HorizontalSizeFlags { get; set; }
Property Value
IsEffectivelyEnabled
public bool IsEffectivelyEnabled { get; }
Property Value
IsHitTestVisible
public bool IsHitTestVisible { get; set; }
Property Value
IsPixelSnappingEnabled
public bool IsPixelSnappingEnabled { get; }
Property Value
Language
public string Language { get; set; }
Property Value
LayoutDirection
Controls bidirectional layout inheritance for containers and alignment-aware controls.
public LayoutDirection LayoutDirection { get; set; }
Property Value
Margin
public Thickness Margin { get; set; }
Property Value
Margins
public Thickness Margins { get; set; }
Property Value
MaxHeight
public float MaxHeight { get; set; }
Property Value
MaxWidth
public float MaxWidth { get; set; }
Property Value
MinHeight
public float MinHeight { get; set; }
Property Value
MinWidth
public float MinWidth { get; set; }
Property Value
MouseFilter
public MouseFilter MouseFilter { get; set; }
Property Value
Name
public string Name { get; set; }
Property Value
OffsetBottom
public float OffsetBottom { get; }
Property Value
OffsetLeft
public float OffsetLeft { get; }
Property Value
OffsetRight
public float OffsetRight { get; }
Property Value
OffsetTop
public float OffsetTop { get; }
Property Value
Opacity
public float Opacity { get; set; }
Property Value
OpacityMask
public Brush OpacityMask { get; set; }
Property Value
Parent
public Control Parent { get; }
Property Value
PixelSnapping
public PixelSnapping PixelSnapping { get; set; }
Property Value
Position
public Vector2 Position { get; set; }
Property Value
- Vector2
RenderTransform
public Transform RenderTransform { get; set; }
Property Value
Resources
public ResourceDictionary Resources { get; }
Property Value
Size
public Vector2 Size { get; set; }
Property Value
- Vector2
SizeFlagsStretchRatio
public float SizeFlagsStretchRatio { get; set; }
Property Value
ThemeOverride
Optional theme applied to this control and inherited by its descendants while drawing.
public Theme ThemeOverride { get; set; }
Property Value
ThemeStyleOverrides
public IDictionary<string, StyleBox> ThemeStyleOverrides { get; }
Property Value
ToolTip
public object ToolTip { get; set; }
Property Value
TooltipText
Text presented by UIContext after the pointer rests over this control.
public string TooltipText { get; set; }
Property Value
TransformOrigin
public Vector2 TransformOrigin { get; set; }
Property Value
- Vector2
VGrowDirection
Matches Godot's Control.GrowVertical (default GROW_DIRECTION_END): how the vertical position compensates when the anchor-resolved height is clamped up to the minimum size.
public GrowDirection VGrowDirection { get; set; }
Property Value
VerticalAlignment
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
VerticalSizeFlags
public SizeFlags VerticalSizeFlags { get; set; }
Property Value
Visibility
public Visibility Visibility { get; set; }
Property Value
Visible
Matches Godot's Control.visible: toggling it requeues the parent's layout, since Container wires each child's visibility_changed signal to queue_sort().
public bool Visible { get; set; }
Property Value
VisualBounds
public Rectangle VisualBounds { get; }
Property Value
- Rectangle
VisualParent
public Control VisualParent { get; }
Property Value
Width
public float Width { get; set; }
Property Value
ZIndex
Drawing and pointer-picking order. Higher values are painted above and receive input before lower values; equal values retain tree insertion order.
public int ZIndex { get; set; }
Property Value
Methods
AcceptEvent()
Matches Godot's Control::accept_event(): marks the current input event as handled for just this one dispatch, stopping propagation to ancestors independent of MouseFilter (which only governs every future event). Unlike setting MouseFilter to Stop, this does not affect later events.
protected void AcceptEvent()
AddChild(Control)
public virtual void AddChild(Control child)
Parameters
childControl
AddThemeIconOverride(string, ThemeIcon)
Adds a local decorative theme-icon override. Existing content-icon properties are unaffected.
public void AddThemeIconOverride(string itemName, ThemeIcon icon)
Parameters
AddThemeStyleOverride(string, StyleBox)
Sets a local StyleBox override, equivalent to Godot's add_theme_style_override.
public void AddThemeStyleOverride(string itemName, StyleBox styleBox)
Parameters
ArrangeChildren()
protected virtual void ArrangeChildren()
BringIntoView(Rectangle?)
public void BringIntoView(Rectangle? targetBounds = null)
Parameters
targetBoundsRectangle?
CanDropData(Point, object)
Returns whether this control accepts the supplied data at the screen position.
public virtual bool CanDropData(Point position, object data)
Parameters
positionPointdataobject
Returns
ClearDataContext()
public void ClearDataContext()
ContainsPoint(Point)
public virtual bool ContainsPoint(Point point)
Parameters
pointPoint
Returns
CreateAccessibilityPeer()
protected virtual AccessibilityPeer CreateAccessibilityPeer()
Returns
DropData(Point, object)
Receives data accepted by CanDropData(Point, object).
public virtual void DropData(Point position, object data)
Parameters
positionPointdataobject
FindName<T>(string)
public T FindName<T>(string name) where T : class
Parameters
namestring
Returns
- T
Type Parameters
T
GetAccessibilityChildren()
public virtual IReadOnlyList<AccessibilityPeer> GetAccessibilityChildren()
Returns
GetBoundDesiredSize()
Returns the desired size clamped to this control's minimum and combined maximum sizes.
public Vector2 GetBoundDesiredSize()
Returns
- Vector2
GetCombinedMaximumSize()
public Vector2 GetCombinedMaximumSize()
Returns
- Vector2
GetDesiredSize()
Returns this control's preferred size before minimum-size clamping, matching Godot's virtual get_desired_size().
public virtual Vector2 GetDesiredSize()
Returns
- Vector2
GetDragData(Point)
Returns data to drag, or null to decline starting a drag.
public virtual object GetDragData(Point position)
Parameters
positionPoint
Returns
GetMaximumSize()
Returns this control's intrinsic maximum size; negative components are unbounded.
public virtual Vector2 GetMaximumSize()
Returns
- Vector2
GetMinimumSize()
public virtual Vector2 GetMinimumSize()
Returns
- Vector2
GetNodeOrNull(string)
public Control GetNodeOrNull(string name)
Parameters
namestring
Returns
GetThemeIcon(string)
Resolves a decorative icon from local overrides, ancestor themes, and the context theme.
public ThemeIcon? GetThemeIcon(string itemName)
Parameters
itemNamestring
Returns
GetThemeIcon(string, string)
protected ThemeIcon? GetThemeIcon(string itemName, string preferredTypeName)
Parameters
Returns
GetThemeStyleBox(string)
public StyleBox GetThemeStyleBox(string itemName)
Parameters
itemNamestring
Returns
GetTooltip(Point)
Returns the tooltip at a global pointer position. Override to provide dynamic help text.
public virtual string GetTooltip(Point position)
Parameters
positionPoint
Returns
GrabFocus()
public void GrabFocus()
IsLayoutRtl()
Whether this control resolves to right-to-left layout.
public bool IsLayoutRtl()
Returns
IsPseudoStateActive(string)
public virtual bool IsPseudoStateActive(string state)
Parameters
statestring
Returns
MoveChild(Control, int)
Moves an existing child to a different sibling index without changing its parent or UI context.
public void MoveChild(Control child, int toIndex)
Parameters
NotifyPseudoStateChanged(string)
protected void NotifyPseudoStateChanged(string state)
Parameters
statestring
OnContextChanged(UIContext, UIContext)
Called when this control enters, exits, or moves between retained UI contexts.
protected virtual void OnContextChanged(UIContext previous, UIContext current)
Parameters
OnPropertyChanged(string)
protected virtual void OnPropertyChanged(string propertyName)
Parameters
propertyNamestring
OnThemeChanged()
protected virtual void OnThemeChanged()
QueueLayout()
Marks this control and every ancestor dirty, matching Godot's Control::update_minimum_size walking the full parent chain so a deeply nested size change reaches the root container.
public void QueueLayout()
ReleaseFocus()
public void ReleaseFocus()
RemoveChild(Control)
public bool RemoveChild(Control child)
Parameters
childControl
Returns
RemoveFromParent()
public void RemoveFromParent()
RemoveThemeIconOverride(string)
Removes a local icon override so theme inheritance becomes visible again.
public void RemoveThemeIconOverride(string itemName)
Parameters
itemNamestring
RemoveThemeStyleOverride(string)
public void RemoveThemeStyleOverride(string itemName)
Parameters
itemNamestring
SetAnchor(Side, float, bool, bool)
Matches Godot's Control::set_anchor exactly: by default (keepOffset false) the offset is
recomputed so the control's resolved position does not jump when only the anchor changes, an anchor is never
allowed to cross its opposite anchor (clamped to it, or pushing the opposite anchor along when
pushOppositeAnchor is set), and geometry is refreshed via QueueLayout().
public void SetAnchor(Side side, float anchor, bool keepOffset = false, bool pushOppositeAnchor = false)
Parameters
SetAnchorsAndOffsets(float, float, float, float)
public void SetAnchorsAndOffsets(float left, float top, float right, float bottom)
Parameters
SetOffset(Side, float)
public void SetOffset(Side side, float offset)
Parameters
SetPseudoState(string, bool)
protected void SetPseudoState(string state, bool active)
Parameters
SuppressThemeIcon(string)
Suppresses a decorative theme icon on this control without affecting content icons.
public void SuppressThemeIcon(string itemName)
Parameters
itemNamestring
TryFindResource(string, out object)
public bool TryFindResource(string key, out object value)
Parameters
Returns
Events
AccessibilityChanged
public event EventHandler<AccessibilityChangedEventArgs> AccessibilityChanged
Event Type
Attached
public event EventHandler Attached
Event Type
BringIntoViewRequested
public event EventHandler<BringIntoViewRequestedEventArgs> BringIntoViewRequested
Event Type
ChildAdded
public event Action<Control, Control> ChildAdded
Event Type
ChildRemoved
public event Action<Control, Control> ChildRemoved
Event Type
DataContextChanged
public event EventHandler<DataContextChangedEventArgs> DataContextChanged
Event Type
Detached
public event EventHandler Detached
Event Type
DragEnded
Raised when a drag started by this control ends; the boolean indicates whether it was accepted.
public event Action<Control, bool> DragEnded
Event Type
DragStarted
Raised when this control supplies drag data after the pointer passes the drag threshold.
public event Action<Control, object> DragStarted
Event Type
EnabledChanged
public event EventHandler EnabledChanged
Event Type
FocusEntered
public event EventHandler FocusEntered
Event Type
FocusExited
public event EventHandler FocusExited
Event Type
LayoutChanged
public event EventHandler LayoutChanged
Event Type
MouseEntered
public event EventHandler MouseEntered
Event Type
MouseExited
public event EventHandler MouseExited
Event Type
NameChanged
public event EventHandler NameChanged
Event Type
ParentChanged
public event EventHandler<ControlParentChangedEventArgs> ParentChanged
Event Type
PropertyChanged
public event PropertyChangedEventHandler PropertyChanged
Event Type
PseudoStateChanged
public event EventHandler<ControlPseudoStateChangedEventArgs> PseudoStateChanged