diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs
index ad4ccb63c..74b90f9fa 100644
--- a/Terminal.Gui/Views/ScrollView.cs
+++ b/Terminal.Gui/Views/ScrollView.cs
@@ -135,6 +135,10 @@ namespace Terminal.Gui {
Driver.SetAttribute (ColorScheme.Normal);
+ if (Bounds.Height == 0) {
+ return;
+ }
+
if (vertical) {
if (region.Right < Bounds.Width - 1)
return;
@@ -149,6 +153,10 @@ namespace Terminal.Gui {
Move (col, 0);
Driver.AddRune (Driver.UpArrow);
+ if (Bounds.Height == 3) {
+ Move (col, 1);
+ Driver.AddRune (Driver.Diamond);
+ }
Move (col, Bounds.Height - 1);
Driver.AddRune (Driver.DownArrow);
} else {
@@ -393,6 +401,11 @@ namespace Terminal.Gui {
}
}
+ ///
+ /// If true the vertical/horizontal scroll bars won't be showed if it's not needed.
+ ///
+ public bool AutoHideScrollBars { get; set; } = true;
+
///
/// Adds the view to the scrollview.
///
@@ -494,17 +507,21 @@ namespace Terminal.Gui {
var savedClip = ClipToBounds ();
OnDrawContent (new Rect (ContentOffset,
- new Size (Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0),
- Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0))));
+ new Size (Math.Max (Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0),
+ Math.Max (Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0), 0))));
contentView.Redraw (contentView.Frame);
Driver.Clip = savedClip;
- if (ShowVerticalScrollIndicator) {
- vertical.Redraw (vertical.Bounds);
- }
+ if (AutoHideScrollBars) {
+ ShowHideScrollBars ();
+ } else {
+ if (ShowVerticalScrollIndicator) {
+ vertical.Redraw (vertical.Bounds);
+ }
- if (ShowHorizontalScrollIndicator) {
- horizontal.Redraw (horizontal.Bounds);
+ if (ShowHorizontalScrollIndicator) {
+ horizontal.Redraw (horizontal.Bounds);
+ }
}
// Fill in the bottom left corner
@@ -514,6 +531,46 @@ namespace Terminal.Gui {
Driver.SetAttribute (ColorScheme.Normal);
}
+ void ShowHideScrollBars ()
+ {
+ bool v = false, h = false;
+
+ if (Bounds.Height == 0 || Bounds.Height > contentSize.Height) {
+ if (ShowVerticalScrollIndicator) {
+ ShowVerticalScrollIndicator = false;
+ }
+ v = false;
+ } else {
+ if (!ShowVerticalScrollIndicator) {
+ ShowVerticalScrollIndicator = true;
+ }
+ v = true;
+ }
+ if (Bounds.Width == 0 || Bounds.Width > contentSize.Width) {
+ if (ShowHorizontalScrollIndicator) {
+ ShowHorizontalScrollIndicator = false;
+ }
+ h = false;
+ } else {
+ if (!ShowHorizontalScrollIndicator) {
+ ShowHorizontalScrollIndicator = true;
+ }
+ h = true;
+ }
+
+ vertical.Height = Dim.Fill (h ? 1 : 0);
+ horizontal.Width = Dim.Fill (v ? 1 : 0);
+
+ if (v) {
+ vertical.SetRelativeLayout (Bounds);
+ vertical.Redraw (vertical.Bounds);
+ }
+ if (h) {
+ horizontal.SetRelativeLayout (Bounds);
+ horizontal.Redraw (horizontal.Bounds);
+ }
+ }
+
void SetViewsNeedsDisplay ()
{
foreach (View view in contentView) {
@@ -631,13 +688,13 @@ namespace Terminal.Gui {
!me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition))
return false;
- if (me.Flags == MouseFlags.WheeledDown)
+ if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
ScrollDown (1);
- else if (me.Flags == MouseFlags.WheeledUp)
+ else if (me.Flags == MouseFlags.WheeledUp && ShowVerticalScrollIndicator)
ScrollUp (1);
- else if (me.X == vertical.Frame.X)
+ else if (me.X == vertical.Frame.X && ShowVerticalScrollIndicator)
vertical.MouseEvent (me);
- else if (me.Y == horizontal.Frame.Y)
+ else if (me.Y == horizontal.Frame.Y && ShowHorizontalScrollIndicator)
horizontal.MouseEvent (me);
else if (IsOverridden (me.View)) {
Application.UngrabMouse ();