Tweaked autohide logic

This commit is contained in:
Tig
2024-11-16 12:11:02 -07:00
parent 0900efc324
commit 29c2e3976c
3 changed files with 11 additions and 13 deletions

View File

@@ -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;
}
}
}

View File

@@ -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)

View File

@@ -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);