Class HorizontalSplitterControl
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A horizontal splitter control that allows users to resize vertically-stacked controls by dragging up/down. Renders as a thin horizontal bar (═══) and supports keyboard and mouse interaction. Works in any container: Window, ColumnContainer, ScrollablePanelControl.
public class HorizontalSplitterControl : BaseControl, IDOMPaintable, INotifyPropertyChanged, IInteractiveControl, IFocusableControl, IMouseAwareControl, IWindowControl, IDisposable
- Inheritance
-
HorizontalSplitterControl
- Implements
- Inherited Members
- Extension Methods
Constructors
HorizontalSplitterControl()
Initializes a new instance of the HorizontalSplitterControl class. Neighbors are auto-discovered from the parent container's children list.
public HorizontalSplitterControl()
HorizontalSplitterControl(IWindowControl, IWindowControl)
Initializes a new instance of the HorizontalSplitterControl class with explicit neighbors.
public HorizontalSplitterControl(IWindowControl aboveControl, IWindowControl belowControl)
Parameters
aboveControlIWindowControlThe control above the splitter.
belowControlIWindowControlThe control below the splitter.
Properties
AboveControl
Gets the control above this splitter (resolved lazily).
public IWindowControl? AboveControl { get; }
Property Value
BackgroundColor
Gets or sets the background color of the splitter in normal state.
public Color? BackgroundColor { get; set; }
Property Value
BelowControl
Gets the control below this splitter (resolved lazily).
public IWindowControl? BelowControl { get; }
Property Value
CanFocusWithMouse
Whether this control can receive focus via mouse clicks
public bool CanFocusWithMouse { get; }
Property Value
CanReceiveFocus
Whether this control can receive focus
public bool CanReceiveFocus { get; }
Property Value
Container
Gets or sets the parent container that hosts this control.
public override IContainer? Container { get; set; }
Property Value
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
DraggingForegroundColor
Gets or sets the foreground color of the splitter when being dragged.
public Color DraggingForegroundColor { get; set; }
Property Value
FocusedBackgroundColor
Gets or sets the background color of the splitter when focused.
public Color FocusedBackgroundColor { get; set; }
Property Value
FocusedForegroundColor
Gets or sets the foreground color of the splitter when focused.
public Color FocusedForegroundColor { get; set; }
Property Value
ForegroundColor
Gets or sets the foreground color of the splitter in normal state.
public Color ForegroundColor { get; set; }
Property Value
HasFocus
public bool HasFocus { get; }
Property Value
IsDragging
Gets a value indicating whether the splitter is currently being dragged.
public bool IsDragging { get; }
Property Value
IsEnabled
Gets or sets whether this control is enabled and can receive input.
public bool IsEnabled { get; set; }
Property Value
MinHeightAbove
Gets or sets the minimum height for the control above the splitter.
public int MinHeightAbove { get; set; }
Property Value
MinHeightBelow
Gets or sets the minimum height for the control below the splitter.
public int MinHeightBelow { get; set; }
Property Value
Visible
Gets or sets whether this control is visible.
public override bool Visible { get; set; }
Property Value
WantsMouseEvents
Whether this control wants to receive mouse events
public bool WantsMouseEvents { get; }
Property Value
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
constraintsLayoutConstraintsThe layout constraints (min/max width/height).
Returns
- LayoutSize
The desired size of the control.
MoveSplitter(int)
Moves the splitter by the specified delta, adjusting neighbor heights. Positive delta moves the splitter down (above grows, below shrinks).
public void MoveSplitter(int delta)
Parameters
deltaintRows to move (positive = down, negative = up).
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
bufferCharacterBufferThe buffer to paint to.
boundsLayoutRectThe absolute bounds where the control should paint.
clipRectLayoutRectThe clipping rectangle (visible area).
defaultFgColordefaultBgColor
ProcessKey(ConsoleKeyInfo)
Processes a keyboard input event.
public bool ProcessKey(ConsoleKeyInfo key)
Parameters
keyConsoleKeyInfoThe 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
argsMouseEventArgsMouse event arguments with control-relative coordinates
Returns
- bool
True if the event was handled and should not propagate further
SetControls(IWindowControl, IWindowControl)
Sets the controls that this splitter will resize.
public void SetControls(IWindowControl aboveControl, IWindowControl belowControl)
Parameters
aboveControlIWindowControlControl above the splitter.
belowControlIWindowControlControl below the splitter.
Events
MouseClick
Event fired when the control is clicked
public event EventHandler<MouseEventArgs>? MouseClick
Event Type
MouseDoubleClick
Event fired when the control is double-clicked
public event EventHandler<MouseEventArgs>? MouseDoubleClick
Event Type
MouseEnter
Event fired when the mouse enters the control area
public event EventHandler<MouseEventArgs>? MouseEnter
Event Type
MouseLeave
Event fired when the mouse leaves the control area
public event EventHandler<MouseEventArgs>? MouseLeave
Event Type
MouseMove
Event fired when the mouse moves over the control
public event EventHandler<MouseEventArgs>? MouseMove
Event Type
MouseRightClick
Occurs when the control is right-clicked with the mouse.
public event EventHandler<MouseEventArgs>? MouseRightClick
Event Type
SplitterMoved
Occurs when the splitter is moved and control heights are adjusted.
public event EventHandler<HorizontalSplitterMovedEventArgs>? SplitterMoved