Component

Description

abstract class Tinman.Engine.GUI.Component

Base class for all user interface components.

The visual style settings of a component are stored in a separate Stylesheet object, which may be accessed via Stylesheet.

Localized text labels of components are stored as visual styles (see Style.Label) in the stylesheets, using custom StyleClass values. As result, the lookup of localized text labels will cascade along the chain of parent components.

The default layout settings of a component are defined by LayoutDefault. Subclasses may override it, in order to define custom default layout settings. If they do so, the class documentation should list these values.

Public / Constants

Label​No


[Localized]
public constant LabelNo → ("no":string)

Common label for: no

Label​Yes


[Localized]
public constant LabelYes → ("yes":string)

Common label for: yes

Public / Methods

Focus​Leaf


public virtual method FocusLeaf → ()

returns → Component

The focused component or null.

Returns the bottom-most component in the hierarchy that has the input focus.

Hovered​Leaf


public virtual method HoveredLeaf → ()

returns → Component

The hovered component or null.

Returns the bottom-most component in the hierarchy that is hovered by the mouse.

Overlay​Add


public method OverlayAdd → (1)

overlay in : ComponentOverlayDelegate

[not-null]
The overlay to add.

Adds an overlay to this component.

Overlay​Remove


public method OverlayRemove → (1)

overlay in : ComponentOverlayDelegate

[not-null]
The overlay to remove.

Removes the given component overlay.

Public / Attributes

Action


public attribute Action → (get,set)

value : InputClick

The input click or InputClick.None.

The input click of the default action of this component.

Defaults to InputClick.None.

Actual​Layout​Baseline


public attribute ActualLayoutBaseline → (get)

value : int32

The actual layout baseline.

The actual layout baseline, as computed by ComputeLayoutBaseline.

Actual​Layout​Margin


public attribute ActualLayoutMargin → (get)

value : Edging

The actual layout margin.

The actual layout margin, as computed by ComputeLayoutMargin.

Actual​Layout​Size


public attribute ActualLayoutSize → (get)

value : Vec2I

The actual layout size.

The actual layout size, as computed by ComputeLayoutSize.

Bounds


public attribute Bounds → (get)

value : Box2I

The component bounds.

Returns the bounds of this component in the client area of its parent container.

Focusable


public attribute Focusable → (get,set)

value : bool

true if the component can receive the input focus, false if not.

Can this component receive the input focus?

Defaults to false.

Graphics


public attribute Graphics → (get)

value : Graphics

The graphics object or null if not attached.

The current graphics object.

Is​Focussed


public virtual attribute IsFocussed → (get)

value : bool

true if this component has the input focus, false if not.

Does this component have the input focus?

Is​Highlighted


public virtual attribute IsHighlighted → (get)

value : bool

true if the component shall be highlighted,
false if not.

Is this component being highlighted?

Is​Hovered


public attribute IsHovered → (get)

value : bool

true if the mouse cursor hovers above this component, false if not.

Does the mouse cursor currently hover above this component?

Is​Visible


public attribute IsVisible → (get)

value : bool

true if this component is visible, false if it is not.

Is this component currently visible?

A component is visible if its state is not ComponentState.Hidden and its parent is also visible.

Layout​Align


public attribute LayoutAlign → (get,set)

value : Anchor

The anchor.

The alignment anchor of this component.

Layout​Default


public virtual attribute LayoutDefault → (get)

value : Layout

The default layout settings.

Returns the default Layout settings that are recommended for this component.

Subclasses may override this method, in order to define custom default layout settings. If they do so, the documentation of the declaring class should list these values.

The default implementation returns Layout.Default.

Layout​Fill


public virtual attribute LayoutFill → (get,set)

value : Axis

The fill mode.

The fill mode of this component.

Layout​Grid


public attribute LayoutGrid → (get,set)

value : Box2I

The layout grid bounds.

The bounds of this component in its parent containers layout grid.

Layout​Grow


public attribute LayoutGrow → (get,set)

value : Axis

The axes that will grow.

Defines how the layout grid column resp. row in the components parent container grows.

Layout​Info


public virtual attribute LayoutInfo → (get,set)

value : Layout

The Layout info object.

The current layout settings of this component.

Defaults to LayoutDefault.

Layout​Limit


public attribute LayoutLimit → (get,set)

value : Vec2I

The maximum size. A value equal to 0 means no maximum size limit.

The maximum size of this component, in pixels.

Layout​Margin


public attribute LayoutMargin → (get,set)

value : Edging

The outer margin.

The outer margin of this component.

Layout​Shrink


public attribute LayoutShrink → (get,set)

value : Axis

The axes that will shrink.

Defines how the layout grid column resp. row in the components parent container grows.

Layout​Size


public attribute LayoutSize → (get,set)

value : Vec2I

The minimum size.

The minimum size of this component, in pixels.

On​Action


public attribute OnAction → (get)

value : IEventGeneric<Component>

[not-null]
The event object.

The components default action has been triggered.

Parent


public attribute Parent → (get)

value : Container

The parent container or null if this component is the root.

The parent container of this component.

Parent​Corners


public attribute ParentCorners → (get)

value : Corner

The shared client area corners.

Returns the corners that this component shares with the client area of its parent container.

Parent​Edges


public attribute ParentEdges → (get)

value : Anchor

The shared client area edges.

Returns the edges that this component shares with the client area of its parent container.

State


public virtual attribute State → (get,set)

value : ComponentState

The component state.

The component state.

Style​Class


public attribute StyleClass → (get)

value : StyleClass

The StyleClass value, based on StyleClassType and StyleClassVariant.

Returns the StyleClass value for this component.

Style​Class​Type


public abstract attribute StyleClassType → (get)

value : StyleClass

The style class (e.g. 'InputField' for InputField).

Returns the style class for this component type.

See also

Stylesheet

Style​Class​Variant


public attribute StyleClassVariant → (get,set)

value : string

The variant name or null.

Optional style class variant of this component.

See also

Stylesheet

Stylesheet


public attribute Stylesheet → (get,set)

value : Stylesheet

The stylesheet object to use or null.

The stylesheet object to use for this user interface element.

The Style class provides pre-defined stylesheet properties, which are used by the built-in GUI components. Client code may define any number of additional stylesheet properties, for use in custom GUI components. To access the stylesheet property values of a component, use the Get, Set and Unset methods of the StyleProperty class.

Protected / Constructors

Component


protected constructor Component → ()

Creates a new instance of Component.

Protected / Methods

Action​Click


protected virtual method ActionClick → ()

The action click has been performed.

The default implementation simply calls ActionNotify.

See also

Component.Action

Action​Notify


protected method ActionNotify → (1)

flash opt : bool = true

Render a visual flash to indicate the action?

Notifies all listeners of the OnAction event.

Border​Color


protected method BorderColor → (1)

border in : bool

true for a visible border, false for a border the blends with the background.

returns → int64

The border color (see Colors).

Returns the border color to use for this component in its current state.

Compute​Layout​Baseline


protected virtual method ComputeLayoutBaseline → ()

returns → int32

The actual layout baseline.

Computes the actual layout baseline of this component.

The default implementation returns the current value of Style.Baseline, which defaults to 0, i.e. no baseline. Subclasses may return a different value.

Subclasses must call InvalidateLayout with LayoutAction.ComputeLayoutGridExtend to notify when ComputeLayoutBaseline returns a different value.

Compute​Layout​Margin


protected virtual method ComputeLayoutMargin → ()

returns → Edging

The actual margin value.

Computes the actual margin of this component.

The default implementation returns LayoutMargin. Subclasses can perform additional computations here.

Subclasses must call InvalidateLayout with LayoutAction.ComputeLayoutGridExtend to notify when ComputeLayoutMargin returns a different value.

Compute​Layout​Size


protected virtual method ComputeLayoutSize → ()

returns → Vec2I

The actual requested layout size.

Computes the actual requested layout size of this component.

During layout computations, the ComputeLayoutSize will always be called first, so subclasses may compute and store information here and rely on that information later.

The default implementation returns the maximum of LayoutSize and the current value of the Style.Size style (which defaults to Vec2I.Zero) and adds the horizontal and vertical padding. Subclasses can perform additional computations here.

Subclasses must call InvalidateLayout with LayoutAction.ComputeLayoutGridExtend to notify when ComputeLayoutSize returns a different value.

Consume​Keyboard


[EmptyBody]
protected virtual method ConsumeKeyboard → (1)

key in : InputEvent

The mouse event.

returns → bool

true if the component has consumed the input event, false if not.

Processes the given input event.

Consume​Keyboard​Scroll


protected method ConsumeKeyboardScroll → (2)

key in : InputEvent

The key input event.

modifiers opt : InputModifiers = InputModifiers.Shift

The required modifiers for performing scrolling actions.

returns → bool

true if a scrolling action has been performed, false if not.

Applies default keyboard controls for scrolling.

Consume​Mouse


protected virtual method ConsumeMouse → (1)

mouse in : InputEvent

The mouse event, translated to the client-area of this component.

returns → bool

true if the component has consumed the input event, false if not.

Processes the given input event.

The default implementation calls IFocusable.Focus if focusable (see Focusable) when pressing the left mouse button.

Consume​Mouse​Scroll


protected method ConsumeMouseScroll → (3)

mouse in : InputEvent

The mouse event, translated to the client-area of this component.

allowMouseWheel opt : bool = false

Use mouse wheel rotation for scrolling?

mouseButtons opt : InputModifiers = InputModifiers.Middle

The mouse buttons to drag for scrolling.

returns → bool

true if a scrolling action has been performed, false if not.

Applies default mouse controls for scrolling.

Dirty


protected method Dirty → ()

Causes IUpdateableFrameTime.UpdateFrameTime to return true once when called the next time.

Do​Render


[EmptyBody]
protected virtual method DoRender → (1)

graphics in : Graphics

The Graphics object to use.

Performs component specific rendering.

Do​Stylesheet​Apply


protected virtual method DoStylesheetApply → ()

Applies the current stylesheet settings to this component.

Implementing methods should query fetch style property values and store them somewhere for using them later quickly.

All graphics resources that are acquired during DoStylesheetApply must be properly disposed in IGraphicsComponent.GraphicsDetach.

Draw​Background


protected method DrawBackground → (2)

border in : bool

Draw a border?

round opt : int32 = 4

Size of round corners.

Draws the background rectangle of this component.

Draw​Hint


protected method DrawHint → (4)

text in : string

The hint text.

in : int32

X-coordinate of anchor point.

in : int32

Y-coordinate of anchor point.

anchor in : Anchor

The text anchor point.

Draws a hint text.

Draw​String


protected method DrawString → (4)

text in : string

The text.

in : int32

X-coordinate of anchor point.

in : int32

Y-coordinate of anchor point.

anchor in : Anchor

The text anchor point.

Draws a text.

Invalidate​Layout


protected method InvalidateLayout → (1)

layoutAction opt : LayoutAction = LayoutAction.ComputeLayoutGridExtend

The layout action that needs to be performed.

Invalidates the layout grid of the parent container of this component.

On​Bounds​Changed


[EmptyBody]
protected virtual method OnBoundsChanged → ()

This method is called each time the Bounds of this component have changed.

On​Focus​Changed


[EmptyBody]
protected virtual method OnFocusChanged → ()

This method is called when this component has lost or gained the input focus.

Depending on the value of IsFocussed when this method is called, the following holds true:
true: the component has gained input focus.
false: the component has gained input focus.

On​Graphics​Attached


protected virtual method OnGraphicsAttached → (1)

graphics in : Graphics

The Graphics object to use.

This method is called when this component is attached to the a graphics component.

On​Hovered​Clear


protected virtual method OnHoveredClear → ()

Clears the IsHovered state.

Set​Bounds


protected virtual method SetBounds → (2)

screenBounds in : Box2I

The screen bounds.

scrollSize in : Vec2I

The scroll size.

returns → bool

true if the component bounds have changed, false if not.

Sets the bounds of this component in its parent containers client area.

Shown


[EmptyBody]
protected virtual method Shown → ()

This method is called once after the component has been shown initially.

Protected / Attributes

color


protected attribute color → (ColorScheme)

The current color scheme.

graphics


protected attribute graphics → (Graphics)

The current Graphics object or null if this component is not attached.

Is​Attached


protected attribute IsAttached → (get)

value : bool

true if this component is attached to a live hierarchy, false if not.

Is this component currently attached to a live component hierarchy?

padding


protected attribute padding → (Edging)

The inner padding, based on the Style.Padding style.

text​Font


[Owner]
protected attribute textFont → (PixelFont)

The Style.TextFont value for this component.

text​Font​Hint


[Owner]
protected attribute textFontHint → (PixelFont)

The Style.TextFontHint value for this component.

Logging

Logger


public static readonly attribute Logger → (ILogger)

The logger object of this class.