Skip to content

ScreenSurface Class

An object that renders a ICellSurface.

C#
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class ScreenSurface : ScreenObject, IDisposable, IScreenSurfaceEditable, IScreenSurface, IScreenObject, IPositionable, IComponentHost, ISurface, ISurfaceSettable, ICellSurfaceResize

Inheritance objectScreenObject

Implements IDisposable, IScreenSurfaceEditable, IScreenSurface, IScreenObject, SadRogue.Primitives.IPositionable, IComponentHost, ISurface, ISurfaceSettable, ICellSurfaceResize

Creates a new screen object that can render a surface.

C#
public ScreenSurface(int width, int height)

width int
The width in cells of the surface.

height int
The height in cells of the surface.

ScreenSurface(int, int, ColoredGlyphBase[])

Section titled “ScreenSurface(int, int, ColoredGlyphBase[])”

Creates a new screen object that can render a surface. Uses the specified cells to generate the surface.

C#
public ScreenSurface(int width, int height, ColoredGlyphBase[] initialCells)

width int
The width in cells of the surface.

height int
The height in cells of the surface.

initialCells ColoredGlyphBase[]
The initial cells to seed the surface.

Creates a new surface with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public ScreenSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight)

viewWidth int
The visible width of the surface in cells.

viewHeight int
The visible height of the surface in cells.

totalWidth int
The total width of the surface in cells.

totalHeight int
The total height of the surface in cells.

ScreenSurface(IGridView<ColoredGlyphBase>, int, int)

Section titled “ScreenSurface(IGridView<ColoredGlyphBase>, int, int)”

Creates a new surface from a grid view. The cells between this object and the grid view are shared.

C#
public ScreenSurface(IGridView<ColoredGlyphBase> surface, int visibleWidth = 0, int visibleHeight = 0)

surface IGridView<ColoredGlyphBase>
The surface to use as the source of cells.

visibleWidth int
Optional view width. If 0, the view width matches the width of the surface.

visibleHeight int
Optional view height. If 0, the view width matches the height of the surface.

ScreenSurface(int, int, int, int, ColoredGlyphBase[]?)

Section titled “ScreenSurface(int, int, int, int, ColoredGlyphBase[]?)”

Creates a new surface with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public ScreenSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight, ColoredGlyphBase[]? initialCells)

viewWidth int
The width of the surface in cells to show.

viewHeight int
The height of the surface in cells to show.

totalWidth int
The total width of the surface in cells.

totalHeight int
The total height of the surface in cells.

initialCells ColoredGlyphBase[]
The cells to seed the surface with. If null, creates the cell array for you.

ScreenSurface(ICellSurface, IFont?, Point?)

Section titled “ScreenSurface(ICellSurface, IFont?, Point?)”

Creates a new screen object wrapping an existing surface.

C#
[JsonConstructor]
public ScreenSurface(ICellSurface surface, IFont? font = null, Point? fontSize = null)

surface ICellSurface
The surface.

font IFont
The font to use with the surface.

fontSize System.NullableSadRogue.Primitives.Point
The font size.

A cached value determined by OnMouseEnter(MouseScreenObjectState). true when the mouse entered the surface bounds with the mouse button down.

C#
protected bool MouseState_EnteredWithButtonDown

Indicates that the mouse is currently over this console.

C#
protected bool IsMouseOver

When true, forces the Renderer to refresh the backing texture with the latest state of the object.

C#
public bool ForceRendererRefresh { get; set; }

The name of the default renderer for this object.

C#
public virtual string DefaultRendererName { get; }

The renderer used to draw this surface.

C#
[DataMember]
[JsonConverter(typeof(RendererJsonConverter))]
public IRenderer? Renderer { get; protected set; }

When true, prevents the Surface property from raising events and virtual methods when the surface changes.

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

The surface this screen object represents.

C#
public ICellSurface Surface { get; set; }

When true, indicates that the Surface needs to be redrawn; otherwise false.

C#
public bool IsDirty { get; set; }

Font used with rendering.

C#
public IFont Font { get; set; }

The size of the Font cells applied to the object when rendering.

C#
public Point FontSize { get; set; }

A tint used in rendering.

C#
public Color Tint { get; set; }

The pixel area on the screen this surface occupies.

C#
public Rectangle AbsoluteArea { get; }

Treats the SadRogue.Primitives.IPositionable.Position of the object as if it is pixels and not cells.

C#
public bool UsePixelPositioning { get; set; }

The width of the surface in pixels.

C#
public int WidthPixels { get; }

The height of the surface in pixels.

C#
public int HeightPixels { get; }

The total width of the console.

C#
public int Width { get; }

The total height of the console.

C#
public int Height { get; }

Gets or sets the visible width of the surface in cells.

C#
public int ViewWidth { get; set; }

Gets or sets the visible height of the surface in cells.

C#
public int ViewHeight { get; set; }

The position of the view within the console.

C#
public Point ViewPosition { get; set; }

When true, this object will move to the front of its parent object when the mouse is clicked.

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

When true, this object will set IsFocused to true when the mouse is clicked.

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

Resizes the surface to the specified width and height.

C#
public void Resize(int viewWidth, int viewHeight, int totalWidth, int totalHeight, bool clear)

viewWidth int
The viewable width of the surface.

viewHeight int
The viewable height of the surface.

totalWidth int
The maximum width of the surface.

totalHeight int
The maximum height of the surface.

clear bool
When true, resets every cell to the DefaultForeground, DefaultBackground and glyph 0.

Resizes the surface and view to the specified width and height.

C#
public void Resize(int width, int height, bool clear)

width int
The width of the surface and view.

height int
The height of the surface and view.

clear bool
When true, resets every cell to the DefaultForeground, DefaultBackground and glyph 0.

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

C#
public override void UpdateAbsolutePosition()

Draws the Surface and all SadComponents and Children.

C#
public override void Render(TimeSpan delta)

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

Updates the Surface effects and all SadComponents and Children.

C#
public override void Update(TimeSpan delta)

delta TimeSpan
The time that has elapsed since this method was last called.

Called when the IsDirty property changes.

C#
protected virtual void OnIsDirtyChanged()

Called when the Font or FontSize property changes.

C#
protected virtual void OnFontChanged(IFont oldFont, Point oldFontSize)

oldFont IFont
The font prior to the change.

oldFontSize SadRogue.Primitives.Point
The font size prior to the change.

Called when the Surface property is changed.

C#
protected virtual void OnSurfaceChanged(ICellSurface oldSurface)

oldSurface ICellSurface
The previous surface.

Called when the Renderer property is changed.

C#
protected virtual void OnRendererChanged()

Returns the value “ScreenSurface”.

C#
public override string ToString()

string
The string “ScreenSurface”.

Calls the OnHostUpdated method on components, renderer, and rendersteps.

C#
public void CallOnHostUpdated()
C#
protected virtual void Dispose(bool disposing)

disposing bool

Disposes Renderer.

C#
protected ~ScreenSurface()
C#
public void Dispose()

Raises the MouseEnter event.

C#
protected virtual void OnMouseEnter(MouseScreenObjectState state)

state MouseScreenObjectState
Current mouse state in relation to this console.

Raises the MouseExit event.

C#
protected virtual void OnMouseExit(MouseScreenObjectState state)

state MouseScreenObjectState
Current mouse state in relation to this console.

Raises the MouseMove event.

C#
protected virtual void OnMouseMove(MouseScreenObjectState state)

state MouseScreenObjectState
Current mouse state in relation to this console.

OnMouseLeftClicked(MouseScreenObjectState)

Section titled “OnMouseLeftClicked(MouseScreenObjectState)”

Raises the MouseButtonClicked event. Possibly moves the console to the top of it’s parent’s children collection.

C#
protected virtual void OnMouseLeftClicked(MouseScreenObjectState state)

state MouseScreenObjectState
Current mouse state in relation to this console.

OnRightMouseClicked(MouseScreenObjectState)

Section titled “OnRightMouseClicked(MouseScreenObjectState)”

Raises the MouseButtonClicked event.

C#
protected virtual void OnRightMouseClicked(MouseScreenObjectState state)

state MouseScreenObjectState
Current mouse state in relation to this console.

Called when the mouse is being used by something else.

C#
public override void LostMouse(MouseScreenObjectState state)

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

Processes the mouse.

C#
public override bool ProcessMouse(MouseScreenObjectState state)

state MouseScreenObjectState
The mouse state related to this object.

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

Raised when a mouse button is clicked on this object.

C#
public event EventHandler<MouseScreenObjectState>? MouseButtonClicked

EventHandler<MouseScreenObjectState>

Raised when the mouse moves around the this object.

C#
public event EventHandler<MouseScreenObjectState>? MouseMove

EventHandler<MouseScreenObjectState>

Raised when the mouse exits this object.

C#
public event EventHandler<MouseScreenObjectState>? MouseExit

EventHandler<MouseScreenObjectState>

Raised when the mouse enters this object.

C#
public event EventHandler<MouseScreenObjectState>? MouseEnter

EventHandler<MouseScreenObjectState>