Forráskód Böngészése

Tweaked autohide logic

Tig 8 hónapja
szülő
commit
29c2e3976c

+ 6 - 6
Terminal.Gui/View/View.ScrollBars.cs

@@ -187,8 +187,8 @@ public partial class View
     {
         if (viewportSettings == ViewportSettings.None)
         {
-            _horizontalScrollBar.Value.KeepContentInAllViewport = true;
-            _verticalScrollBar.Value.KeepContentInAllViewport = true;
+            //_horizontalScrollBar.Value.KeepContentInAllViewport = true;
+            //_verticalScrollBar.Value.KeepContentInAllViewport = true;
         }
         else if (viewportSettings.HasFlag (ViewportSettings.AllowNegativeX))
         {
@@ -205,16 +205,16 @@ public partial class View
         }
         else if (viewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
         {
-            _horizontalScrollBar.Value.KeepContentInAllViewport = false;
+            //_horizontalScrollBar.Value.KeepContentInAllViewport = false;
         }
         else if (viewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
         {
-            _verticalScrollBar.Value.KeepContentInAllViewport = false;
+            //_verticalScrollBar.Value.KeepContentInAllViewport = false;
         }
         else if (viewportSettings.HasFlag (ViewportSettings.AllowLocationGreaterThanContentSize))
         {
-            _horizontalScrollBar.Value.KeepContentInAllViewport = false;
-            _verticalScrollBar.Value.KeepContentInAllViewport = false;
+            //_horizontalScrollBar.Value.KeepContentInAllViewport = false;
+            //_verticalScrollBar.Value.KeepContentInAllViewport = false;
         }
     }
 }

+ 2 - 4
Terminal.Gui/Views/ScrollBar/ScrollBar.cs

@@ -93,11 +93,9 @@ public class ScrollBar : View, IOrientation, IDesignable
 
     private void ShowHide ()
     {
-        Visible = VisibleContentSize < ScrollableContentSize;
-
-        if (!AutoHide)
+        if (AutoHide)
         {
-            Visible = true;
+            Visible = VisibleContentSize < ScrollableContentSize;
         }
 
         if (Orientation == Orientation.Vertical)

+ 3 - 3
UnitTests/Views/ScrollBarTests.cs

@@ -922,15 +922,15 @@ public class ScrollBarTests (ITestOutputHelper output)
         top.Add (view);
         Application.Begin (top);
 
-        Assert.False (scrollBar.KeepContentInAllViewport);
-        scrollBar.KeepContentInAllViewport = true;
+        //Assert.False (scrollBar.KeepContentInAllViewport);
+        //scrollBar.KeepContentInAllViewport = true;
         Assert.Equal (80, view.Padding.Viewport.Width);
         Assert.Equal (25, view.Padding.Viewport.Height);
         Assert.Equal (2, scrollBar.Viewport.Width);
         Assert.Equal (25, scrollBar.Viewport.Height);
         Assert.Equal (30, scrollBar.ScrollableContentSize);
 
-        scrollBar.KeepContentInAllViewport = false;
+        //scrollBar.KeepContentInAllViewport = false;
         scrollBar.Position = 50;
         Assert.Equal (scrollBar.GetSliderPosition (), scrollBar.ScrollableContentSize - 1);
         Assert.Equal (scrollBar.GetSliderPosition (), view.Viewport.Y);