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
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
Visible
Gets or sets whether this element is visible.
bool Visible { get; set; }
Property Value
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
panelPanelThe 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
argsMouseEventArgsThe mouse event arguments.
elementXintThe x position of this element on screen.
elementWidthintThe 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)