Преглед изворни кода

ViewportSettings enum to sep file

Tig пре 1 година
родитељ
комит
675ef57ab7
2 измењених фајлова са 115 додато и 123 уклоњено
  1. 0 123
      Terminal.Gui/View/ViewContent.cs
  2. 115 0
      Terminal.Gui/View/ViewportSettings.cs

+ 0 - 123
Terminal.Gui/View/ViewContent.cs

@@ -2,120 +2,6 @@
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
-/// <summary>
-///     Settings for how the <see cref="View.Viewport"/> behaves relative to the View's Content area.
-/// </summary>
-[Flags]
-public enum ViewportSettings
-{
-    /// <summary>
-    ///     No settings.
-    /// </summary>
-    None = 0,
-
-    /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.X</c> can be set to negative values enabling scrolling beyond the left of
-    ///     the
-    ///     content area.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to positive values.
-    ///     </para>
-    /// </remarks>
-    AllowNegativeX = 1,
-
-    /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.Y</c> can be set to negative values enabling scrolling beyond the top of the
-    ///     content area.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to positive values.
-    ///     </para>
-    /// </remarks>
-    AllowNegativeY = 2,
-
-    /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.Size</c> can be set to negative coordinates enabling scrolling beyond the
-    ///     top-left of the
-    ///     content area.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.Size</c> is constrained to positive coordinates.
-    ///     </para>
-    /// </remarks>
-    AllowNegativeLocation = AllowNegativeX | AllowNegativeY,
-
-    /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.X</c> can be set values greater than <see cref="View.ContentSize"/>
-    ///     <c>.Width</c> enabling scrolling beyond the right
-    ///     of the content area.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to <see cref="View.ContentSize"/>
-    ///         <c>.Width - 1</c>.
-    ///         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.
-    ///     </para>
-    ///     <para>
-    ///         The practical effect of this is that the last column of the content will always be visible.
-    ///     </para>
-    /// </remarks>
-    AllowXGreaterThanContentWidth = 4,
-
-    /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.Y</c> can be set values greater than <see cref="View.ContentSize"/>
-    ///     <c>.Height</c> enabling scrolling beyond the right
-    ///     of the content area.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to <see cref="View.ContentSize"/>
-    ///         <c>.Height - 1</c>.
-    ///         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.
-    ///     </para>
-    ///     <para>
-    ///         The practical effect of this is that the last row of the content will always be visible.
-    ///     </para>
-    /// </remarks>
-    AllowYGreaterThanContentHeight = 8,
-
-    /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.Size</c> can be set values greater than <see cref="View.ContentSize"/>
-    ///     enabling scrolling beyond the bottom-right
-    ///     of the content area.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         When not set, <see cref="View.Viewport"/> is constrained to <see cref="View.ContentSize"/><c> -1</c>.
-    ///         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.
-    ///     </para>
-    /// </remarks>
-    AllowLocationGreaterThanContentSize = AllowXGreaterThanContentWidth | AllowYGreaterThanContentHeight,
-
-    /// <summary>
-    ///     By default, clipping is applied to the <see cref="View.Viewport"/>. Setting this flag will cause clipping to be
-    ///     applied to the visible content area.
-    /// </summary>
-    ClipContentOnly = 16,
-
-    /// <summary>
-    ///     If set <see cref="View.Clear()"/> will clear only the portion of the content
-    ///     area that is visible within the <see cref="View.Viewport"/>. This is useful for views that have a
-    ///     content area larger than the Viewport and want the area outside the content to be visually distinct.
-    /// </summary>
-    /// <remarks>
-    ///     <see cref="ClipContentOnly"/> must be set for this setting to work (clipping beyond the visible area must be
-    ///     disabled).
-    /// </remarks>
-    ClearContentOnly = 32
-}
-
 public partial class View
 public partial class View
 {
 {
     #region Content Area
     #region Content Area
@@ -314,15 +200,6 @@ public partial class View
     {
     {
         get
         get
         {
         {
-//#if DEBUG
-//            if ((_width.ReferencesOtherViews () || _height.ReferencesOtherViews ()) && !IsInitialized)
-//            {
-//                Debug.WriteLine (
-//                                 $"WARNING: The dimensions of {this} are dependent on other views and Viewport is being accessed before the View has been initialized. This is likely a bug."
-//                                );
-//            }
-//#endif // DEBUG
-
             if (Margin is null || Border is null || Padding is null)
             if (Margin is null || Border is null || Padding is null)
             {
             {
                 // CreateAdornments has not been called yet.
                 // CreateAdornments has not been called yet.

+ 115 - 0
Terminal.Gui/View/ViewportSettings.cs

@@ -0,0 +1,115 @@
+namespace Terminal.Gui;
+
+/// <summary>
+///     Settings for how the <see cref="View.Viewport"/> behaves relative to the View's Content area.
+/// </summary>
+[Flags]
+public enum ViewportSettings
+{
+    /// <summary>
+    ///     No settings.
+    /// </summary>
+    None = 0,
+
+    /// <summary>
+    ///     If set, <see cref="View.Viewport"/><c>.X</c> can be set to negative values enabling scrolling beyond the left of
+    ///     the
+    ///     content area.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to positive values.
+    ///     </para>
+    /// </remarks>
+    AllowNegativeX = 1,
+
+    /// <summary>
+    ///     If set, <see cref="View.Viewport"/><c>.Y</c> can be set to negative values enabling scrolling beyond the top of the
+    ///     content area.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to positive values.
+    ///     </para>
+    /// </remarks>
+    AllowNegativeY = 2,
+
+    /// <summary>
+    ///     If set, <see cref="View.Viewport"/><c>.Size</c> can be set to negative coordinates enabling scrolling beyond the
+    ///     top-left of the
+    ///     content area.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         When not set, <see cref="View.Viewport"/><c>.Size</c> is constrained to positive coordinates.
+    ///     </para>
+    /// </remarks>
+    AllowNegativeLocation = AllowNegativeX | AllowNegativeY,
+
+    /// <summary>
+    ///     If set, <see cref="View.Viewport"/><c>.X</c> can be set values greater than <see cref="View.ContentSize"/>
+    ///     <c>.Width</c> enabling scrolling beyond the right
+    ///     of the content area.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to <see cref="View.ContentSize"/>
+    ///         <c>.Width - 1</c>.
+    ///         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.
+    ///     </para>
+    ///     <para>
+    ///         The practical effect of this is that the last column of the content will always be visible.
+    ///     </para>
+    /// </remarks>
+    AllowXGreaterThanContentWidth = 4,
+
+    /// <summary>
+    ///     If set, <see cref="View.Viewport"/><c>.Y</c> can be set values greater than <see cref="View.ContentSize"/>
+    ///     <c>.Height</c> enabling scrolling beyond the right
+    ///     of the content area.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to <see cref="View.ContentSize"/>
+    ///         <c>.Height - 1</c>.
+    ///         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.
+    ///     </para>
+    ///     <para>
+    ///         The practical effect of this is that the last row of the content will always be visible.
+    ///     </para>
+    /// </remarks>
+    AllowYGreaterThanContentHeight = 8,
+
+    /// <summary>
+    ///     If set, <see cref="View.Viewport"/><c>.Size</c> can be set values greater than <see cref="View.ContentSize"/>
+    ///     enabling scrolling beyond the bottom-right
+    ///     of the content area.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         When not set, <see cref="View.Viewport"/> is constrained to <see cref="View.ContentSize"/><c> -1</c>.
+    ///         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.
+    ///     </para>
+    /// </remarks>
+    AllowLocationGreaterThanContentSize = AllowXGreaterThanContentWidth | AllowYGreaterThanContentHeight,
+
+    /// <summary>
+    ///     By default, clipping is applied to the <see cref="View.Viewport"/>. Setting this flag will cause clipping to be
+    ///     applied to the visible content area.
+    /// </summary>
+    ClipContentOnly = 16,
+
+    /// <summary>
+    ///     If set <see cref="View.Clear()"/> will clear only the portion of the content
+    ///     area that is visible within the <see cref="View.Viewport"/>. This is useful for views that have a
+    ///     content area larger than the Viewport and want the area outside the content to be visually distinct.
+    /// </summary>
+    /// <remarks>
+    ///     <see cref="ClipContentOnly"/> must be set for this setting to work (clipping beyond the visible area must be
+    ///     disabled).
+    /// </remarks>
+    ClearContentOnly = 32
+}