Skip to content

ScreenObject Class

A generic object processed by SadConsole. Provides parent/child, components, and position.

C#
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class ScreenObject : IScreenObject, IPositionable, IComponentHost

Inheritance object

Implements IScreenObject, SadRogue.Primitives.IPositionable, IComponentHost

Creates a new instance of this class.

C#
public ScreenObject()

A filtered list from SadComponents where IsUpdate is true.

C#
protected List<IComponent> ComponentsUpdate

A filtered list from SadComponents where IsRender is true.

C#
protected List<IComponent> ComponentsRender

A filtered list from SadComponents where IsMouse is true.

C#
protected List<IComponent> ComponentsMouse

A filtered list from SadComponents where IsKeyboard is true.

C#
protected List<IComponent> ComponentsKeyboard

A filtered list from SadComponents that is not set for update, render, mouse, or keyboard.

C#
protected List<IComponent> ComponentsEmpty

Indicates the sorting order this object should use when parented. Sorting is a manual operation on the Children collection.

C#
[DataMember]
public uint SortOrder { get; set; }

The child objects of this instance.

C#
public ScreenObjectCollection Children { get; protected set; }

The parent object that this instance is a child of.

C#
public IScreenObject? Parent { get; set; }

A position that is based on the current Position and Parent position, in pixels.

C#
public Point Position { get; set; }

A position that’s based on the current SadRogue.Primitives.IPositionable.Position, as interpreted by the implementing class, in pixels.

C#
public Point AbsolutePosition { get; protected set; }

Most objects will implement this property based on SadRogue.Primitives.IPositionable.Position which usually depends on the Parent object’s position.

When true, this object should ignore it’s parent position when calculating AbsolutePosition; otherwise false.

C#
[DataMember]
public bool IgnoreParentPosition { get; set; }

Gets or sets the visibility of this object.

C#
[DataMember]
public bool IsVisible { get; set; }

Gets or sets the visibility of this object.

C#
[DataMember]
public bool IsEnabled { get; set; }

Gets or sets this console as the focused object for input.

C#
public bool IsFocused { get; set; }

How the object should handle becoming active.

C#
[DataMember]
public FocusBehavior FocusedMode { get; set; }

Gets or sets whether or not this object has exclusive access to the mouse events.

C#
[DataMember]
public bool IsExclusiveMouse { get; set; }

When true, this object will use the keyboard; otherwise false.

C#
[DataMember]
public bool UseKeyboard { get; set; }

When true, this object will use the mouse; otherwise false.

C#
[DataMember]
public bool UseMouse { get; set; }

A collection of components processed by this console.

C#
public ObservableCollection<IComponent> SadComponents { get; protected set; }

Draws all SadComponents and Children.

C#
public virtual void Render(TimeSpan delta)

delta TimeSpan
The time that has elapsed since the last call.

Only processes if IsVisible is true.

Updates all SadComponents and Children.

C#
public virtual void Update(TimeSpan delta)

delta TimeSpan
The time that has elapsed since the last call.

Only processes if IsEnabled is true.

Called by the engine to process the keyboard.

C#
public virtual bool ProcessKeyboard(Keyboard keyboard)

keyboard Keyboard
Keyboard information.

bool
True when the keyboard had data and this console did something with it.

Processes the mouse.

C#
public virtual bool ProcessMouse(MouseScreenObjectState state)

state MouseScreenObjectState
The mouse state related to this object.

bool
True when this object should halt further mouse processing..

Called when the mouse is being used by something else.

C#
public virtual void LostMouse(MouseScreenObjectState state)

state MouseScreenObjectState
The current state of the mouse based on this object.

Called when this object’s focus has been lost.

C#
public virtual void OnFocusLost()

Called when this object is focused.

C#
public virtual void OnFocused()

OnParentChanged(IScreenObject?, IScreenObject?)

Section titled “OnParentChanged(IScreenObject?, IScreenObject?)”

Raises the ParentChanged event.

C#
protected virtual void OnParentChanged(IScreenObject? oldParent, IScreenObject? newParent)

oldParent IScreenObject
The previous parent.

newParent IScreenObject
The new parent.

Raises the PositionChanging event.

C#
protected virtual void OnPositionChanging(Point oldPosition, Point newPosition)

oldPosition SadRogue.Primitives.Point
The previous position.

newPosition SadRogue.Primitives.Point
The new position.

Raises the PositionChanged event.

C#
protected virtual void OnPositionChanged(Point oldPosition, Point newPosition)

oldPosition SadRogue.Primitives.Point
The previous position.

newPosition SadRogue.Primitives.Point
The new position.

Called when the visibility of the object changes.

C#
protected virtual void OnVisibleChanged()

Called when the paused status of the object changes.

C#
protected virtual void OnEnabledChanged()

Sets a value for AbsolutePosition based on the SadRogue.Primitives.IPositionable.Position of this instance and the Parent instance.

C#
public virtual void UpdateAbsolutePosition()

Returns the value “ScreenObject”.

C#
public override string ToString()

string
The string “ScreenObject”.

Gets components of the specified types.

C#
public IEnumerable<TComponent> GetSadComponents<TComponent>() where TComponent : class, IComponent

IEnumerable<TComponent>
The components found.

Gets the first component of the specified type.

C#
public TComponent? GetSadComponent<TComponent>() where TComponent : class, IComponent

TComponent
The component if found, otherwise null.

HasSadComponent<TComponent>(out TComponent?)

Section titled “HasSadComponent<TComponent>(out TComponent?)”

Indicates whether or not the component exists in the SadComponents collection.

C#
public bool HasSadComponent<TComponent>(out TComponent? component) where TComponent : class, IComponent

component TComponent

bool
true when the component exists; otherwise false.

Called when a component is added to the SadComponents collection.

C#
protected virtual void OnSadComponentAdded(IComponent component)

component IComponent
The component added.

Called when a component is removed from the SadComponents collection.

C#
protected virtual void OnSadComponentRemoved(IComponent component)

component IComponent
The component removed.

Sorts the components based on the SortOrder value.

C#
public void SortComponents()

Components_FilterAddItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)

Section titled “Components_FilterAddItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)”

Adds a component to the provided collections, based on its configuration.

C#
public static void Components_FilterAddItem(IComponent component, List<IComponent> componentsRender, List<IComponent> componentsUpdate, List<IComponent> componentsKeyboard, List<IComponent> componentsMouse, List<IComponent> componentsEmpty)

component IComponent
The component.

componentsRender List<IComponent>
The render collection.

componentsUpdate List<IComponent>
The update collection.

componentsKeyboard List<IComponent>
The keyboard collection.

componentsMouse List<IComponent>
The mouse collection.

componentsEmpty List<IComponent>
The empty collection.

Components_FilterRemoveItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)

Section titled “Components_FilterRemoveItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)”

Removes a component to the provided collections, based on its configuration.

C#
public static void Components_FilterRemoveItem(IComponent component, List<IComponent> componentsRender, List<IComponent> componentsUpdate, List<IComponent> componentsKeyboard, List<IComponent> componentsMouse, List<IComponent> componentsEmpty)

component IComponent
The component.

componentsRender List<IComponent>
The render collection.

componentsUpdate List<IComponent>
The update collection.

componentsKeyboard List<IComponent>
The keyboard collection.

componentsMouse List<IComponent>
The mouse collection.

componentsEmpty List<IComponent>
The empty collection.

Components_Sort(List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)

Section titled “Components_Sort(List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)”

Helper to sort the components in the split collections.

C#
public static void Components_Sort(List<IComponent> componentsRender, List<IComponent> componentsUpdate, List<IComponent> componentsKeyboard, List<IComponent> componentsMouse, List<IComponent> componentsEmpty)

componentsRender List<IComponent>
The render collection.

componentsUpdate List<IComponent>
The update collection.

componentsKeyboard List<IComponent>
The keyboard collection.

componentsMouse List<IComponent>
The mouse collection.

componentsEmpty List<IComponent>
The empty collection.

Nothing.

C#
[OnSerializing]
protected void OnSerializingMethod(StreamingContext context)

context StreamingContext
Nothing.

Raised when the Parent property changes.

C#
public event EventHandler<ValueChangedEventArgs<IScreenObject?>>? ParentChanged

EventHandler<ValueChangedEventArgs<IScreenObject>>

C#
public event EventHandler<ValueChangedEventArgs<Point>>? PositionChanged

EventHandler<ValueChangedEventArgs<Point>>

C#
public event EventHandler<ValueChangedEventArgs<Point>>? PositionChanging

EventHandler<ValueChangedEventArgs<Point>>

Raised when the IsVisible property changes.

C#
public event EventHandler? IsVisibleChanged

EventHandler

Raised when the IsEnabled property changes.

C#
public event EventHandler? IsEnabledChanged

EventHandler

Raised when the IsFocused property is false.

C#
public event EventHandler? FocusLost

EventHandler

Raised when the IsFocused property is true.

C#
public event EventHandler? Focused

EventHandler