|
@@ -153,7 +153,7 @@ public class ScrollBarTests
|
|
◄░░██░░░░►",
|
|
◄░░██░░░░►",
|
|
@"
|
|
@"
|
|
◄░█░░░░░░►")]
|
|
◄░█░░░░░░►")]
|
|
- public void Changing_Position_Size_Orientation_Draws_Correctly (
|
|
|
|
|
|
+ public void Changing_Position_Size_Orientation_Draws_Correctly_KeepContentInAllViewport_True (
|
|
int size,
|
|
int size,
|
|
string firstVertExpected,
|
|
string firstVertExpected,
|
|
string middleVertExpected,
|
|
string middleVertExpected,
|
|
@@ -169,7 +169,8 @@ public class ScrollBarTests
|
|
{
|
|
{
|
|
Orientation = Orientation.Vertical,
|
|
Orientation = Orientation.Vertical,
|
|
Size = size,
|
|
Size = size,
|
|
- Height = 10
|
|
|
|
|
|
+ Height = 10,
|
|
|
|
+ KeepContentInAllViewport = true
|
|
};
|
|
};
|
|
var top = new Toplevel ();
|
|
var top = new Toplevel ();
|
|
top.Add (scrollBar);
|
|
top.Add (scrollBar);
|
|
@@ -231,6 +232,38 @@ public class ScrollBarTests
|
|
Assert.True (scrollBar.AutoHide);
|
|
Assert.True (scrollBar.AutoHide);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [Fact]
|
|
|
|
+ [AutoInitShutdown]
|
|
|
|
+ public void KeepContentInAllViewport_True_False ()
|
|
|
|
+ {
|
|
|
|
+ var view = new View { Width = Dim.Fill (), Height = Dim.Fill () };
|
|
|
|
+ view.Padding.Thickness = new (0, 0, 2, 0);
|
|
|
|
+ view.SetContentSize (new (view.Viewport.Width, 30));
|
|
|
|
+ var scrollBar = new ScrollBar { Width = 2, Height = Dim.Fill (), Size = view.GetContentSize ().Height };
|
|
|
|
+ scrollBar.PositionChanged += (_, e) => view.Viewport = view.Viewport with { Y = e.CurrentValue };
|
|
|
|
+ view.Padding.Add (scrollBar);
|
|
|
|
+ var top = new Toplevel ();
|
|
|
|
+ top.Add (view);
|
|
|
|
+ Application.Begin (top);
|
|
|
|
+
|
|
|
|
+ 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.Size);
|
|
|
|
+
|
|
|
|
+ scrollBar.KeepContentInAllViewport = false;
|
|
|
|
+ scrollBar.Position = 50;
|
|
|
|
+ Assert.Equal (scrollBar.Position, scrollBar.Size - 1);
|
|
|
|
+ Assert.Equal (scrollBar.Position, view.Viewport.Y);
|
|
|
|
+ Assert.Equal (29, scrollBar.Position);
|
|
|
|
+ Assert.Equal (29, view.Viewport.Y);
|
|
|
|
+
|
|
|
|
+ top.Dispose ();
|
|
|
|
+ }
|
|
|
|
+
|
|
[Theory]
|
|
[Theory]
|
|
[AutoInitShutdown]
|
|
[AutoInitShutdown]
|
|
[InlineData (
|
|
[InlineData (
|
|
@@ -309,14 +342,15 @@ public class ScrollBarTests
|
|
18,
|
|
18,
|
|
@"
|
|
@"
|
|
◄░░░░██░░►")]
|
|
◄░░░░██░░►")]
|
|
- public void Mouse_On_The_Container (Orientation orientation, int size, int position, int location, string output, int expectedPos, string expectedOut)
|
|
|
|
|
|
+ public void Mouse_On_The_Container_KeepContentInAllViewport_True (Orientation orientation, int size, int position, int location, string output, int expectedPos, string expectedOut)
|
|
{
|
|
{
|
|
var scrollBar = new ScrollBar
|
|
var scrollBar = new ScrollBar
|
|
{
|
|
{
|
|
Width = orientation == Orientation.Vertical ? 1 : 10,
|
|
Width = orientation == Orientation.Vertical ? 1 : 10,
|
|
Height = orientation == Orientation.Vertical ? 10 : 1,
|
|
Height = orientation == Orientation.Vertical ? 10 : 1,
|
|
Orientation = orientation, Size = size,
|
|
Orientation = orientation, Size = size,
|
|
- Position = position
|
|
|
|
|
|
+ Position = position,
|
|
|
|
+ KeepContentInAllViewport = true
|
|
};
|
|
};
|
|
var top = new Toplevel ();
|
|
var top = new Toplevel ();
|
|
top.Add (scrollBar);
|
|
top.Add (scrollBar);
|
|
@@ -440,7 +474,7 @@ public class ScrollBarTests
|
|
█
|
|
█
|
|
▼",
|
|
▼",
|
|
MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
|
|
MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
|
|
- 12,
|
|
|
|
|
|
+ 10,
|
|
@"
|
|
@"
|
|
▲
|
|
▲
|
|
░
|
|
░
|
|
@@ -482,7 +516,7 @@ public class ScrollBarTests
|
|
█
|
|
█
|
|
▼",
|
|
▼",
|
|
MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
|
|
MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
|
|
- 12,
|
|
|
|
|
|
+ 10,
|
|
@"
|
|
@"
|
|
▲
|
|
▲
|
|
░
|
|
░
|
|
@@ -503,7 +537,7 @@ public class ScrollBarTests
|
|
@"
|
|
@"
|
|
◄░░░░████►",
|
|
◄░░░░████►",
|
|
MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
|
|
MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
|
|
- 12,
|
|
|
|
|
|
+ 10,
|
|
@"
|
|
@"
|
|
◄░░░░████►")]
|
|
◄░░░░████►")]
|
|
[InlineData (
|
|
[InlineData (
|
|
@@ -674,7 +708,7 @@ public class ScrollBarTests
|
|
20,
|
|
20,
|
|
@"
|
|
@"
|
|
◄░░░░██░░►")]
|
|
◄░░░░██░░►")]
|
|
- public void Mouse_On_The_Slider (
|
|
|
|
|
|
+ public void Mouse_On_The_Slider_KeepContentInAllViewport_True (
|
|
Orientation orientation,
|
|
Orientation orientation,
|
|
int size,
|
|
int size,
|
|
int position,
|
|
int position,
|
|
@@ -691,7 +725,8 @@ public class ScrollBarTests
|
|
Width = orientation == Orientation.Vertical ? 1 : 10,
|
|
Width = orientation == Orientation.Vertical ? 1 : 10,
|
|
Height = orientation == Orientation.Vertical ? 10 : 1,
|
|
Height = orientation == Orientation.Vertical ? 10 : 1,
|
|
Orientation = orientation,
|
|
Orientation = orientation,
|
|
- Size = size, Position = position
|
|
|
|
|
|
+ Size = size, Position = position,
|
|
|
|
+ KeepContentInAllViewport = true
|
|
};
|
|
};
|
|
var top = new Toplevel ();
|
|
var top = new Toplevel ();
|
|
top.Add (scrollBar);
|
|
top.Add (scrollBar);
|
|
@@ -751,12 +786,12 @@ public class ScrollBarTests
|
|
[AutoInitShutdown]
|
|
[AutoInitShutdown]
|
|
[InlineData (Orientation.Vertical)]
|
|
[InlineData (Orientation.Vertical)]
|
|
[InlineData (Orientation.Horizontal)]
|
|
[InlineData (Orientation.Horizontal)]
|
|
- public void Mouse_Pressed_On_ScrollButton_Changes_Position (Orientation orientation)
|
|
|
|
|
|
+ public void Mouse_Pressed_On_ScrollButton_Changes_Position_KeepContentInAllViewport_True (Orientation orientation)
|
|
{
|
|
{
|
|
var scrollBar = new ScrollBar
|
|
var scrollBar = new ScrollBar
|
|
{
|
|
{
|
|
X = 10, Y = 10, Width = orientation == Orientation.Vertical ? 1 : 10, Height = orientation == Orientation.Vertical ? 10 : 1, Size = 20,
|
|
X = 10, Y = 10, Width = orientation == Orientation.Vertical ? 1 : 10, Height = orientation == Orientation.Vertical ? 10 : 1, Size = 20,
|
|
- Orientation = orientation
|
|
|
|
|
|
+ Orientation = orientation, KeepContentInAllViewport = true
|
|
};
|
|
};
|
|
var top = new Toplevel ();
|
|
var top = new Toplevel ();
|
|
top.Add (scrollBar);
|
|
top.Add (scrollBar);
|
|
@@ -768,7 +803,7 @@ public class ScrollBarTests
|
|
Assert.Equal (0, scrollBar.Position);
|
|
Assert.Equal (0, scrollBar.Position);
|
|
|
|
|
|
// ScrollButton increase
|
|
// ScrollButton increase
|
|
- for (var i = 0; i < 13; i++)
|
|
|
|
|
|
+ for (var i = 0; i < 11; i++)
|
|
{
|
|
{
|
|
Application.OnMouseEvent (
|
|
Application.OnMouseEvent (
|
|
new ()
|
|
new ()
|
|
@@ -776,7 +811,7 @@ public class ScrollBarTests
|
|
Position = orientation == Orientation.Vertical ? new (10, 19) : new (19, 10), Flags = MouseFlags.Button1Pressed
|
|
Position = orientation == Orientation.Vertical ? new (10, 19) : new (19, 10), Flags = MouseFlags.Button1Pressed
|
|
});
|
|
});
|
|
|
|
|
|
- if (i < 12)
|
|
|
|
|
|
+ if (i < 10)
|
|
{
|
|
{
|
|
Assert.Equal (i + 1, scrollBar.Position);
|
|
Assert.Equal (i + 1, scrollBar.Position);
|
|
}
|
|
}
|
|
@@ -790,7 +825,7 @@ public class ScrollBarTests
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for (var i = 12; i > -1; i--)
|
|
|
|
|
|
+ for (var i = 10; i > -1; i--)
|
|
{
|
|
{
|
|
Application.OnMouseEvent (new () { Position = new (10, 10), Flags = MouseFlags.Button1Pressed });
|
|
Application.OnMouseEvent (new () { Position = new (10, 10), Flags = MouseFlags.Button1Pressed });
|
|
|
|
|
|
@@ -810,12 +845,12 @@ public class ScrollBarTests
|
|
[AutoInitShutdown]
|
|
[AutoInitShutdown]
|
|
[InlineData (Orientation.Vertical)]
|
|
[InlineData (Orientation.Vertical)]
|
|
[InlineData (Orientation.Horizontal)]
|
|
[InlineData (Orientation.Horizontal)]
|
|
- public void Moving_Mouse_Outside_Host_Ensures_Correct_Location (Orientation orientation)
|
|
|
|
|
|
+ public void Moving_Mouse_Outside_Host_Ensures_Correct_Location_KeepContentInAllViewport_True (Orientation orientation)
|
|
{
|
|
{
|
|
var scrollBar = new ScrollBar
|
|
var scrollBar = new ScrollBar
|
|
{
|
|
{
|
|
X = 10, Y = 10, Width = orientation == Orientation.Vertical ? 1 : 10, Height = orientation == Orientation.Vertical ? 10 : 1, Size = 20,
|
|
X = 10, Y = 10, Width = orientation == Orientation.Vertical ? 1 : 10, Height = orientation == Orientation.Vertical ? 10 : 1, Size = 20,
|
|
- Position = 5, Orientation = orientation
|
|
|
|
|
|
+ Position = 5, Orientation = orientation, KeepContentInAllViewport = true
|
|
};
|
|
};
|
|
var top = new Toplevel ();
|
|
var top = new Toplevel ();
|
|
top.Add (scrollBar);
|
|
top.Add (scrollBar);
|
|
@@ -848,21 +883,21 @@ public class ScrollBarTests
|
|
}
|
|
}
|
|
|
|
|
|
[Theory]
|
|
[Theory]
|
|
- [InlineData (Orientation.Vertical, 20, 10)]
|
|
|
|
- [InlineData (Orientation.Vertical, 40, 30)]
|
|
|
|
- public void Position_Cannot_Be_Negative_Nor_Greater_Than_Size_Minus_Frame_Length (Orientation orientation, int size, int expectedPos)
|
|
|
|
|
|
+ [InlineData (Orientation.Vertical, 20, 10, 10)]
|
|
|
|
+ [InlineData (Orientation.Vertical, 40, 30, 30)]
|
|
|
|
+ public void Position_Cannot_Be_Negative_Nor_Greater_Than_Size_Minus_Frame_Length_KeepContentInAllViewport_True (Orientation orientation, int size, int expectedPos1, int expectedPos2)
|
|
{
|
|
{
|
|
- var scrollBar = new ScrollBar { Orientation = orientation, Height = 10, Size = size };
|
|
|
|
|
|
+ var scrollBar = new ScrollBar { Orientation = orientation, Height = 10, Size = size, KeepContentInAllViewport = true };
|
|
Assert.Equal (0, scrollBar.Position);
|
|
Assert.Equal (0, scrollBar.Position);
|
|
|
|
|
|
scrollBar.Position = -1;
|
|
scrollBar.Position = -1;
|
|
Assert.Equal (0, scrollBar.Position);
|
|
Assert.Equal (0, scrollBar.Position);
|
|
|
|
|
|
scrollBar.Position = size;
|
|
scrollBar.Position = size;
|
|
- Assert.Equal (0, scrollBar.Position);
|
|
|
|
|
|
+ Assert.Equal (expectedPos1, scrollBar.Position);
|
|
|
|
|
|
- scrollBar.Position = expectedPos;
|
|
|
|
- Assert.Equal (expectedPos, scrollBar.Position);
|
|
|
|
|
|
+ scrollBar.Position = expectedPos2;
|
|
|
|
+ Assert.Equal (expectedPos2, scrollBar.Position);
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -895,12 +930,12 @@ public class ScrollBarTests
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- public void PositionChanging_PositionChanged_Events_Only_Raises_Once_If_Position_Was_Really_Changed ()
|
|
|
|
|
|
+ public void PositionChanging_PositionChanged_Events_Only_Raises_Once_If_Position_Was_Really_Changed_KeepContentInAllViewport_True ()
|
|
{
|
|
{
|
|
var changing = 0;
|
|
var changing = 0;
|
|
var cancel = false;
|
|
var cancel = false;
|
|
var changed = 0;
|
|
var changed = 0;
|
|
- var scrollBar = new ScrollBar { Height = 10, Size = 20 };
|
|
|
|
|
|
+ var scrollBar = new ScrollBar { Height = 10, Size = 20, KeepContentInAllViewport = true };
|
|
scrollBar.PositionChanging += Scroll_PositionChanging;
|
|
scrollBar.PositionChanging += Scroll_PositionChanging;
|
|
scrollBar.PositionChanged += Scroll_PositionChanged;
|
|
scrollBar.PositionChanged += Scroll_PositionChanged;
|
|
|
|
|
|
@@ -935,19 +970,19 @@ public class ScrollBarTests
|
|
|
|
|
|
Reset ();
|
|
Reset ();
|
|
scrollBar.Position = 11;
|
|
scrollBar.Position = 11;
|
|
- Assert.Equal (11, scrollBar.Position);
|
|
|
|
- Assert.Equal (1, changing);
|
|
|
|
- Assert.Equal (1, changed);
|
|
|
|
|
|
+ Assert.Equal (10, scrollBar.Position);
|
|
|
|
+ Assert.Equal (0, changing);
|
|
|
|
+ Assert.Equal (0, changed);
|
|
|
|
|
|
Reset ();
|
|
Reset ();
|
|
scrollBar.Position = 12;
|
|
scrollBar.Position = 12;
|
|
- Assert.Equal (12, scrollBar.Position);
|
|
|
|
- Assert.Equal (1, changing);
|
|
|
|
- Assert.Equal (1, changed);
|
|
|
|
|
|
+ Assert.Equal (10, scrollBar.Position);
|
|
|
|
+ Assert.Equal (0, changing);
|
|
|
|
+ Assert.Equal (0, changed);
|
|
|
|
|
|
Reset ();
|
|
Reset ();
|
|
scrollBar.Position = 13;
|
|
scrollBar.Position = 13;
|
|
- Assert.Equal (12, scrollBar.Position);
|
|
|
|
|
|
+ Assert.Equal (10, scrollBar.Position);
|
|
Assert.Equal (0, changing);
|
|
Assert.Equal (0, changing);
|
|
Assert.Equal (0, changed);
|
|
Assert.Equal (0, changed);
|
|
|
|
|
|
@@ -1000,6 +1035,15 @@ public class ScrollBarTests
|
|
scrollBarSuperView.SuperView!.Dispose ();
|
|
scrollBarSuperView.SuperView!.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [Fact]
|
|
|
|
+ public void Size_Cannot_Be_Negative ()
|
|
|
|
+ {
|
|
|
|
+ var scrollBar = new ScrollBar { Height = 10, Size = -1 };
|
|
|
|
+ Assert.Equal (0, scrollBar.Size);
|
|
|
|
+ scrollBar.Size = -10;
|
|
|
|
+ Assert.Equal (0, scrollBar.Size);
|
|
|
|
+ }
|
|
|
|
+
|
|
[Fact]
|
|
[Fact]
|
|
public void SizeChanged_Event ()
|
|
public void SizeChanged_Event ()
|
|
{
|
|
{
|