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 : IInteractiveControl, IFocusableControl, IWindowControl, IDisposable, IDOMPaintable
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

ActualWidth

Gets the actual rendered width of the control, or null if not yet rendered.

public int? ActualWidth { get; }

Property Value

int?

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

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 IContainer? Container { get; set; }

Property Value

IContainer

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

Gets or sets whether this control currently has keyboard focus.

public bool HasFocus { get; set; }

Property Value

bool

HorizontalAlignment

Gets or sets the horizontal alignment of the control within its container.

public HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

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

Margin

Gets or sets the margin (spacing) around the control.

public Margin Margin { get; set; }

Property Value

Margin

Name

Gets or sets the unique name identifier for this control, used for lookup.

public string? Name { get; set; }

Property Value

string

StickyPosition

Gets or sets whether this control should stick to the top or bottom during scrolling.

public StickyPosition StickyPosition { get; set; }

Property Value

StickyPosition

Tag

Gets or sets an arbitrary object value that can be used to store custom data.

public object? Tag { get; set; }

Property Value

object

VerticalAlignment

Gets or sets the vertical alignment of the control within its container.

public VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

Visible

Gets or sets whether this control is visible.

public bool Visible { get; set; }

Property Value

bool

Width

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

public int? Width { get; set; }

Property Value

int?

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetLogicalContentSize()

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

public Size GetLogicalContentSize()

Returns

Size

The size representing the content's natural dimensions.

Invalidate()

Marks this control as needing to be re-rendered.

public void Invalidate()

MeasureDOM(LayoutConstraints)

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

public LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

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

Returns

LayoutSize

The desired size of the control.

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

Paints the control's content directly to a CharacterBuffer.

public 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.

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

SetFocus(bool, FocusReason)

Sets focus to this control

public void SetFocus(bool focus, FocusReason reason = FocusReason.Programmatic)

Parameters

focus bool

Whether to give or remove focus

reason FocusReason

The reason for the focus change

Events

GotFocus

Event fired when the control gains focus

public event EventHandler? GotFocus

Event Type

EventHandler

LostFocus

Event fired when the control loses focus

public event EventHandler? LostFocus

Event Type

EventHandler

SplitterMoved

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

public event EventHandler<SplitterMovedEventArgs>? SplitterMoved

Event Type

EventHandler<SplitterMovedEventArgs>