Table of Contents

Interface IPanelElement

Namespace
SharpConsoleUI.Panel
Assembly
SharpConsoleUI.dll

Contract for anything that can live inside a Panel. Elements are self-contained widgets (start menu, taskbar, clock, etc.) that handle their own rendering and mouse input.

public interface IPanelElement
Extension Methods

Properties

FixedWidth

Gets the fixed width of this element, or null if it uses MeasureWidth() or flex sizing.

int? FixedWidth { get; }

Property Value

int?

FlexGrow

Gets the flex grow factor. 0 = fixed sizing, >0 = flex proportional to other flex elements.

int FlexGrow { get; }

Property Value

int

MaxWidth

Gets the maximum width constraint for flex elements.

int? MaxWidth { get; }

Property Value

int?

MinWidth

Gets the minimum width constraint for flex elements.

int? MinWidth { get; }

Property Value

int?

Name

Gets the unique name of this element.

string Name { get; }

Property Value

string

Visible

Gets or sets whether this element is visible.

bool Visible { get; set; }

Property Value

bool

Methods

MeasureWidth()

Measures the natural content width of this element. Used when FixedWidth is null and FlexGrow is 0.

int MeasureWidth()

Returns

int

The measured width in columns.

OnAttached(Panel)

Called when this element is added to a panel.

void OnAttached(Panel panel)

Parameters

panel Panel

The parent panel.

OnDetached()

Called when this element is removed from a panel.

void OnDetached()

ProcessMouseEvent(MouseEventArgs, int, int)

Processes a mouse event that occurred within this element's bounds.

bool ProcessMouseEvent(MouseEventArgs args, int elementX, int elementWidth)

Parameters

args MouseEventArgs

The mouse event arguments.

elementX int

The x position of this element on screen.

elementWidth int

The allocated width of this element.

Returns

bool

True if the event was handled.

Render(CharacterBuffer, int, int, int, Color, Color)

Renders the element into the character buffer at the specified position.

void Render(CharacterBuffer buffer, int x, int y, int width, Color fg, Color bg)

Parameters

buffer CharacterBuffer

The character buffer to render into.

x int

The x position to render at.

y int

The y position to render at.

width int

The allocated width for this element.

fg Color

The default foreground color.

bg Color

The default background color.