Table of Contents

Class SplitterControl

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

A vertical splitter control that allows users to resize adjacent columns in a HorizontalGridControl. Supports keyboard-based resizing with arrow keys and provides visual feedback during focus and dragging.

public class SplitterControl : BaseControl, IDOMPaintable, INotifyPropertyChanged, IInteractiveControl, IFocusableControl, IMouseAwareControl, IWindowControl, IDisposable
Inheritance
SplitterControl
Implements
Inherited Members
Extension Methods

Constructors

SplitterControl()

Initializes a new instance of the SplitterControl class.

public SplitterControl()

SplitterControl(ColumnContainer, ColumnContainer)

Initializes a new instance of the SplitterControl class with specified adjacent columns.

public SplitterControl(ColumnContainer leftColumn, ColumnContainer rightColumn)

Parameters

leftColumn ColumnContainer

The column to the left of the splitter.

rightColumn ColumnContainer

The column to the right of the splitter.

Properties

BackgroundColor

Gets or sets the background color of the splitter in normal state.

public Color? BackgroundColor { get; set; }

Property Value

Color?

BorderColor

Gets or sets the border color of the splitter.

public Color BorderColor { get; set; }

Property Value

Color

CanFocusWithMouse

Whether this control can receive focus via mouse clicks

public bool CanFocusWithMouse { get; }

Property Value

bool

CanReceiveFocus

Whether this control can receive focus

public bool CanReceiveFocus { get; }

Property Value

bool

Container

Gets or sets the parent container that hosts this control.

public override IContainer? Container { get; set; }

Property Value

IContainer

ContentWidth

Gets the minimum width needed to display the control's content, including margins. Returns null if width cannot be determined. This is calculated based on content (text length, child controls, etc.) and represents the natural/intrinsic size.

public override int? ContentWidth { get; }

Property Value

int?

DraggingBackgroundColor

Gets or sets the background color of the splitter when being dragged.

public Color DraggingBackgroundColor { get; set; }

Property Value

Color

DraggingForegroundColor

Gets or sets the foreground color of the splitter when being dragged.

public Color DraggingForegroundColor { get; set; }

Property Value

Color

FocusedBackgroundColor

Gets or sets the background color of the splitter when focused.

public Color FocusedBackgroundColor { get; set; }

Property Value

Color

FocusedForegroundColor

Gets or sets the foreground color of the splitter when focused.

public Color FocusedForegroundColor { get; set; }

Property Value

Color

ForegroundColor

Gets or sets the foreground color of the splitter in normal state.

public Color ForegroundColor { get; set; }

Property Value

Color

HasFocus

public bool HasFocus { get; }

Property Value

bool

IsDragging

Gets a value indicating whether the splitter is currently being dragged.

public bool IsDragging { get; }

Property Value

bool

IsEnabled

Gets or sets whether this control is enabled and can receive input.

public bool IsEnabled { get; set; }

Property Value

bool

IsMouseDragging

Gets a value indicating whether the splitter is currently being dragged by the mouse.

public bool IsMouseDragging { get; }

Property Value

bool

WantsMouseEvents

Whether this control wants to receive mouse events

public bool WantsMouseEvents { get; }

Property Value

bool

Width

Gets or sets the explicit width of the control, or null for automatic sizing.

public override int? Width { get; set; }

Property Value

int?

Methods

GetLogicalContentSize()

Gets the logical size of the control's content without rendering.

public override Size GetLogicalContentSize()

Returns

Size

The size representing the content's natural dimensions.

MeasureDOM(LayoutConstraints)

Measures the control's desired size given the available constraints.

public override LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

The layout constraints (min/max width/height).

Returns

LayoutSize

The desired size of the control.

OnDisposing()

Called during Dispose() before Container is set to null. Override to perform control-specific cleanup (null events, close portals, clear data, etc.).

protected override void OnDisposing()

PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)

Paints the control's content directly to a CharacterBuffer.

public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultFg, Color defaultBg)

Parameters

buffer CharacterBuffer

The buffer to paint to.

bounds LayoutRect

The absolute bounds where the control should paint.

clipRect LayoutRect

The clipping rectangle (visible area).

defaultFg Color
defaultBg Color

ProcessKey(ConsoleKeyInfo)

Processes a keyboard input event.

public bool ProcessKey(ConsoleKeyInfo key)

Parameters

key ConsoleKeyInfo

The key information for the pressed key.

Returns

bool

True if the key was handled by this control; otherwise, false.

ProcessMouseEvent(MouseEventArgs)

Processes a mouse event for this control

public bool ProcessMouseEvent(MouseEventArgs args)

Parameters

args MouseEventArgs

Mouse event arguments with control-relative coordinates

Returns

bool

True if the event was handled and should not propagate further

SetColumns(ColumnContainer, ColumnContainer, HorizontalGridControl?)

Sets the columns that this splitter will resize

public void SetColumns(ColumnContainer leftColumn, ColumnContainer rightColumn, HorizontalGridControl? parentGrid = null)

Parameters

leftColumn ColumnContainer

Column to the left of the splitter

rightColumn ColumnContainer

Column to the right of the splitter

parentGrid HorizontalGridControl

The parent HorizontalGridControl that contains this splitter

Events

MouseClick

Event fired when the control is clicked

public event EventHandler<MouseEventArgs>? MouseClick

Event Type

EventHandler<MouseEventArgs>

MouseDoubleClick

Event fired when the control is double-clicked

public event EventHandler<MouseEventArgs>? MouseDoubleClick

Event Type

EventHandler<MouseEventArgs>

MouseEnter

Event fired when the mouse enters the control area

public event EventHandler<MouseEventArgs>? MouseEnter

Event Type

EventHandler<MouseEventArgs>

MouseLeave

Event fired when the mouse leaves the control area

public event EventHandler<MouseEventArgs>? MouseLeave

Event Type

EventHandler<MouseEventArgs>

MouseMove

Event fired when the mouse moves over the control

public event EventHandler<MouseEventArgs>? MouseMove

Event Type

EventHandler<MouseEventArgs>

MouseRightClick

Occurs when the control is right-clicked with the mouse.

public event EventHandler<MouseEventArgs>? MouseRightClick

Event Type

EventHandler<MouseEventArgs>

SplitterMoved

Occurs when the splitter is moved and column widths are adjusted.

public event EventHandler<SplitterMovedEventArgs>? SplitterMoved

Event Type

EventHandler<SplitterMovedEventArgs>