diff --git a/Terminal.Gui/View/Layout/Dim.cs b/Terminal.Gui/View/Layout/Dim.cs
index cc31d41b1..16db2fe17 100644
--- a/Terminal.Gui/View/Layout/Dim.cs
+++ b/Terminal.Gui/View/Layout/Dim.cs
@@ -187,7 +187,7 @@ public abstract class Dim
/// Gets a dimension that is anchored to a certain point in the layout.
/// This method is typically used internally by the layout system to determine the size of a View.
///
- /// The width of the area where the View is being sized (Superview.ContentSize).
+ /// The width of the area where the View is being sized (Superview.GetContentSize ()).
///
/// An integer representing the calculated dimension. The way this dimension is calculated depends on the specific
/// subclass of Dim that is used. For example, DimAbsolute returns a fixed dimension, DimFactor returns a
diff --git a/Terminal.Gui/View/Layout/DimAuto.cs b/Terminal.Gui/View/Layout/DimAuto.cs
index d956fb94d..0538c6f08 100644
--- a/Terminal.Gui/View/Layout/DimAuto.cs
+++ b/Terminal.Gui/View/Layout/DimAuto.cs
@@ -72,7 +72,7 @@ public class DimAuto () : Dim
if (!us.ContentSizeTracksViewport)
{
// ContentSize was explicitly set. Ignore subviews.
- subviewsSize = dimension == Dimension.Width ? us.ContentSize.Width : us.ContentSize.Height;
+ subviewsSize = dimension == Dimension.Width ? us.GetContentSize ().Width : us.GetContentSize ().Height;
}
else
{
diff --git a/Terminal.Gui/View/Layout/DimAutoStyle.cs b/Terminal.Gui/View/Layout/DimAutoStyle.cs
index df7f7065c..a0b464d59 100644
--- a/Terminal.Gui/View/Layout/DimAutoStyle.cs
+++ b/Terminal.Gui/View/Layout/DimAutoStyle.cs
@@ -10,9 +10,9 @@ namespace Terminal.Gui;
public enum DimAutoStyle
{
///
- /// The dimensions will be computed based on the View's and/or .
+ /// The dimensions will be computed based on the View's and/or .
///
- /// If is , will be used to determine the dimension.
+ /// If is , will be used to determine the dimension.
///
///
/// Otherwise, the Subview in with the largest corresponding position plus dimension
@@ -31,13 +31,13 @@ public enum DimAutoStyle
/// will be used to determine the dimension.
///
///
- /// The corresponding dimensions of and/or will be ignored.
+ /// The corresponding dimensions of and/or will be ignored.
///
///
Text = 2,
///
- /// The dimension will be computed using the largest of the view's , , and
+ /// The dimension will be computed using the largest of the view's , , and
/// corresponding dimension
///
Auto = Content | Text,
diff --git a/Terminal.Gui/View/Layout/DimPercent.cs b/Terminal.Gui/View/Layout/DimPercent.cs
index af849c53f..2ae81302a 100644
--- a/Terminal.Gui/View/Layout/DimPercent.cs
+++ b/Terminal.Gui/View/Layout/DimPercent.cs
@@ -11,7 +11,7 @@ namespace Terminal.Gui;
/// The percentage.
///
/// If the dimension is computed using the View's position ( or
-/// ); otherwise, the dimension is computed using the View's .
+/// ); otherwise, the dimension is computed using the View's .
///
public class DimPercent (int percent, DimPercentMode mode = DimPercentMode.ContentSize) : Dim
{
@@ -32,7 +32,7 @@ public class DimPercent (int percent, DimPercentMode mode = DimPercentMode.Conte
public override string ToString () { return $"Percent({Percent},{Mode})"; }
///
- /// Gets whether the dimension is computed using the View's position or ContentSize.
+ /// Gets whether the dimension is computed using the View's position or GetContentSize ().
///
public DimPercentMode Mode { get; } = mode;
diff --git a/Terminal.Gui/View/Layout/DimPercentMode.cs b/Terminal.Gui/View/Layout/DimPercentMode.cs
index 74d64b77c..60a7da056 100644
--- a/Terminal.Gui/View/Layout/DimPercentMode.cs
+++ b/Terminal.Gui/View/Layout/DimPercentMode.cs
@@ -15,7 +15,7 @@ public enum DimPercentMode
Position = 0,
///
- /// The dimension is computed using the View's .
+ /// The dimension is computed using the View's .
///
ContentSize = 1
}
\ No newline at end of file
diff --git a/Terminal.Gui/View/Layout/Pos.cs b/Terminal.Gui/View/Layout/Pos.cs
index 609c1ffd7..a5cf52249 100644
--- a/Terminal.Gui/View/Layout/Pos.cs
+++ b/Terminal.Gui/View/Layout/Pos.cs
@@ -296,12 +296,12 @@ public abstract class Pos
///
/// Gets the starting point of an element based on the size of the parent element (typically
- /// Superview.ContentSize).
+ /// Superview.GetContentSize ()).
/// This method is meant to be overridden by subclasses to provide different ways of calculating the starting point.
/// This method is used
/// internally by the layout system to determine where a View should be positioned.
///
- /// The size of the parent element (typically Superview.ContentSize).
+ /// The size of the parent element (typically Superview.GetContentSize ()).
///
/// An integer representing the calculated position. The way this position is calculated depends on the specific
/// subclass of Pos that is used. For example, PosAbsolute returns a fixed position, PosAnchorEnd returns a
diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs
index 110cc2238..15afd8765 100644
--- a/Terminal.Gui/View/Layout/ViewLayout.cs
+++ b/Terminal.Gui/View/Layout/ViewLayout.cs
@@ -13,10 +13,10 @@ public partial class View
/// Gets or sets the absolute location and dimension of the view.
///
/// The rectangle describing absolute location and dimension of the view, in coordinates relative to the
- /// 's Content, which is bound by .
+ /// 's Content, which is bound by .
///
///
- /// Frame is relative to the 's Content, which is bound by .
+ /// Frame is relative to the 's Content, which is bound by .
///
/// Setting Frame will set , , , and to the
/// values of the corresponding properties of the parameter.
@@ -136,7 +136,7 @@ public partial class View
/// The object representing the X position.
///
///
- /// The position is relative to the 's Content, which is bound by .
+ /// The position is relative to the 's Content, which is bound by .
///
///
/// If set to a relative value (e.g. ) the value is indeterminate until the view has been
@@ -175,7 +175,7 @@ public partial class View
/// The object representing the Y position.
///
///
- /// The position is relative to the 's Content, which is bound by .
+ /// The position is relative to the 's Content, which is bound by .
///
///
/// If set to a relative value (e.g. ) the value is indeterminate until the view has been
@@ -213,7 +213,7 @@ public partial class View
/// The object representing the height of the view (the number of rows).
///
///
- /// The dimension is relative to the 's Content, which is bound by
+ /// The dimension is relative to the 's Content, which is bound by
/// .
///
///
@@ -259,7 +259,7 @@ public partial class View
/// The object representing the width of the view (the number of columns).
///
///
- /// The dimension is relative to the 's Content, which is bound by
+ /// The dimension is relative to the 's Content, which is bound by
/// .
///
///
@@ -649,7 +649,7 @@ public partial class View
CheckDimAuto ();
- var contentSize = ContentSize;
+ var contentSize = GetContentSize ();
OnLayoutStarted (new (contentSize));
LayoutAdornments ();
@@ -673,7 +673,7 @@ public partial class View
{
foreach ((View from, View to) in edges)
{
- LayoutSubview (to, from.ContentSize);
+ LayoutSubview (to, from.GetContentSize ());
}
}
@@ -726,8 +726,8 @@ public partial class View
// Determine our container's ContentSize -
// First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
// Finally, if none of those are valid, use int.MaxValue (for Unit tests).
- Size superViewContentSize = SuperView is { IsInitialized: true } ? SuperView.ContentSize :
- Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.ContentSize :
+ Size superViewContentSize = SuperView is { IsInitialized: true } ? SuperView.GetContentSize () :
+ Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.GetContentSize () :
Application.Driver?.Screen.Size ?? new (int.MaxValue, int.MaxValue);
SetTextFormatterSize ();
@@ -769,7 +769,7 @@ public partial class View
///
/// Adjusts given the SuperView's ContentSize (nominally the same as
- /// this.SuperView.ContentSize)
+ /// this.SuperView.GetContentSize ())
/// and the position (, ) and dimension (, and
/// ).
///
@@ -781,7 +781,7 @@ public partial class View
///
///
///
- /// The size of the SuperView's content (nominally the same as this.SuperView.ContentSize).
+ /// The size of the SuperView's content (nominally the same as this.SuperView.GetContentSize ()).
///
internal void SetRelativeLayout (Size superviewContentSize)
{
diff --git a/Terminal.Gui/View/ViewContent.cs b/Terminal.Gui/View/ViewContent.cs
index 58788499f..4003c1c1d 100644
--- a/Terminal.Gui/View/ViewContent.cs
+++ b/Terminal.Gui/View/ViewContent.cs
@@ -6,7 +6,34 @@ public partial class View
internal Size? _contentSize;
- private void SetContentSize (Size? contentSize)
+ ///
+ /// Sets the size of the View's content.
+ ///
+ ///
+ ///
+ /// Negative sizes are not supported.
+ ///
+ ///
+ /// If not explicitly set, and the View has no visible subviews, will return the
+ /// size of
+ /// .
+ ///
+ ///
+ /// If not explicitly set, and the View has visible subviews, will return the
+ /// maximum
+ /// position + dimension of the Subviews, supporting with the
+ /// flag set.
+ ///
+ ///
+ /// If set describes the portion of the content currently visible to the user. This enables
+ /// virtual scrolling.
+ ///
+ ///
+ /// If set the behavior of will be to use the ContentSize to determine the size
+ /// of the view.
+ ///
+ ///
+ public void SetContentSize (Size? contentSize)
{
if (contentSize is { } && (contentSize.Value.Width < 0 || contentSize.Value.Height < 0))
{
@@ -23,8 +50,38 @@ public partial class View
}
///
- /// Gets or sets a value indicating whether the tracks the 's size or
- /// not.
+ /// Gets the size of the View's content.
+ ///
+ /// a>
+ ///
+ /// If the content size was not explicitly set by , and the View has no visible subviews, will return the
+ /// size of
+ /// .
+ ///
+ ///
+ /// If the content size was not explicitly set by , and the View has visible subviews, will return the
+ /// maximum
+ /// position + dimension of the Subviews, supporting with the
+ /// flag set.
+ ///
+ ///
+ /// If set describes the portion of the content currently visible to the user. This enables
+ /// virtual scrolling.
+ ///
+ ///
+ /// If set the behavior of will be to use the ContentSize to determine the size
+ /// of the view.
+ ///
+ ///
+ ///
+ /// If the content size was not explicitly set by , will
+ /// return the size of the and will be .
+ ///
+ public Size GetContentSize () { return _contentSize ?? Viewport.Size; }
+
+ ///
+ /// Gets or sets a value indicating whether the view's content size tracks the 's
+ /// size or not.
///
///
///
@@ -37,13 +94,14 @@ public partial class View
///
///
///
- /// is tracking the 's size. Content scrolling will be
+ /// will return the 's size. Content scrolling
+ /// will be
/// disabled.
///
///
/// The behavior of will be to use position and size of the Subviews
/// to
- /// determine the size of the view, ignoring .
+ /// determine the size of the view, ignoring .
///
///
///
@@ -53,12 +111,12 @@ public partial class View
///
///
///
- /// is independent of and
- /// describes the portion of the content currently visible to the user, bound by
- /// , enabling content scrolling.
+ /// The return value of is independent of and
+ /// describes the portion of the content currently visible to the user enabling content scrolling.
///
///
- /// The behavior of will be to use to
+ /// The behavior of will be to use
+ /// to
/// determine the
/// size of the view, ignoring the position and size of the Subviews.
///
@@ -73,38 +131,7 @@ public partial class View
}
///
- /// Gets the size of the View's content.
- ///
- ///
- ///
- /// Negative sizes are not supported.
- ///
- ///
- /// If not explicitly set, and the View has no visible subviews, will track the size of
- /// .
- ///
- ///
- /// If not explicitly set, and the View has visible subviews, will track the maximum
- /// position + dimension of the Subviews, supporting with the
- /// flag set.
- ///
- ///
- /// If set describes the portion of the content currently visible to the user. This enables
- /// virtual scrolling.
- ///
- ///
- /// If set the behavior of will be to use the ContentSize to determine the size
- /// of the view.
- ///
- ///
- public Size ContentSize
- {
- get => _contentSize ?? Viewport.Size;
- protected internal set => SetContentSize (value);
- }
-
- ///
- /// Called when has changed.
+ /// Called when has changed.
///
///
///
@@ -124,7 +151,7 @@ public partial class View
}
///
- /// Event raised when the changes.
+ /// Event raised when the changes.
///
public event EventHandler ContentSizeChanged;
@@ -192,28 +219,30 @@ public partial class View
///
/// The location of the viewport into the view's content (0,0) is the top-left corner of the content. The Content
/// area's size
- /// is .
+ /// is .
///
private Point _viewportLocation;
///
/// Gets or sets the rectangle describing the portion of the View's content that is visible to the user.
/// The viewport Location is relative to the top-left corner of the inner rectangle of .
- /// If the viewport Size is the same as , or is
+ /// If the viewport Size is the same as , or is
/// the Location will be 0, 0.
///
///
/// The rectangle describing the location and size of the viewport into the View's virtual content, described by
- /// .
+ /// .
///
///
///
/// Positive values for the location indicate the visible area is offset into (down-and-right) the View's virtual
- /// . This enables scrolling down and to the right (e.g. in a .
+ /// . This enables scrolling down and to the right (e.g. in a
+ /// .
///
///
/// Negative values for the location indicate the visible area is offset above (up-and-left) the View's virtual
- /// . This enables scrolling up and to the left (e.g. in an image viewer that supports
+ /// . This enables scrolling up and to the left (e.g. in an image viewer that
+ /// supports
/// zoom
/// where the image stays centered).
///
@@ -294,9 +323,9 @@ public partial class View
{
if (!ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
{
- if (newViewport.X >= ContentSize.Width)
+ if (newViewport.X >= GetContentSize ().Width)
{
- newViewport.X = ContentSize.Width - 1;
+ newViewport.X = GetContentSize ().Width - 1;
}
}
@@ -311,9 +340,9 @@ public partial class View
if (!ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
{
- if (newViewport.Y >= ContentSize.Height)
+ if (newViewport.Y >= GetContentSize ().Height)
{
- newViewport.Y = ContentSize.Height - 1;
+ newViewport.Y = GetContentSize ().Height - 1;
}
}
@@ -402,7 +431,7 @@ public partial class View
/// if the was changed.
public bool? ScrollVertical (int rows)
{
- if (ContentSize == Size.Empty || ContentSize == Viewport.Size)
+ if (GetContentSize () == Size.Empty || GetContentSize () == Viewport.Size)
{
return false;
}
@@ -423,7 +452,7 @@ public partial class View
/// if the was changed.
public bool? ScrollHorizontal (int cols)
{
- if (ContentSize == Size.Empty || ContentSize == Viewport.Size)
+ if (GetContentSize () == Size.Empty || GetContentSize () == Viewport.Size)
{
return false;
}
diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs
index 6ddf5281d..74beffd3f 100644
--- a/Terminal.Gui/View/ViewDrawing.cs
+++ b/Terminal.Gui/View/ViewDrawing.cs
@@ -106,7 +106,7 @@ public partial class View
if (ViewportSettings.HasFlag (ViewportSettings.ClearContentOnly))
{
- Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), ContentSize));
+ Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), GetContentSize ()));
toClear = Rectangle.Intersect (toClear, visibleContent);
}
@@ -172,7 +172,7 @@ public partial class View
if (ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly))
{
// Clamp the Clip to the just content area that is within the viewport
- Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), ContentSize));
+ Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), GetContentSize ()));
clip = Rectangle.Intersect (clip, visibleContent);
}
@@ -445,12 +445,12 @@ public partial class View
///
///
/// The Location and Size indicate what part of the View's content, defined
- /// by , is visible and should be drawn. The coordinates taken by and
+ /// by , is visible and should be drawn. The coordinates taken by and
/// are relative to , thus if ViewPort.Location.Y is 5
/// the 6th row of the content should be drawn using MoveTo (x, 5).
///
///
- /// If is larger than ViewPort.Size drawing code should use
+ /// If is larger than ViewPort.Size drawing code should use
/// to constrain drawing for better performance.
///
///
@@ -485,7 +485,7 @@ public partial class View
// This should NOT clear
// TODO: If the output is not in the Viewport, do nothing
- var drawRect = new Rectangle (ContentToScreen (Point.Empty), ContentSize);
+ var drawRect = new Rectangle (ContentToScreen (Point.Empty), GetContentSize ());
TextFormatter?.Draw (
drawRect,
@@ -594,7 +594,7 @@ public partial class View
///
///
/// The location of is relative to the View's content, bound by Size.Empty and
- /// .
+ /// .
///
///
/// If the view has not been initialized ( is ), the area to be
diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs
index 4b203091b..e56fda674 100644
--- a/Terminal.Gui/View/ViewText.cs
+++ b/Terminal.Gui/View/ViewText.cs
@@ -37,11 +37,11 @@ public partial class View
/// to and .
///
///
- /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height
+ /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height
/// is 1, the text will be clipped.
///
/// If or are using ,
- /// the will be adjusted to fit the text.
+ /// the will be adjusted to fit the text.
/// When the text changes, the is fired.
///
public virtual string Text
@@ -84,7 +84,7 @@ public partial class View
/// redisplay the .
///
///
- /// or are using , the will be adjusted to fit the text.
+ /// or are using , the will be adjusted to fit the text.
///
/// The text alignment.
public virtual Alignment TextAlignment
@@ -103,7 +103,7 @@ public partial class View
/// .
///
///
- /// or are using , the will be adjusted to fit the text.
+ /// or are using , the will be adjusted to fit the text.
///
/// The text direction.
public virtual TextDirection TextDirection
@@ -127,7 +127,7 @@ public partial class View
/// the .
///
///
- /// or are using , the will be adjusted to fit the text.
+ /// or are using , the will be adjusted to fit the text.
///
/// The vertical text alignment.
public virtual Alignment VerticalTextAlignment
@@ -179,8 +179,8 @@ public partial class View
// We need to ensure TextFormatter is accurate by calling it here.
UpdateTextFormatterText ();
- // Default is to use ContentSize.
- var size = ContentSize;
+ // Default is to use GetContentSize ().
+ var size = GetContentSize ();
// TODO: This is a hack. Figure out how to move this into DimDimAuto
// Use _width & _height instead of Width & Height to avoid debug spew
@@ -193,12 +193,12 @@ public partial class View
if (widthAuto is null || !widthAuto.Style.FastHasFlags (DimAutoStyle.Text))
{
- size.Width = ContentSize.Width;
+ size.Width = GetContentSize ().Width;
}
if (heightAuto is null || !heightAuto.Style.FastHasFlags (DimAutoStyle.Text))
{
- size.Height = ContentSize.Height;
+ size.Height = GetContentSize ().Height;
}
}
diff --git a/Terminal.Gui/View/ViewportSettings.cs b/Terminal.Gui/View/ViewportSettings.cs
index 443d1b0ca..f0e2af75e 100644
--- a/Terminal.Gui/View/ViewportSettings.cs
+++ b/Terminal.Gui/View/ViewportSettings.cs
@@ -47,13 +47,13 @@ public enum ViewportSettings
AllowNegativeLocation = AllowNegativeX | AllowNegativeY,
///
- /// If set, .X can be set values greater than
+ /// If set, .X can be set values greater than
/// .Width enabling scrolling beyond the right
/// of the content area.
///
///
///
- /// When not set, .X is constrained to
+ /// When not set, .X is constrained to
/// .Width - 1.
/// This means the last column of the content will remain visible even if there is an attempt to scroll the
/// Viewport past the last column.
@@ -65,13 +65,13 @@ public enum ViewportSettings
AllowXGreaterThanContentWidth = 4,
///
- /// If set, .Y can be set values greater than
+ /// If set, .Y can be set values greater than
/// .Height enabling scrolling beyond the right
/// of the content area.
///
///
///
- /// When not set, .Y is constrained to
+ /// When not set, .Y is constrained to
/// .Height - 1.
/// This means the last row of the content will remain visible even if there is an attempt to scroll the Viewport
/// past the last row.
@@ -83,13 +83,13 @@ public enum ViewportSettings
AllowYGreaterThanContentHeight = 8,
///
- /// If set, .Size can be set values greater than
+ /// If set, .Size can be set values greater than
/// enabling scrolling beyond the bottom-right
/// of the content area.
///
///
///
- /// When not set, is constrained to -1.
+ /// When not set, is constrained to -1.
/// This means the last column and row of the content will remain visible even if there is an attempt to
/// scroll the Viewport past the last column or row.
///
diff --git a/Terminal.Gui/Views/ColorPicker.cs b/Terminal.Gui/Views/ColorPicker.cs
index 01383dcc7..addf7a1a4 100644
--- a/Terminal.Gui/Views/ColorPicker.cs
+++ b/Terminal.Gui/Views/ColorPicker.cs
@@ -39,7 +39,7 @@ public class ColorPicker : View
Width = Dim.Auto (minimumContentDim: _boxWidth * _cols);
Height = Dim.Auto (minimumContentDim: _boxHeight * _rows);
- ContentSize = new (_boxWidth * _cols, _boxHeight * _rows);
+ SetContentSize (new (_boxWidth * _cols, _boxHeight * _rows));
MouseClick += ColorPicker_MouseClick;
}
@@ -67,7 +67,7 @@ public class ColorPicker : View
_boxHeight = value;
Width = Dim.Auto (minimumContentDim: _boxWidth * _cols);
Height = Dim.Auto (minimumContentDim: _boxHeight * _rows);
- ContentSize = new (_boxWidth * _cols, _boxHeight * _rows);
+ SetContentSize (new (_boxWidth * _cols, _boxHeight * _rows));
SetNeedsLayout ();
}
}
@@ -84,7 +84,7 @@ public class ColorPicker : View
_boxWidth = value;
Width = Dim.Auto (minimumContentDim: _boxWidth * _cols);
Height = Dim.Auto (minimumContentDim: _boxHeight * _rows);
- ContentSize = new (_boxWidth * _cols, _boxHeight * _rows);
+ SetContentSize (new (_boxWidth * _cols, _boxHeight * _rows));
SetNeedsLayout ();
}
}
diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index 3eb630e64..048a58647 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -619,8 +619,8 @@ public class ComboBox : View
{
_search.Width = _listview.Width = _autoHide ? Viewport.Width - 1 : Viewport.Width;
_listview.Height = CalculatetHeight ();
- _search.SetRelativeLayout (ContentSize);
- _listview.SetRelativeLayout (ContentSize);
+ _search.SetRelativeLayout (GetContentSize ());
+ _listview.SetRelativeLayout (GetContentSize ());
}
}
diff --git a/Terminal.Gui/Views/DatePicker.cs b/Terminal.Gui/Views/DatePicker.cs
index ba3459ba3..d0cb41330 100644
--- a/Terminal.Gui/Views/DatePicker.cs
+++ b/Terminal.Gui/Views/DatePicker.cs
@@ -275,7 +275,7 @@ public class DatePicker : View
Height = Dim.Auto (DimAutoStyle.Content);
// BUGBUG: Remove when Dim.Auto(subviews) fully works
- ContentSize = new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1);
+ SetContentSize (new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1));
_dateField.DateChanged += DateField_DateChanged;
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 65ad03c64..bf2586185 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -264,7 +264,7 @@ public class ListView : View
}
_source = value;
- ContentSize = new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width);
+ SetContentSize (new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width));
if (IsInitialized)
{
Viewport = Viewport with { Y = 0 };
diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs
index 8739e1833..7891ce7e0 100644
--- a/Terminal.Gui/Views/Menu/MenuBar.cs
+++ b/Terminal.Gui/Views/Menu/MenuBar.cs
@@ -256,7 +256,7 @@ public class MenuBar : View
X = 0;
Y = 0;
Width = Dim.Fill ();
- Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
+ Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
Menus = new MenuBarItem [] { };
//CanFocus = true;
diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs
index e4ae3f814..8ef41aff2 100644
--- a/Terminal.Gui/Views/MessageBox.cs
+++ b/Terminal.Gui/Views/MessageBox.cs
@@ -405,7 +405,7 @@ public static class MessageBox
Size GetWrapSize ()
{
// A bit of a hack to get the height of the wrapped text.
- messageLabel.TextFormatter.Size = d.ContentSize with { Height = 1000 };
+ messageLabel.TextFormatter.Size = d.GetContentSize () with { Height = 1000 };
return messageLabel.TextFormatter.FormatAndGetSize ();
}
}
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index 7fcac2f3b..a42f6d840 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -456,7 +456,7 @@ private void SetContentSize ()
width = Math.Max (s.GetColumns () + 2, width);
}
- ContentSize = new (width, _radioLabels.Count);
+ SetContentSize (new (width, _radioLabels.Count));
break;
case Orientation.Horizontal:
@@ -471,7 +471,7 @@ private void SetContentSize ()
length = _radioLabels [i].GetColumns () + 2 + (i < _radioLabels.Count - 1 ? _horizontalSpace : 0);
_horizontal.Add ((start, length));
}
- ContentSize = new (_horizontal.Sum (item => item.length), 1);
+ SetContentSize (new (_horizontal.Sum (item => item.length), 1));
break;
}
}
diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs
index a884be638..c14d79719 100644
--- a/Terminal.Gui/Views/ScrollView.cs
+++ b/Terminal.Gui/Views/ScrollView.cs
@@ -21,7 +21,7 @@ namespace Terminal.Gui;
///
/// The subviews that are added to this are offset by the
/// property. The view itself is a window into the space represented by the
-/// .
+/// .
///
/// Use the
///
@@ -88,10 +88,10 @@ public class ScrollView : View
AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height));
AddCommand (Command.PageLeft, () => ScrollLeft (Viewport.Width));
AddCommand (Command.PageRight, () => ScrollRight (Viewport.Width));
- AddCommand (Command.TopHome, () => ScrollUp (ContentSize.Height));
- AddCommand (Command.BottomEnd, () => ScrollDown (ContentSize.Height));
- AddCommand (Command.LeftHome, () => ScrollLeft (ContentSize.Width));
- AddCommand (Command.RightEnd, () => ScrollRight (ContentSize.Width));
+ AddCommand (Command.TopHome, () => ScrollUp (GetContentSize ().Height));
+ AddCommand (Command.BottomEnd, () => ScrollDown (GetContentSize ().Height));
+ AddCommand (Command.LeftHome, () => ScrollLeft (GetContentSize ().Width));
+ AddCommand (Command.RightEnd, () => ScrollRight (GetContentSize ().Width));
// Default keybindings for this view
KeyBindings.Add (Key.CursorUp, Command.ScrollUp);
@@ -127,7 +127,7 @@ public class ScrollView : View
}
SetContentOffset (_contentOffset);
- _contentView.Frame = new Rectangle (ContentOffset, ContentSize);
+ _contentView.Frame = new Rectangle (ContentOffset, GetContentSize ());
// PERF: How about calls to Point.Offset instead?
_vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
@@ -136,13 +136,6 @@ public class ScrollView : View
ContentSizeChanged += ScrollViewContentSizeChanged;
}
- [ObsoleteAttribute ("This method is obsolete and will be removed in v2.", false)]
- public void SetContentSize (Size contentSize)
- {
- ContentSize = contentSize;
- }
-
-
private void ScrollViewContentSizeChanged (object sender, SizeChangedEventArgs e)
{
if (e.Size is null)
@@ -227,12 +220,12 @@ public class ScrollView : View
// get => ContentSize;
// set
// {
- // if (ContentSize != value)
+ // if (GetContentSize () != value)
// {
// ContentSize = value;
// _contentView.Frame = new Rectangle (_contentOffset, value);
- // _vertical.Size = ContentSize.Height;
- // _horizontal.Size = ContentSize.Width;
+ // _vertical.Size = GetContentSize ().Height;
+ // _horizontal.Size = GetContentSize ().Width;
// SetNeedsDisplay ();
// }
// }
@@ -251,26 +244,26 @@ public class ScrollView : View
_horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
Point p = default;
- if (value && -_contentOffset.X + Viewport.Width > ContentSize.Width)
+ if (value && -_contentOffset.X + Viewport.Width > GetContentSize ().Width)
{
p = new Point (
- ContentSize.Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
+ GetContentSize ().Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
-_contentOffset.Y
);
}
- if (value && -_contentOffset.Y + Viewport.Height > ContentSize.Height)
+ if (value && -_contentOffset.Y + Viewport.Height > GetContentSize ().Height)
{
if (p == default (Point))
{
p = new Point (
-_contentOffset.X,
- ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
+ GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
);
}
else
{
- p.Y = ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
+ p.Y = GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
}
}
@@ -614,7 +607,7 @@ public class ScrollView : View
{
// INTENT: Unclear intent. How about a call to Offset?
_contentOffset = new Point (-Math.Abs (offset.X), -Math.Abs (offset.Y));
- _contentView.Frame = new Rectangle (_contentOffset, ContentSize);
+ _contentView.Frame = new Rectangle (_contentOffset, GetContentSize ());
int p = Math.Max (0, -_contentOffset.Y);
if (_vertical.Position != p)
@@ -645,7 +638,7 @@ public class ScrollView : View
bool v = false, h = false;
var p = false;
- if (ContentSize is { } && (Viewport.Height == 0 || Viewport.Height > ContentSize.Height))
+ if (GetContentSize () is { } && (Viewport.Height == 0 || Viewport.Height > GetContentSize ().Height))
{
if (ShowVerticalScrollIndicator)
{
@@ -654,7 +647,7 @@ public class ScrollView : View
v = false;
}
- else if (ContentSize is { } && Viewport.Height > 0 && Viewport.Height == ContentSize.Height)
+ else if (GetContentSize () is { } && Viewport.Height > 0 && Viewport.Height == GetContentSize ().Height)
{
p = true;
}
@@ -668,7 +661,7 @@ public class ScrollView : View
v = true;
}
- if (ContentSize is { } && (Viewport.Width == 0 || Viewport.Width > ContentSize.Width))
+ if (GetContentSize () is { } && (Viewport.Width == 0 || Viewport.Width > GetContentSize ().Width))
{
if (ShowHorizontalScrollIndicator)
{
@@ -677,7 +670,7 @@ public class ScrollView : View
h = false;
}
- else if (ContentSize is { } && Viewport.Width > 0 && Viewport.Width == ContentSize.Width && p)
+ else if (GetContentSize () is { } && Viewport.Width > 0 && Viewport.Width == GetContentSize ().Width && p)
{
if (ShowHorizontalScrollIndicator)
{
diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs
index 095ce4210..c42247299 100644
--- a/Terminal.Gui/Views/Slider.cs
+++ b/Terminal.Gui/Views/Slider.cs
@@ -464,7 +464,7 @@ public class Slider : View
CalcSpacingConfig (horizontal ? Viewport.Width : Viewport.Height);
}
- ContentSize = new (GetIdealWidth (), GetIdealHeight ());
+ SetContentSize (new (GetIdealWidth (), GetIdealHeight ()));
return;
diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs
index 71208e034..0105610e3 100644
--- a/Terminal.Gui/Views/StatusBar.cs
+++ b/Terminal.Gui/Views/StatusBar.cs
@@ -93,7 +93,7 @@ public class StatusBar : View
X = 0;
Y = Pos.AnchorEnd (1);
Width = Dim.Fill ();
- Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
+ Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
AddCommand (Command.Accept, InvokeItem);
}
diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs
index 52036e1e9..381268711 100644
--- a/Terminal.Gui/Views/TabView.cs
+++ b/Terminal.Gui/Views/TabView.cs
@@ -564,7 +564,7 @@ public class TabView : View
_host = host;
CanFocus = true;
- Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
+ Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
Width = Dim.Fill ();
_rightScrollIndicator = new View
diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs
index e1ecff50f..5eb586aa1 100644
--- a/UICatalog/Scenarios/ASCIICustomButton.cs
+++ b/UICatalog/Scenarios/ASCIICustomButton.cs
@@ -270,7 +270,7 @@ public class ASCIICustomButtonTest : Scenario
case KeyCode.End:
_scrollView.ContentOffset = new Point (
_scrollView.ContentOffset.X,
- -(_scrollView.ContentSize.Height
+ -(_scrollView.GetContentSize ().Height
- _scrollView.Frame.Height
+ (_scrollView.ShowHorizontalScrollIndicator ? 1 : 0))
);
@@ -288,7 +288,7 @@ public class ASCIICustomButtonTest : Scenario
Math.Max (
_scrollView.ContentOffset.Y
- _scrollView.Frame.Height,
- -(_scrollView.ContentSize.Height
+ -(_scrollView.GetContentSize ().Height
- _scrollView.Frame.Height
+ (_scrollView.ShowHorizontalScrollIndicator
? 1
diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs
index 8a45b2e2a..02c11da5c 100644
--- a/UICatalog/Scenarios/CharacterMap.cs
+++ b/UICatalog/Scenarios/CharacterMap.cs
@@ -328,7 +328,7 @@ internal class CharMap : View
CanFocus = true;
CursorVisibility = CursorVisibility.Default;
- ContentSize = new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight);
+ SetContentSize (new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight));
AddCommand (
Command.ScrollUp,
diff --git a/UICatalog/Scenarios/Clipping.cs b/UICatalog/Scenarios/Clipping.cs
index 2e30253ab..94cfc4751 100644
--- a/UICatalog/Scenarios/Clipping.cs
+++ b/UICatalog/Scenarios/Clipping.cs
@@ -23,7 +23,7 @@ public class Clipping : Scenario
//Win.Height = Dim.Fill () - 2;
var label = new Label
{
- X = 0, Y = 0, Text = "ScrollView (new Rectangle (3, 3, 50, 20)) with a 200, 100 ContentSize..."
+ X = 0, Y = 0, Text = "ScrollView (new Rectangle (3, 3, 50, 20)) with a 200, 100 GetContentSize ()..."
};
Top.Add (label);
diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ContentScrolling.cs
index c08870f25..9bad9bd99 100644
--- a/UICatalog/Scenarios/ContentScrolling.cs
+++ b/UICatalog/Scenarios/ContentScrolling.cs
@@ -5,7 +5,7 @@ using Terminal.Gui;
namespace UICatalog.Scenarios;
-[ScenarioMetadata ("Content Scrolling", "Demonstrates using View.Viewport and View.ContentSize to scroll content.")]
+[ScenarioMetadata ("Content Scrolling", "Demonstrates using View.Viewport and View.GetContentSize () to scroll content.")]
[ScenarioCategory ("Layout")]
[ScenarioCategory ("Drawing")]
[ScenarioCategory ("Scrolling")]
@@ -27,7 +27,7 @@ public class ContentScrolling : Scenario
BorderStyle = LineStyle.Rounded;
Arrangement = ViewArrangement.Fixed;
- ContentSize = new (60, 40);
+ SetContentSize (new (60, 40));
ViewportSettings |= ViewportSettings.ClearContentOnly;
ViewportSettings |= ViewportSettings.ClipContentOnly;
@@ -52,12 +52,6 @@ public class ContentScrolling : Scenario
MouseEvent += VirtualDemoView_MouseEvent;
}
- [ObsoleteAttribute ("This method is obsolete and will be removed in v2.", false)]
- public void SetContentSize (Size contentSize)
- {
- ContentSize = contentSize;
- }
-
private void VirtualDemoView_MouseEvent (object sender, MouseEventEventArgs e)
{
if (e.MouseEvent.Flags == MouseFlags.WheeledDown)
@@ -93,7 +87,7 @@ public class ContentScrolling : Scenario
if (status is { })
{
- status.Title = $"Frame: {Frame}\n\nViewport: {Viewport}, ContentSize = {ContentSize}";
+ status.Title = $"Frame: {Frame}\n\nViewport: {Viewport}, ContentSize = {GetContentSize ()}";
status.Width = Border.Frame.Width - status.Frame.X - Border.Thickness.Right;
status.Height = Border.Thickness.Top;
}
@@ -237,7 +231,7 @@ public class ContentScrolling : Scenario
Buttons.NumericUpDown contentSizeWidth = new Buttons.NumericUpDown
{
- Value = view.ContentSize.Width,
+ Value = view.GetContentSize ().Width,
X = Pos.Right (labelContentSize) + 1,
Y = Pos.Top (labelContentSize)
};
@@ -252,7 +246,7 @@ public class ContentScrolling : Scenario
return;
}
// BUGBUG: set_ContentSize is supposed to be `protected`.
- view.SetContentSize (view.ContentSize with { Width = e.NewValue });
+ view.SetContentSize (view.GetContentSize () with { Width = e.NewValue });
}
var labelComma = new Label
@@ -264,7 +258,7 @@ public class ContentScrolling : Scenario
Buttons.NumericUpDown contentSizeHeight = new Buttons.NumericUpDown
{
- Value = view.ContentSize.Height,
+ Value = view.GetContentSize ().Height,
X = Pos.Right (labelComma) + 1,
Y = Pos.Top (labelContentSize),
CanFocus = false
@@ -280,7 +274,7 @@ public class ContentScrolling : Scenario
return;
}
// BUGBUG: set_ContentSize is supposed to be `protected`.
- view.SetContentSize (view.ContentSize with { Height = e.NewValue });
+ view.SetContentSize (view.GetContentSize () with { Height = e.NewValue });
}
var cbClearOnlyVisible = new CheckBox
@@ -362,7 +356,7 @@ public class ContentScrolling : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (textView) + 1,
- Width = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Func (() => view.ContentSize.Width)),
+ Width = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Func (() => view.GetContentSize ().Width)),
Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Percent (20)),
};
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index 50434772f..c9af1da10 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -48,7 +48,7 @@ public class Scrolling : Scenario
scrollView.SetContentSize (new (120, 40));
scrollView.Padding.Thickness = new (1);
- label.Text = $"{scrollView}\nContentSize: {scrollView.ContentSize}\nContentOffset: {scrollView.ContentOffset}";
+ label.Text = $"{scrollView}\nContentSize: {scrollView.GetContentSize ()}\nContentOffset: {scrollView.ContentOffset}";
const string rule = "0123456789";
diff --git a/UnitTests/Application/MouseTests.cs b/UnitTests/Application/MouseTests.cs
index eaa42138b..458689008 100644
--- a/UnitTests/Application/MouseTests.cs
+++ b/UnitTests/Application/MouseTests.cs
@@ -236,7 +236,7 @@ public class MouseTests
{
var tf = new TextField { Width = 10 };
var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill () };
- sv.ContentSize = new (100, 100);
+ sv.SetContentSize (new (100, 100));
sv.Add (tf);
var top = new Toplevel ();
diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs
index 339f7d096..b11ad3fa8 100644
--- a/UnitTests/View/DrawTests.cs
+++ b/UnitTests/View/DrawTests.cs
@@ -921,7 +921,7 @@ public class DrawTests (ITestOutputHelper _output)
Height = Dim.Fill (),
ViewportSettings = ViewportSettings.ClipContentOnly
};
- view.ContentSize = new Size (10, 10);
+ view.SetContentSize (new Size (10, 10));
view.Border.Thickness = new Thickness (1);
view.BeginInit ();
view.EndInit ();
@@ -953,7 +953,7 @@ public class DrawTests (ITestOutputHelper _output)
Width = Dim.Fill (),
Height = Dim.Fill (),
};
- view.ContentSize = new Size (10, 10);
+ view.SetContentSize (new Size (10, 10));
view.Border.Thickness = new Thickness (1);
view.BeginInit ();
view.EndInit ();
diff --git a/UnitTests/View/FindDeepestViewTests.cs b/UnitTests/View/FindDeepestViewTests.cs
index 1273867d3..c6ea6fa06 100644
--- a/UnitTests/View/FindDeepestViewTests.cs
+++ b/UnitTests/View/FindDeepestViewTests.cs
@@ -470,7 +470,7 @@ public class FindDeepestViewTests ()
subview.Padding.Thickness = new (1);
// Scroll the subview
- subview.ContentSize = new (10, 10);
+ subview.SetContentSize (new (10, 10));
subview.Viewport = subview.Viewport with { Location = new (1, 1) };
// This subview will be at the bottom-right-corner of subview
diff --git a/UnitTests/View/Layout/Dim.AutoTests.cs b/UnitTests/View/Layout/Dim.AutoTests.cs
index 9abf6b315..6ad50ed16 100644
--- a/UnitTests/View/Layout/Dim.AutoTests.cs
+++ b/UnitTests/View/Layout/Dim.AutoTests.cs
@@ -83,7 +83,7 @@ public class DimAutoTests (ITestOutputHelper output)
ValidatePosDim = true
};
- view.ContentSize = new (contentSize, 0);
+ view.SetContentSize (new (contentSize, 0));
Assert.Equal (expected, view.Frame.Width);
}
@@ -102,7 +102,7 @@ public class DimAutoTests (ITestOutputHelper output)
ValidatePosDim = true
};
- view.ContentSize = new (contentSize, 0);
+ view.SetContentSize (new (contentSize, 0));
view.SetRelativeLayout (new (100, 100));
Assert.Equal (expected, view.Frame.Width);
@@ -124,7 +124,7 @@ public class DimAutoTests (ITestOutputHelper output)
ValidatePosDim = true
};
- view.ContentSize = new (contentSize, 0);
+ view.SetContentSize (new (contentSize, 0));
view.SetRelativeLayout (new (100, 100));
Assert.Equal (expected, view.Frame.Width);
@@ -671,7 +671,7 @@ public class DimAutoTests (ITestOutputHelper output)
superView.BeginInit ();
superView.EndInit ();
- superView.SetRelativeLayout (superView.ContentSize);
+ superView.SetRelativeLayout (superView.GetContentSize ());
superView.LayoutSubviews ();
Assert.Equal (expectedSubWidth, subView.Frame.Width);
@@ -720,7 +720,7 @@ public class DimAutoTests (ITestOutputHelper output)
superView.BeginInit ();
superView.EndInit ();
- superView.SetRelativeLayout (superView.ContentSize);
+ superView.SetRelativeLayout (superView.GetContentSize ());
superView.LayoutSubviews ();
Assert.Equal (expectedSubWidth, subView.Frame.Width);
@@ -745,7 +745,7 @@ public class DimAutoTests (ITestOutputHelper output)
super.Add (view);
Rectangle expectedViewport = new (0, 0, 8, 1);
- Assert.Equal (expectedViewport.Size, view.ContentSize);
+ Assert.Equal (expectedViewport.Size, view.GetContentSize ());
Assert.Equal (expectedViewport, view.Frame);
Assert.Equal (expectedViewport, view.Viewport);
@@ -766,7 +766,7 @@ public class DimAutoTests (ITestOutputHelper output)
var view = new View ();
view.Width = Auto (DimAutoStyle.Text);
view.Height = Auto (DimAutoStyle.Text);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.Text = text;
Assert.Equal (new (expectedW, expectedH), view.TextFormatter.Size);
}
@@ -943,19 +943,19 @@ public class DimAutoTests (ITestOutputHelper output)
};
Assert.Equal (new Rectangle (0, 0, 5, 1), view.Frame);
- Assert.Equal (new Size (5, 1), view.ContentSize);
+ Assert.Equal (new Size (5, 1), view.GetContentSize ());
// Change text to a longer string
view.Text = "0123456789";
Assert.Equal (new Rectangle (0, 0, 10, 1), view.Frame);
- Assert.Equal (new Size (10, 1), view.ContentSize);
+ Assert.Equal (new Size (10, 1), view.GetContentSize ());
// If ContentSize was reset, these should cause it to update
view.Width = 5;
view.Height = 1;
- Assert.Equal (new Size (5, 1), view.ContentSize);
+ Assert.Equal (new Size (5, 1), view.GetContentSize ());
}
// DimAutoStyle.Content tests
@@ -963,7 +963,7 @@ public class DimAutoTests (ITestOutputHelper output)
public void DimAutoStyle_Content_UsesContentSize_WhenSet ()
{
var view = new View ();
- view.ContentSize = new (10, 5);
+ view.SetContentSize (new (10, 5));
var dim = Dim.Auto (DimAutoStyle.Content);
@@ -979,7 +979,7 @@ public class DimAutoTests (ITestOutputHelper output)
var subview = new View () {
Frame = new Rectangle (50, 50, 1, 1)
};
- view.ContentSize = new (10, 5);
+ view.SetContentSize (new (10, 5));
var dim = Dim.Auto (DimAutoStyle.Content);
@@ -1315,7 +1315,7 @@ public class DimAutoTests (ITestOutputHelper output)
public void DimAutoStyle_Content_UsesContentSize_If_No_Subviews ()
{
DimAutoTestView view = new (Auto (DimAutoStyle.Content), Auto (DimAutoStyle.Content));
- view.ContentSize = new (5, 5);
+ view.SetContentSize (new (5, 5));
view.SetRelativeLayout (new (10, 10));
Assert.Equal (new (5, 5), view.Frame.Size);
diff --git a/UnitTests/View/Layout/LayoutTests.cs b/UnitTests/View/Layout/LayoutTests.cs
index 21a108259..d965e90e9 100644
--- a/UnitTests/View/Layout/LayoutTests.cs
+++ b/UnitTests/View/Layout/LayoutTests.cs
@@ -123,7 +123,7 @@ public class LayoutTests (ITestOutputHelper output)
Width = 5,
Height = 5,
};
- superView.ContentSize = new (10, 10);
+ superView.SetContentSize (new (10, 10));
var view = new View ()
{
X = Pos.Center ()
diff --git a/UnitTests/View/Layout/ScreenToTests.cs b/UnitTests/View/Layout/ScreenToTests.cs
index c6d75e806..43b60ad99 100644
--- a/UnitTests/View/Layout/ScreenToTests.cs
+++ b/UnitTests/View/Layout/ScreenToTests.cs
@@ -108,7 +108,7 @@ public class ScreenToTests
BorderStyle = LineStyle.Single,
};
var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };
- view.ContentSize = new (6, 6);
+ view.SetContentSize (new (6, 6));
super.Add (view);
view.Viewport = new (1, 1, 5, 5);
@@ -164,7 +164,7 @@ public class ScreenToTests
X = viewX, Y = viewY, Width = 5, Height = 5,
BorderStyle = LineStyle.Single,
};
- view.ContentSize = new (10, 10);
+ view.SetContentSize (new (10, 10));
super.Add (view);
view.Viewport = view.Viewport with { Location = new (1, 1) };
diff --git a/UnitTests/View/Layout/ToScreenTests.cs b/UnitTests/View/Layout/ToScreenTests.cs
index f9b5dc65a..2524b0727 100644
--- a/UnitTests/View/Layout/ToScreenTests.cs
+++ b/UnitTests/View/Layout/ToScreenTests.cs
@@ -336,7 +336,7 @@ public class ToScreenTests (ITestOutputHelper output)
Width = 10,
Height = 10
};
- view.ContentSize = new (20, 20);
+ view.SetContentSize (new (20, 20));
Point testPoint = new (0, 0);
Assert.Equal (new Point (1, 1), view.ContentToScreen (testPoint));
@@ -362,7 +362,7 @@ public class ToScreenTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.ContentSize = new (20, 20);
+ view.SetContentSize (new (20, 20));
view.BorderStyle = LineStyle.Single;
// Act
@@ -403,7 +403,7 @@ public class ToScreenTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.ContentSize = new (20, 20);
+ view.SetContentSize (new (20, 20));
superView.Add (view);
superView.LayoutSubviews ();
@@ -608,7 +608,7 @@ public class ToScreenTests (ITestOutputHelper output)
// var view = new View ();
// view.Frame = frame;
- // view.ContentSize = new (11, 11);
+ // view.SetContentSize (new (11, 11));
// view.Content = view.Content with { Location = new (1, 1) };
// superView.Add (view);
@@ -928,7 +928,7 @@ public class ToScreenTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.ContentSize = new (11, 11);
+ view.SetContentSize (new (11, 11));
view.Viewport = view.Viewport with { Location = new (1, 1) };
superView.Add (view);
diff --git a/UnitTests/View/Layout/ViewportTests.cs b/UnitTests/View/Layout/ViewportTests.cs
index 8a2126303..29c04502c 100644
--- a/UnitTests/View/Layout/ViewportTests.cs
+++ b/UnitTests/View/Layout/ViewportTests.cs
@@ -279,7 +279,7 @@ public class ViewportTests (ITestOutputHelper output)
{
// Arrange
var view = new View ();
- view.ContentSize = new (100, 100);
+ view.SetContentSize (new (100, 100));
var newViewport = new Rectangle (0, 0, 200, 200);
view.ViewportSettings = ViewportSettings.AllowLocationGreaterThanContentSize;
@@ -348,7 +348,7 @@ public class ViewportTests (ITestOutputHelper output)
Height = 1
};
Assert.True (view.ContentSizeTracksViewport);
- Assert.Equal (view.Viewport.Size, view.ContentSize);
+ Assert.Equal (view.Viewport.Size, view.GetContentSize ());
}
[Fact]
@@ -358,10 +358,10 @@ public class ViewportTests (ITestOutputHelper output)
{
Width = 1,
Height = 1,
- ContentSize = new Size (5, 5)
};
+ view.SetContentSize (new Size (5, 5));
Assert.False (view.ContentSizeTracksViewport);
- Assert.NotEqual (view.Viewport.Size, view.ContentSize);
+ Assert.NotEqual (view.Viewport.Size, view.GetContentSize ());
}
[Fact]
@@ -371,11 +371,11 @@ public class ViewportTests (ITestOutputHelper output)
{
Width = 1,
Height = 1,
- ContentSize = new Size (5, 5)
};
+ view.SetContentSize (new Size (5, 5));
view.Viewport = new (0, 0, 10, 10);
view.ContentSizeTracksViewport = true;
- Assert.Equal (view.Viewport.Size, view.ContentSize);
+ Assert.Equal (view.Viewport.Size, view.GetContentSize ());
}
@@ -386,11 +386,11 @@ public class ViewportTests (ITestOutputHelper output)
{
Width = 1,
Height = 1,
- ContentSize = new Size (5, 5)
};
+ view.SetContentSize (new Size (5, 5));
view.Viewport = new (0, 0, 10, 10);
view.ContentSizeTracksViewport = false;
- Assert.NotEqual (view.Viewport.Size, view.ContentSize);
+ Assert.NotEqual (view.Viewport.Size, view.GetContentSize ());
}
//[Theory]
diff --git a/UnitTests/View/SubviewTests.cs b/UnitTests/View/SubviewTests.cs
index 768b5d1ea..c55afe104 100644
--- a/UnitTests/View/SubviewTests.cs
+++ b/UnitTests/View/SubviewTests.cs
@@ -338,7 +338,7 @@ public class SubviewTests
public void Add_Does_Not_Impact_ContentSize ()
{
var view = new View ();
- view.ContentSize = new Size (1, 1);
+ view.SetContentSize (new Size (1, 1));
var subview = new View ()
{
@@ -346,16 +346,16 @@ public class SubviewTests
Y = 10
};
- Assert.Equal (new Size (1, 1), view.ContentSize);
+ Assert.Equal (new Size (1, 1), view.GetContentSize ());
view.Add (subview);
- Assert.Equal (new Size (1, 1), view.ContentSize);
+ Assert.Equal (new Size (1, 1), view.GetContentSize ());
}
[Fact]
public void Remove_Does_Not_Impact_ContentSize ()
{
var view = new View ();
- view.ContentSize = new Size (1, 1);
+ view.SetContentSize (new Size (1, 1));
var subview = new View ()
{
@@ -363,14 +363,14 @@ public class SubviewTests
Y = 10
};
- Assert.Equal (new Size (1, 1), view.ContentSize);
+ Assert.Equal (new Size (1, 1), view.GetContentSize ());
view.Add (subview);
- Assert.Equal (new Size (1, 1), view.ContentSize);
+ Assert.Equal (new Size (1, 1), view.GetContentSize ());
- view.ContentSize = new Size (5, 5);
- Assert.Equal (new Size (5, 5), view.ContentSize);
+ view.SetContentSize (new Size (5, 5));
+ Assert.Equal (new Size (5, 5), view.GetContentSize ());
view.Remove (subview);
- Assert.Equal (new Size (5, 5), view.ContentSize);
+ Assert.Equal (new Size (5, 5), view.GetContentSize ());
}
}
diff --git a/UnitTests/View/TextTests.cs b/UnitTests/View/TextTests.cs
index e4bcc84ee..05b896d72 100644
--- a/UnitTests/View/TextTests.cs
+++ b/UnitTests/View/TextTests.cs
@@ -32,7 +32,7 @@ public class TextTests (ITestOutputHelper output)
public void TextFormatter_Size_Tracks_ContentSize (string text, int expectedW, int expectedH)
{
var view = new View ();
- view.ContentSize = new (1,1);
+ view.SetContentSize (new (1,1));
view.Text = text;
Assert.Equal (new (expectedW, expectedH), view.TextFormatter.Size);
}
diff --git a/UnitTests/View/TitleTests.cs b/UnitTests/View/TitleTests.cs
index 7f55e1293..cee5120cc 100644
--- a/UnitTests/View/TitleTests.cs
+++ b/UnitTests/View/TitleTests.cs
@@ -102,7 +102,7 @@ public class TitleTests (ITestOutputHelper output)
Assert.Equal (text, view.Text);
// SetupFakeDriver only create a screen with 25 cols and 25 rows
- Assert.Equal (new (text.Length, 1), view.ContentSize);
+ Assert.Equal (new (text.Length, 1), view.GetContentSize ());
top.Dispose ();
}
diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs
index 51e1faaea..5e99c4e2b 100644
--- a/UnitTests/Views/ButtonTests.cs
+++ b/UnitTests/Views/ButtonTests.cs
@@ -62,7 +62,7 @@ public class ButtonTests (ITestOutputHelper output)
Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
- Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.ContentSize);
+ Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.GetContentSize ());
Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
btn1.Dispose ();
@@ -204,7 +204,7 @@ public class ButtonTests (ITestOutputHelper output)
Assert.Equal ('_', btn.HotKeySpecifier.Value);
Assert.Equal (10, btn.TextFormatter.Format ().Length);
Assert.Equal (new (10, 1), btn.TextFormatter.Size);
- Assert.Equal (new (10, 1), btn.ContentSize);
+ Assert.Equal (new (10, 1), btn.GetContentSize ());
Assert.Equal (new (0, 0, 10, 1), btn.Viewport);
Assert.Equal (new (0, 0, 10, 1), btn.Frame);
Assert.Equal (KeyCode.T, btn.HotKey);
diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs
index c658fd39b..0a7afd9f5 100644
--- a/UnitTests/Views/ScrollViewTests.cs
+++ b/UnitTests/Views/ScrollViewTests.cs
@@ -12,14 +12,14 @@ public class ScrollViewTests
public void Adding_Views ()
{
var sv = new ScrollView { Width = 20, Height = 10 };
- sv.ContentSize = new (30, 20);
+ sv.SetContentSize (new (30, 20));
sv.Add (
new View { Width = 10, Height = 5 },
new View { X = 12, Y = 7, Width = 10, Height = 5 }
);
- Assert.Equal (new (30, 20), sv.ContentSize);
+ Assert.Equal (new (30, 20), sv.GetContentSize ());
Assert.Equal (2, sv.Subviews [0].Subviews.Count);
}
@@ -187,7 +187,7 @@ public class ScrollViewTests
Height = 10,
KeepContentAlwaysInViewport = false
};
- sv.ContentSize = new (23, 23);
+ sv.SetContentSize (new (23, 23));
var bottomLabel = new Label { X = 15, Y = 15, Text = "At 15,15" };
var top = new Toplevel ();
top.Add (topLabel, sv, bottomLabel);
@@ -346,7 +346,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (0, 0, 0, 0), sv.Frame);
Assert.Equal (Rectangle.Empty, sv.Frame);
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.Equal (Size.Empty, sv.ContentSize);
+ Assert.Equal (Size.Empty, sv.GetContentSize ());
Assert.True (sv.AutoHideScrollBars);
Assert.True (sv.KeepContentAlwaysInViewport);
@@ -355,7 +355,7 @@ public class ScrollViewTests
Assert.True (sv.CanFocus);
Assert.Equal (new Rectangle (1, 2, 20, 10), sv.Frame);
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.Equal (sv.Viewport.Size, sv.ContentSize);
+ Assert.Equal (sv.Viewport.Size, sv.GetContentSize ());
Assert.True (sv.AutoHideScrollBars);
Assert.True (sv.KeepContentAlwaysInViewport);
}
@@ -378,7 +378,7 @@ public class ScrollViewTests
Height = 5,
ColorScheme = new ColorScheme { Normal = new Attribute (Color.Red, Color.Green) }
};
- sv.ContentSize = size;
+ sv.SetContentSize (size);
string text = null;
for (var i = 0; i < size.Height; i++)
@@ -447,7 +447,7 @@ public class ScrollViewTests
{
Width = 10, Height = 10,
};
- sv.ContentSize = new (50, 50);
+ sv.SetContentSize (new (50, 50));
sv.ContentOffset = new (25, 25);
var top = new Toplevel ();
@@ -455,7 +455,7 @@ public class ScrollViewTests
Application.Begin (top);
Assert.Equal (new (-25, -25), sv.ContentOffset);
- Assert.Equal (new (50, 50), sv.ContentSize);
+ Assert.Equal (new (50, 50), sv.GetContentSize ());
Assert.True (sv.AutoHideScrollBars);
Assert.True (sv.ShowHorizontalScrollIndicator);
Assert.True (sv.ShowVerticalScrollIndicator);
@@ -482,14 +482,14 @@ public class ScrollViewTests
public void ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
{
var sv = new ScrollView { Width = 10, Height = 10, };
- sv.ContentSize = new (50, 50);
+ sv.SetContentSize (new (50, 50));
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
- Assert.Equal (50, sv.ContentSize.Width);
- Assert.Equal (50, sv.ContentSize.Height);
+ Assert.Equal (50, sv.GetContentSize ().Width);
+ Assert.Equal (50, sv.GetContentSize ().Height);
Assert.True (sv.AutoHideScrollBars);
Assert.True (sv.ShowHorizontalScrollIndicator);
Assert.True (sv.ShowVerticalScrollIndicator);
@@ -546,7 +546,7 @@ public class ScrollViewTests
ShowHorizontalScrollIndicator = true,
ShowVerticalScrollIndicator = true
};
- scrollView.ContentSize = size;
+ scrollView.SetContentSize (size);
scrollView.Add (view);
var win = new Window { X = 1, Y = 1, Width = 20, Height = 14 };
win.Add (scrollView);
@@ -871,7 +871,7 @@ public class ScrollViewTests
Width = 10,
Height = 10,
};
- sv.ContentSize = new (50, 50);
+ sv.SetContentSize (new (50, 50));
for (var i = 0; i < 8; i++)
{
@@ -921,7 +921,7 @@ public class ScrollViewTests
public void KeyBindings_Command ()
{
var sv = new ScrollView { Width = 20, Height = 10, };
- sv.ContentSize = new (40, 20);
+ sv.SetContentSize (new (40, 20));
sv.Add (
new View { Width = 20, Height = 5 },
@@ -1056,7 +1056,7 @@ public class ScrollViewTests
public void Remove_Added_View_Is_Allowed ()
{
var sv = new ScrollView { Width = 20, Height = 20, };
- sv.ContentSize = new (100, 100);
+ sv.SetContentSize (new (100, 100));
sv.Add (
new View { Width = Dim.Fill (), Height = Dim.Fill (50), Id = "View1" },
diff --git a/UnitTests/Views/SliderTests.cs b/UnitTests/Views/SliderTests.cs
index 3e3e532fc..3f1298726 100644
--- a/UnitTests/Views/SliderTests.cs
+++ b/UnitTests/Views/SliderTests.cs
@@ -175,7 +175,7 @@ public class SliderTests
// 0123456789
// 1 2 3
Assert.Equal (1, slider.MinimumInnerSpacing);
- Assert.Equal (new Size (5, 2), slider.ContentSize);
+ Assert.Equal (new Size (5, 2), slider.GetContentSize ());
Assert.Equal (new Size (5, 2), slider.Frame.Size);
Assert.NotNull (slider);
Assert.NotNull (slider.Options);
@@ -519,7 +519,7 @@ public class SliderTests
Assert.Equal (new (6, 3), expectedSize);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.LayoutSubviews ();
slider.SetRelativeLayout (view.Viewport.Size);
@@ -552,7 +552,7 @@ public class SliderTests
Assert.Equal (new (6, 10), expectedSize);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.LayoutSubviews ();
slider.SetRelativeLayout (view.Viewport.Size);
@@ -585,7 +585,7 @@ public class SliderTests
Assert.Equal (new (10, 3), expectedSize);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.LayoutSubviews ();
slider.SetRelativeLayout (view.Viewport.Size);
diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs
index 637898b3a..62f4580fc 100644
--- a/UnitTests/Views/ToplevelTests.cs
+++ b/UnitTests/Views/ToplevelTests.cs
@@ -1321,7 +1321,7 @@ public class ToplevelTests
Width = 40,
Height = 16,
};
- scrollView.ContentSize = new (200, 100);
+ scrollView.SetContentSize (new (200, 100));
var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), Arrangement = ViewArrangement.Movable };
scrollView.Add (win);
Toplevel top = new ();
diff --git a/docfx/docs/dimauto.md b/docfx/docs/dimauto.md
index 419fe300b..e138348d5 100644
--- a/docfx/docs/dimauto.md
+++ b/docfx/docs/dimauto.md
@@ -7,7 +7,7 @@ Like all `Dim` types, `Dim.Auto` is used to set the `Width` or `Height` of a vie
The `DimAutoStyle` enum defines the different ways that `Dim.Auto` can be used to size a view. The `DimAutoStyle` enum has the following values:
* `Text` - The view is sized based on the `Text` property and `TextFormatter` settings.
-* `Content` - The view is sized based on either the `ContentSize` or the `Subviews` property. If `ContentSize` is not explicitly set (via `View.SetContentSize()`), the view is sized based on the Subview with the largest relvant dimension plus location. If `ContentSize` is explicitly set, the view is sized based on the `ContentSize`.
+* `Content` - The view is sized based on either the value returned by `View.SetContentSize()` or the `Subviews` property. If the content size is not explicitly set (via `View.SetContentSize()`), the view is sized based on the Subview with the largest relvant dimension plus location. If the content size is explicitly set, the view is sized based on the value returned by `View.SetContentSize()`.
* `Auto` - The view is sized based on both the text and content, whichever is larger.
## Using Dim.Auto
@@ -113,6 +113,6 @@ view.Add (slider);
Note the developer does not need to specify the size of the `Slider`, it will size itself based on the number of options and the orientation.
-Views like `Slider` do this by setting `Width` and `Height` to `Dim.Auto (DimAutoStyle.Content)` in the constructor and calling `SetContentSize ()` whenever the desired content size changes. The View will then be sized to be big enough to fit the content.
+Views like `Slider` do this by setting `Width` and `Height` to `Dim.Auto (DimAutoStyle.Content)` in the constructor and calling `SetContentSize()` whenever the desired content size changes. The View will then be sized to be big enough to fit the content.
Views that use `Text` for their content can just set `Width` and `Height` to `Dim.Auto (DimAutoStyle.Text)`. It is recommended to use `Height = Dim.Auto (DimAutoStyle.Text, minimumContentDim: 1)` to ensure the View can show at least one line of text.
diff --git a/docfx/docs/layout.md b/docfx/docs/layout.md
index 56c94b5d9..fb7d0f012 100644
--- a/docfx/docs/layout.md
+++ b/docfx/docs/layout.md
@@ -7,22 +7,22 @@ Terminal.Gui provides a rich system for how `View` objects are laid out relative
* **Screen-Relative** - Describes the dimensions and characteristics of the underlying terminal. Currently Terminal.Gui only supports applications that run "full-screen", meaning they fill the entire terminal when running. As the user resizes their terminal, the `Screen` changes size and the applicaiton will be resized to fit. *Screen-Relative* means an origin (`0, 0`) at the top-left corner of the terminal. `ConsoleDriver`s operate exclusively on *Screen-Relative* coordinates.
* **Application.Relative** - The dimensions and characteristics of the application. Because only full-screen apps are currently supported, `Application` is effectively the same as `Screen` from a layout perspective. *Application-Relative* currently means an origin (`0, 0`) at the top-left corner of the terminal. `Applicaiton.Top` is a `View` with a top-left corner fixed at the *Application.Relative* coordinate of (`0, 0`) and is the size of `Screen`.
* **Frame-Relative** - The `Frame` property of a `View` is a rectangle that describes the current location and size of the view relative to the `Superview`'s content area. *Frame-Relative* means a coordinate is relative to the top-left corner of the View in question. `View.FrameToScreen ()` and `View.ScreenToFrame ()` are helper methods for translating a *Frame-Relative* coordinate to a *Screen-Relative* coordinate and vice-versa.
-* **Content-Relative** - A rectangle, with an origin of (`0, 0`) and size (defined by `View.ContentSize`) where the View's content exists. *Content-Relative* means a coordinate is relative to the top-left corner of the content, which is always (`0,0`). `View.ContentToScreen ()` and `View.ScreenToContent ()` are helper methods for translating a *Content-Relative* coordinate to a *Screen-Relative* coordinate and vice-versa.
-* **Viewport-Relative** - A *Content-Relative* rectangle representing the subset of the View's content that is visible to the user. If `View.ContentSize` is larger than the Viewport, scrolling is enabled. *Viewport-Relative* means a coordinate that is bound by (`0,0`) and the size of the inner-rectangle of the View's `Padding`. The View drawing primitives (e.g. `View.Move`) take *Viewport-Relative* coordinates; `Move (0, 0)` means the `Cell` in the top-left corner of the inner rectangle of `Padding`. `View.ViewportToScreen ()` and `View.ScreenToViewport ()` are helper methods for translating a *Viewport-Relative* coordinate to a *Screen-Relative* coordinate and vice-versa. To convert a *Viewport-Relative* coordinate to a *Content-Relative* coordinate, simply subtract `Viewport.X` and/or `Viewport.Y` from the *Content-Relative* coordinate. To convert a *Viewport-Relative* coordinate to a *Frame-Relative* coordinate, subtract the point returned by `View.GetViewportOffsetFromFrame`.
+* **Content-Relative** - A rectangle, with an origin of (`0, 0`) and size (defined by `View.GetContentSize()`) where the View's content exists. *Content-Relative* means a coordinate is relative to the top-left corner of the content, which is always (`0,0`). `View.ContentToScreen ()` and `View.ScreenToContent ()` are helper methods for translating a *Content-Relative* coordinate to a *Screen-Relative* coordinate and vice-versa.
+* **Viewport-Relative** - A *Content-Relative* rectangle representing the subset of the View's content that is visible to the user. If `View.GetContentSize()` is larger than the Viewport, scrolling is enabled. *Viewport-Relative* means a coordinate that is bound by (`0,0`) and the size of the inner-rectangle of the View's `Padding`. The View drawing primitives (e.g. `View.Move`) take *Viewport-Relative* coordinates; `Move (0, 0)` means the `Cell` in the top-left corner of the inner rectangle of `Padding`. `View.ViewportToScreen ()` and `View.ScreenToViewport ()` are helper methods for translating a *Viewport-Relative* coordinate to a *Screen-Relative* coordinate and vice-versa. To convert a *Viewport-Relative* coordinate to a *Content-Relative* coordinate, simply subtract `Viewport.X` and/or `Viewport.Y` from the *Content-Relative* coordinate. To convert a *Viewport-Relative* coordinate to a *Frame-Relative* coordinate, subtract the point returned by `View.GetViewportOffsetFromFrame`.
## The Frame
-The `Frame` property of a `View` is a rectangle that describes the current location and size of the view relative to the `Superview`'s content area. The `Frame` has a `Location` and `Size`. The `Location` describes the top-left corner of the view relative to the `Superview`'s content area. The `Size` describes the width and height of the view. The `Frame` is used to determine where the view is drawn on the screen and is used to calculate the `Viewport` and `ContentSize`.
+The `Frame` property of a `View` is a rectangle that describes the current location and size of the view relative to the `Superview`'s content area. The `Frame` has a `Location` and `Size`. The `Location` describes the top-left corner of the view relative to the `Superview`'s content area. The `Size` describes the width and height of the view. The `Frame` is used to determine where the view is drawn on the screen and is used to calculate the Viewport and content size.
## The Content Area
- The content area is the area where the view's content is drawn. Content can be any combination of the `View.Text` property, `Subviews`, and other content drawn by the View. The `View.ContentSize` property gets the size of the content area of the view. *Content Area* refers to the rectangle with a location of `0,0` with a size of `ContentSize`.
+ The content area is the area where the view's content is drawn. Content can be any combination of the `View.Text` property, `Subviews`, and other content drawn by the View. The `View.GetContentSize()` property gets the size of the content area of the view. *Content Area* refers to the rectangle with a location of `0,0` with a size of `ContentSize`.
- `ContentSize` tracks the size of the `Viewport` by default. If `ContentSize` is set via `SetContentSize()`, the content area is the provided size. If `ContentSize` is larger than the `Viewport`, scrolling is enabled.
+ The Content size tracks the size of the `Viewport` by default. If the content size is set via `SetContentSize()`, the content area is the provided size. If the content size is larger than the `Viewport`, scrolling is enabled.
## The Viewport
-The Viewport (`View.Viewport`) is a rectangle describing the portion of the *Content Area* that is currently visible to the user. It is a "portal" into the content. The `Viewport.Location` is relative to the top-left corner of the inner rectangle of `View.Padding`. If `Viewport.Size` is the same as `View.ContentSize`, `Viewport.Location` will be `0,0`.
+The Viewport (`View.Viewport`) is a rectangle describing the portion of the *Content Area* that is currently visible to the user. It is a "portal" into the content. The `Viewport.Location` is relative to the top-left corner of the inner rectangle of `View.Padding`. If `Viewport.Size` is the same as `View.GetContentSize()`, `Viewport.Location` will be `0,0`.
To enable scrolling call `View.SetContentSize()` and then set `Viewport.Location` to positive values. Making `Viewport.Location` positive moves the Viewport down and to the right in the content.
@@ -32,17 +32,11 @@ The default `ViewportSettings` also constrains the Viewport to the size of the c
## Layout
-Terminal.Gui provides a rich system for how views are laid out relative to each other. **Computed Layout** means the position and size of a View is being computed by the layout engine. **Absolute Layout** means the position and size of a View has been declared to be an absolute values. The position of a view is set by setting the `X` and `Y` properties, which are of time [Pos](~/api/Terminal.Gui.Pos.yml). The size is set via `Width` and `Height`, which are of type [Dim](~/api/Terminal.Gui.Dim.yml).
-
-* **Computed Layout** supports dynamic console apps where UI elements (Views) automatically adjust as the terminal resizes or other Views change size or position. The X, Y, Width, and Height properties are Dim and Pos objects that dynamically update the position of a view.
-
-* **Absolute Layout** requires specifying coordinates and sizes of Views explicitly, and the View will typically stay in a fixed position and size.
+Terminal.Gui provides a rich system for how views are laid out relative to each other. The position of a view is set by setting the `X` and `Y` properties, which are of time [Pos](~/api/Terminal.Gui.Pos.yml). The size is set via `Width` and `Height`, which are of type [Dim](~/api/Terminal.Gui.Dim.yml).
```cs
-// Absolute layout using a absoulte values for X, Y, Width, and Height
var label1 = new Label () { X = 1, Y = 2, Width = 3, Height = 4, Title = "Absolute")
-// Computed Layout using Pos and Dim objects for X, Y, Width, and Height
var label2 = new Label () {
Title = "Computed",
X = Pos.Right (otherView),
@@ -54,8 +48,6 @@ var label2 = new Label () {
The `Frame` property is a rectangle that provides the current location and size of the view relative to the View's `Superview`'s Content area.
-The `View.LayoutStyle` property can be used to determine how the View is treated. If the style is `Absolute`, the `X`, `Y`, `Width`, and `Height` objects are all absolute values. If the style is `Computed`, one or more of the `X`, `Y`, `Width`, and `Height` objects describe a computed value.
-
## The `Pos` Type
The [Pos](~/api/Terminal.Gui.Pos.yml) is the type of `View.X` and `View.Y` and supports the following sub-types:
diff --git a/docfx/docs/migratingfromv1.md b/docfx/docs/migratingfromv1.md
index 9e476aa36..cd49babda 100644
--- a/docfx/docs/migratingfromv1.md
+++ b/docfx/docs/migratingfromv1.md
@@ -117,7 +117,7 @@ In v2, the layout system has been improved to make it easier to create complex u
* [View.Frame](~/api/Terminal.Gui.View.Frame.yml) now represents the position and size of the view in the superview's coordinate system. The `Frame` property is of type `Rectangle`.
* [View.Bounds](~/api/Terminal.Gui.View.Bounds.yml) has been replaced by [View.Viewport](~/api/Terminal.Gui.View.Viewport.yml). The `Viewport` property represents the visible area of the view in its own coordinate system. The `Viewport` property is of type `Rectangle`.
-* [View.ContentSize](~/api/Terminal.Gui.View.ContentSize.yml) represents the size of the view's content. The `ContentSize` property is of type `Size`. This replaces `ScrollView` and `ScrollBarView` in v1. See more below.
+* [View.GetContentSize()](~/api/Terminal.Gui.View.GetContentSize.yml) represents the size of the view's content. This replaces `ScrollView` and `ScrollBarView` in v1. See more below.
### How to Fix
@@ -125,7 +125,7 @@ In v2, the layout system has been improved to make it easier to create complex u
* Rename `Bounds` to `Viewport`. The `Location` property of `Bounds` can now have non-zero values.
* Update any code that assumed `Bounds.Location` was always `Point.Empty`.
-* Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.
+* Update any code that used `Bounds` to refer to the size of the view's content. Use `GetContentSize()` instead.
* Update any code that assumed `Bounds.Size` was the same as `Frame.Size`. `Frame.Size` defines the size of the view in the superview's coordinate system, while `Viewport.Size` defines the visible area of the view in its own coordinate system.
* Use [View.GetAdornmentsThickness](~/api/Terminal.Gui.View.GetAdornmentsThickness.yml) to get the total thickness of the view's border, margin, and padding.
* Not assume a View can draw outside of 'Viewport'. Use the 'Margin', 'Border', and 'Padding' Adornments to do things outside of `Viewport`. View subclasses should not implement their own concept of padding or margins but leverage these `Adornments` instead.
@@ -149,13 +149,13 @@ In v2, the `Border`, `Margin`, and `Padding` properties have been added to all v
## Built-in Scrolling
-In v1, scrolling was enabled by using `ScrollView` or `ScrollBarView`. In v2, the base [View](~/api/Terminal.Gui.View.yml) class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by [View.ContentSize](~/api/Terminal.Gui.View.ContentSize.yml). See [Layout](layout.md) for details.
+In v1, scrolling was enabled by using `ScrollView` or `ScrollBarView`. In v2, the base [View](~/api/Terminal.Gui.View.yml) class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by [View.GetContentSize()](~/api/Terminal.Gui.View.GetContentSize.yml). See [Layout](layout.md) for details.
### How to Fix
-* Replace `ScrollView` with [View](~/api/Terminal.Gui.View.yml) and use the `Viewport` and `ContentSize` properties to control scrolling.
+* Replace `ScrollView` with [View](~/api/Terminal.Gui.View.yml) and use `Viewport` and [View.GetContentSize()](~/api/Terminal.Gui.View.GetContentSize.yml) to control scrolling.
* Update any code that assumed `Bounds.Location` was always `Point.Empty`.
-* Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.
+* Update any code that used `Bounds` to refer to the size of the view's content. Use [View.GetContentSize()](~/api/Terminal.Gui.View.GetContentSize.yml) instead.
* Update any code that assumed `Bounds.Size` was the same as `Frame.Size`. `Frame.Size` defines the size of the view in the superview's coordinate system, while `Viewport.Size` defines the visible area of the view in its own coordinate system.
## Updated Keyboard API
diff --git a/docfx/docs/newinv2.md b/docfx/docs/newinv2.md
index 66fbfcd37..fef491045 100644
--- a/docfx/docs/newinv2.md
+++ b/docfx/docs/newinv2.md
@@ -24,7 +24,7 @@ The entire library has been reviewed and simplified. As a result, the API is mor
* In v1, `View` was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and `View` is the base-class supporting `IDisposable`.
* `Application.Init` no longer automatically creates a toplevel or sets `Applicaton.Top`; app developers must explicitly create the toplevel view and pass it to `Appliation.Run` (or use `Application.Run`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting.
* New! *Adornments* - Adornments are a special form of View that appear outside the `Viewport`: `Margin`, `Border`, and `Padding`.
-* New! *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
+* New! *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.GetContentSize()`. See [Layout](layout.md) for details.
* New! *`Dim.Auto`* - Automatically sizes the view to fitthe view's Text, SubViews, or ContentArea.
* Improved! *`Pos.AnchorEnd ()`* - New to v2 is `Pos.AnchorEnd ()` (with no parameters) which allows a view to be anchored to the right or bottom of the Superview.
* New! *`Pos.Align ()`* - Aligns a set of views horizontally or vertically (left, rigth, center, etc...).