diff --git a/Terminal.Gui/View/ViewScrolling.cs b/Terminal.Gui/View/ViewContent.cs
similarity index 77%
rename from Terminal.Gui/View/ViewScrolling.cs
rename to Terminal.Gui/View/ViewContent.cs
index 60ca76e42..8783448ff 100644
--- a/Terminal.Gui/View/ViewScrolling.cs
+++ b/Terminal.Gui/View/ViewContent.cs
@@ -3,7 +3,7 @@
namespace Terminal.Gui;
///
-/// Controls the scrolling behavior of a view.
+/// Settings for how scrolling the on the View's Content Area is handled.
///
[Flags]
public enum ScrollSettings
@@ -14,17 +14,17 @@ public enum ScrollSettings
Default = 0,
///
- /// If set, does not restrict vertical scrolling to the content size.
+ /// If set, does not restrict vertical scrolling to .Height.
///
NoRestrictVertical = 1,
///
- /// If set, does not restrict horizontal scrolling to the content size.
+ /// If set, does not restrict horizontal scrolling to .Width.
///
NoRestrictHorizontal = 2,
///
- /// If set, does not restrict either vertical or horizontal scrolling to the content size.
+ /// If set, does not restrict either vertical or horizontal scrolling to .
///
NoRestrict = NoRestrictVertical | NoRestrictHorizontal
}
@@ -37,22 +37,39 @@ public partial class View
///
/// Gets or sets the size of the View's content. If the value is Size.Empty the size of the content is
- /// the same as the size of the , and Viewport.Location will always be 0, 0.
- /// If a positive size is provided, describes the portion of the content currently visible
- /// to the view. This enables virtual scrolling.
+ /// the same as the size of , and Viewport.Location will always be 0, 0.
///
+ ///
+ ///
+ /// If a positive size is provided, describes the portion of the content currently visible
+ /// to the view. This enables virtual scrolling.
+ ///
+ ///
+ /// Negative sizes are not supported.
+ ///
+ ///
public Size ContentSize
{
get => _contentSize == Size.Empty ? Viewport.Size : _contentSize;
set
{
+ if (value.Width < 0 || value.Height < 0)
+ {
+ throw new ArgumentException (@"ContentSize cannot be negative.", nameof (value));
+ }
+
+ if (value == _contentSize)
+ {
+ return;
+ }
+
_contentSize = value;
OnContentSizeChanged (new (_contentSize));
}
}
///
- /// Called when the changes. Invokes the event.
+ /// Called when changes. Invokes the event.
///
///
///
@@ -65,11 +82,11 @@ public partial class View
SetNeedsDisplay ();
}
- return e.Cancel == true;
+ return e.Cancel;
}
///
- /// Event that is raised when the changes.
+ /// Event that is raised when the changes.
///
public event EventHandler ContentSizeChanged;
@@ -113,22 +130,21 @@ public partial class View
#region Viewport
///
- /// Gets or sets the scrolling behavior of the view.
+ /// Gets or sets how scrolling the on the View's Content Area is handled.
///
public ScrollSettings ScrollSettings { get; set; }
///
- /// The location of the viewport.in the view's content (0,0) is the top-left corner of the content. It's size
- /// is .
+ /// 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 .
///
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 s.
- /// If the viewport Size is the sames as the the Location will be 0, 0.
- /// Positive values for the location indicate the visible area is offset into the View's virtual
- /// .
+ /// The viewport Location is relative to the top-left corner of the inner rectangle of .
+ /// If the viewport Size is the same as the Location will be 0, 0.
///
///
/// The rectangle describing the location and size of the viewport into the View's virtual content, described by
@@ -136,6 +152,17 @@ public partial class View
///
///
///
+ /// Positive values for the location indicate the visible area is offset into (down-and-right) the View's virtual
+ /// . This enables virtual scrolling.
+ ///
+ ///
+ /// Negative values for the location indicate the visible area is offset above (up-and-left) the View's virtual
+ /// . This enables virtual zoom.
+ ///
+ ///
+ /// The property controls how scrolling is handled. If is
+ ///
+ ///
/// If is the value of Viewport is indeterminate until
/// the view has been initialized ( is true) and has been
/// called.
@@ -170,10 +197,12 @@ public partial class View
Thickness thickness = GetAdornmentsThickness ();
- return new (_viewportLocation, new (
- Math.Max (0, Frame.Size.Width - thickness.Horizontal),
- Math.Max (0, Frame.Size.Height - thickness.Vertical)
- ));
+ return new (
+ _viewportLocation,
+ new (
+ Math.Max (0, Frame.Size.Width - thickness.Horizontal),
+ Math.Max (0, Frame.Size.Height - thickness.Vertical)
+ ));
}
set
{
@@ -204,8 +233,11 @@ public partial class View
}
Thickness thickness = GetAdornmentsThickness ();
- Size newSize = new (value.Size.Width + thickness.Horizontal,
+
+ Size newSize = new (
+ value.Size.Width + thickness.Horizontal,
value.Size.Height + thickness.Vertical);
+
if (newSize == Frame.Size)
{
// The change is not changing the Frame, so we don't need to update it.
@@ -215,6 +247,7 @@ public partial class View
_viewportLocation = value.Location;
SetNeedsLayout ();
}
+
return;
}