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

Renamed ScrollSettings enum members to be more clear

Tig пре 1 година
родитељ
комит
d49bc3c06f

+ 26 - 11
Terminal.Gui/View/ViewContent.cs

@@ -14,22 +14,37 @@ public enum ScrollSettings
     None = 0,
 
     /// <summary>
-    ///     If set, <c>Viewport.Location.Y</c> can be negative or greater than to <see cref="View.ContentSize"/>.<c>Height</c>,
-    ///     enabling scrolling beyond the dimensions of the content area vertically.
+    ///     If set, <see cref="View.Viewport"/> can be set to a rectangle that does not perfectly intersect with the Content Area
+    ///     rectangle (<see cref="View.ContentSize"/> in the horizontal direction, enabling scrolling beyond the dimensions of the content area vertically.
     /// </summary>
-    AllowViewportYBeyondContent = 1,
+    /// <remarks>
+    /// <para>
+    ///     When not set, <see cref="View.Viewport"/> is constrained to the bounds of the Content Area rectangle in the horizontal direction.
+    /// </para>
+    /// </remarks>
+    AllowViewportOutsideContentHorizontal = 1,
 
     /// <summary>
-    ///     If set, <c>Viewport.Location.X</c> can be negative or greater than to <see cref="View.ContentSize"/>.<c>Width</c>,
-    ///     enabling scrolling beyond the dimensions of the content area horizontally.
+    ///     If set, <see cref="View.Viewport"/> can be set to a rectangle that does not perfectly intersect with the Content Area
+    ///     rectangle (<see cref="View.ContentSize"/> in the vertical direction, enabling scrolling beyond the dimensions of the content area vertically.
     /// </summary>
-    AllowViewportXBeyondContent = 2,
+    /// <remarks>
+    /// <para>
+    ///     When not set, <see cref="View.Viewport"/> is constrained to the bounds of the Content Area rectangle in the vertical direction.
+    /// </para>
+    /// </remarks>
+    AllowViewportOutsideContentVertical = 2,
 
     /// <summary>
-    ///     If set, <c>Viewport.Location</c> can be negative or greater than to <see cref="View.ContentSize"/>,
-    ///     enabling scrolling beyond the dimensions of the content area either horizontally or vertically.
+    ///     If set, <see cref="View.Viewport"/> can be set to a rectangle that does not perfectly intersect with the Content Area
+    ///     rectangle (<see cref="View.ContentSize"/>, enabling scrolling beyond the dimensions of the content area vertically.
     /// </summary>
-    AllowViewportLocationBeyondContent = AllowViewportYBeyondContent | AllowViewportXBeyondContent
+    /// <remarks>
+    /// <para>
+    ///     When not set, <see cref="View.Viewport"/> is constrained to the bounds of the Content Area rectangle.
+    /// </para>
+    /// </remarks>
+    AllowViewportOutsideContent = AllowViewportOutsideContentHorizontal | AllowViewportOutsideContentVertical
 }
 
 public partial class View
@@ -261,7 +276,7 @@ public partial class View
 
         void ApplySettings (ref Rectangle location)
         {
-            if (!ScrollSettings.HasFlag (ScrollSettings.AllowViewportYBeyondContent))
+            if (!ScrollSettings.HasFlag (ScrollSettings.AllowViewportOutsideContentHorizontal))
             {
                 if (location.Y + Viewport.Height > ContentSize.Height)
                 {
@@ -274,7 +289,7 @@ public partial class View
                 }
             }
 
-            if (!ScrollSettings.HasFlag (ScrollSettings.AllowViewportXBeyondContent))
+            if (!ScrollSettings.HasFlag (ScrollSettings.AllowViewportOutsideContentVertical))
             {
                 if (location.X + Viewport.Width > ContentSize.Width)
                 {

+ 1 - 0
Terminal.Gui/Views/ListView.cs

@@ -106,6 +106,7 @@ public class ListView : View
     public ListView ()
     {
         CanFocus = true;
+        ScrollSettings = ScrollSettings.AllowViewportOutsideContent;
 
         // Things this view knows how to do
         AddCommand (Command.LineUp, () => MoveUp ());

+ 7 - 7
UICatalog/Scenarios/VirtualContentScrolling.cs

@@ -25,7 +25,7 @@ public class VirtualScrolling : Scenario
 
             // TODO: Add a way to set the scroll settings in the Scenario
             ContentSize = new Size (60, 40);
-            ScrollSettings = ScrollSettings.AllowViewportLocationBeyondContent;
+            ScrollSettings = ScrollSettings.AllowViewportOutsideContent;
 
             // Things this view knows how to do
             AddCommand (Command.ScrollDown, () => ScrollVertical (1));
@@ -113,18 +113,18 @@ public class VirtualScrolling : Scenario
             Y = 0,
             CanFocus = false
         };
-        cbAllowXBeyondContent.Checked = view.ScrollSettings.HasFlag (ScrollSettings.AllowViewportXBeyondContent);
+        cbAllowXBeyondContent.Checked = view.ScrollSettings.HasFlag (ScrollSettings.AllowViewportOutsideContentVertical);
         cbAllowXBeyondContent.Toggled += NoRestrictHorizontal_Toggled;
 
         void NoRestrictHorizontal_Toggled (object sender, StateEventArgs<bool?> e)
         {
             if (e.NewValue == true)
             {
-                view.ScrollSettings = view.ScrollSettings | ScrollSettings.AllowViewportXBeyondContent;
+                view.ScrollSettings = view.ScrollSettings | ScrollSettings.AllowViewportOutsideContentVertical;
             }
             else
             {
-                view.ScrollSettings = view.ScrollSettings & ~ScrollSettings.AllowViewportXBeyondContent;
+                view.ScrollSettings = view.ScrollSettings & ~ScrollSettings.AllowViewportOutsideContentVertical;
             }
         }
 
@@ -137,18 +137,18 @@ public class VirtualScrolling : Scenario
             Y = 0,
             CanFocus = false
         };
-        cbAllowYBeyondContent.Checked = view.ScrollSettings.HasFlag (ScrollSettings.AllowViewportYBeyondContent);
+        cbAllowYBeyondContent.Checked = view.ScrollSettings.HasFlag (ScrollSettings.AllowViewportOutsideContentHorizontal);
         cbAllowYBeyondContent.Toggled += NoRestrictVertical_Toggled;
 
         void NoRestrictVertical_Toggled (object sender, StateEventArgs<bool?> e)
         {
             if (e.NewValue == true)
             {
-                view.ScrollSettings = view.ScrollSettings | ScrollSettings.AllowViewportYBeyondContent;
+                view.ScrollSettings = view.ScrollSettings | ScrollSettings.AllowViewportOutsideContentHorizontal;
             }
             else
             {
-                view.ScrollSettings = view.ScrollSettings & ~ScrollSettings.AllowViewportYBeyondContent;
+                view.ScrollSettings = view.ScrollSettings & ~ScrollSettings.AllowViewportOutsideContentHorizontal;
             }
         }
 

+ 1 - 1
UnitTests/View/Layout/ToScreenTests.cs

@@ -630,7 +630,7 @@ public class ToScreenTests (ITestOutputHelper output)
         {
             Width = 10,
             Height = 10,
-            ScrollSettings = ScrollSettings.AllowViewportLocationBeyondContent
+            ScrollSettings = ScrollSettings.AllowViewportOutsideContent
         };
 
         Rectangle testRect = new Rectangle (0, 0, 1, 1);

+ 1 - 1
UnitTests/View/Layout/ViewportTests.cs

@@ -161,7 +161,7 @@ public class ViewportTests (ITestOutputHelper output)
         {
             Width = 10,
             Height = 10,
-            ScrollSettings = ScrollSettings.AllowViewportLocationBeyondContent
+            ScrollSettings = ScrollSettings.AllowViewportOutsideContent
         };
 
         Assert.Equal (new Rectangle (0, 0, 10, 10), view.Frame);