Namespace Terminal.Gui.ViewBase
Core view system, base classes, layout primitives, and adornments.
The ViewBase namespace contains the foundational view architecture for all Terminal.Gui UI elements.
Key Types
- View - Base class for all UI elements
- Adornment / Margin / Border / Padding - Visual decorations around content
- Pos / Dim - Flexible positioning and sizing system
- ViewArrangement - User interaction flags (Movable, Resizable, Overlapped)
- IValue<T> - Interface for views with strongly-typed values
View Architecture
Views are composed of nested layers:
- Frame - Outer rectangle in SuperView coordinates
- Margin - Transparent spacing outside Border
- Border - Visual frame with title and line style
- Padding - Spacing inside Border
- Viewport - Visible window into content area
- Content Area - Where content is drawn (can be larger than Viewport for scrolling)
Example
View view = new ()
{
X = Pos.Center (),
Y = Pos.Center (),
Width = Dim.Percent (50),
Height = Dim.Auto (),
Title = "My View",
BorderStyle = LineStyle.Rounded,
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable
};
See Also
- View Deep Dive
- Layout Deep Dive
- Views Overview
- Arrangement Deep Dive
- Navigation Deep Dive
- Scrolling Deep Dive
- Events Deep Dive - Event handling patterns
Classes
- AddOrSubtractExtensions
Extension methods for the AddOrSubtract enum type.
- Adornment
Adornments are a special form of View that appear outside the Viewport: Margin, Border, and Padding. They are defined using the Thickness class, which specifies the thickness of the sides of a rectangle.
- AdvanceFocusEventArgs
The event arguments for AdvanceFocus(NavigationDirection, TabBehavior?) events.
- Aligner
Aligns items within a container based on the specified Alignment. Both horizontal and vertical alignments are supported.
- AlignmentModesExtensions
Extension methods for the AlignmentModes enum type.
- BorderSettingsExtensions
Extension methods for the BorderSettings enum type.
- Dim
A Dim object describes the dimensions of a View. Dim is the type of the Width and Height properties of View.
Integer values are implicitly convertible to an absolute Dim. These objects are created using the static methods described below. The Dim objects can be combined with the addition and subtraction operators.
- DimAbsolute
Represents a dimension that is a fixed size.
- DimAuto
Represents a dimension that automatically sizes the view to fit all the view's Content, SubViews, and/or Text.
- DimAutoStyleExtensions
Extension methods for the DimAutoStyle enum type.
- DimCombine
Represents a dimension that is a combination of two other dimensions.
- DimFill
Represents a dimension that fills the dimension, leaving the specified margin.
- DimFunc
Represents a function Dim object that computes the dimension based on the passed view and by executing the provided function.
- DimPercent
Represents a dimension that is a percentage of the width or height of the SuperView.
- DimPercentModeExtensions
Extension methods for the DimPercentMode enum type.
- DimView
Represents a dimension that tracks the Height or Width of the specified View.
- DrawAdornmentsEventArgs
Provides data for events that allow cancellation of adornment drawing in the Cancellable Work Pattern (CWP).
- DrawContext
Tracks the region that has been drawn during Draw(DrawContext?). This is primarily in support of Transparent.
- DrawEventArgs
Event args for draw events
- HasFocusEventArgs
The event arguments for HasFocus events.
- LayoutEventArgs
Event arguments for the SubViewsLaidOut event.
- LayoutException
Represents an exception that is thrown when a layout operation fails.
- OrientationHelper
Helper class for implementing IOrientation.
- Pos
Describes the position of a View which can be an absolute value, a percentage, centered, or relative to the ending dimension. Integer values are implicitly convertible to an absolute Pos. These objects are created using the static methods Percent, AnchorEnd, and Center. The Pos objects can be combined with the addition and subtraction operators.
- PosAbsolute
Represents an absolute position in the layout. This is used to specify a fixed position in the layout.
- PosAlign
Enables alignment of a set of views.
- PosAnchorEnd
Represents a position anchored to the end (right side or bottom) of the SuperView's content area.
- PosCenter
Represents a position that is centered.
- PosCombine
Represents a position that is a combination of two other positions.
- PosFunc
Represents a position that is computed by executing a function that returns an integer position.
- PosPercent
Represents a position that is a percentage of the width or height of the SuperView.
- PosView
Represents a position that is anchored to the side of another view.
- SizeChangedEventArgs
Args for events about Size (e.g. Resized)
- StackExtensions
Extension of Stack<T> helper to work with specific IEqualityComparer<T>
- SuperViewChangedEventArgs
Args for events where the SuperView of a View is changed (e.g. Removed).
- View
View is the base class all visible elements. View can render itself and contains zero or more nested views, called SubViews. View provides basic functionality for layout, arrangement, and drawing. In addition, View provides keyboard and mouse event handling.
See the View Deep Dive for more.
- ViewDiagnosticFlagsExtensions
Extension methods for the ViewDiagnosticFlags enum type.
- ViewEventArgs
Args for events that relate to specific View
- ViewManipulator
Helper class that encapsulates view manipulation operations for arrangement (move/resize). Provides methods to move and resize a view while respecting minimum size constraints.
Interfaces
- IDesignable
Interface declaring common functionality useful for designer implementations.
- IMouseHoldRepeater
Handler for raising periodic events while the mouse is held down. Typically, mouse button only needs to be pressed down in a view to begin this event after which it can be moved elsewhere.
Common use cases for this includes holding a button down to increase a counter (e.g. in NumericUpDown).
- IOrientation
Implement this interface to provide orientation support.
- IValue
Non-generic interface for accessing a View's value as a boxed object.
- IValue<TValue>
Interface for views that provide a strongly-typed value.
Enums
- AddOrSubtract
Describes whether an operation should add or subtract values.
- Alignment
Determines the position of items when arranged in a container.
- AlignmentModes
Determines alignment modes for Alignment.
- ArrangeButtons
Identifies the different arrangement buttons that can be displayed on a border during arrange mode.
- BorderSettings
Determines the settings for Border.
- DimAutoStyle
Specifies how Auto(DimAutoStyle, Dim?, Dim?) will compute the dimension. See the Dim.Auto Deep Dive for comprehensive documentation.
- DimPercentMode
Indicates the mode for a DimPercent object.
- MouseState
Used to describe the state of the mouse in relation to a View (MouseState) and to specify visual effects, such as highlighting a button when the mouse is over it or changing the appearance of a view when the mouse is pressed (MouseHighlightStates).
- NavigationDirection
Indicates navigation direction.
- Orientation
Direction of an element (horizontal or vertical)
- ShadowStyle
Defines the style of shadow to be drawn on the right and bottom sides of the View.
- TabBehavior
Describes how TabStop behaves. A TabStop is a stop-point for keyboard navigation between Views.
- ViewArrangement
Describes what user actions are enabled for arranging a View within it's SuperView . See Arrangement.
- ViewDiagnosticFlags
Enables diagnostic functions for View.
- ViewportSettingsFlags
Settings for how the Viewport behaves.
Delegates
- View.CommandImplementation
Function signature commands.