Selaa lähdekoodia

Removed legacy scrollview stuff.

Tig 8 kuukautta sitten
vanhempi
commit
362c1d97af

+ 0 - 24
Terminal.Gui/Input/Responder.cs

@@ -49,30 +49,6 @@ public class Responder : IDisposable
         }
     }
 
-    // TODO: v2 - nuke this
-    /// <summary>Utilty function to determine <paramref name="method"/> is overridden in the <paramref name="subclass"/>.</summary>
-    /// <param name="subclass">The view.</param>
-    /// <param name="method">The method name.</param>
-    /// <returns><see langword="true"/> if it's overridden, <see langword="false"/> otherwise.</returns>
-    internal static bool IsOverridden (Responder subclass, string method)
-    {
-        MethodInfo m = subclass.GetType ()
-                               .GetMethod (
-                                           method,
-                                           BindingFlags.Instance
-                                           | BindingFlags.Public
-                                           | BindingFlags.NonPublic
-                                           | BindingFlags.DeclaredOnly
-                                          );
-
-        if (m is null)
-        {
-            return false;
-        }
-
-        return m.GetBaseDefinition ().DeclaringType != m.DeclaringType;
-    }
-
 #if DEBUG_IDISPOSABLE
     /// <summary>For debug purposes to verify objects are being disposed properly</summary>
     public bool WasDisposed;

+ 0 - 1086
Terminal.Gui/Views/ScrollBarView.cs

@@ -1,1086 +0,0 @@
-//
-// ScrollBarView.cs: ScrollBarView view.
-//
-// Authors:
-//   Miguel de Icaza ([email protected])
-//
-
-using System.Diagnostics;
-
-namespace Terminal.Gui;
-
-/// <summary>ScrollBarViews are views that display a 1-character scrollbar, either horizontal or vertical</summary>
-/// <remarks>
-///     <para>
-///         The scrollbar is drawn to be a representation of the Size, assuming that the scroll position is set at
-///         Position.
-///     </para>
-///     <para>If the region to display the scrollbar is larger than three characters, arrow indicators are drawn.</para>
-/// </remarks>
-public class ScrollBarView : View
-{
-    private bool _autoHideScrollBars = true;
-    private View _contentBottomRightCorner;
-    private bool _hosted;
-    private bool _keepContentAlwaysInViewport = true;
-    private int _lastLocation = -1;
-    private ScrollBarView _otherScrollBarView;
-    private int _posBarOffset;
-    private int _posBottomTee;
-    private int _posLeftTee;
-    private int _posRightTee;
-    private int _posTopTee;
-    private bool _showScrollIndicator;
-    private int _size, _position;
-    private bool _vertical;
-
-    /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class.
-    /// </summary>
-    public ScrollBarView ()
-    {
-        WantContinuousButtonPressed = true;
-
-        Added += (s, e) => CreateBottomRightCorner (e.SuperView);
-        Initialized += ScrollBarView_Initialized;
-    }
-
-    /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class.
-    /// </summary>
-    /// <param name="host">The view that will host this scrollbar.</param>
-    /// <param name="isVertical">If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal.</param>
-    /// <param name="showBothScrollIndicator">
-    ///     If set to <c>true (default)</c> will have the other scrollbar, otherwise will
-    ///     have only one.
-    /// </param>
-    public ScrollBarView (View host, bool isVertical, bool showBothScrollIndicator = true)
-    {
-        if (host is null)
-        {
-            throw new ArgumentNullException ("The host parameter can't be null.");
-        }
-
-        if (host.SuperView is null)
-        {
-            throw new ArgumentNullException ("The host SuperView parameter can't be null.");
-        }
-
-        _hosted = true;
-        IsVertical = isVertical;
-        ColorScheme = host.ColorScheme;
-        X = isVertical ? Pos.Right (host) - 1 : Pos.Left (host);
-        Y = isVertical ? Pos.Top (host) : Pos.Bottom (host) - 1;
-        Host = host;
-        CanFocus = false;
-        Enabled = host.Enabled;
-        Visible = host.Visible;
-        Initialized += ScrollBarView_Initialized;
-
-        //Host.CanFocusChanged += Host_CanFocusChanged;
-        Host.EnabledChanged += Host_EnabledChanged;
-        Host.VisibleChanged += Host_VisibleChanged;
-        Host.SuperView.Add (this);
-        AutoHideScrollBars = true;
-
-        if (showBothScrollIndicator)
-        {
-            OtherScrollBarView = new ScrollBarView
-            {
-                IsVertical = !isVertical,
-                ColorScheme = host.ColorScheme,
-                Host = host,
-                CanFocus = false,
-                Enabled = host.Enabled,
-                Visible = host.Visible,
-                OtherScrollBarView = this
-            };
-            OtherScrollBarView._hosted = true;
-            OtherScrollBarView.X = OtherScrollBarView.IsVertical ? Pos.Right (host) - 1 : Pos.Left (host);
-            OtherScrollBarView.Y = OtherScrollBarView.IsVertical ? Pos.Top (host) : Pos.Bottom (host) - 1;
-            OtherScrollBarView.Host.SuperView.Add (OtherScrollBarView);
-            OtherScrollBarView.ShowScrollIndicator = true;
-        }
-
-        ShowScrollIndicator = true;
-        CreateBottomRightCorner (Host);
-    }
-
-    /// <summary>If true the vertical/horizontal scroll bars won't be showed if it's not needed.</summary>
-    public bool AutoHideScrollBars
-    {
-        get => _autoHideScrollBars;
-        set
-        {
-            if (_autoHideScrollBars != value)
-            {
-                _autoHideScrollBars = value;
-                SetNeedsDraw ();
-            }
-        }
-    }
-
-    // BUGBUG: v2 - for consistency this should be named "Parent" not "Host"
-    /// <summary>Get or sets the view that host this <see cref="ScrollBarView"/></summary>
-    public View Host { get; internal set; }
-
-    /// <summary>If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal.</summary>
-    public bool IsVertical
-    {
-        get => _vertical;
-        set
-        {
-            _vertical = value;
-
-            if (IsInitialized)
-            {
-                SetWidthHeight ();
-            }
-        }
-    }
-
-    /// <summary>Get or sets if the view-port is kept always visible in the area of this <see cref="ScrollBarView"/></summary>
-    public bool KeepContentAlwaysInViewport
-    {
-        get => _keepContentAlwaysInViewport;
-        set
-        {
-            if (_keepContentAlwaysInViewport != value)
-            {
-                _keepContentAlwaysInViewport = value;
-                var pos = 0;
-
-                if (value && !_vertical && _position + Host.Viewport.Width > _size)
-                {
-                    pos = _size - Host.Viewport.Width + (_showBothScrollIndicator ? 1 : 0);
-                }
-
-                if (value && _vertical && _position + Host.Viewport.Height > _size)
-                {
-                    pos = _size - Host.Viewport.Height + (_showBothScrollIndicator ? 1 : 0);
-                }
-
-                if (pos != 0)
-                {
-                    Position = pos;
-                }
-
-                if (OtherScrollBarView is { } && OtherScrollBarView._keepContentAlwaysInViewport != value)
-                {
-                    OtherScrollBarView.KeepContentAlwaysInViewport = value;
-                }
-
-                if (pos == 0)
-                {
-                    Refresh ();
-                }
-            }
-        }
-    }
-
-    /// <summary>Represent a vertical or horizontal ScrollBarView other than this.</summary>
-    public ScrollBarView OtherScrollBarView
-    {
-        get => _otherScrollBarView;
-        set
-        {
-            if (value is { } && ((value.IsVertical && _vertical) || (!value.IsVertical && !_vertical)))
-            {
-                throw new ArgumentException (
-                                             $"There is already a {(_vertical ? "vertical" : "horizontal")} ScrollBarView."
-                                            );
-            }
-
-            _otherScrollBarView = value;
-        }
-    }
-
-    /// <summary>The position, relative to <see cref="Size"/>, to set the scrollbar at.</summary>
-    /// <value>The position.</value>
-    public int Position
-    {
-        get => _position;
-        set
-        {
-            if (_position == value)
-            {
-                return;
-            }
-
-            SetPosition (value);
-        }
-    }
-
-    // BUGBUG: v2 - Why can't we get rid of this and just use Visible?
-    /// <summary>Gets or sets the visibility for the vertical or horizontal scroll indicator.</summary>
-    /// <value><c>true</c> if show vertical or horizontal scroll indicator; otherwise, <c>false</c>.</value>
-    public bool ShowScrollIndicator
-    {
-        get => _showScrollIndicator && Visible;
-        set
-        {
-            //if (value == showScrollIndicator) {
-            //	return;
-            //}
-
-            _showScrollIndicator = value;
-
-            if (IsInitialized)
-            {
-                SetNeedsLayout ();
-
-                if (value)
-                {
-                    Visible = true;
-                }
-                else
-                {
-                    Visible = false;
-                    Position = 0;
-                }
-
-                SetWidthHeight ();
-            }
-        }
-    }
-
-    /// <summary>The size of content the scrollbar represents.</summary>
-    /// <value>The size.</value>
-    /// <remarks>
-    ///     The <see cref="Size"/> is typically the size of the virtual content. E.g. when a Scrollbar is part of a
-    ///     <see cref="View"/> the Size is set to the appropriate dimension of <see cref="Host"/>.
-    /// </remarks>
-    public int Size
-    {
-        get => _size;
-        set
-        {
-            _size = value;
-
-            if (IsInitialized)
-            {
-                SetRelativeLayout (SuperView?.Frame.Size ?? Host.Frame.Size);
-                ShowHideScrollBars (false);
-                SetNeedsLayout ();
-            }
-        }
-    }
-
-    private bool _showBothScrollIndicator => OtherScrollBarView?.ShowScrollIndicator == true && ShowScrollIndicator;
-
-    /// <summary>This event is raised when the position on the scrollbar has changed.</summary>
-    public event EventHandler ChangedPosition;
-
-    /// <inheritdoc/>
-    protected override bool OnMouseEvent (MouseEventArgs mouseEvent)
-    {
-        if (mouseEvent.Flags != MouseFlags.Button1Pressed
-            && mouseEvent.Flags != MouseFlags.Button1DoubleClicked
-            && !mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition)
-            && mouseEvent.Flags != MouseFlags.Button1Released
-            && mouseEvent.Flags != MouseFlags.WheeledDown
-            && mouseEvent.Flags != MouseFlags.WheeledUp
-            && mouseEvent.Flags != MouseFlags.WheeledRight
-            && mouseEvent.Flags != MouseFlags.WheeledLeft
-            && mouseEvent.Flags != MouseFlags.Button1TripleClicked)
-        {
-            return false;
-        }
-
-        if (!Host.CanFocus)
-        {
-            return true;
-        }
-
-        if (Host?.HasFocus == false)
-        {
-            Host.SetFocus ();
-        }
-
-        int location = _vertical ? mouseEvent.Position.Y : mouseEvent.Position.X;
-        int barsize = _vertical ? Viewport.Height : Viewport.Width;
-        int posTopLeftTee = _vertical ? _posTopTee + 1 : _posLeftTee + 1;
-        int posBottomRightTee = _vertical ? _posBottomTee + 1 : _posRightTee + 1;
-        barsize -= 2;
-        int pos = Position;
-
-        if (mouseEvent.Flags != MouseFlags.Button1Released && (Application.MouseGrabView is null || Application.MouseGrabView != this))
-        {
-            Application.GrabMouse (this);
-        }
-        else if (mouseEvent.Flags == MouseFlags.Button1Released && Application.MouseGrabView is { } && Application.MouseGrabView == this)
-        {
-            _lastLocation = -1;
-            Application.UngrabMouse ();
-
-            return true;
-        }
-
-        if (ShowScrollIndicator
-            && (mouseEvent.Flags == MouseFlags.WheeledDown
-                || mouseEvent.Flags == MouseFlags.WheeledUp
-                || mouseEvent.Flags == MouseFlags.WheeledRight
-                || mouseEvent.Flags == MouseFlags.WheeledLeft))
-        {
-            return Host.NewMouseEvent (mouseEvent) == true;
-        }
-
-        if (mouseEvent.Flags == MouseFlags.Button1Pressed && location == 0)
-        {
-            if (pos > 0)
-            {
-                Position = pos - 1;
-            }
-        }
-        else if (mouseEvent.Flags == MouseFlags.Button1Pressed && location == barsize + 1)
-        {
-            if (CanScroll (1, out _, _vertical))
-            {
-                Position = pos + 1;
-            }
-        }
-        else if (location > 0 && location < barsize + 1)
-        {
-            //var b1 = pos * (Size > 0 ? barsize / Size : 0);
-            //var b2 = Size > 0
-            //	? (KeepContentAlwaysInViewport ? Math.Min (((pos + barsize) * barsize / Size) + 1, barsize - 1) : (pos + barsize) * barsize / Size)
-            //	: 0;
-            //if (KeepContentAlwaysInViewport && b1 == b2) {
-            //	b1 = Math.Max (b1 - 1, 0);
-            //}
-
-            if (_lastLocation > -1
-                || (location >= posTopLeftTee
-                    && location <= posBottomRightTee
-                    && mouseEvent.Flags.HasFlag (
-                                                 MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
-                                                )))
-            {
-                if (_lastLocation == -1)
-                {
-                    _lastLocation = location;
-
-                    _posBarOffset = _keepContentAlwaysInViewport
-                                        ? Math.Max (location - posTopLeftTee, 1)
-                                        : 0;
-
-                    return true;
-                }
-
-                if (location > _lastLocation)
-                {
-                    if (location - _posBarOffset < barsize)
-                    {
-                        int np = (location - _posBarOffset) * Size / barsize + Size / barsize;
-
-                        if (CanScroll (np - pos, out int nv, _vertical))
-                        {
-                            Position = pos + nv;
-                        }
-                    }
-                    else if (CanScroll (Size - pos, out int nv, _vertical))
-                    {
-                        Position = Math.Min (pos + nv, Size);
-                    }
-                }
-                else if (location < _lastLocation)
-                {
-                    if (location - _posBarOffset > 0)
-                    {
-                        int np = (location - _posBarOffset) * Size / barsize - Size / barsize;
-
-                        if (CanScroll (np - pos, out int nv, _vertical))
-                        {
-                            Position = pos + nv;
-                        }
-                    }
-                    else
-                    {
-                        Position = 0;
-                    }
-                }
-                else if (location - _posBarOffset >= barsize && posBottomRightTee - posTopLeftTee >= 3 && CanScroll (Size - pos, out int nv, _vertical))
-                {
-                    Position = Math.Min (pos + nv, Size);
-                }
-                else if (location - _posBarOffset >= barsize - 1 && posBottomRightTee - posTopLeftTee <= 3 && CanScroll (Size - pos, out nv, _vertical))
-                {
-                    Position = Math.Min (pos + nv, Size);
-                }
-                else if (location - _posBarOffset <= 0 && posBottomRightTee - posTopLeftTee <= 3)
-                {
-                    Position = 0;
-                }
-            }
-            else if (location > posBottomRightTee)
-            {
-                if (CanScroll (barsize, out int nv, _vertical))
-                {
-                    Position = pos + nv;
-                }
-            }
-            else if (location < posTopLeftTee)
-            {
-                if (CanScroll (-barsize, out int nv, _vertical))
-                {
-                    Position = pos + nv;
-                }
-            }
-            else if (location == 1 && posTopLeftTee <= 3)
-            {
-                Position = 0;
-            }
-            else if (location == barsize)
-            {
-                if (CanScroll (Size - pos, out int nv, _vertical))
-                {
-                    Position = Math.Min (pos + nv, Size);
-                }
-            }
-        }
-
-        return true;
-    }
-
-    /// <summary>Virtual method to invoke the <see cref="ChangedPosition"/> action event.</summary>
-    public virtual void OnChangedPosition () { ChangedPosition?.Invoke (this, EventArgs.Empty); }
-
-    /// <inheritdoc/>
-    protected override bool OnDrawingContent ()
-    {
-        if (ColorScheme is null || ((!ShowScrollIndicator || Size == 0) && AutoHideScrollBars && Visible))
-        {
-            if ((!ShowScrollIndicator || Size == 0) && AutoHideScrollBars && Visible)
-            {
-                ShowHideScrollBars (false);
-            }
-
-            return false;
-        }
-
-        if (Size == 0 || (_vertical && Viewport.Height == 0) || (!_vertical && Viewport.Width == 0))
-        {
-            return false;
-        }
-
-        SetAttribute (Host.HasFocus ? ColorScheme.Focus : GetNormalColor ());
-
-        if (_vertical)
-        {
-            if (Viewport.Right < Viewport.Width - 1)
-            {
-                return true;
-            }
-
-            int col = Viewport.Width - 1;
-            int bh = Viewport.Height;
-            Rune special;
-
-            if (bh < 4)
-            {
-                int by1 = _position * bh / Size;
-                int by2 = (_position + bh) * bh / Size;
-
-                Move (col, 0);
-
-                if (Viewport.Height == 1)
-                {
-                    Driver.AddRune (Glyphs.Diamond);
-                }
-                else
-                {
-                    Driver.AddRune (Glyphs.UpArrow);
-                }
-
-                if (Viewport.Height == 3)
-                {
-                    Move (col, 1);
-                    Driver.AddRune (Glyphs.Diamond);
-                }
-
-                if (Viewport.Height > 1)
-                {
-                    Move (col, Viewport.Height - 1);
-                    Driver.AddRune (Glyphs.DownArrow);
-                }
-            }
-            else
-            {
-                bh -= 2;
-
-                int by1 = KeepContentAlwaysInViewport
-                              ? _position * bh / Size
-                              : _position * bh / (Size + bh);
-
-                int by2 = KeepContentAlwaysInViewport
-                              ? Math.Min ((_position + bh) * bh / Size + 1, bh - 1)
-                              : (_position + bh) * bh / (Size + bh);
-
-                if (KeepContentAlwaysInViewport && by1 == by2)
-                {
-                    by1 = Math.Max (by1 - 1, 0);
-                }
-
-                AddRune (col, 0, Glyphs.UpArrow);
-
-                var hasTopTee = false;
-                var hasDiamond = false;
-                var hasBottomTee = false;
-
-                for (var y = 0; y < bh; y++)
-                {
-
-                    if ((y < by1 || y > by2) && ((_position > 0 && !hasTopTee) || (hasTopTee && hasBottomTee)))
-                    {
-                        special = Glyphs.Stipple;
-                    }
-                    else
-                    {
-                        if (y != by2 && y > 1 && by2 - by1 == 0 && by1 < bh - 1 && hasTopTee && !hasDiamond)
-                        {
-                            hasDiamond = true;
-                            special = Glyphs.Diamond;
-                        }
-                        else
-                        {
-                            if (y == by1 && !hasTopTee)
-                            {
-                                hasTopTee = true;
-                                _posTopTee = y;
-                                special = Glyphs.TopTee;
-                            }
-                            else if (((_position == 0 && y == bh - 1) || y >= by2 || by2 == 0) && !hasBottomTee)
-                            {
-                                hasBottomTee = true;
-                                _posBottomTee = y;
-                                special = Glyphs.BottomTee;
-                            }
-                            else
-                            {
-                                special = Glyphs.VLine;
-                            }
-                        }
-                    }
-
-                    AddRune (col, y + 1, special);
-                }
-
-                if (!hasTopTee)
-                {
-                    AddRune (col, Viewport.Height - 2, Glyphs.TopTee);
-                }
-
-                AddRune (col, Viewport.Height - 1, Glyphs.DownArrow);
-            }
-        }
-        else
-        {
-            if (Viewport.Bottom < Viewport.Height - 1)
-            {
-                return true;
-            }
-
-            int row = Viewport.Height - 1;
-            int bw = Viewport.Width;
-            Rune special;
-
-            if (bw < 4)
-            {
-                int bx1 = _position * bw / Size;
-                int bx2 = (_position + bw) * bw / Size;
-
-                Move (0, row);
-                Driver.AddRune (Glyphs.LeftArrow);
-                Driver.AddRune (Glyphs.RightArrow);
-            }
-            else
-            {
-                bw -= 2;
-
-                int bx1 = KeepContentAlwaysInViewport
-                              ? _position * bw / Size
-                              : _position * bw / (Size + bw);
-
-                int bx2 = KeepContentAlwaysInViewport
-                              ? Math.Min ((_position + bw) * bw / Size + 1, bw - 1)
-                              : (_position + bw) * bw / (Size + bw);
-
-                if (KeepContentAlwaysInViewport && bx1 == bx2)
-                {
-                    bx1 = Math.Max (bx1 - 1, 0);
-                }
-
-                Move (0, row);
-                Driver.AddRune (Glyphs.LeftArrow);
-
-                var hasLeftTee = false;
-                var hasDiamond = false;
-                var hasRightTee = false;
-
-                for (var x = 0; x < bw; x++)
-                {
-                    if ((x < bx1 || x >= bx2 + 1) && ((_position > 0 && !hasLeftTee) || (hasLeftTee && hasRightTee)))
-                    {
-                        special = Glyphs.Stipple;
-                    }
-                    else
-                    {
-                        if (x != bx2 && x > 1 && bx2 - bx1 == 0 && bx1 < bw - 1 && hasLeftTee && !hasDiamond)
-                        {
-                            hasDiamond = true;
-                            special = Glyphs.Diamond;
-                        }
-                        else
-                        {
-                            if (x == bx1 && !hasLeftTee)
-                            {
-                                hasLeftTee = true;
-                                _posLeftTee = x;
-                                special = Glyphs.LeftTee;
-                            }
-                            else if (((_position == 0 && x == bw - 1) || x >= bx2 || bx2 == 0) && !hasRightTee)
-                            {
-                                hasRightTee = true;
-                                _posRightTee = x;
-                                special = Glyphs.RightTee;
-                            }
-                            else
-                            {
-                                special = Glyphs.HLine;
-                            }
-                        }
-                    }
-
-                    Driver.AddRune (special);
-                }
-
-                if (!hasLeftTee)
-                {
-                    Move (Viewport.Width - 2, row);
-                    Driver.AddRune (Glyphs.LeftTee);
-                }
-
-                Driver.AddRune (Glyphs.RightArrow);
-            }
-        }
-
-        return false;
-    }
-
-
-    /// <summary>Only used for a hosted view that will update and redraw the scrollbars.</summary>
-    public virtual void Refresh () { ShowHideScrollBars (); }
-
-    internal bool CanScroll (int n, out int max, bool isVertical = false)
-    {
-        if (Host?.Viewport.IsEmpty != false)
-        {
-            max = 0;
-
-            return false;
-        }
-
-        int s = GetBarsize (isVertical);
-        int newSize = Math.Max (Math.Min (_size - s, _position + n), 0);
-        max = _size > s + newSize ? newSize == 0 ? -_position : n : _size - (s + _position) - 1;
-
-        if (_size >= s + newSize && max != 0)
-        {
-            return true;
-        }
-
-        return false;
-    }
-
-    private bool CheckBothScrollBars (ScrollBarView scrollBarView, bool pending = false)
-    {
-        int barsize = scrollBarView._vertical ? scrollBarView.Viewport.Height : scrollBarView.Viewport.Width;
-
-        if (barsize == 0 || barsize >= scrollBarView._size)
-        {
-            if (scrollBarView.ShowScrollIndicator)
-            {
-                scrollBarView.ShowScrollIndicator = false;
-            }
-
-            if (scrollBarView.Visible)
-            {
-                scrollBarView.Visible = false;
-            }
-        }
-        else if (barsize > 0 && barsize == scrollBarView._size && scrollBarView.OtherScrollBarView is { } && pending)
-        {
-            if (scrollBarView.ShowScrollIndicator)
-            {
-                scrollBarView.ShowScrollIndicator = false;
-            }
-
-            if (scrollBarView.Visible)
-            {
-                scrollBarView.Visible = false;
-            }
-
-            if (scrollBarView.OtherScrollBarView is { } && scrollBarView._showBothScrollIndicator)
-            {
-                scrollBarView.OtherScrollBarView.ShowScrollIndicator = false;
-            }
-
-            if (scrollBarView.OtherScrollBarView.Visible)
-            {
-                scrollBarView.OtherScrollBarView.Visible = false;
-            }
-        }
-        else if (barsize > 0 && barsize == _size && scrollBarView.OtherScrollBarView is { } && !pending)
-        {
-            pending = true;
-        }
-        else
-        {
-            if (scrollBarView.OtherScrollBarView is { } && pending)
-            {
-                if (!scrollBarView._showBothScrollIndicator)
-                {
-                    scrollBarView.OtherScrollBarView.ShowScrollIndicator = true;
-                }
-
-                if (!scrollBarView.OtherScrollBarView.Visible)
-                {
-                    scrollBarView.OtherScrollBarView.Visible = true;
-                }
-            }
-
-            if (!scrollBarView.ShowScrollIndicator)
-            {
-                scrollBarView.ShowScrollIndicator = true;
-            }
-
-            if (!scrollBarView.Visible)
-            {
-                scrollBarView.Visible = true;
-            }
-        }
-
-        return pending;
-    }
-
-    private void ContentBottomRightCorner_DrawContent (object sender, DrawEventArgs e)
-    {
-        SetAttribute (Host.HasFocus ? ColorScheme.Focus : GetNormalColor ());
-
-        // I'm forced to do this here because the Clear method is
-        // changing the color attribute and is different of this one
-        Driver.FillRect (Driver.Clip.GetBounds());
-        e.Cancel = true;
-    }
-
-    //private void Host_CanFocusChanged ()
-    //{
-    //	CanFocus = Host.CanFocus;
-    //	if (otherScrollBarView is { }) {
-    //		otherScrollBarView.CanFocus = CanFocus;
-    //	}
-    //}
-
-    private void ContentBottomRightCorner_MouseClick (object sender, MouseEventArgs me)
-    {
-        if (me.Flags == MouseFlags.WheeledDown
-            || me.Flags == MouseFlags.WheeledUp
-            || me.Flags == MouseFlags.WheeledRight
-            || me.Flags == MouseFlags.WheeledLeft)
-        {
-            NewMouseEvent (me);
-        }
-        else if (me.Flags == MouseFlags.Button1Clicked)
-        {
-            Host.SetFocus ();
-        }
-
-        me.Handled = true;
-    }
-
-    private void CreateBottomRightCorner (View host)
-    {
-        if (Host is null)
-        {
-            Host = host;
-        }
-
-        if (Host != null
-            && ((_contentBottomRightCorner is null && OtherScrollBarView is null)
-                || (_contentBottomRightCorner is null && OtherScrollBarView is { } && OtherScrollBarView._contentBottomRightCorner is null)))
-        {
-            _contentBottomRightCorner = new ContentBottomRightCorner { Visible = Host.Visible };
-
-            if (_hosted)
-            {
-                Host.SuperView.Add (_contentBottomRightCorner);
-                _contentBottomRightCorner.X = Pos.Right (Host) - 1;
-                _contentBottomRightCorner.Y = Pos.Bottom (Host) - 1;
-            }
-            else
-            {
-                Host.Add (_contentBottomRightCorner);
-                _contentBottomRightCorner.X = Pos.AnchorEnd (1);
-                _contentBottomRightCorner.Y = Pos.AnchorEnd (1);
-            }
-
-            _contentBottomRightCorner.Width = 1;
-            _contentBottomRightCorner.Height = 1;
-            _contentBottomRightCorner.MouseClick += ContentBottomRightCorner_MouseClick;
-            _contentBottomRightCorner.DrawingContent += ContentBottomRightCorner_DrawContent;
-        }
-    }
-
-    private int GetBarsize (bool isVertical)
-    {
-        if (Host?.Viewport.IsEmpty != false)
-        {
-            return 0;
-        }
-
-        return isVertical ? KeepContentAlwaysInViewport
-                                ? Host.Viewport.Height + (_showBothScrollIndicator ? -2 : -1)
-                                : 0 :
-               KeepContentAlwaysInViewport ? Host.Viewport.Width + (_showBothScrollIndicator ? -2 : -1) : 0;
-    }
-
-    private void Host_EnabledChanged (object sender, EventArgs e)
-    {
-        Enabled = Host.Enabled;
-
-        if (_otherScrollBarView is { })
-        {
-            _otherScrollBarView.Enabled = Enabled;
-        }
-
-        _contentBottomRightCorner.Enabled = Enabled;
-    }
-
-    private void Host_VisibleChanged (object sender, EventArgs e)
-    {
-        if (!Host.Visible)
-        {
-            Visible = Host.Visible;
-
-            if (_otherScrollBarView is { })
-            {
-                _otherScrollBarView.Visible = Visible;
-            }
-
-            _contentBottomRightCorner.Visible = Visible;
-        }
-        else
-        {
-            ShowHideScrollBars ();
-        }
-    }
-
-    private void ScrollBarView_Initialized (object sender, EventArgs e)
-    {
-        SetWidthHeight ();
-        SetRelativeLayout (SuperView?.Frame.Size ?? Host?.Frame.Size ?? Frame.Size);
-
-        if (OtherScrollBarView is null)
-        {
-            // Only do this once if both scrollbars are enabled
-            ShowHideScrollBars ();
-        }
-
-        SetPosition (Position);
-    }
-
-    // Helper to assist Initialized event handler
-    private void SetPosition (int newPosition)
-    {
-        if (!IsInitialized)
-        {
-            // We're not initialized so we can't do anything fancy. Just cache value.
-            _position = newPosition;
-
-            return;
-        }
-
-        if (newPosition < 0)
-        {
-            _position = 0;
-            SetNeedsDraw ();
-
-            return;
-        }
-        else if (CanScroll (newPosition - _position, out int max, _vertical))
-        {
-            if (max == newPosition - _position)
-            {
-                _position = newPosition;
-            }
-            else
-            {
-                _position = Math.Max (_position + max, 0);
-            }
-        }
-        else if (max < 0)
-        {
-            _position = Math.Max (_position + max, 0);
-        }
-        else
-        {
-            _position = Math.Max (newPosition, 0);
-        }
-
-        OnChangedPosition ();
-        SetNeedsDraw ();
-    }
-
-    // BUGBUG: v2 - rationalize this with View.SetMinWidthHeight
-    private void SetWidthHeight ()
-    {
-        // BUGBUG: v2 - If Host is also the ScrollBarView's superview, this is all bogus because it's not
-        // supported that a view can reference it's superview's Dims. This code also assumes the host does 
-        //  not have a margin/borderframe/padding.
-        if (!IsInitialized || _otherScrollBarView is { IsInitialized: false })
-        {
-            return;
-        }
-
-        if (_showBothScrollIndicator)
-        {
-            Width = _vertical ? 1 :
-                    Host != SuperView ? Dim.Width (Host) - 1 : Dim.Fill () - 1;
-            Height = _vertical ? Host != SuperView ? Dim.Height (Host) - 1 : Dim.Fill () - 1 : 1;
-
-            _otherScrollBarView.Width = _otherScrollBarView._vertical ? 1 :
-                                        Host != SuperView ? Dim.Width (Host) - 1 : Dim.Fill () - 1;
-
-            _otherScrollBarView.Height = _otherScrollBarView._vertical
-                                             ? Host != SuperView ? Dim.Height (Host) - 1 : Dim.Fill () - 1
-                                             : 1;
-        }
-        else if (ShowScrollIndicator)
-        {
-            Width = _vertical ? 1 :
-                    Host != SuperView ? Dim.Width (Host) : Dim.Fill ();
-            Height = _vertical ? Host != SuperView ? Dim.Height (Host) : Dim.Fill () : 1;
-        }
-        else if (_otherScrollBarView?.ShowScrollIndicator == true)
-        {
-            _otherScrollBarView.Width = _otherScrollBarView._vertical ? 1 :
-                                        Host != SuperView ? Dim.Width (Host) : Dim.Fill () - 0;
-
-            _otherScrollBarView.Height = _otherScrollBarView._vertical
-                                             ? Host != SuperView ? Dim.Height (Host) : Dim.Fill () - 0
-                                             : 1;
-        }
-    }
-
-    private void ShowHideScrollBars (bool redraw = true)
-    {
-        if (!_hosted || (_hosted && !_autoHideScrollBars))
-        {
-            if (_contentBottomRightCorner is { } && _contentBottomRightCorner.Visible)
-            {
-                _contentBottomRightCorner.Visible = false;
-            }
-            else if (_otherScrollBarView != null
-                     && _otherScrollBarView._contentBottomRightCorner != null
-                     && _otherScrollBarView._contentBottomRightCorner.Visible)
-            {
-                _otherScrollBarView._contentBottomRightCorner.Visible = false;
-            }
-
-            return;
-        }
-
-        bool pending = CheckBothScrollBars (this);
-
-        if (_otherScrollBarView is { })
-        {
-            CheckBothScrollBars (_otherScrollBarView, pending);
-        }
-
-        SetWidthHeight ();
-        SetRelativeLayout (SuperView?.Frame.Size ?? Host.Frame.Size);
-
-        if (_otherScrollBarView is { })
-        {
-            OtherScrollBarView.SetRelativeLayout (SuperView?.Frame.Size ?? Host.Frame.Size);
-        }
-
-        if (_showBothScrollIndicator)
-        {
-            if (_contentBottomRightCorner is { })
-            {
-                _contentBottomRightCorner.Visible = true;
-            }
-            else if (_otherScrollBarView is { } && _otherScrollBarView._contentBottomRightCorner is { })
-            {
-                _otherScrollBarView._contentBottomRightCorner.Visible = true;
-            }
-        }
-        else if (!ShowScrollIndicator)
-        {
-            if (_contentBottomRightCorner is { })
-            {
-                _contentBottomRightCorner.Visible = false;
-            }
-            else if (_otherScrollBarView is { } && _otherScrollBarView._contentBottomRightCorner is { })
-            {
-                _otherScrollBarView._contentBottomRightCorner.Visible = false;
-            }
-
-            if (Application.MouseGrabView is { } && Application.MouseGrabView == this)
-            {
-                Application.UngrabMouse ();
-            }
-        }
-        else if (_contentBottomRightCorner is { })
-        {
-            _contentBottomRightCorner.Visible = false;
-        }
-        else if (_otherScrollBarView is { } && _otherScrollBarView._contentBottomRightCorner is { })
-        {
-            _otherScrollBarView._contentBottomRightCorner.Visible = false;
-        }
-
-        if (Host?.Visible == true && ShowScrollIndicator && !Visible)
-        {
-            Visible = true;
-        }
-
-        if (Host?.Visible == true && _otherScrollBarView?.ShowScrollIndicator == true && !_otherScrollBarView.Visible)
-        {
-            _otherScrollBarView.Visible = true;
-        }
-
-        if (!redraw)
-        {
-            return;
-        }
-
-        if (ShowScrollIndicator)
-        {
-            Draw ();
-        }
-
-        if (_otherScrollBarView is { } && _otherScrollBarView.ShowScrollIndicator)
-        {
-            _otherScrollBarView.Draw ();
-        }
-
-        if (_contentBottomRightCorner is { } && _contentBottomRightCorner.Visible)
-        {
-            _contentBottomRightCorner.Draw ();
-        }
-        else if (_otherScrollBarView is { } && _otherScrollBarView._contentBottomRightCorner is { } && _otherScrollBarView._contentBottomRightCorner.Visible)
-        {
-            _otherScrollBarView._contentBottomRightCorner.Draw ();
-        }
-    }
-
-    internal class ContentBottomRightCorner : View
-    {
-        public ContentBottomRightCorner ()
-        {
-            ColorScheme = ColorScheme;
-        }
-    }
-}

+ 0 - 774
Terminal.Gui/Views/ScrollView.cs

@@ -1,774 +0,0 @@
-//
-// ScrollView.cs: ScrollView view.
-//
-// Authors:
-//   Miguel de Icaza ([email protected])
-//
-//
-// TODO:
-// - focus in scrollview
-// - focus handling in scrollview to auto scroll to focused view
-// - Raise events
-// - Perhaps allow an option to not display the scrollbar arrow indicators?
-
-using System.ComponentModel;
-
-namespace Terminal.Gui;
-
-/// <summary>
-///     Scrollviews are views that present a window into a virtual space where subviews are added.  Similar to the iOS
-///     UIScrollView.
-/// </summary>
-/// <remarks>
-///     <para>
-///         The subviews that are added to this <see cref="Gui.ScrollView"/> are offset by the
-///         <see cref="ContentOffset"/> property.  The view itself is a window into the space represented by the
-///         <see cref="View.GetContentSize ()"/>.
-///     </para>
-///     <para>Use the</para>
-/// </remarks>
-public class ScrollView : View
-{
-    private readonly ContentView _contentView;
-    private readonly ScrollBarView _horizontal;
-    private readonly ScrollBarView _vertical;
-    private bool _autoHideScrollBars = true;
-    private View _contentBottomRightCorner;
-    private Point _contentOffset;
-    private bool _keepContentAlwaysInViewport = true;
-    private bool _showHorizontalScrollIndicator;
-    private bool _showVerticalScrollIndicator;
-
-    /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.ScrollView"/> class.
-    /// </summary>
-    public ScrollView ()
-    {
-        _contentView = new ContentView ();
-
-        _vertical = new ScrollBarView
-        {
-            X = Pos.AnchorEnd (1),
-            Y = 0,
-            Width = 1,
-            Height = Dim.Fill (_showHorizontalScrollIndicator ? 1 : 0),
-            Size = 1,
-            IsVertical = true,
-            Host = this
-        };
-
-        _horizontal = new ScrollBarView
-        {
-            X = 0,
-            Y = Pos.AnchorEnd (1),
-            Width = Dim.Fill (_showVerticalScrollIndicator ? 1 : 0),
-            Height = 1,
-            Size = 1,
-            IsVertical = false,
-            Host = this
-        };
-
-        _vertical.OtherScrollBarView = _horizontal;
-        _horizontal.OtherScrollBarView = _vertical;
-        base.Add (_contentView);
-        CanFocus = true;
-        TabStop = TabBehavior.TabGroup;
-
-        MouseEnter += View_MouseEnter;
-        MouseLeave += View_MouseLeave;
-        _contentView.MouseEnter += View_MouseEnter;
-        _contentView.MouseLeave += View_MouseLeave;
-
-        Application.UnGrabbedMouse += Application_UnGrabbedMouse;
-
-        // Things this view knows how to do
-        AddCommand (Command.ScrollUp, () => ScrollUp (1));
-        AddCommand (Command.ScrollDown, () => ScrollDown (1));
-        AddCommand (Command.ScrollLeft, () => ScrollLeft (1));
-        AddCommand (Command.ScrollRight, () => ScrollRight (1));
-        AddCommand (Command.PageUp, () => ScrollUp (Viewport.Height));
-        AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height));
-        AddCommand (Command.PageLeft, () => ScrollLeft (Viewport.Width));
-        AddCommand (Command.PageRight, () => ScrollRight (Viewport.Width));
-        AddCommand (Command.Start, () => ScrollUp (GetContentSize ().Height));
-        AddCommand (Command.End, () => ScrollDown (GetContentSize ().Height));
-        AddCommand (Command.LeftStart, () => ScrollLeft (GetContentSize ().Width));
-        AddCommand (Command.RightEnd, () => ScrollRight (GetContentSize ().Width));
-
-        // Default keybindings for this view
-        KeyBindings.Add (Key.CursorUp, Command.ScrollUp);
-        KeyBindings.Add (Key.CursorDown, Command.ScrollDown);
-        KeyBindings.Add (Key.CursorLeft, Command.ScrollLeft);
-        KeyBindings.Add (Key.CursorRight, Command.ScrollRight);
-
-        KeyBindings.Add (Key.PageUp, Command.PageUp);
-        KeyBindings.Add (Key.V.WithAlt, Command.PageUp);
-
-        KeyBindings.Add (Key.PageDown, Command.PageDown);
-        KeyBindings.Add (Key.V.WithCtrl, Command.PageDown);
-
-        KeyBindings.Add (Key.PageUp.WithCtrl, Command.PageLeft);
-        KeyBindings.Add (Key.PageDown.WithCtrl, Command.PageRight);
-        KeyBindings.Add (Key.Home, Command.Start);
-        KeyBindings.Add (Key.End, Command.End);
-        KeyBindings.Add (Key.Home.WithCtrl, Command.LeftStart);
-        KeyBindings.Add (Key.End.WithCtrl, Command.RightEnd);
-
-        Initialized += (s, e) =>
-                       {
-                           if (!_vertical.IsInitialized)
-                           {
-                               _vertical.BeginInit ();
-                               _vertical.EndInit ();
-                           }
-
-                           if (!_horizontal.IsInitialized)
-                           {
-                               _horizontal.BeginInit ();
-                               _horizontal.EndInit ();
-                           }
-
-                           SetContentOffset (_contentOffset);
-                           _contentView.Frame = new Rectangle (ContentOffset, GetContentSize ());
-
-                           // PERF: How about calls to Point.Offset instead?
-                           _vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
-                           _horizontal.ChangedPosition += delegate { ContentOffset = new Point (_horizontal.Position, ContentOffset.Y); };
-                       };
-        ContentSizeChanged += ScrollViewContentSizeChanged;
-    }
-
-    private void ScrollViewContentSizeChanged (object sender, SizeChangedEventArgs e)
-    {
-        if (e.Size is null)
-        {
-            return;
-        }
-        _contentView.Frame = new Rectangle (ContentOffset, e.Size.Value with { Width = e.Size.Value.Width - 1, Height = e.Size.Value.Height - 1 });
-        _vertical.Size = e.Size.Value.Height;
-        _horizontal.Size = e.Size.Value.Width;
-    }
-
-    private void Application_UnGrabbedMouse (object sender, ViewEventArgs e)
-    {
-        var parent = e.View is Adornment adornment ? adornment.Parent : e.View;
-
-        if (parent is { })
-        {
-            var supView = parent.SuperView;
-
-            while (supView is { })
-            {
-                if (supView == _contentView)
-                {
-                    Application.GrabMouse (this);
-
-                    break;
-                }
-
-                supView = supView.SuperView;
-            }
-        }
-    }
-
-    /// <summary>If true the vertical/horizontal scroll bars won't be showed if it's not needed.</summary>
-    public bool AutoHideScrollBars
-    {
-        get => _autoHideScrollBars;
-        set
-        {
-            if (_autoHideScrollBars != value)
-            {
-                _autoHideScrollBars = value;
-
-                if (Subviews.Contains (_vertical))
-                {
-                    _vertical.AutoHideScrollBars = value;
-                }
-
-                if (Subviews.Contains (_horizontal))
-                {
-                    _horizontal.AutoHideScrollBars = value;
-                }
-
-                SetNeedsDraw ();
-            }
-        }
-    }
-
-    /// <summary>Represents the top left corner coordinate that is displayed by the scrollview</summary>
-    /// <value>The content offset.</value>
-    public Point ContentOffset
-    {
-        get => _contentOffset;
-        set
-        {
-            if (!IsInitialized)
-            {
-                // We're not initialized so we can't do anything fancy. Just cache value.
-                _contentOffset = new Point (-Math.Abs (value.X), -Math.Abs (value.Y));
-
-                return;
-            }
-
-            SetContentOffset (value);
-        }
-    }
-
-    ///// <summary>Represents the contents of the data shown inside the scrollview</summary>
-    ///// <value>The size of the content.</value>
-    //public new Size ContentSize
-    //{
-    //    get => ContentSize;
-    //    set
-    //    {
-    //        if (GetContentSize () != value)
-    //        {
-    //            ContentSize = value;
-    //            _contentView.Frame = new Rectangle (_contentOffset, value);
-    //            _vertical.Size = GetContentSize ().Height;
-    //            _horizontal.Size = GetContentSize ().Width;
-    //            SetNeedsDraw ();
-    //        }
-    //    }
-    //}
-
-    /// <summary>Get or sets if the view-port is kept always visible in the area of this <see cref="ScrollView"/></summary>
-    public bool KeepContentAlwaysInViewport
-    {
-        get => _keepContentAlwaysInViewport;
-        set
-        {
-            if (_keepContentAlwaysInViewport != value)
-            {
-                _keepContentAlwaysInViewport = value;
-                _vertical.OtherScrollBarView.KeepContentAlwaysInViewport = value;
-                _horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
-                Point p = default;
-
-                if (value && -_contentOffset.X + Viewport.Width > GetContentSize ().Width)
-                {
-                    p = new Point (
-                                   GetContentSize ().Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
-                                   -_contentOffset.Y
-                                  );
-                }
-
-                if (value && -_contentOffset.Y + Viewport.Height > GetContentSize ().Height)
-                {
-                    if (p == default (Point))
-                    {
-                        p = new Point (
-                                       -_contentOffset.X,
-                                       GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
-                                      );
-                    }
-                    else
-                    {
-                        p.Y = GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
-                    }
-                }
-
-                if (p != default (Point))
-                {
-                    ContentOffset = p;
-                }
-            }
-        }
-    }
-
-    /// <summary>Gets or sets the visibility for the horizontal scroll indicator.</summary>
-    /// <value><c>true</c> if show horizontal scroll indicator; otherwise, <c>false</c>.</value>
-    public bool ShowHorizontalScrollIndicator
-    {
-        get => _showHorizontalScrollIndicator;
-        set
-        {
-            if (value != _showHorizontalScrollIndicator)
-            {
-                _showHorizontalScrollIndicator = value;
-                SetNeedsLayout ();
-
-                if (value)
-                {
-                    _horizontal.OtherScrollBarView = _vertical;
-                    base.Add (_horizontal);
-                    _horizontal.ShowScrollIndicator = value;
-                    _horizontal.AutoHideScrollBars = _autoHideScrollBars;
-                    _horizontal.OtherScrollBarView.ShowScrollIndicator = value;
-                    _horizontal.MouseEnter += View_MouseEnter;
-                    _horizontal.MouseLeave += View_MouseLeave;
-                }
-                else
-                {
-                    base.Remove (_horizontal);
-                    _horizontal.OtherScrollBarView = null;
-                    _horizontal.MouseEnter -= View_MouseEnter;
-                    _horizontal.MouseLeave -= View_MouseLeave;
-                }
-            }
-
-            _vertical.Height = Dim.Fill (_showHorizontalScrollIndicator ? 1 : 0);
-        }
-    }
-
-    /// <summary>Gets or sets the visibility for the vertical scroll indicator.</summary>
-    /// <value><c>true</c> if show vertical scroll indicator; otherwise, <c>false</c>.</value>
-    public bool ShowVerticalScrollIndicator
-    {
-        get => _showVerticalScrollIndicator;
-        set
-        {
-            if (value != _showVerticalScrollIndicator)
-            {
-                _showVerticalScrollIndicator = value;
-                SetNeedsLayout ();
-
-                if (value)
-                {
-                    _vertical.OtherScrollBarView = _horizontal;
-                    base.Add (_vertical);
-                    _vertical.ShowScrollIndicator = value;
-                    _vertical.AutoHideScrollBars = _autoHideScrollBars;
-                    _vertical.OtherScrollBarView.ShowScrollIndicator = value;
-                    _vertical.MouseEnter += View_MouseEnter;
-                    _vertical.MouseLeave += View_MouseLeave;
-                }
-                else
-                {
-                    Remove (_vertical);
-                    _vertical.OtherScrollBarView = null;
-                    _vertical.MouseEnter -= View_MouseEnter;
-                    _vertical.MouseLeave -= View_MouseLeave;
-                }
-            }
-
-            _horizontal.Width = Dim.Fill (_showVerticalScrollIndicator ? 1 : 0);
-        }
-    }
-
-    /// <summary>Adds the view to the scrollview.</summary>
-    /// <param name="view">The view to add to the scrollview.</param>
-    public override View Add (View view)
-    {
-        if (view is ScrollBarView.ContentBottomRightCorner)
-        {
-            _contentBottomRightCorner = view;
-            base.Add (view);
-        }
-        else
-        {
-            if (!IsOverridden (view, "OnMouseEvent"))
-            {
-                view.MouseEnter += View_MouseEnter;
-                view.MouseLeave += View_MouseLeave;
-            }
-
-            _contentView.Add (view);
-        }
-
-        SetNeedsLayout ();
-        return view;
-    }
-
-    /// <inheritdoc/>
-    protected override bool OnDrawingContent ()
-    {
-        SetViewsNeedsDraw ();
-
-        // TODO: It's bad practice for views to always clear a view. It negates clipping.
-        ClearViewport ();
-
-        if (!string.IsNullOrEmpty (_contentView.Text) || _contentView.Subviews.Count > 0)
-        {
-            Region? saved = ClipFrame();
-            _contentView.Draw ();
-            View.SetClip (saved);
-        }
-
-        DrawScrollBars ();
-
-        return true;
-    }
-
-    /// <inheritdoc/>
-    protected override bool OnKeyDown (Key a)
-    {
-        if (base.OnKeyDown (a))
-        {
-            return true;
-        }
-
-        bool? result = InvokeCommands (a, KeyBindingScope.HotKey | KeyBindingScope.Focused);
-
-        if (result is { })
-        {
-            return (bool)result;
-        }
-
-        return false;
-    }
-
-    /// <inheritdoc/>
-    protected override bool OnMouseEvent (MouseEventArgs me)
-    {
-        if (!Enabled)
-        {
-            // A disabled view should not eat mouse events
-            return false;
-        }
-
-        if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
-        {
-            return ScrollDown (1);
-        }
-        else if (me.Flags == MouseFlags.WheeledUp && ShowVerticalScrollIndicator)
-        {
-            return ScrollUp (1);
-        }
-        else if (me.Flags == MouseFlags.WheeledRight && _showHorizontalScrollIndicator)
-        {
-            return ScrollRight (1);
-        }
-        else if (me.Flags == MouseFlags.WheeledLeft && ShowVerticalScrollIndicator)
-        {
-            return ScrollLeft (1);
-        }
-        else if (me.Position.X == _vertical.Frame.X && ShowVerticalScrollIndicator)
-        {
-            _vertical.NewMouseEvent (me);
-        }
-        else if (me.Position.Y == _horizontal.Frame.Y && ShowHorizontalScrollIndicator)
-        {
-            _horizontal.NewMouseEvent (me);
-        }
-        else if (IsOverridden (me.View, "OnMouseEvent"))
-        {
-            Application.UngrabMouse ();
-        }
-
-        return me.Handled;
-    }
-
-    /// <inheritdoc/>
-    public override Point? PositionCursor ()
-    {
-        if (InternalSubviews.Count == 0)
-        {
-            Move (0, 0);
-
-            return null; // Don't show the cursor
-        }
-        return base.PositionCursor ();
-    }
-
-    /// <summary>Removes the view from the scrollview.</summary>
-    /// <param name="view">The view to remove from the scrollview.</param>
-    public override View Remove (View view)
-    {
-        if (view is null)
-        {
-            return view;
-        }
-
-        SetNeedsDraw ();
-        View container = view?.SuperView;
-
-        if (container == this)
-        {
-            base.Remove (view);
-        }
-        else
-        {
-            container?.Remove (view);
-        }
-
-        if (_contentView.InternalSubviews.Count < 1)
-        {
-            CanFocus = false;
-        }
-
-        return view;
-    }
-
-    /// <summary>Removes all widgets from this container.</summary>
-    public override void RemoveAll () { _contentView.RemoveAll (); }
-
-    /// <summary>Scrolls the view down.</summary>
-    /// <returns><c>true</c>, if left was scrolled, <c>false</c> otherwise.</returns>
-    /// <param name="lines">Number of lines to scroll.</param>
-    public bool ScrollDown (int lines)
-    {
-        if (_vertical.CanScroll (lines, out _, true))
-        {
-            ContentOffset = new Point (_contentOffset.X, _contentOffset.Y - lines);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /// <summary>Scrolls the view to the left</summary>
-    /// <returns><c>true</c>, if left was scrolled, <c>false</c> otherwise.</returns>
-    /// <param name="cols">Number of columns to scroll by.</param>
-    public bool ScrollLeft (int cols)
-    {
-        if (_contentOffset.X < 0)
-        {
-            ContentOffset = new Point (Math.Min (_contentOffset.X + cols, 0), _contentOffset.Y);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /// <summary>Scrolls the view to the right.</summary>
-    /// <returns><c>true</c>, if right was scrolled, <c>false</c> otherwise.</returns>
-    /// <param name="cols">Number of columns to scroll by.</param>
-    public bool ScrollRight (int cols)
-    {
-        if (_horizontal.CanScroll (cols, out _))
-        {
-            ContentOffset = new Point (_contentOffset.X - cols, _contentOffset.Y);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /// <summary>Scrolls the view up.</summary>
-    /// <returns><c>true</c>, if left was scrolled, <c>false</c> otherwise.</returns>
-    /// <param name="lines">Number of lines to scroll.</param>
-    public bool ScrollUp (int lines)
-    {
-        if (_contentOffset.Y < 0)
-        {
-            ContentOffset = new Point (_contentOffset.X, Math.Min (_contentOffset.Y + lines, 0));
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /// <inheritdoc/>
-    protected override void Dispose (bool disposing)
-    {
-        if (!_showVerticalScrollIndicator)
-        {
-            // It was not added to SuperView, so it won't get disposed automatically
-            _vertical?.Dispose ();
-        }
-
-        if (!_showHorizontalScrollIndicator)
-        {
-            // It was not added to SuperView, so it won't get disposed automatically
-            _horizontal?.Dispose ();
-        }
-
-        Application.UnGrabbedMouse -= Application_UnGrabbedMouse;
-
-        base.Dispose (disposing);
-    }
-
-    private void DrawScrollBars ()
-    {
-        if (_autoHideScrollBars)
-        {
-            ShowHideScrollBars ();
-        }
-        else
-        {
-            if (ShowVerticalScrollIndicator)
-            {
-                Region? saved = View.SetClipToScreen ();
-                _vertical.Draw ();
-                View.SetClip (saved);
-            }
-
-            if (ShowHorizontalScrollIndicator)
-            {
-                Region? saved = View.SetClipToScreen ();
-                _horizontal.Draw ();
-                View.SetClip (saved);
-            }
-
-            if (ShowVerticalScrollIndicator && ShowHorizontalScrollIndicator)
-            {
-                SetContentBottomRightCornerVisibility ();
-                Region? saved = View.SetClipToScreen ();
-                _contentBottomRightCorner.Draw ();
-                View.SetClip (saved);
-            }
-        }
-    }
-
-    private void SetContentBottomRightCornerVisibility ()
-    {
-        if (_showHorizontalScrollIndicator && _showVerticalScrollIndicator)
-        {
-            _contentBottomRightCorner.Visible = true;
-        }
-        else if (_horizontal.IsAdded || _vertical.IsAdded)
-        {
-            _contentBottomRightCorner.Visible = false;
-        }
-    }
-
-    private void SetContentOffset (Point offset)
-    {
-        // INTENT: Unclear intent. How about a call to Offset?
-        _contentOffset = new Point (-Math.Abs (offset.X), -Math.Abs (offset.Y));
-        _contentView.Frame = new Rectangle (_contentOffset, GetContentSize ());
-        int p = Math.Max (0, -_contentOffset.Y);
-
-        if (_vertical.Position != p)
-        {
-            _vertical.Position = Math.Max (0, -_contentOffset.Y);
-        }
-
-        p = Math.Max (0, -_contentOffset.X);
-
-        if (_horizontal.Position != p)
-        {
-            _horizontal.Position = Math.Max (0, -_contentOffset.X);
-        }
-        SetNeedsDraw ();
-    }
-
-    private void SetViewsNeedsDraw ()
-    {
-        foreach (View view in _contentView.Subviews)
-        {
-            view.SetNeedsDraw ();
-        }
-    }
-
-    private void ShowHideScrollBars ()
-    {
-        bool v = false, h = false;
-        var p = false;
-
-        if (GetContentSize () is { } && (Viewport.Height == 0 || Viewport.Height > GetContentSize ().Height))
-        {
-            if (ShowVerticalScrollIndicator)
-            {
-                ShowVerticalScrollIndicator = false;
-            }
-
-            v = false;
-        }
-        else if (GetContentSize () is { } && Viewport.Height > 0 && Viewport.Height == GetContentSize ().Height)
-        {
-            p = true;
-        }
-        else
-        {
-            if (!ShowVerticalScrollIndicator)
-            {
-                ShowVerticalScrollIndicator = true;
-            }
-
-            v = true;
-        }
-
-        if (GetContentSize () is { } && (Viewport.Width == 0 || Viewport.Width > GetContentSize ().Width))
-        {
-            if (ShowHorizontalScrollIndicator)
-            {
-                ShowHorizontalScrollIndicator = false;
-            }
-
-            h = false;
-        }
-        else if (GetContentSize () is { } && Viewport.Width > 0 && Viewport.Width == GetContentSize ().Width && p)
-        {
-            if (ShowHorizontalScrollIndicator)
-            {
-                ShowHorizontalScrollIndicator = false;
-            }
-
-            h = false;
-
-            if (ShowVerticalScrollIndicator)
-            {
-                ShowVerticalScrollIndicator = false;
-            }
-
-            v = false;
-        }
-        else
-        {
-            if (p)
-            {
-                if (!ShowVerticalScrollIndicator)
-                {
-                    ShowVerticalScrollIndicator = true;
-                }
-
-                v = true;
-            }
-
-            if (!ShowHorizontalScrollIndicator)
-            {
-                ShowHorizontalScrollIndicator = true;
-            }
-
-            h = true;
-        }
-
-        Dim dim = Dim.Fill (h ? 1 : 0);
-
-        if (!_vertical.Height.Equals (dim))
-        {
-            _vertical.Height = dim;
-        }
-
-        dim = Dim.Fill (v ? 1 : 0);
-
-        if (!_horizontal.Width.Equals (dim))
-        {
-            _horizontal.Width = dim;
-        }
-
-        if (v)
-        {
-            _vertical.SetRelativeLayout (Viewport.Size);
-            _vertical.Draw ();
-        }
-
-        if (h)
-        {
-            _horizontal.SetRelativeLayout (Viewport.Size);
-            _horizontal.Draw ();
-        }
-
-        SetContentBottomRightCornerVisibility ();
-
-        if (v && h)
-        {
-            _contentBottomRightCorner.SetRelativeLayout (Viewport.Size);
-            _contentBottomRightCorner.Draw ();
-        }
-    }
-
-    private void View_MouseEnter (object sender, CancelEventArgs e) { Application.GrabMouse (this); }
-
-    private void View_MouseLeave (object sender, EventArgs e)
-    {
-        if (Application.MouseGrabView is { } && Application.MouseGrabView != this && Application.MouseGrabView != _vertical && Application.MouseGrabView != _horizontal)
-        {
-            Application.UngrabMouse ();
-        }
-    }
-
-    // The ContentView is the view that contains the subviews  and content that are being scrolled
-    // The ContentView is the size of the ContentSize and is offset by the ContentOffset
-    private class ContentView : View
-    {
-        public ContentView () { CanFocus = true; }
-    }
-}

+ 108 - 108
UICatalog/Scenarios/ASCIICustomButton.cs

@@ -137,7 +137,7 @@ public class ASCIICustomButtonTest : Scenario
         private const int BUTTONS_ON_PAGE = 7;
 
         private readonly List<Button> _buttons;
-        private readonly ScrollView _scrollView;
+        //private readonly ScrollView _scrollView;
         private ASCIICustomButton _selected;
 
         public ScrollViewTestWindow ()
@@ -151,15 +151,15 @@ public class ASCIICustomButtonTest : Scenario
                 Width = 80;
                 Height = 25;
 
-                _scrollView = new ScrollView
-                {
-                    X = 3,
-                    Y = 1,
-                    Width = 24,
-                    Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
-                    ShowVerticalScrollIndicator = true,
-                    ShowHorizontalScrollIndicator = false
-                };
+                //_scrollView = new ScrollView
+                //{
+                //    X = 3,
+                //    Y = 1,
+                //    Width = 24,
+                //    Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
+                //    ShowVerticalScrollIndicator = true,
+                //    ShowHorizontalScrollIndicator = false
+                //};
             }
             else
             {
@@ -168,18 +168,18 @@ public class ASCIICustomButtonTest : Scenario
 
                 titleLabel = new Label { X = 0, Y = 0, Text = "DOCUMENTS" };
 
-                _scrollView = new ScrollView
-                {
-                    X = 0,
-                    Y = 1,
-                    Width = 27,
-                    Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
-                    ShowVerticalScrollIndicator = true,
-                    ShowHorizontalScrollIndicator = false
-                };
+                //_scrollView = new ScrollView
+                //{
+                //    X = 0,
+                //    Y = 1,
+                //    Width = 27,
+                //    Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
+                //    ShowVerticalScrollIndicator = true,
+                //    ShowHorizontalScrollIndicator = false
+                //};
             }
 
-            _scrollView.KeyBindings.Clear ();
+            //_scrollView.KeyBindings.Clear ();
 
             _buttons = new List<Button> ();
             Button prevButton = null;
@@ -202,7 +202,7 @@ public class ASCIICustomButtonTest : Scenario
                 button.PointerEnter += Button_PointerEnter;
                 button.MouseClick += Button_MouseClick;
                 button.KeyDown += Button_KeyPress;
-                _scrollView.Add (button);
+                //_scrollView.Add (button);
                 _buttons.Add (button);
                 prevButton = button;
             }
@@ -220,7 +220,7 @@ public class ASCIICustomButtonTest : Scenario
             closeButton.PointerEnter += Button_PointerEnter;
             closeButton.MouseClick += Button_MouseClick;
             closeButton.KeyDown += Button_KeyPress;
-            _scrollView.Add (closeButton);
+            //_scrollView.Add (closeButton);
             _buttons.Add (closeButton);
 
             int pages = _buttons.Count / BUTTONS_ON_PAGE;
@@ -231,15 +231,15 @@ public class ASCIICustomButtonTest : Scenario
             }
 
             // BUGBUG: set_ContentSize is supposed to be `protected`. 
-            _scrollView.SetContentSize (new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT));
+            //_scrollView.SetContentSize (new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT));
 
             if (_smallerWindow)
             {
-                Add (_scrollView);
+                //Add (_scrollView);
             }
             else
             {
-                Add (titleLabel, _scrollView);
+                //Add (titleLabel, _scrollView);
             }
 
             Y = 1;
@@ -265,45 +265,45 @@ public class ASCIICustomButtonTest : Scenario
             switch (obj.KeyCode)
             {
                 case KeyCode.End:
-                    _scrollView.ContentOffset = new Point (
-                                                           _scrollView.ContentOffset.X,
-                                                           -(_scrollView.GetContentSize ().Height
-                                                             - _scrollView.Frame.Height
-                                                             + (_scrollView.ShowHorizontalScrollIndicator ? 1 : 0))
-                                                          );
+                    //_scrollView.ContentOffset = new Point (
+                    //                                       _scrollView.ContentOffset.X,
+                    //                                       -(_scrollView.GetContentSize ().Height
+                    //                                         - _scrollView.Frame.Height
+                    //                                         + (_scrollView.ShowHorizontalScrollIndicator ? 1 : 0))
+                    //                                      );
                     obj.Handled = true;
 
                     return;
                 case KeyCode.Home:
-                    _scrollView.ContentOffset = new Point (_scrollView.ContentOffset.X, 0);
+                    //_scrollView.ContentOffset = new Point (_scrollView.ContentOffset.X, 0);
                     obj.Handled = true;
 
                     return;
                 case KeyCode.PageDown:
-                    _scrollView.ContentOffset = new Point (
-                                                           _scrollView.ContentOffset.X,
-                                                           Math.Max (
-                                                                     _scrollView.ContentOffset.Y
-                                                                     - _scrollView.Frame.Height,
-                                                                     -(_scrollView.GetContentSize ().Height
-                                                                       - _scrollView.Frame.Height
-                                                                       + (_scrollView.ShowHorizontalScrollIndicator
-                                                                              ? 1
-                                                                              : 0))
-                                                                    )
-                                                          );
+                    //_scrollView.ContentOffset = new Point (
+                    //                                       _scrollView.ContentOffset.X,
+                    //                                       Math.Max (
+                    //                                                 _scrollView.ContentOffset.Y
+                    //                                                 - _scrollView.Frame.Height,
+                    //                                                 -(_scrollView.GetContentSize ().Height
+                    //                                                   - _scrollView.Frame.Height
+                    //                                                   + (_scrollView.ShowHorizontalScrollIndicator
+                    //                                                          ? 1
+                    //                                                          : 0))
+                    //                                                )
+                    //                                      );
                     obj.Handled = true;
 
                     return;
                 case KeyCode.PageUp:
-                    _scrollView.ContentOffset = new Point (
-                                                           _scrollView.ContentOffset.X,
-                                                           Math.Min (
-                                                                     _scrollView.ContentOffset.Y
-                                                                     + _scrollView.Frame.Height,
-                                                                     0
-                                                                    )
-                                                          );
+                    //_scrollView.ContentOffset = new Point (
+                    //                                       _scrollView.ContentOffset.X,
+                    //                                       Math.Min (
+                    //                                                 _scrollView.ContentOffset.Y
+                    //                                                 + _scrollView.Frame.Height,
+                    //                                                 0
+                    //                                                )
+                    //                                      );
                     obj.Handled = true;
 
                     return;
@@ -314,18 +314,18 @@ public class ASCIICustomButtonTest : Scenario
         {
             if (obj.Flags == MouseFlags.WheeledDown)
             {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       _scrollView.ContentOffset.Y - BUTTON_HEIGHT
-                                                      );
+                //_scrollView.ContentOffset = new Point (
+                //                                       _scrollView.ContentOffset.X,
+                //                                       _scrollView.ContentOffset.Y - BUTTON_HEIGHT
+                //                                      );
                 obj.Handled = true;
             }
             else if (obj.Flags == MouseFlags.WheeledUp)
             {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       Math.Min (_scrollView.ContentOffset.Y + BUTTON_HEIGHT, 0)
-                                                      );
+                //_scrollView.ContentOffset = new Point (
+                //                                       _scrollView.ContentOffset.X,
+                //                                       Math.Min (_scrollView.ContentOffset.Y + BUTTON_HEIGHT, 0)
+                //                                      );
                 obj.Handled = true;
             }
         }
@@ -347,54 +347,54 @@ public class ASCIICustomButtonTest : Scenario
                 moveDown = null;
             }
 
-            int offSet = _selected != null
-                             ? obj.Frame.Y - _selected.Frame.Y + -_scrollView.ContentOffset.Y % BUTTON_HEIGHT
-                             : 0;
-            _selected = obj;
-
-            if (moveDown == true && _selected.Frame.Y + _scrollView.ContentOffset.Y + BUTTON_HEIGHT >= _scrollView.Frame.Height && offSet != BUTTON_HEIGHT)
-            {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       Math.Min (
-                                                                 _scrollView.ContentOffset.Y - BUTTON_HEIGHT,
-                                                                 -(_selected.Frame.Y
-                                                                   - _scrollView.Frame.Height
-                                                                   + BUTTON_HEIGHT)
-                                                                )
-                                                      );
-            }
-            else if (moveDown == true && _selected.Frame.Y + _scrollView.ContentOffset.Y >= _scrollView.Frame.Height)
-            {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       _scrollView.ContentOffset.Y - BUTTON_HEIGHT
-                                                      );
-            }
-            else if (moveDown == true && _selected.Frame.Y + _scrollView.ContentOffset.Y < 0)
-            {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       -_selected.Frame.Y
-                                                      );
-            }
-            else if (moveDown == false && _selected.Frame.Y < -_scrollView.ContentOffset.Y)
-            {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       Math.Max (
-                                                                 _scrollView.ContentOffset.Y + BUTTON_HEIGHT,
-                                                                 _selected.Frame.Y
-                                                                )
-                                                      );
-            }
-            else if (moveDown == false && _selected.Frame.Y + _scrollView.ContentOffset.Y > _scrollView.Frame.Height)
-            {
-                _scrollView.ContentOffset = new Point (
-                                                       _scrollView.ContentOffset.X,
-                                                       -(_selected.Frame.Y - _scrollView.Frame.Height + BUTTON_HEIGHT)
-                                                      );
-            }
+            //int offSet = _selected != null
+            //                 ? obj.Frame.Y - _selected.Frame.Y + -_scrollView.ContentOffset.Y % BUTTON_HEIGHT
+            //                 : 0;
+            //_selected = obj;
+
+            //if (moveDown == true && _selected.Frame.Y + _scrollView.ContentOffset.Y + BUTTON_HEIGHT >= _scrollView.Frame.Height && offSet != BUTTON_HEIGHT)
+            //{
+            //    _scrollView.ContentOffset = new Point (
+            //                                           _scrollView.ContentOffset.X,
+            //                                           Math.Min (
+            //                                                     _scrollView.ContentOffset.Y - BUTTON_HEIGHT,
+            //                                                     -(_selected.Frame.Y
+            //                                                       - _scrollView.Frame.Height
+            //                                                       + BUTTON_HEIGHT)
+            //                                                    )
+            //                                          );
+            //}
+            //else if (moveDown == true && _selected.Frame.Y + _scrollView.ContentOffset.Y >= _scrollView.Frame.Height)
+            //{
+            //    _scrollView.ContentOffset = new Point (
+            //                                           _scrollView.ContentOffset.X,
+            //                                           _scrollView.ContentOffset.Y - BUTTON_HEIGHT
+            //                                          );
+            //}
+            //else if (moveDown == true && _selected.Frame.Y + _scrollView.ContentOffset.Y < 0)
+            //{
+            //    _scrollView.ContentOffset = new Point (
+            //                                           _scrollView.ContentOffset.X,
+            //                                           -_selected.Frame.Y
+            //                                          );
+            //}
+            //else if (moveDown == false && _selected.Frame.Y < -_scrollView.ContentOffset.Y)
+            //{
+            //    _scrollView.ContentOffset = new Point (
+            //                                           _scrollView.ContentOffset.X,
+            //                                           Math.Max (
+            //                                                     _scrollView.ContentOffset.Y + BUTTON_HEIGHT,
+            //                                                     _selected.Frame.Y
+            //                                                    )
+            //                                          );
+            //}
+            //else if (moveDown == false && _selected.Frame.Y + _scrollView.ContentOffset.Y > _scrollView.Frame.Height)
+            //{
+            //    _scrollView.ContentOffset = new Point (
+            //                                           _scrollView.ContentOffset.X,
+            //                                           -(_selected.Frame.Y - _scrollView.Frame.Height + BUTTON_HEIGHT)
+            //                                          );
+            //}
         }
     }
 }

+ 10 - 10
UICatalog/Scenarios/Clipping.cs

@@ -20,15 +20,15 @@ public class Clipping : Scenario
         };
         win.Add (label);
 
-        var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
-        scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
-        // BUGBUG: set_ContentSize is supposed to be `protected`. 
-        scrollView.SetContentSize (new (200, 100));
+        //var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
+        //scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
+        //// BUGBUG: set_ContentSize is supposed to be `protected`. 
+        //scrollView.SetContentSize (new (200, 100));
 
-        //ContentOffset = Point.Empty,
-        scrollView.AutoHideScrollBars = true;
-        scrollView.ShowVerticalScrollIndicator = true;
-        scrollView.ShowHorizontalScrollIndicator = true;
+        ////ContentOffset = Point.Empty,
+        //scrollView.AutoHideScrollBars = true;
+        //scrollView.ShowVerticalScrollIndicator = true;
+        //scrollView.ShowHorizontalScrollIndicator = true;
 
         var embedded1 = new View
         {
@@ -75,9 +75,9 @@ public class Clipping : Scenario
         embedded3.Add (testButton);
         embedded2.Add (embedded3);
 
-        scrollView.Add (embedded1);
+        //scrollView.Add (embedded1);
 
-        win.Add (scrollView);
+        //win.Add (scrollView);
 
         Application.Run (win);
         win.Dispose ();

+ 35 - 35
UICatalog/Scenarios/CsvEditor.cs

@@ -141,7 +141,7 @@ public class CsvEditor : Scenario
         _tableView.CellActivated += EditCurrentCell;
         _tableView.KeyDown += TableViewKeyPress;
 
-        SetupScrollBar ();
+        //SetupScrollBar ();
 
         // Run - Start the application.
         Application.Run (appWindow);
@@ -614,40 +614,40 @@ public class CsvEditor : Scenario
 
     private void SetTable (DataTable dataTable) { _tableView.Table = new DataTableSource (_currentTable = dataTable); }
 
-    private void SetupScrollBar ()
-    {
-        var scrollBar = new ScrollBarView (_tableView, true);
-
-        scrollBar.ChangedPosition += (s, e) =>
-                                     {
-                                         _tableView.RowOffset = scrollBar.Position;
-
-                                         if (_tableView.RowOffset != scrollBar.Position)
-                                         {
-                                             scrollBar.Position = _tableView.RowOffset;
-                                         }
-
-                                         _tableView.SetNeedsDraw ();
-                                     };
-        /*
-        scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
-            tableView.LeftItem = scrollBar.OtherScrollBarView.Position;
-            if (tableView.LeftItem != scrollBar.OtherScrollBarView.Position) {
-                scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
-            }
-            tableView.SetNeedsDraw ();
-        };*/
-
-        _tableView.DrawingContent += (s, e) =>
-                                  {
-                                      scrollBar.Size = _tableView.Table?.Rows ?? 0;
-                                      scrollBar.Position = _tableView.RowOffset;
-
-                                      //scrollBar.OtherScrollBarView.Size = tableView.Maxlength - 1;
-                                      //scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
-                                      scrollBar.Refresh ();
-                                  };
-    }
+    //private void SetupScrollBar ()
+    //{
+    //    var scrollBar = new ScrollBarView (_tableView, true);
+
+    //    scrollBar.ChangedPosition += (s, e) =>
+    //                                 {
+    //                                     _tableView.RowOffset = scrollBar.Position;
+
+    //                                     if (_tableView.RowOffset != scrollBar.Position)
+    //                                     {
+    //                                         scrollBar.Position = _tableView.RowOffset;
+    //                                     }
+
+    //                                     _tableView.SetNeedsDraw ();
+    //                                 };
+    //    /*
+    //    scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
+    //        tableView.LeftItem = scrollBar.OtherScrollBarView.Position;
+    //        if (tableView.LeftItem != scrollBar.OtherScrollBarView.Position) {
+    //            scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
+    //        }
+    //        tableView.SetNeedsDraw ();
+    //    };*/
+
+    //    _tableView.DrawingContent += (s, e) =>
+    //                              {
+    //                                  scrollBar.Size = _tableView.Table?.Rows ?? 0;
+    //                                  scrollBar.Position = _tableView.RowOffset;
+
+    //                                  //scrollBar.OtherScrollBarView.Size = tableView.Maxlength - 1;
+    //                                  //scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
+    //                                  scrollBar.Refresh ();
+    //                              };
+    //}
 
     private void Sort (bool asc)
     {

+ 32 - 33
UICatalog/Scenarios/Editor.cs

@@ -31,7 +31,6 @@ public class Editor : Scenario
     private MenuItem _miForceMinimumPosToZero;
     private byte [] _originalText;
     private bool _saved = true;
-    private ScrollBarView _scrollBar;
     private TabView _tabView;
     private string _textToFind;
     private string _textToReplace;
@@ -270,43 +269,43 @@ public class Editor : Scenario
 
         _appWindow.Add (statusBar);
 
-        _scrollBar = new (_textView, true);
+        //_scrollBar = new (_textView, true);
 
-        _scrollBar.ChangedPosition += (s, e) =>
-                                      {
-                                          _textView.TopRow = _scrollBar.Position;
+        //_scrollBar.ChangedPosition += (s, e) =>
+        //                              {
+        //                                  _textView.TopRow = _scrollBar.Position;
 
-                                          if (_textView.TopRow != _scrollBar.Position)
-                                          {
-                                              _scrollBar.Position = _textView.TopRow;
-                                          }
+        //                                  if (_textView.TopRow != _scrollBar.Position)
+        //                                  {
+        //                                      _scrollBar.Position = _textView.TopRow;
+        //                                  }
 
-                                          _textView.SetNeedsDraw ();
-                                      };
+        //                                  _textView.SetNeedsDraw ();
+        //                              };
 
-        _scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
-                                                         {
-                                                             _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position;
+        //_scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
+        //                                                 {
+        //                                                     _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position;
 
-                                                             if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position)
-                                                             {
-                                                                 _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn;
-                                                             }
+        //                                                     if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position)
+        //                                                     {
+        //                                                         _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn;
+        //                                                     }
 
-                                                             _textView.SetNeedsDraw ();
-                                                         };
+        //                                                     _textView.SetNeedsDraw ();
+        //                                                 };
 
-        _textView.DrawingContent += (s, e) =>
-                                 {
-                                     _scrollBar.Size = _textView.Lines;
-                                     _scrollBar.Position = _textView.TopRow;
-
-                                     if (_scrollBar.OtherScrollBarView != null)
-                                     {
-                                         _scrollBar.OtherScrollBarView.Size = _textView.Maxlength;
-                                         _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn;
-                                     }
-                                 };
+        //_textView.DrawingContent += (s, e) =>
+        //                         {
+        //                             _scrollBar.Size = _textView.Lines;
+        //                             _scrollBar.Position = _textView.TopRow;
+
+        //                             if (_scrollBar.OtherScrollBarView != null)
+        //                             {
+        //                                 _scrollBar.OtherScrollBarView.Size = _textView.Maxlength;
+        //                                 _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn;
+        //                             }
+        //                         };
 
 
         _appWindow.Closed += (s, e) => Thread.CurrentThread.CurrentUICulture = new ("en-US");
@@ -772,7 +771,7 @@ public class Editor : Scenario
         item.Title = "Keep Content Always In Viewport";
         item.CheckType |= MenuItemCheckStyle.Checked;
         item.Checked = true;
-        item.Action += () => _scrollBar.KeepContentAlwaysInViewport = (bool)(item.Checked = !item.Checked);
+        //item.Action += () => _scrollBar.KeepContentAlwaysInViewport = (bool)(item.Checked = !item.Checked);
 
         return new [] { item };
     }
@@ -818,7 +817,7 @@ public class Editor : Scenario
 
                            if (_textView.WordWrap)
                            {
-                               _scrollBar.OtherScrollBarView.ShowScrollIndicator = false;
+                               //_scrollBar.OtherScrollBarView.ShowScrollIndicator = false;
                            }
                        };
 

+ 36 - 36
UICatalog/Scenarios/ListColumns.cs

@@ -236,7 +236,7 @@ public class ListColumns : Scenario
         _listColView.SelectedCellChanged += (s, e) => { selectedCellLabel.Text = $"{_listColView.SelectedRow},{_listColView.SelectedColumn}"; };
         _listColView.KeyDown += TableViewKeyPress;
 
-        SetupScrollBar ();
+        //SetupScrollBar ();
 
         _alternatingColorScheme = new ()
         {
@@ -324,41 +324,41 @@ public class ListColumns : Scenario
         }
     }
 
-    private void SetupScrollBar ()
-    {
-        var scrollBar = new ScrollBarView (_listColView, true); // (listColView, true, true);
-
-        scrollBar.ChangedPosition += (s, e) =>
-                                     {
-                                         _listColView.RowOffset = scrollBar.Position;
-
-                                         if (_listColView.RowOffset != scrollBar.Position)
-                                         {
-                                             scrollBar.Position = _listColView.RowOffset;
-                                         }
-
-                                         _listColView.SetNeedsDraw ();
-                                     };
-        /*
-        scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
-            listColView.ColumnOffset = scrollBar.OtherScrollBarView.Position;
-            if (listColView.ColumnOffset != scrollBar.OtherScrollBarView.Position) {
-                scrollBar.OtherScrollBarView.Position = listColView.ColumnOffset;
-            }
-            listColView.SetNeedsDraw ();
-        };
-        */
-
-        _listColView.DrawingContent += (s, e) =>
-                                    {
-                                        scrollBar.Size = _listColView.Table?.Rows ?? 0;
-                                        scrollBar.Position = _listColView.RowOffset;
-
-                                        //scrollBar.OtherScrollBarView.Size = listColView.Table?.Columns - 1 ?? 0;
-                                        //scrollBar.OtherScrollBarView.Position = listColView.ColumnOffset;
-                                        scrollBar.Refresh ();
-                                    };
-    }
+    //private void SetupScrollBar ()
+    //{
+    //    var scrollBar = new ScrollBarView (_listColView, true); // (listColView, true, true);
+
+    //    scrollBar.ChangedPosition += (s, e) =>
+    //                                 {
+    //                                     _listColView.RowOffset = scrollBar.Position;
+
+    //                                     if (_listColView.RowOffset != scrollBar.Position)
+    //                                     {
+    //                                         scrollBar.Position = _listColView.RowOffset;
+    //                                     }
+
+    //                                     _listColView.SetNeedsDraw ();
+    //                                 };
+    //    /*
+    //    scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
+    //        listColView.ColumnOffset = scrollBar.OtherScrollBarView.Position;
+    //        if (listColView.ColumnOffset != scrollBar.OtherScrollBarView.Position) {
+    //            scrollBar.OtherScrollBarView.Position = listColView.ColumnOffset;
+    //        }
+    //        listColView.SetNeedsDraw ();
+    //    };
+    //    */
+
+    //    _listColView.DrawingContent += (s, e) =>
+    //                                {
+    //                                    scrollBar.Size = _listColView.Table?.Rows ?? 0;
+    //                                    scrollBar.Position = _listColView.RowOffset;
+
+    //                                    //scrollBar.OtherScrollBarView.Size = listColView.Table?.Columns - 1 ?? 0;
+    //                                    //scrollBar.OtherScrollBarView.Position = listColView.ColumnOffset;
+    //                                    scrollBar.Refresh ();
+    //                                };
+    //}
 
     private void TableViewKeyPress (object sender, Key e)
     {

+ 29 - 29
UICatalog/Scenarios/ListViewWithSelection.cs

@@ -73,40 +73,40 @@ public class ListViewWithSelection : Scenario
         _listView.RowRender += ListView_RowRender;
         _appWindow.Add (_listView);
 
-        var scrollBar = new ScrollBarView (_listView, true);
+        //var scrollBar = new ScrollBarView (_listView, true);
 
-        scrollBar.ChangedPosition += (s, e) =>
-        {
-            _listView.TopItem = scrollBar.Position;
+        //scrollBar.ChangedPosition += (s, e) =>
+        //{
+        //    _listView.TopItem = scrollBar.Position;
 
-            if (_listView.TopItem != scrollBar.Position)
-            {
-                scrollBar.Position = _listView.TopItem;
-            }
+        //    if (_listView.TopItem != scrollBar.Position)
+        //    {
+        //        scrollBar.Position = _listView.TopItem;
+        //    }
 
-            _listView.SetNeedsDraw ();
-        };
+        //    _listView.SetNeedsDraw ();
+        //};
 
-        scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
-        {
-            _listView.LeftItem = scrollBar.OtherScrollBarView.Position;
+        //scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
+        //{
+        //    _listView.LeftItem = scrollBar.OtherScrollBarView.Position;
 
-            if (_listView.LeftItem != scrollBar.OtherScrollBarView.Position)
-            {
-                scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
-            }
+        //    if (_listView.LeftItem != scrollBar.OtherScrollBarView.Position)
+        //    {
+        //        scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
+        //    }
 
-            _listView.SetNeedsDraw ();
-        };
+        //    _listView.SetNeedsDraw ();
+        //};
 
-        _listView.DrawingContent += (s, e) =>
-        {
-            scrollBar.Size = _listView.Source.Count;
-            scrollBar.Position = _listView.TopItem;
-            scrollBar.OtherScrollBarView.Size = _listView.MaxLength;
-            scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
-            scrollBar.Refresh ();
-        };
+        //_listView.DrawingContent += (s, e) =>
+        //{
+        //    scrollBar.Size = _listView.Source.Count;
+        //    scrollBar.Position = _listView.TopItem;
+        //    scrollBar.OtherScrollBarView.Size = _listView.MaxLength;
+        //    scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
+        //    scrollBar.Refresh ();
+        //};
 
         _listView.SetSource (_scenarios);
 
@@ -117,9 +117,9 @@ public class ListViewWithSelection : Scenario
             X = Pos.Right(_allowMultipleCB) + 1,
             Y = 0, 
             Text = k, 
-            CheckedState = scrollBar.AutoHideScrollBars ? CheckState.Checked : CheckState.UnChecked
+            //CheckedState = scrollBar.AutoHideScrollBars ? CheckState.Checked : CheckState.UnChecked
         };
-        keepCheckBox.CheckedStateChanging += (s, e) => scrollBar.KeepContentAlwaysInViewport = e.NewValue == CheckState.Checked;
+        //keepCheckBox.CheckedStateChanging += (s, e) => scrollBar.KeepContentAlwaysInViewport = e.NewValue == CheckState.Checked;
         _appWindow.Add (keepCheckBox);
 
         _eventList = new ();

+ 54 - 54
UICatalog/Scenarios/ListsAndCombos.cs

@@ -54,40 +54,40 @@ public class ListsAndCombos : Scenario
         listview.SelectedItemChanged += (s, e) => lbListView.Text = items [listview.SelectedItem];
         win.Add (lbListView, listview);
 
-        var scrollBar = new ScrollBarView (listview, true);
+        //var scrollBar = new ScrollBarView (listview, true);
 
-        scrollBar.ChangedPosition += (s, e) =>
-                                     {
-                                         listview.TopItem = scrollBar.Position;
+        //scrollBar.ChangedPosition += (s, e) =>
+        //                             {
+        //                                 listview.TopItem = scrollBar.Position;
 
-                                         if (listview.TopItem != scrollBar.Position)
-                                         {
-                                             scrollBar.Position = listview.TopItem;
-                                         }
+        //                                 if (listview.TopItem != scrollBar.Position)
+        //                                 {
+        //                                     scrollBar.Position = listview.TopItem;
+        //                                 }
 
-                                         listview.SetNeedsDraw ();
-                                     };
+        //                                 listview.SetNeedsDraw ();
+        //                             };
 
-        scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
-                                                        {
-                                                            listview.LeftItem = scrollBar.OtherScrollBarView.Position;
+        //scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
+        //                                                {
+        //                                                    listview.LeftItem = scrollBar.OtherScrollBarView.Position;
 
-                                                            if (listview.LeftItem != scrollBar.OtherScrollBarView.Position)
-                                                            {
-                                                                scrollBar.OtherScrollBarView.Position = listview.LeftItem;
-                                                            }
+        //                                                    if (listview.LeftItem != scrollBar.OtherScrollBarView.Position)
+        //                                                    {
+        //                                                        scrollBar.OtherScrollBarView.Position = listview.LeftItem;
+        //                                                    }
 
-                                                            listview.SetNeedsDraw ();
-                                                        };
+        //                                                    listview.SetNeedsDraw ();
+        //                                                };
 
-        listview.DrawingContent += (s, e) =>
-                                {
-                                    scrollBar.Size = listview.Source.Count - 1;
-                                    scrollBar.Position = listview.TopItem;
-                                    scrollBar.OtherScrollBarView.Size = listview.MaxLength - 1;
-                                    scrollBar.OtherScrollBarView.Position = listview.LeftItem;
-                                    scrollBar.Refresh ();
-                                };
+        //listview.DrawingContent += (s, e) =>
+        //                        {
+        //                            scrollBar.Size = listview.Source.Count - 1;
+        //                            scrollBar.Position = listview.TopItem;
+        //                            scrollBar.OtherScrollBarView.Size = listview.MaxLength - 1;
+        //                            scrollBar.OtherScrollBarView.Position = listview.LeftItem;
+        //                            scrollBar.Refresh ();
+        //                        };
 
         // ComboBox
         var lbComboBox = new Label
@@ -111,40 +111,40 @@ public class ListsAndCombos : Scenario
         comboBox.SelectedItemChanged += (s, text) => lbComboBox.Text = text.Value.ToString ();
         win.Add (lbComboBox, comboBox);
 
-        var scrollBarCbx = new ScrollBarView (comboBox.Subviews [1], true);
+        //var scrollBarCbx = new ScrollBarView (comboBox.Subviews [1], true);
 
-        scrollBarCbx.ChangedPosition += (s, e) =>
-                                        {
-                                            ((ListView)comboBox.Subviews [1]).TopItem = scrollBarCbx.Position;
+        //scrollBarCbx.ChangedPosition += (s, e) =>
+        //                                {
+        //                                    ((ListView)comboBox.Subviews [1]).TopItem = scrollBarCbx.Position;
 
-                                            if (((ListView)comboBox.Subviews [1]).TopItem != scrollBarCbx.Position)
-                                            {
-                                                scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
-                                            }
+        //                                    if (((ListView)comboBox.Subviews [1]).TopItem != scrollBarCbx.Position)
+        //                                    {
+        //                                        scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
+        //                                    }
 
-                                            comboBox.SetNeedsDraw ();
-                                        };
+        //                                    comboBox.SetNeedsDraw ();
+        //                                };
 
-        scrollBarCbx.OtherScrollBarView.ChangedPosition += (s, e) =>
-                                                           {
-                                                               ((ListView)comboBox.Subviews [1]).LeftItem = scrollBarCbx.OtherScrollBarView.Position;
+        //scrollBarCbx.OtherScrollBarView.ChangedPosition += (s, e) =>
+        //                                                   {
+        //                                                       ((ListView)comboBox.Subviews [1]).LeftItem = scrollBarCbx.OtherScrollBarView.Position;
 
-                                                               if (((ListView)comboBox.Subviews [1]).LeftItem != scrollBarCbx.OtherScrollBarView.Position)
-                                                               {
-                                                                   scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
-                                                               }
+        //                                                       if (((ListView)comboBox.Subviews [1]).LeftItem != scrollBarCbx.OtherScrollBarView.Position)
+        //                                                       {
+        //                                                           scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
+        //                                                       }
 
-                                                               comboBox.SetNeedsDraw ();
-                                                           };
+        //                                                       comboBox.SetNeedsDraw ();
+        //                                                   };
 
-        comboBox.DrawingContent += (s, e) =>
-                                {
-                                    scrollBarCbx.Size = comboBox.Source.Count;
-                                    scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
-                                    scrollBarCbx.OtherScrollBarView.Size = ((ListView)comboBox.Subviews [1]).MaxLength - 1;
-                                    scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
-                                    scrollBarCbx.Refresh ();
-                                };
+        //comboBox.DrawingContent += (s, e) =>
+        //                        {
+        //                            scrollBarCbx.Size = comboBox.Source.Count;
+        //                            scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
+        //                            scrollBarCbx.OtherScrollBarView.Size = ((ListView)comboBox.Subviews [1]).MaxLength - 1;
+        //                            scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
+        //                            scrollBarCbx.Refresh ();
+        //                        };
 
         var btnMoveUp = new Button { X = 1, Y = Pos.Bottom (lbListView), Text = "Move _Up" };
         btnMoveUp.Accepting += (s, e) => { listview.MoveUp (); };

+ 35 - 35
UICatalog/Scenarios/TableEditor.cs

@@ -666,7 +666,7 @@ public class TableEditor : Scenario
         _tableView.CellActivated += EditCurrentCell;
         _tableView.KeyDown += TableViewKeyPress;
 
-        SetupScrollBar ();
+        //SetupScrollBar ();
 
         _redColorScheme = new ()
         {
@@ -1157,40 +1157,40 @@ public class TableEditor : Scenario
 
     private void SetTable (DataTable dataTable) { _tableView.Table = new DataTableSource (_currentTable = dataTable); }
 
-    private void SetupScrollBar ()
-    {
-        var scrollBar = new ScrollBarView (_tableView, true);
-
-        scrollBar.ChangedPosition += (s, e) =>
-                                     {
-                                         _tableView.RowOffset = scrollBar.Position;
-
-                                         if (_tableView.RowOffset != scrollBar.Position)
-                                         {
-                                             scrollBar.Position = _tableView.RowOffset;
-                                         }
-
-                                         _tableView.SetNeedsDraw ();
-                                     };
-        /*
-        scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
-            tableView.LeftItem = scrollBar.OtherScrollBarView.Position;
-            if (tableView.LeftItem != scrollBar.OtherScrollBarView.Position) {
-                scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
-            }
-            tableView.SetNeedsDraw ();
-        };*/
-
-        _tableView.DrawingContent += (s, e) =>
-                                  {
-                                      scrollBar.Size = _tableView.Table?.Rows ?? 0;
-                                      scrollBar.Position = _tableView.RowOffset;
-
-                                      //scrollBar.OtherScrollBarView.Size = tableView.Maxlength - 1;
-                                      //scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
-                                      scrollBar.Refresh ();
-                                  };
-    }
+    //private void SetupScrollBar ()
+    //{
+    //    var scrollBar = new ScrollBarView (_tableView, true);
+
+    //    scrollBar.ChangedPosition += (s, e) =>
+    //                                 {
+    //                                     _tableView.RowOffset = scrollBar.Position;
+
+    //                                     if (_tableView.RowOffset != scrollBar.Position)
+    //                                     {
+    //                                         scrollBar.Position = _tableView.RowOffset;
+    //                                     }
+
+    //                                     _tableView.SetNeedsDraw ();
+    //                                 };
+    //    /*
+    //    scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
+    //        tableView.LeftItem = scrollBar.OtherScrollBarView.Position;
+    //        if (tableView.LeftItem != scrollBar.OtherScrollBarView.Position) {
+    //            scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
+    //        }
+    //        tableView.SetNeedsDraw ();
+    //    };*/
+
+    //    _tableView.DrawingContent += (s, e) =>
+    //                              {
+    //                                  scrollBar.Size = _tableView.Table?.Rows ?? 0;
+    //                                  scrollBar.Position = _tableView.RowOffset;
+
+    //                                  //scrollBar.OtherScrollBarView.Size = tableView.Maxlength - 1;
+    //                                  //scrollBar.OtherScrollBarView.Position = tableView.LeftItem;
+    //                                  scrollBar.Refresh ();
+    //                              };
+    //}
 
     private void ShowAllColumns ()
     {

+ 41 - 41
UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -199,7 +199,7 @@ public class TreeViewFileSystem : Scenario
         _treeViewFiles.GoToFirst ();
         _treeViewFiles.Expand ();
 
-        SetupScrollBar ();
+        //SetupScrollBar ();
 
         _treeViewFiles.SetFocus ();
 
@@ -364,46 +364,46 @@ public class TreeViewFileSystem : Scenario
         _iconProvider.IsOpenGetter = _treeViewFiles.IsExpanded;
     }
 
-    private void SetupScrollBar ()
-    {
-        // When using scroll bar leave the last row of the control free (for over-rendering with scroll bar)
-        _treeViewFiles.Style.LeaveLastRow = true;
-
-        var scrollBar = new ScrollBarView (_treeViewFiles, true);
-
-        scrollBar.ChangedPosition += (s, e) =>
-                                     {
-                                         _treeViewFiles.ScrollOffsetVertical = scrollBar.Position;
-
-                                         if (_treeViewFiles.ScrollOffsetVertical != scrollBar.Position)
-                                         {
-                                             scrollBar.Position = _treeViewFiles.ScrollOffsetVertical;
-                                         }
-
-                                         _treeViewFiles.SetNeedsDraw ();
-                                     };
-
-        scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
-                                                        {
-                                                            _treeViewFiles.ScrollOffsetHorizontal = scrollBar.OtherScrollBarView.Position;
-
-                                                            if (_treeViewFiles.ScrollOffsetHorizontal != scrollBar.OtherScrollBarView.Position)
-                                                            {
-                                                                scrollBar.OtherScrollBarView.Position = _treeViewFiles.ScrollOffsetHorizontal;
-                                                            }
-
-                                                            _treeViewFiles.SetNeedsDraw ();
-                                                        };
-
-        _treeViewFiles.DrawingContent += (s, e) =>
-                                      {
-                                          scrollBar.Size = _treeViewFiles.ContentHeight;
-                                          scrollBar.Position = _treeViewFiles.ScrollOffsetVertical;
-                                          scrollBar.OtherScrollBarView.Size = _treeViewFiles.GetContentWidth (true);
-                                          scrollBar.OtherScrollBarView.Position = _treeViewFiles.ScrollOffsetHorizontal;
-                                          scrollBar.Refresh ();
-                                      };
-    }
+    //private void SetupScrollBar ()
+    //{
+    //    // When using scroll bar leave the last row of the control free (for over-rendering with scroll bar)
+    //    _treeViewFiles.Style.LeaveLastRow = true;
+
+    //    var scrollBar = new ScrollBarView (_treeViewFiles, true);
+
+    //    scrollBar.ChangedPosition += (s, e) =>
+    //                                 {
+    //                                     _treeViewFiles.ScrollOffsetVertical = scrollBar.Position;
+
+    //                                     if (_treeViewFiles.ScrollOffsetVertical != scrollBar.Position)
+    //                                     {
+    //                                         scrollBar.Position = _treeViewFiles.ScrollOffsetVertical;
+    //                                     }
+
+    //                                     _treeViewFiles.SetNeedsDraw ();
+    //                                 };
+
+    //    scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
+    //                                                    {
+    //                                                        _treeViewFiles.ScrollOffsetHorizontal = scrollBar.OtherScrollBarView.Position;
+
+    //                                                        if (_treeViewFiles.ScrollOffsetHorizontal != scrollBar.OtherScrollBarView.Position)
+    //                                                        {
+    //                                                            scrollBar.OtherScrollBarView.Position = _treeViewFiles.ScrollOffsetHorizontal;
+    //                                                        }
+
+    //                                                        _treeViewFiles.SetNeedsDraw ();
+    //                                                    };
+
+    //    _treeViewFiles.DrawingContent += (s, e) =>
+    //                                  {
+    //                                      scrollBar.Size = _treeViewFiles.ContentHeight;
+    //                                      scrollBar.Position = _treeViewFiles.ScrollOffsetVertical;
+    //                                      scrollBar.OtherScrollBarView.Size = _treeViewFiles.GetContentWidth (true);
+    //                                      scrollBar.OtherScrollBarView.Position = _treeViewFiles.ScrollOffsetHorizontal;
+    //                                      scrollBar.Refresh ();
+    //                                  };
+    //}
 
     private void ShowColoredExpandableSymbols ()
     {

+ 26 - 26
UICatalog/Scenarios/Wizards.cs

@@ -311,32 +311,32 @@ public class Wizards : Scenario
                                                                  };
                                            fourthStep.Add (hideHelpBtn);
                                            fourthStep.NextButtonText = "_Go To Last Step";
-                                           var scrollBar = new ScrollBarView (someText, true);
-
-                                           scrollBar.ChangedPosition += (s, e) =>
-                                                                        {
-                                                                            someText.TopRow = scrollBar.Position;
-
-                                                                            if (someText.TopRow != scrollBar.Position)
-                                                                            {
-                                                                                scrollBar.Position = someText.TopRow;
-                                                                            }
-
-                                                                            someText.SetNeedsDraw ();
-                                                                        };
-
-                                           someText.DrawingContent += (s, e) =>
-                                                                   {
-                                                                       scrollBar.Size = someText.Lines;
-                                                                       scrollBar.Position = someText.TopRow;
-
-                                                                       if (scrollBar.OtherScrollBarView != null)
-                                                                       {
-                                                                           scrollBar.OtherScrollBarView.Size = someText.Maxlength;
-                                                                           scrollBar.OtherScrollBarView.Position = someText.LeftColumn;
-                                                                       }
-                                                                   };
-                                           fourthStep.Add (scrollBar);
+                                           //var scrollBar = new ScrollBarView (someText, true);
+
+                                           //scrollBar.ChangedPosition += (s, e) =>
+                                           //                             {
+                                           //                                 someText.TopRow = scrollBar.Position;
+
+                                           //                                 if (someText.TopRow != scrollBar.Position)
+                                           //                                 {
+                                           //                                     scrollBar.Position = someText.TopRow;
+                                           //                                 }
+
+                                           //                                 someText.SetNeedsDraw ();
+                                           //                             };
+
+                                           //someText.DrawingContent += (s, e) =>
+                                           //                        {
+                                           //                            scrollBar.Size = someText.Lines;
+                                           //                            scrollBar.Position = someText.TopRow;
+
+                                           //                            if (scrollBar.OtherScrollBarView != null)
+                                           //                            {
+                                           //                                scrollBar.OtherScrollBarView.Size = someText.Maxlength;
+                                           //                                scrollBar.OtherScrollBarView.Position = someText.LeftColumn;
+                                           //                            }
+                                           //                        };
+                                           //fourthStep.Add (scrollBar);
 
                                            // Add last step
                                            var lastStep = new WizardStep { Title = "The last step" };

+ 41 - 41
UnitTests/Application/Mouse/ApplicationMouseTests.cs

@@ -238,67 +238,67 @@ public class ApplicationMouseTests
 
     #region mouse grab tests
 
-    [Fact]
+    [Fact (Skip = "Rebuild to use ScrollBar")]
     [AutoInitShutdown]
     public void MouseGrabView_WithNullMouseEventView ()
     {
-        var tf = new TextField { Width = 10 };
-        var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill () };
-        sv.SetContentSize (new (100, 100));
+        //var tf = new TextField { Width = 10 };
+        //var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill () };
+        //sv.SetContentSize (new (100, 100));
 
-        sv.Add (tf);
-        var top = new Toplevel ();
-        top.Add (sv);
+        //sv.Add (tf);
+        //var top = new Toplevel ();
+        //top.Add (sv);
 
-        int iterations = -1;
+        //int iterations = -1;
 
-        Application.Iteration += (s, a) =>
-                                 {
-                                     iterations++;
+        //Application.Iteration += (s, a) =>
+        //                         {
+        //                             iterations++;
 
-                                     if (iterations == 0)
-                                     {
-                                         Assert.True (tf.HasFocus);
-                                         Assert.Null (Application.MouseGrabView);
+        //                             if (iterations == 0)
+        //                             {
+        //                                 Assert.True (tf.HasFocus);
+        //                                 Assert.Null (Application.MouseGrabView);
 
-                                         Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 5), Flags = MouseFlags.ReportMousePosition });
+        //                                 Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 5), Flags = MouseFlags.ReportMousePosition });
 
-                                         Assert.Equal (sv, Application.MouseGrabView);
+        //                                 Assert.Equal (sv, Application.MouseGrabView);
 
-                                         MessageBox.Query ("Title", "Test", "Ok");
+        //                                 MessageBox.Query ("Title", "Test", "Ok");
 
-                                         Assert.Null (Application.MouseGrabView);
-                                     }
-                                     else if (iterations == 1)
-                                     {
-                                         // Application.MouseGrabView is null because
-                                         // another toplevel (Dialog) was opened
-                                         Assert.Null (Application.MouseGrabView);
+        //                                 Assert.Null (Application.MouseGrabView);
+        //                             }
+        //                             else if (iterations == 1)
+        //                             {
+        //                                 // Application.MouseGrabView is null because
+        //                                 // another toplevel (Dialog) was opened
+        //                                 Assert.Null (Application.MouseGrabView);
 
-                                         Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 5), Flags = MouseFlags.ReportMousePosition });
+        //                                 Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 5), Flags = MouseFlags.ReportMousePosition });
 
-                                         Assert.Null (Application.MouseGrabView);
+        //                                 Assert.Null (Application.MouseGrabView);
 
-                                         Application.RaiseMouseEvent (new () { ScreenPosition = new (40, 12), Flags = MouseFlags.ReportMousePosition });
+        //                                 Application.RaiseMouseEvent (new () { ScreenPosition = new (40, 12), Flags = MouseFlags.ReportMousePosition });
 
-                                         Assert.Null (Application.MouseGrabView);
+        //                                 Assert.Null (Application.MouseGrabView);
 
-                                         Application.RaiseMouseEvent (new () { ScreenPosition = new (0, 0), Flags = MouseFlags.Button1Pressed });
+        //                                 Application.RaiseMouseEvent (new () { ScreenPosition = new (0, 0), Flags = MouseFlags.Button1Pressed });
 
-                                         Assert.Null (Application.MouseGrabView);
+        //                                 Assert.Null (Application.MouseGrabView);
 
-                                         Application.RequestStop ();
-                                     }
-                                     else if (iterations == 2)
-                                     {
-                                         Assert.Null (Application.MouseGrabView);
+        //                                 Application.RequestStop ();
+        //                             }
+        //                             else if (iterations == 2)
+        //                             {
+        //                                 Assert.Null (Application.MouseGrabView);
 
-                                         Application.RequestStop ();
-                                     }
-                                 };
+        //                                 Application.RequestStop ();
+        //                             }
+        //                         };
 
-        Application.Run (top);
-        top.Dispose ();
+        //Application.Run (top);
+        //top.Dispose ();
     }
 
     [Fact]

+ 0 - 90
UnitTests/Input/ResponderTests.cs

@@ -108,96 +108,6 @@ public class ResponderTests
     #endif
     }
 
-    [Fact]
-    [TestRespondersDisposed]
-    public void IsOverridden_False_IfNotOverridden ()
-    {
-        // MouseEvent IS defined on Responder but NOT overridden
-        Assert.False (Responder.IsOverridden (new Responder (), "OnMouseEvent"));
-
-        // MouseEvent is defined on Responder and NOT overrident on View
-        Assert.False (
-                      Responder.IsOverridden (
-                                              new View { Text = "View does not override OnMouseEvent" },
-                                              "OnMouseEvent"
-                                             )
-                     );
-
-        Assert.False (
-                      Responder.IsOverridden (
-                                              new DerivedView { Text = "DerivedView does not override OnMouseEvent" },
-                                              "OnMouseEvent"
-                                             )
-                     );
-
-        // MouseEvent is NOT defined on DerivedView 
-        Assert.False (
-                      Responder.IsOverridden (
-                                              new DerivedView { Text = "DerivedView does not override OnMouseEvent" },
-                                              "OnMouseEvent"
-                                             )
-                     );
-
-        // OnKeyDown is defined on View and NOT overrident on Button
-        Assert.False (
-                      Responder.IsOverridden (
-                                              new Button { Text = "Button does not override OnKeyDown" },
-                                              "OnKeyDown"
-                                             )
-                     );
-
-#if DEBUG_IDISPOSABLE
-
-        // HACK: Force clean up of Responders to avoid having to Dispose all the Views created above.
-        Responder.Instances.Clear ();
-        Assert.Empty (Responder.Instances);
-#endif
-    }
-
-    [Fact]
-    [TestRespondersDisposed]
-    public void IsOverridden_True_IfOverridden ()
-    {
-        // MouseEvent is defined on Responder IS overriden on ScrollBarView (but not View)
-        Assert.True (
-                     Responder.IsOverridden (
-                                             new ScrollBarView { Text = "ScrollBarView overrides OnMouseEvent" },
-                                             "OnMouseEvent"
-                                            )
-                    );
-
-        // OnKeyDown is defined on View
-        Assert.False (Responder.IsOverridden (new View { Text = "View overrides OnKeyDown" }, "OnKeyDown"));
-
-        // OnKeyDown is defined on DerivedView
-        Assert.True (
-                     Responder.IsOverridden (
-                                             new DerivedView { Text = "DerivedView overrides OnKeyDown" },
-                                             "OnKeyDown"
-                                            )
-                    );
-
-        // ScrollBarView overrides both MouseEvent (from Responder) and Redraw (from View)
-        Assert.True (
-                     Responder.IsOverridden (
-                                             new ScrollBarView { Text = "ScrollBarView overrides OnMouseEvent" },
-                                             "OnMouseEvent"
-                                            )
-                    );
-
-        Assert.True (
-                     Responder.IsOverridden (
-                                             new ScrollBarView { Text = "ScrollBarView overrides OnDrawingContent" },
-                                             "OnDrawingContent"
-                                            )
-                    );
-#if DEBUG_IDISPOSABLE
-
-        // HACK: Force clean up of Responders to avoid having to Dispose all the Views created above.
-        Responder.Instances.Clear ();
-        Assert.Empty (Responder.Instances);
-#endif
-    }
 
     [Fact]
     public void KeyPressed_Handled_True_Cancels_KeyPress ()

+ 0 - 1390
UnitTests/Views/ScrollBarViewTests.cs

@@ -1,1390 +0,0 @@
-using System.Collections.ObjectModel;
-using System.Reflection;
-using Xunit.Abstractions;
-
-namespace Terminal.Gui.ViewsTests;
-
-public class ScrollBarViewTests
-{
-    private static HostView _hostView;
-    private readonly ITestOutputHelper _output;
-    private bool _added;
-    private ScrollBarView _scrollBar;
-    public ScrollBarViewTests (ITestOutputHelper output) { _output = output; }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void AutoHideScrollBars_Check ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        Application.Begin (_hostView.SuperView as Toplevel);
-
-        AddHandlers ();
-
-        _hostView.Draw ();
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.Visible);
-        Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
-        Assert.Equal (1, _scrollBar.Viewport.Width);
-
-        Assert.Equal (
-                      $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))",
-                      _scrollBar.Height.ToString ()
-                     );
-        Assert.Equal (24, _scrollBar.Viewport.Height);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.Visible);
-
-        Assert.Equal (
-                      $"Combine(View(Width,HostView(){_hostView.Frame})-Absolute(1))",
-                      _scrollBar.OtherScrollBarView.Width.ToString ()
-                     );
-        Assert.Equal (79, _scrollBar.OtherScrollBarView.Viewport.Width);
-        Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
-        Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height);
-
-        _hostView.Lines = 10;
-        _hostView.SetNeedsDraw ();
-        _hostView.Draw ();
-        Assert.False (_scrollBar.ShowScrollIndicator);
-        Assert.False (_scrollBar.Visible);
-        Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
-        Assert.Equal (1, _scrollBar.Viewport.Width);
-
-        Assert.Equal (
-                      $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))",
-                      _scrollBar.Height.ToString ()
-                     );
-        Assert.Equal (24, _scrollBar.Viewport.Height);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.Visible);
-
-        Assert.Equal (
-                      $"View(Width,HostView(){_hostView.Frame})",
-                      _scrollBar.OtherScrollBarView.Width.ToString ()
-                     );
-        Assert.Equal (80, _scrollBar.OtherScrollBarView.Viewport.Width);
-        Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
-        Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height);
-
-        _hostView.Cols = 60;
-        _hostView.SetNeedsDraw ();
-        _hostView.Draw ();
-        Assert.False (_scrollBar.ShowScrollIndicator);
-        Assert.False (_scrollBar.Visible);
-        Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
-        Assert.Equal (1, _scrollBar.Viewport.Width);
-
-        Assert.Equal (
-                      $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))",
-                      _scrollBar.Height.ToString ()
-                     );
-        Assert.Equal (24, _scrollBar.Viewport.Height);
-        Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.False (_scrollBar.OtherScrollBarView.Visible);
-
-        Assert.Equal (
-                      $"View(Width,HostView(){_hostView.Frame})",
-                      _scrollBar.OtherScrollBarView.Width.ToString ()
-                     );
-        Assert.Equal (80, _scrollBar.OtherScrollBarView.Viewport.Width);
-        Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
-        Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height);
-
-        _hostView.Lines = 40;
-        _hostView.SetNeedsDraw ();
-        _hostView.Draw ();
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.Visible);
-        Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
-        Assert.Equal (1, _scrollBar.Viewport.Width);
-
-        Assert.Equal (
-                      $"View(Height,HostView(){_hostView.Frame})",
-                      _scrollBar.Height.ToString ()
-                     );
-        Assert.Equal (25, _scrollBar.Viewport.Height);
-        Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.False (_scrollBar.OtherScrollBarView.Visible);
-
-        Assert.Equal (
-                      $"View(Width,HostView(){_hostView.Frame})",
-                      _scrollBar.OtherScrollBarView.Width.ToString ()
-                     );
-        Assert.Equal (80, _scrollBar.OtherScrollBarView.Viewport.Width);
-        Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
-        Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height);
-
-        _hostView.Cols = 120;
-        _hostView.SetNeedsDraw ();
-        _hostView.Draw ();
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.Visible);
-        Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
-        Assert.Equal (1, _scrollBar.Viewport.Width);
-
-        Assert.Equal (
-                      $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))",
-                      _scrollBar.Height.ToString ()
-                     );
-        Assert.Equal (24, _scrollBar.Viewport.Height);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.Visible);
-
-        Assert.Equal (
-                      $"Combine(View(Width,HostView(){_hostView.Frame})-Absolute(1))",
-                      _scrollBar.OtherScrollBarView.Width.ToString ()
-                     );
-        Assert.Equal (79, _scrollBar.OtherScrollBarView.Viewport.Width);
-        Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
-        Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Both_Default_Draws_Correctly ()
-    {
-        var width = 3;
-        var height = 40;
-
-        var super = new Window { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
-        var top = new Toplevel ();
-        top.Add (super);
-
-        var horiz = new ScrollBarView
-        {
-            Id = "horiz",
-            Size = width * 2,
-
-            // BUGBUG: ScrollBarView should work if Host is null
-            Host = super,
-            ShowScrollIndicator = true,
-            IsVertical = true
-        };
-        super.Add (horiz);
-
-        var vert = new ScrollBarView
-        {
-            Id = "vert",
-            Size = height * 2,
-
-            // BUGBUG: ScrollBarView should work if Host is null
-            Host = super,
-            ShowScrollIndicator = true,
-            IsVertical = true
-        };
-        super.Add (vert);
-
-        Application.Begin (top);
-        ((FakeDriver)Application.Driver!).SetBufferSize (width, height);
-        Application.LayoutAndDraw ();
-
-        var expected = @"
-┌─┐
-│▲│
-│┬│
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│┴│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│▼│
-└─┘";
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        top.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void ChangedPosition_Negative_Value ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        Application.Begin (_hostView.SuperView as Toplevel);
-        Application.LayoutAndDraw ();
-
-        AddHandlers ();
-
-        _scrollBar.Position = -20;
-        Assert.Equal (0, _scrollBar.Position);
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-
-        _scrollBar.OtherScrollBarView.Position = -50;
-        Assert.Equal (0, _scrollBar.OtherScrollBarView.Position);
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void ChangedPosition_Scrolling ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        Application.Begin (_hostView.SuperView as Toplevel);
-        Application.LayoutAndDraw ();
-
-        AddHandlers ();
-
-        for (var i = 0; i < _scrollBar.Size; i++)
-        {
-            _scrollBar.Position += 1;
-            Assert.Equal (_scrollBar.Position, _hostView.Top);
-        }
-
-        for (int i = _scrollBar.Size - 1; i >= 0; i--)
-        {
-            _scrollBar.Position -= 1;
-            Assert.Equal (_scrollBar.Position, _hostView.Top);
-        }
-
-        for (var i = 0; i < _scrollBar.OtherScrollBarView.Size; i++)
-        {
-            _scrollBar.OtherScrollBarView.Position += i;
-            Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        }
-
-        for (int i = _scrollBar.OtherScrollBarView.Size - 1; i >= 0; i--)
-        {
-            _scrollBar.OtherScrollBarView.Position -= 1;
-            Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        }
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void ChangedPosition_Update_The_Hosted_View ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        Application.Begin (_hostView.SuperView as Toplevel);
-        Application.LayoutAndDraw ();
-
-        AddHandlers ();
-
-        _scrollBar.Position = 2;
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-
-        _scrollBar.OtherScrollBarView.Position = 5;
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Visible_Gets_Sets ()
-    {
-        var text =
-            "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
-        var label = new Label { Text = text };
-        var top = new Toplevel ();
-        top.Add (label);
-
-        var sbv = new ScrollBarView (label, true, false) { Size = 100 };
-        RunState rs = Application.Begin (top);
-        Application.RunIteration (ref rs);
-
-        Assert.True (sbv.Visible);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a tes▲
-This is a tes┬
-This is a tes┴
-This is a tes░
-This is a tes░
-This is a tes▼
-",
-                                                      _output
-                                                     );
-
-        sbv.Visible = false;
-        Assert.False (sbv.Visible);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-",
-                                                      _output
-                                                     );
-
-        sbv.Visible = true;
-        Assert.True (sbv.Visible);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a tes▲
-This is a tes┬
-This is a tes┴
-This is a tes░
-This is a tes░
-This is a tes▼
-",
-                                                      _output
-                                                     );
-
-        sbv.Visible = false;
-        Assert.False (sbv.Visible);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-",
-                                                      _output
-                                                     );
-        top.Dispose ();
-    }
-
-    [Fact (Skip = "#3798 broke - Fix with #3498")]
-    public void
-        Constructor_ShowBothScrollIndicator_False_And_IsVertical_False_Refresh_Does_Not_Throws_An_Object_Null_Exception ()
-    {
-        var exception = Record.Exception (
-                                          () =>
-                                          {
-                                              Application.Init (new FakeDriver ());
-
-                                              Toplevel top = new ();
-
-                                              var win = new Window { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
-
-                                              ObservableCollection<string> source = [];
-
-                                              for (var i = 0; i < 50; i++)
-                                              {
-                                                  var text = $"item {i} - ";
-
-                                                  for (var j = 0; j < 160; j++)
-                                                  {
-                                                      var col = j.ToString ();
-                                                      text += col.Length == 1 ? col [0] : col [1];
-                                                  }
-
-                                                  source.Add (text);
-                                              }
-
-                                              var listView = new ListView
-                                              {
-                                                  X = 0,
-                                                  Y = 0,
-                                                  Width = Dim.Fill (),
-                                                  Height = Dim.Fill (),
-                                                  Source = new ListWrapper<string> (source)
-                                              };
-                                              win.Add (listView);
-
-                                              var newScrollBarView = new ScrollBarView (listView, false, false) { KeepContentAlwaysInViewport = true };
-                                              win.Add (newScrollBarView);
-
-                                              newScrollBarView.ChangedPosition += (s, e) =>
-                                                                                  {
-                                                                                      listView.LeftItem = newScrollBarView.Position;
-
-                                                                                      if (listView.LeftItem != newScrollBarView.Position)
-                                                                                      {
-                                                                                          newScrollBarView.Position = listView.LeftItem;
-                                                                                      }
-
-                                                                                      Assert.Equal (newScrollBarView.Position, listView.LeftItem);
-                                                                                      listView.SetNeedsDraw ();
-                                                                                      Application.LayoutAndDraw ();
-
-                                                                                  };
-
-                                              listView.DrawingContent += (s, e) =>
-                                                                      {
-                                                                          newScrollBarView.Size = listView.MaxLength;
-                                                                          Assert.Equal (newScrollBarView.Size, listView.MaxLength);
-                                                                          newScrollBarView.Position = listView.LeftItem;
-                                                                          Assert.Equal (newScrollBarView.Position, listView.LeftItem);
-                                                                          newScrollBarView.Refresh ();
-                                                                      };
-
-                                              top.Ready += (s, e) =>
-                                                           {
-                                                               newScrollBarView.Position = 100;
-
-                                                               Assert.Equal (
-                                                                             newScrollBarView.Position,
-                                                                             newScrollBarView.Size
-                                                                             - listView.LeftItem
-                                                                             + (listView.LeftItem - listView.Viewport.Width));
-                                                               Assert.Equal (newScrollBarView.Position, listView.LeftItem);
-
-                                                               Assert.Equal (92, newScrollBarView.Position);
-                                                               Assert.Equal (92, listView.LeftItem);
-                                                               Application.RequestStop ();
-                                                           };
-
-                                              top.Add (win);
-
-                                              Application.Run (top);
-
-                                              top.Dispose ();
-                                              Application.Shutdown ();
-
-                                          });
-
-        Assert.Null (exception);
-    }
-
-    [Fact (Skip = "#3798 broke - Fix with #3498")]
-    public void
-        Constructor_ShowBothScrollIndicator_False_And_IsVertical_True_Refresh_Does_Not_Throws_An_Object_Null_Exception ()
-    {
-        Exception exception = Record.Exception (
-                                                () =>
-                                                {
-                                                    Application.Init (new FakeDriver ());
-                                                    Toplevel top = new ();
-                                                    var win = new Window { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
-                                                    ObservableCollection<string> source = [];
-
-                                                    for (var i = 0; i < 50; i++)
-                                                    {
-                                                        source.Add ($"item {i}");
-                                                    }
-
-                                                    var listView = new ListView
-                                                    {
-                                                        X = 0,
-                                                        Y = 0,
-                                                        Width = Dim.Fill (),
-                                                        Height = Dim.Fill (),
-                                                        Source = new ListWrapper<string> (source)
-                                                    };
-                                                    win.Add (listView);
-                                                    var newScrollBarView = new ScrollBarView (listView, true, false) { KeepContentAlwaysInViewport = true };
-                                                    win.Add (newScrollBarView);
-
-                                                    newScrollBarView.ChangedPosition += (s, e) =>
-                                                                                        {
-                                                                                            listView.TopItem = newScrollBarView.Position;
-
-                                                                                            if (listView.TopItem != newScrollBarView.Position)
-                                                                                            {
-                                                                                                newScrollBarView.Position = listView.TopItem;
-                                                                                            }
-
-                                                                                            Assert.Equal (newScrollBarView.Position, listView.TopItem);
-                                                                                            listView.SetNeedsDraw ();
-                                                                                            Application.LayoutAndDraw ();
-
-                                                                                        };
-
-                                                    listView.DrawingContent += (s, e) =>
-                                                                            {
-                                                                                newScrollBarView.Size = listView.Source.Count;
-                                                                                Assert.Equal (newScrollBarView.Size, listView.Source.Count);
-                                                                                newScrollBarView.Position = listView.TopItem;
-                                                                                Assert.Equal (newScrollBarView.Position, listView.TopItem);
-                                                                                newScrollBarView.Refresh ();
-                                                                            };
-
-                                                    top.Ready += (s, e) =>
-                                                                 {
-                                                                     newScrollBarView.Position = 45;
-
-                                                                     Assert.Equal (
-                                                                                   newScrollBarView.Position,
-                                                                                   newScrollBarView.Size
-                                                                                   - listView.TopItem
-                                                                                   + (listView.TopItem - listView.Viewport.Height)
-                                                                                  );
-                                                                     Assert.Equal (newScrollBarView.Position, listView.TopItem);
-                                                                     Assert.Equal (27, newScrollBarView.Position);
-                                                                     Assert.Equal (27, listView.TopItem);
-                                                                     Application.RequestStop ();
-                                                                 };
-                                                    top.Add (win);
-                                                    Application.Run (top);
-                                                    top.Dispose ();
-                                                    Application.Shutdown ();
-                                                }
-                                               );
-
-        Assert.Null (exception);
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void ContentBottomRightCorner_Not_Redraw_If_Both_Size_Equal_To_Zero ()
-    {
-        var text =
-            "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
-        var label = new Label { Text = text };
-        var top = new Toplevel ();
-        top.Add (label);
-
-        var sbv = new ScrollBarView (label, true) { Size = 100 };
-        sbv.OtherScrollBarView.Size = 100;
-        RunState rs = Application.Begin (top);
-
-        Application.RunIteration (ref rs);
-        Assert.Equal (100, sbv.Size);
-        Assert.Equal (100, sbv.OtherScrollBarView.Size);
-        Assert.True (sbv.ShowScrollIndicator);
-        Assert.True (sbv.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (sbv.Visible);
-        Assert.True (sbv.OtherScrollBarView.Visible);
-
-        View contentBottomRightCorner =
-            label.SuperView.Subviews.First (v => v is ScrollBarView.ContentBottomRightCorner);
-        Assert.True (contentBottomRightCorner is ScrollBarView.ContentBottomRightCorner);
-        Assert.True (contentBottomRightCorner.Visible);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a tes▲
-This is a tes┬
-This is a tes┴
-This is a tes░
-This is a tes▼
-◄├─┤░░░░░░░░► 
-",
-                                                      _output
-                                                     );
-
-        sbv.Size = 0;
-        sbv.OtherScrollBarView.Size = 0;
-        Assert.Equal (0, sbv.Size);
-        Assert.Equal (0, sbv.OtherScrollBarView.Size);
-        Assert.False (sbv.ShowScrollIndicator);
-        Assert.False (sbv.OtherScrollBarView.ShowScrollIndicator);
-        Assert.False (sbv.Visible);
-        Assert.False (sbv.OtherScrollBarView.Visible);
-        top.Draw ();
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-",
-                                                      _output
-                                                     );
-
-        sbv.Size = 50;
-        sbv.OtherScrollBarView.Size = 50;
-        Assert.Equal (50, sbv.Size);
-        Assert.Equal (50, sbv.OtherScrollBarView.Size);
-        Assert.True (sbv.ShowScrollIndicator);
-        Assert.True (sbv.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (sbv.Visible);
-        Assert.True (sbv.OtherScrollBarView.Visible);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a tes▲
-This is a tes┬
-This is a tes┴
-This is a tes░
-This is a tes▼
-◄├──┤░░░░░░░► 
-",
-                                                      _output
-                                                     );
-        top.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void ContentBottomRightCorner_Not_Redraw_If_One_Size_Equal_To_Zero ()
-    {
-        var text =
-            "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
-        var label = new Label { Text = text };
-        var top = new Toplevel ();
-        top.Add (label);
-
-        var sbv = new ScrollBarView (label, true, false) { Size = 100 };
-        Application.Begin (top);
-        Application.LayoutAndDraw ();
-
-        Assert.Equal (100, sbv.Size);
-        Assert.Null (sbv.OtherScrollBarView);
-        Assert.True (sbv.ShowScrollIndicator);
-        Assert.True (sbv.Visible);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a tes▲
-This is a tes┬
-This is a tes┴
-This is a tes░
-This is a tes░
-This is a tes▼
-",
-                                                      _output
-                                                     );
-
-        sbv.Size = 0;
-        Assert.Equal (0, sbv.Size);
-        Assert.False (sbv.ShowScrollIndicator);
-        Assert.False (sbv.Visible);
-        top.Draw ();
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-This is a test
-",
-                                                      _output
-                                                     );
-        top.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void DrawContent_Update_The_ScrollBarView_Position ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        Application.Begin (_hostView.SuperView as Toplevel);
-        Application.LayoutAndDraw ();
-
-        AddHandlers ();
-
-        _hostView.Top = 3;
-        _hostView.SetNeedsDraw ();
-        _hostView.Draw ();
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-
-        _hostView.Left = 6;
-        _hostView.SetNeedsDraw ();
-        _hostView.Draw ();
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Horizontal_Default_Draws_Correctly ()
-    {
-        var width = 40;
-        var height = 3;
-
-        var super = new Window { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
-        var top = new Toplevel ();
-        top.Add (super);
-
-        var sbv = new ScrollBarView { Id = "sbv", Size = width * 2, ShowScrollIndicator = true };
-        super.Add (sbv);
-        Application.Begin (top);
-        ((FakeDriver)Application.Driver!).SetBufferSize (width, height);
-
-        var expected = @"
-┌──────────────────────────────────────┐
-│◄├────────────────┤░░░░░░░░░░░░░░░░░░►│
-└──────────────────────────────────────┘";
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        top.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void Hosting_A_Null_SuperView_View_To_A_ScrollBarView_Throws_ArgumentNullException ()
-    {
-        Assert.Throws<ArgumentNullException> (
-                                              "The host SuperView parameter can't be null.",
-                                              () => new ScrollBarView (new View (), true)
-                                             );
-
-        Assert.Throws<ArgumentNullException> (
-                                              "The host SuperView parameter can't be null.",
-                                              () => new ScrollBarView (new View (), false)
-                                             );
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void Hosting_A_Null_View_To_A_ScrollBarView_Throws_ArgumentNullException ()
-    {
-        Assert.Throws<ArgumentNullException> (
-                                              "The host parameter can't be null.",
-                                              () => new ScrollBarView (null, true)
-                                             );
-
-        Assert.Throws<ArgumentNullException> (
-                                              "The host parameter can't be null.",
-                                              () => new ScrollBarView (null, false)
-                                             );
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void Hosting_A_View_To_A_ScrollBarView ()
-    {
-        RemoveHandlers ();
-
-        _scrollBar = new ScrollBarView (_hostView, true);
-        RunState rs = Application.Begin (_hostView.SuperView as Toplevel);
-
-        Assert.True (_scrollBar.IsVertical);
-        Assert.False (_scrollBar.OtherScrollBarView.IsVertical);
-
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-        Assert.NotEqual (_scrollBar.Size, _hostView.Lines);
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        Assert.NotEqual (_scrollBar.OtherScrollBarView.Size, _hostView.Cols);
-
-        AddHandlers ();
-        Application.RunIteration (ref rs);
-
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-        Assert.Equal (_scrollBar.Size, _hostView.Lines);
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        Assert.Equal (_scrollBar.OtherScrollBarView.Size, _hostView.Cols);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Hosting_ShowBothScrollIndicator_Invisible ()
-    {
-        var textView = new TextView
-        {
-            Width = Dim.Fill (),
-            Height = Dim.Fill (),
-            Text =
-                "This is the help text for the Second Step.\n\nPress the button to see a message box.\n\nEnter name too."
-        };
-        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
-        win.Add (textView);
-
-        var scrollBar = new ScrollBarView (textView, true);
-
-        scrollBar.ChangedPosition += (s, e) =>
-                                     {
-                                         textView.TopRow = scrollBar.Position;
-
-                                         if (textView.TopRow != scrollBar.Position)
-                                         {
-                                             scrollBar.Position = textView.TopRow;
-                                         }
-
-                                         textView.SetNeedsDraw ();
-                                     };
-
-        scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
-                                                        {
-                                                            textView.LeftColumn = scrollBar.OtherScrollBarView.Position;
-
-                                                            if (textView.LeftColumn != scrollBar.OtherScrollBarView.Position)
-                                                            {
-                                                                scrollBar.OtherScrollBarView.Position = textView.LeftColumn;
-                                                            }
-
-                                                            textView.SetNeedsDraw ();
-                                                        };
-
-        textView.SubviewsLaidOut += (s, e) =>
-                                   {
-                                       scrollBar.Size = textView.Lines;
-                                       scrollBar.Position = textView.TopRow;
-
-                                       if (scrollBar.OtherScrollBarView != null)
-                                       {
-                                           scrollBar.OtherScrollBarView.Size = textView.Maxlength;
-                                           scrollBar.OtherScrollBarView.Position = textView.LeftColumn;
-                                       }
-                                   };
-        var top = new Toplevel ();
-        top.Add (win);
-
-        RunState rs = Application.Begin (top);
-        ((FakeDriver)Application.Driver!).SetBufferSize (45, 20);
-
-        Assert.True (scrollBar.AutoHideScrollBars);
-        Assert.False (scrollBar.ShowScrollIndicator);
-        Assert.False (scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.Equal (5, textView.Lines);
-        Assert.Equal (42, textView.Maxlength);
-        Assert.Equal (0, textView.LeftColumn);
-        Assert.Equal (0, scrollBar.Position);
-        Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
-
-        var expected = @"
-┌───────────────────────────────────────────┐
-│This is the help text for the Second Step. │
-│                                           │
-│Press the button to see a message box.     │
-│                                           │
-│Enter name too.                            │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-│                                           │
-└───────────────────────────────────────────┘
-";
-
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 45, 20), pos);
-
-        textView.WordWrap = true;
-        ((FakeDriver)Application.Driver!).SetBufferSize (26, 20);
-        Application.RunIteration (ref rs);
-
-        Assert.True (textView.WordWrap);
-        Assert.True (scrollBar.AutoHideScrollBars);
-        Assert.Equal (7, textView.Lines);
-        Assert.Equal (22, textView.Maxlength);
-        Assert.Equal (0, textView.LeftColumn);
-        Assert.Equal (0, scrollBar.Position);
-        Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
-
-        expected = @"
-┌────────────────────────┐
-│This is the help text   │
-│for the Second Step.    │
-│                        │
-│Press the button to     │
-│see a message box.      │
-│                        │
-│Enter name too.         │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-│                        │
-└────────────────────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 26, 20), pos);
-
-        ((FakeDriver)Application.Driver!).SetBufferSize (10, 10);
-        Application.RunIteration (ref rs);
-
-        Assert.True (textView.WordWrap);
-        Assert.True (scrollBar.AutoHideScrollBars);
-        Assert.Equal (20, textView.Lines);
-        Assert.Equal (7, textView.Maxlength);
-        Assert.Equal (0, textView.LeftColumn);
-        Assert.Equal (0, scrollBar.Position);
-        Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
-        Assert.True (scrollBar.ShowScrollIndicator);
-
-        expected = @"
-┌────────┐
-│This   ▲│
-│is the ┬│
-│help   ││
-│text   ┴│
-│for    ░│
-│the    ░│
-│Second ░│
-│Step.  ▼│
-└────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 10, 10), pos);
-        top.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void Hosting_Two_Horizontal_ScrollBarView_Throws_ArgumentException ()
-    {
-        var top = new Toplevel ();
-        var host = new View ();
-        top.Add (host);
-        var v = new ScrollBarView (host, false);
-        var h = new ScrollBarView (host, false);
-
-        Assert.Throws<ArgumentException> (() => v.OtherScrollBarView = h);
-        Assert.Throws<ArgumentException> (() => h.OtherScrollBarView = v);
-        top.Dispose ();
-
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void Hosting_Two_Vertical_ScrollBarView_Throws_ArgumentException ()
-    {
-        var top = new Toplevel ();
-        var host = new View ();
-        top.Add (host);
-        var v = new ScrollBarView (host, true);
-        var h = new ScrollBarView (host, true);
-
-        Assert.Throws<ArgumentException> (() => v.OtherScrollBarView = h);
-        Assert.Throws<ArgumentException> (() => h.OtherScrollBarView = v);
-        top.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Internal_Tests ()
-    {
-        Toplevel top = new ();
-        top.Layout ();
-        Assert.Equal (new Rectangle (0, 0, 80, 25), top.Viewport);
-        var view = new View { Width = Dim.Fill (), Height = Dim.Fill () };
-        top.Add (view);
-        var sbv = new ScrollBarView (view, true);
-        top.Add (sbv);
-        Assert.Equal (view, sbv.Host);
-        sbv.Size = 40;
-        sbv.Position = 0;
-        sbv.OtherScrollBarView.Size = 100;
-        sbv.OtherScrollBarView.Position = 0;
-        top.Layout ();
-
-        // Host bounds is not empty.
-        Assert.True (sbv.CanScroll (10, out int max, sbv.IsVertical));
-        Assert.Equal (10, max);
-        Assert.True (sbv.OtherScrollBarView.CanScroll (10, out max, sbv.OtherScrollBarView.IsVertical));
-        Assert.Equal (10, max);
-
-        Application.Begin (top);
-
-        // They are visible so they are drawn.
-        Assert.True (sbv.Visible);
-        Assert.True (sbv.OtherScrollBarView.Visible);
-        top.LayoutSubviews ();
-
-        // Now the host bounds is not empty.
-        Assert.True (sbv.CanScroll (10, out max, sbv.IsVertical));
-        Assert.Equal (10, max);
-        Assert.True (sbv.OtherScrollBarView.CanScroll (10, out max, sbv.OtherScrollBarView.IsVertical));
-        Assert.Equal (10, max);
-        Assert.True (sbv.CanScroll (50, out max, sbv.IsVertical));
-        Assert.Equal (40, sbv.Size);
-        Assert.Equal (16, max); // 16+25=41
-        Assert.True (sbv.OtherScrollBarView.CanScroll (150, out max, sbv.OtherScrollBarView.IsVertical));
-        Assert.Equal (100, sbv.OtherScrollBarView.Size);
-        Assert.Equal (21, max); // 21+80=101
-        Assert.True (sbv.Visible);
-        Assert.True (sbv.OtherScrollBarView.Visible);
-        sbv.KeepContentAlwaysInViewport = false;
-        sbv.OtherScrollBarView.KeepContentAlwaysInViewport = false;
-        Assert.True (sbv.CanScroll (50, out max, sbv.IsVertical));
-        Assert.Equal (39, max);
-        Assert.True (sbv.OtherScrollBarView.CanScroll (150, out max, sbv.OtherScrollBarView.IsVertical));
-        Assert.Equal (99, max);
-        Assert.True (sbv.Visible);
-        Assert.True (sbv.OtherScrollBarView.Visible);
-        top.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void KeepContentAlwaysInViewport_False ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        RunState rs = Application.Begin (_hostView.SuperView as Toplevel);
-
-        AddHandlers ();
-        Application.RunIteration (ref rs);
-
-        _scrollBar.KeepContentAlwaysInViewport = false;
-        _scrollBar.Position = 50;
-        Assert.Equal (_scrollBar.Position, _scrollBar.Size - 1);
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-        Assert.Equal (29, _scrollBar.Position);
-        Assert.Equal (29, _hostView.Top);
-
-        _scrollBar.OtherScrollBarView.Position = 150;
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _scrollBar.OtherScrollBarView.Size - 1);
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        Assert.Equal (99, _scrollBar.OtherScrollBarView.Position);
-        Assert.Equal (99, _hostView.Left);
-        _hostView.SuperView.Dispose ();
-
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void KeepContentAlwaysInViewport_True ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        RunState rs = Application.Begin (_hostView.SuperView as Toplevel);
-
-        AddHandlers ();
-        Application.RunIteration (ref rs);
-
-        Assert.Equal (80, _hostView.Viewport.Width);
-        Assert.Equal (25, _hostView.Viewport.Height);
-        Assert.Equal (79, _scrollBar.OtherScrollBarView.Viewport.Width);
-        Assert.Equal (24, _scrollBar.Viewport.Height);
-        Assert.Equal (30, _scrollBar.Size);
-        Assert.Equal (100, _scrollBar.OtherScrollBarView.Size);
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (_scrollBar.Visible);
-        Assert.True (_scrollBar.OtherScrollBarView.Visible);
-
-        _scrollBar.Position = 50;
-        Assert.Equal (_scrollBar.Position, _scrollBar.Size - _scrollBar.Viewport.Height);
-        Assert.Equal (_scrollBar.Position, _hostView.Top);
-        Assert.Equal (6, _scrollBar.Position);
-        Assert.Equal (6, _hostView.Top);
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (_scrollBar.Visible);
-        Assert.True (_scrollBar.OtherScrollBarView.Visible);
-
-        _scrollBar.OtherScrollBarView.Position = 150;
-
-        Assert.Equal (
-                      _scrollBar.OtherScrollBarView.Position,
-                      _scrollBar.OtherScrollBarView.Size - _scrollBar.OtherScrollBarView.Viewport.Width
-                     );
-        Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
-        Assert.Equal (21, _scrollBar.OtherScrollBarView.Position);
-        Assert.Equal (21, _hostView.Left);
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        Assert.True (_scrollBar.Visible);
-        Assert.True (_scrollBar.OtherScrollBarView.Visible);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void OtherScrollBarView_Not_Null ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        Application.Begin (_hostView.SuperView as Toplevel);
-
-        AddHandlers ();
-
-        Assert.NotNull (_scrollBar.OtherScrollBarView);
-        Assert.NotEqual (_scrollBar, _scrollBar.OtherScrollBarView);
-        Assert.Equal (_scrollBar.OtherScrollBarView.OtherScrollBarView, _scrollBar);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void Scrolling_With_Default_Constructor_Do_Not_Scroll ()
-    {
-        var sbv = new ScrollBarView { Position = 1 };
-        Assert.Equal (1, sbv.Position);
-        Assert.NotEqual (0, sbv.Position);
-        sbv.Dispose ();
-    }
-
-    [Fact]
-    [ScrollBarAutoInitShutdown]
-    public void ShowScrollIndicator_Check ()
-    {
-        _scrollBar = new ScrollBarView (_hostView, true);
-        RunState rs = Application.Begin (_hostView.SuperView as Toplevel);
-
-        AddHandlers ();
-        Application.RunIteration (ref rs);
-
-        Assert.True (_scrollBar.ShowScrollIndicator);
-        Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
-        _hostView.SuperView.Dispose ();
-    }
-
-    [Fact (Skip = "#3798 broke - Fix with #3498")]
-    [AutoInitShutdown]
-    public void ShowScrollIndicator_False_Must_Also_Set_Visible_To_False_To_Not_Respond_To_Events ()
-    {
-        // Override CM
-        Window.DefaultBorderStyle = LineStyle.Single;
-        Dialog.DefaultButtonAlignment = Alignment.Center;
-        Dialog.DefaultBorderStyle = LineStyle.Single;
-        Dialog.DefaultShadow = ShadowStyle.None;
-        Button.DefaultShadow = ShadowStyle.None;
-
-        var clicked = false;
-        var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
-        var label = new Label { Width = 14, Height = 5, Text = text };
-        var btn = new Button { X = 14, Text = "Click Me!" };
-        btn.Accepting += (s, e) => clicked = true;
-        var top = new Toplevel ();
-        top.Add (label, btn);
-
-        var sbv = new ScrollBarView (label, true, false) { Size = 5 };
-        Application.Begin (top);
-        Application.LayoutAndDraw ();
-
-        Assert.Equal (5, sbv.Size);
-        Assert.Null (sbv.OtherScrollBarView);
-        Assert.False (sbv.ShowScrollIndicator);
-        Assert.False (sbv.Visible);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @$"
-This is a test{CM.Glyphs.LeftBracket} Click Me! {CM.Glyphs.RightBracket}
-This is a test             
-This is a test             
-This is a test             
-This is a test             ",
-                                                      _output
-                                                     );
-
-        Application.RaiseMouseEvent (new MouseEventArgs { Position = new (15, 0), Flags = MouseFlags.Button1Clicked });
-
-        Assert.Null (Application.MouseGrabView);
-        Assert.True (clicked);
-
-        clicked = false;
-
-        sbv.Visible = true;
-        Assert.Equal (5, sbv.Size);
-        Assert.False (sbv.ShowScrollIndicator);
-        Assert.True (sbv.Visible);
-        Application.LayoutAndDraw ();
-        Assert.False (sbv.Visible);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @$"
-This is a test{CM.Glyphs.LeftBracket} Click Me! {CM.Glyphs.RightBracket}
-This is a test             
-This is a test             
-This is a test             
-This is a test             ",
-                                                      _output
-                                                     );
-
-        Application.RaiseMouseEvent (new MouseEventArgs { Position = new (15, 0), Flags = MouseFlags.Button1Clicked });
-
-        Assert.Null (Application.MouseGrabView);
-        Assert.True (clicked);
-        Assert.Equal (5, sbv.Size);
-        Assert.False (sbv.ShowScrollIndicator);
-        Assert.False (sbv.Visible);
-        top.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Vertical_Default_Draws_Correctly ()
-    {
-        var width = 3;
-        var height = 40;
-
-        var super = new Window { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
-        var top = new Toplevel ();
-        top.Add (super);
-
-        var sbv = new ScrollBarView
-        {
-            Id = "sbv",
-            Size = height * 2,
-
-            // BUGBUG: ScrollBarView should work if Host is null
-            Host = super,
-            ShowScrollIndicator = true,
-            IsVertical = true
-        };
-
-        super.Add (sbv);
-        Application.Begin (top);
-        ((FakeDriver)Application.Driver!).SetBufferSize (width, height);
-
-        var expected = @"
-┌─┐
-│▲│
-│┬│
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│││
-│┴│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│░│
-│▼│
-└─┘";
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        top.Dispose ();
-    }
-
-    private void _hostView_DrawContent (object sender, DrawEventArgs e)
-    {
-        _scrollBar.Size = _hostView.Lines;
-        _scrollBar.Position = _hostView.Top;
-        _scrollBar.OtherScrollBarView.Size = _hostView.Cols;
-        _scrollBar.OtherScrollBarView.Position = _hostView.Left;
-        _scrollBar.Refresh ();
-    }
-
-    private void _scrollBar_ChangedPosition (object sender, EventArgs e)
-    {
-        _hostView.Top = _scrollBar.Position;
-
-        if (_hostView.Top != _scrollBar.Position)
-        {
-            _scrollBar.Position = _hostView.Top;
-        }
-
-        _hostView.SetNeedsDraw ();
-    }
-
-    private void _scrollBar_OtherScrollBarView_ChangedPosition (object sender, EventArgs e)
-    {
-        _hostView.Left = _scrollBar.OtherScrollBarView.Position;
-
-        if (_hostView.Left != _scrollBar.OtherScrollBarView.Position)
-        {
-            _scrollBar.OtherScrollBarView.Position = _hostView.Left;
-        }
-
-        _hostView.SetNeedsDraw ();
-    }
-
-    private void AddHandlers ()
-    {
-        if (!_added)
-        {
-            _hostView.DrawingContent += _hostView_DrawContent;
-            _scrollBar.ChangedPosition += _scrollBar_ChangedPosition;
-            _scrollBar.OtherScrollBarView.ChangedPosition += _scrollBar_OtherScrollBarView_ChangedPosition;
-        }
-
-        _added = true;
-    }
-
-    private void RemoveHandlers ()
-    {
-        if (_added)
-        {
-            _hostView.DrawingContent -= _hostView_DrawContent;
-            _scrollBar.ChangedPosition -= _scrollBar_ChangedPosition;
-            _scrollBar.OtherScrollBarView.ChangedPosition -= _scrollBar_OtherScrollBarView_ChangedPosition;
-        }
-
-        _added = false;
-    }
-
-    public class HostView : View
-    {
-        public int Cols { get; set; }
-        public int Left { get; set; }
-        public int Lines { get; set; }
-        public int Top { get; set; }
-    }
-
-    // This class enables test functions annotated with the [InitShutdown] attribute
-    // to have a function called before the test function is called and after.
-    // 
-    // This is necessary because a) Application is a singleton and Init/Shutdown must be called
-    // as a pair, and b) all unit test functions should be atomic.
-    [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method)]
-    public class ScrollBarAutoInitShutdownAttribute : AutoInitShutdownAttribute
-    {
-        public override void After (MethodInfo methodUnderTest)
-        {
-            _hostView = null;
-            base.After (methodUnderTest);
-        }
-
-        public override void Before (MethodInfo methodUnderTest)
-        {
-            base.Before (methodUnderTest);
-
-            _hostView = new HostView
-            {
-                Width = Dim.Fill (),
-                Height = Dim.Fill (),
-                Top = 0,
-                Lines = 30,
-                Left = 0,
-                Cols = 100
-            };
-
-            var top = new Toplevel ();
-            top.Add (_hostView);
-        }
-    }
-}

+ 0 - 1155
UnitTests/Views/ScrollViewTests.cs

@@ -1,1155 +0,0 @@
-using System.Text;
-using JetBrains.Annotations;
-using Xunit.Abstractions;
-
-namespace Terminal.Gui.ViewsTests;
-
-public class ScrollViewTests (ITestOutputHelper output)
-{
-#if meh
-    [Fact]
-    public void Adding_Views ()
-    {
-        var sv = new ScrollView { Width = 20, Height = 10 };
-        sv.SetContentSize (new (30, 20));
-
-        sv.Add (
-                new View { Width = 10, Height = 5 },
-                new View { X = 12, Y = 7, Width = 10, Height = 5 }
-               );
-
-        Assert.Equal (new (30, 20), sv.GetContentSize ());
-        Assert.Equal (2, sv.Subviews [0].Subviews.Count);
-    }
-
-    [Fact (Skip = "#3798 broke - Fix with #3498")]
-    [AutoInitShutdown]
-    public void AutoHideScrollBars_False_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
-    {
-        var sv = new ScrollView { Width = 10, Height = 10, AutoHideScrollBars = false };
-
-        sv.ShowHorizontalScrollIndicator = true;
-        sv.ShowVerticalScrollIndicator = true;
-
-        var top = new Toplevel ();
-        top.Add (sv);
-        Application.Begin (top);
-
-        Assert.Equal (new (0, 0, 10, 10), sv.Viewport);
-
-        Assert.False (sv.AutoHideScrollBars);
-        Assert.True (sv.ShowHorizontalScrollIndicator);
-        Assert.True (sv.ShowVerticalScrollIndicator);
-        sv.Draw ();
-
-        TestHelpers.AssertDriverContentsAre (
-                                             @"
-         ▲
-         ┬
-         │
-         │
-         │
-         │
-         │
-         ┴
-         ▼
-◄├─────┤► 
-",
-                                             output
-                                            );
-
-        sv.ShowHorizontalScrollIndicator = false;
-        Assert.Equal (new (0, 0, 10, 10), sv.Viewport);
-        sv.ShowVerticalScrollIndicator = true;
-        Assert.Equal (new (0, 0, 10, 10), sv.Viewport);
-
-        Assert.False (sv.AutoHideScrollBars);
-        Assert.False (sv.ShowHorizontalScrollIndicator);
-        Assert.True (sv.ShowVerticalScrollIndicator);
-        top.Layout ();
-        sv.Draw ();
-
-        TestHelpers.AssertDriverContentsAre (
-                                             @"
-         ▲
-         ┬
-         │
-         │
-         │
-         │
-         │
-         │
-         ┴
-         ▼
-",
-                                             output
-                                            );
-
-        sv.ShowHorizontalScrollIndicator = true;
-        sv.ShowVerticalScrollIndicator = false;
-
-        Assert.False (sv.AutoHideScrollBars);
-        Assert.True (sv.ShowHorizontalScrollIndicator);
-        Assert.False (sv.ShowVerticalScrollIndicator);
-        top.Layout ();
-        sv.Draw ();
-
-        TestHelpers.AssertDriverContentsAre (
-                                             @"
-         
-         
-         
-         
-         
-         
-         
-         
-         
-◄├──────┤► 
-",
-                                             output
-                                            );
-
-        sv.ShowHorizontalScrollIndicator = false;
-        sv.ShowVerticalScrollIndicator = false;
-
-        Assert.False (sv.AutoHideScrollBars);
-        Assert.False (sv.ShowHorizontalScrollIndicator);
-        Assert.False (sv.ShowVerticalScrollIndicator);
-        top.Layout ();
-        sv.Draw ();
-
-        TestHelpers.AssertDriverContentsAre (
-                                             @"
-         
-         
-         
-         
-         
-         
-         
-         
-         
-         
-",
-                                             output
-                                            );
-        top.Dispose ();
-    }
-
-    [Fact (Skip = "#3798 broke - Fix with #3498")]
-    [AutoInitShutdown]
-    public void AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
-    {
-        var sv = new ScrollView { Width = 10, Height = 10 };
-
-        var top = new Toplevel ();
-        top.Add (sv);
-        Application.Begin (top);
-
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.False (sv.ShowHorizontalScrollIndicator);
-        Assert.False (sv.ShowVerticalScrollIndicator);
-        TestHelpers.AssertDriverContentsWithFrameAre ("", output);
-
-        sv.AutoHideScrollBars = false;
-        sv.ShowHorizontalScrollIndicator = true;
-        sv.ShowVerticalScrollIndicator = true;
-        sv.LayoutSubviews ();
-        sv.Draw ();
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-         ▲
-         ┬
-         │
-         │
-         │
-         │
-         │
-         ┴
-         ▼
-◄├─────┤► 
-",
-                                                      output
-                                                     );
-        top.Dispose ();
-    }
-
-    // There are still issue with the lower right corner of the scroll view
-    [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
-    public void Clear_Window_Inside_ScrollView ()
-    {
-        var topLabel = new Label { X = 15, Text = "At 15,0" };
-
-        var sv = new ScrollView
-        {
-            X = 3,
-            Y = 3,
-            Width = 10,
-            Height = 10,
-            KeepContentAlwaysInViewport = false
-        };
-        sv.SetContentSize (new (23, 23));
-        var bottomLabel = new Label { X = 15, Y = 15, Text = "At 15,15" };
-        var top = new Toplevel ();
-        top.Add (topLabel, sv, bottomLabel);
-        RunState rs = Application.Begin (top);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-               At 15,0 
-                       
-                       
-            ▲          
-            ┬          
-            ┴          
-            ░          
-            ░          
-            ░          
-            ░          
-            ░          
-            ▼          
-   ◄├┤░░░░░►           
-                       
-                       
-               At 15,15",
-                                                      output
-                                                     );
-
-        Attribute [] attributes =
-        {
-            Colors.ColorSchemes ["TopLevel"].Normal,
-            Colors.ColorSchemes ["TopLevel"].Focus,
-            Colors.ColorSchemes ["Base"].Normal
-        };
-
-        TestHelpers.AssertDriverAttributesAre (
-                                               @"
-00000000000000000000000
-00000000000000000000000
-00000000000000000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00011111111110000000000
-00000000000000000000000
-00000000000000000000000
-00000000000000000000000",
-                                               output,
-                                               null,
-                                               attributes
-                                              );
-
-        sv.Add (new Window { X = 3, Y = 3, Width = 20, Height = 20 });
-
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-               At 15,0 
-                       
-                       
-            ▲          
-            ┬          
-            ┴          
-      ┌─────░          
-      │     ░          
-      │     ░          
-      │     ░          
-      │     ░          
-      │     ▼          
-   ◄├┤░░░░░►           
-                       
-                       
-               At 15,15",
-                                                      output
-                                                     );
-
-        TestHelpers.AssertDriverAttributesAre (
-                                               @"
-00000000000000000000000
-00000000000000000000000
-00000000000000000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000022222210000000000
-00000022222210000000000
-00000022222210000000000
-00000022222210000000000
-00000022222210000000000
-00000022222210000000000
-00011111111110000000000
-00000000000000000000000
-00000000000000000000000
-00000000000000000000000",
-                                               output,
-                                               null,
-                                               attributes
-                                              );
-
-        sv.ContentOffset = new (20, 20);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-               At 15,0 
-                       
-                       
-     │      ▲          
-     │      ░          
-   ──┘      ░          
-            ░          
-            ░          
-            ┬          
-            │          
-            ┴          
-            ▼          
-   ◄░░░░├─┤►           
-                       
-                       
-               At 15,15",
-                                                      output
-                                                     );
-
-        TestHelpers.AssertDriverAttributesAre (
-                                               @"
-00000000000000000000000
-00000000000000000000000
-00000000000000000000000
-00022200000010000000000
-00022200000010000000000
-00022200000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00000000000010000000000
-00011111111110000000000
-00000000000000000000000
-00000000000000000000000
-00000000000000000000000",
-                                               output,
-                                               null,
-                                               attributes
-                                              );
-        top.Dispose ();
-    }
-
-    [Fact]
-    public void Constructors_Defaults ()
-    {
-        var sv = new ScrollView ();
-        Assert.True (sv.CanFocus);
-        Assert.Equal (new (0, 0, 0, 0), sv.Frame);
-        Assert.Equal (Rectangle.Empty, sv.Frame);
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.Equal (Size.Empty, sv.GetContentSize ());
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.True (sv.KeepContentAlwaysInViewport);
-
-        sv = new () { X = 1, Y = 2, Width = 20, Height = 10 };
-        Assert.True (sv.CanFocus);
-        Assert.Equal (new (1, 2, 20, 10), sv.Frame);
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.Equal (sv.Viewport.Size, sv.GetContentSize ());
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.True (sv.KeepContentAlwaysInViewport);
-    }
-
-    [Fact]
-    [SetupFakeDriver]
-    public void ContentBottomRightCorner_Draw ()
-    {
-        ((FakeDriver)Application.Driver!).SetBufferSize (30, 30);
-
-        var top = new View { Width = 30, Height = 30, ColorScheme = new () { Normal = Attribute.Default } };
-
-        Size size = new (20, 10);
-
-        var sv = new ScrollView
-        {
-            X = 1,
-            Y = 1,
-            Width = 10,
-            Height = 5,
-            ColorScheme = new () { Normal = new (Color.Red, Color.Green) }
-        };
-        sv.SetContentSize (size);
-        string text = null;
-
-        for (var i = 0; i < size.Height; i++)
-        {
-            text += "*".Repeat (size.Width);
-
-            if (i < size.Height)
-            {
-                text += '\n';
-            }
-        }
-
-        var view = new View
-        {
-            ColorScheme = new () { Normal = new (Color.Blue, Color.Yellow) },
-            Width = Dim.Auto (DimAutoStyle.Text),
-            Height = Dim.Auto (DimAutoStyle.Text),
-            Text = text
-        };
-        sv.Add (view);
-
-        top.Add (sv);
-        top.BeginInit ();
-        top.EndInit ();
-
-        top.LayoutSubviews ();
-
-        View.ClipToScreen ();
-        top.Draw ();
-
-        View contentBottomRightCorner = sv.Subviews.First (v => v is ScrollBarView.ContentBottomRightCorner);
-        Assert.True (contentBottomRightCorner is ScrollBarView.ContentBottomRightCorner);
-        Assert.True (contentBottomRightCorner.Visible);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
- *********▲
- *********┬
- *********┴
- *********▼
- ◄├──┤░░░► ",
-                                                      output
-                                                     );
-
-        Attribute [] attrs = { Attribute.Default, new (Color.Red, Color.Green), new (Color.Blue, Color.Yellow) };
-
-        TestHelpers.AssertDriverAttributesAre (
-                                               @"
-000000000000
-022222222210
-022222222210
-022222222210
-022222222210
-011111111110
-000000000000",
-                                               output,
-                                               null,
-                                               attrs
-                                              );
-        top.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void
-        ContentOffset_ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
-    {
-        var sv = new ScrollView
-        {
-            Width = 10, Height = 10
-        };
-        sv.SetContentSize (new (50, 50));
-        sv.ContentOffset = new (25, 25);
-
-        var top = new Toplevel ();
-        top.Add (sv);
-        Application.Begin (top);
-        Application.LayoutAndDrawToplevels ();
-
-        Assert.Equal (new (-25, -25), sv.ContentOffset);
-        Assert.Equal (new (50, 50), sv.GetContentSize ());
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.True (sv.ShowHorizontalScrollIndicator);
-        Assert.True (sv.ShowVerticalScrollIndicator);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-         ▲
-         ░
-         ░
-         ░
-         ┬
-         │
-         ┴
-         ░
-         ▼
-◄░░░├─┤░► 
-",
-                                                      output
-                                                     );
-        top.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
-    {
-        var sv = new ScrollView { Width = 10, Height = 10 };
-        sv.SetContentSize (new (50, 50));
-
-        var top = new Toplevel ();
-        top.Add (sv);
-        Application.Begin (top);
-        Application.LayoutAndDrawToplevels ();
-
-        Assert.Equal (50, sv.GetContentSize ().Width);
-        Assert.Equal (50, sv.GetContentSize ().Height);
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.True (sv.ShowHorizontalScrollIndicator);
-        Assert.True (sv.ShowVerticalScrollIndicator);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-         ▲
-         ┬
-         ┴
-         ░
-         ░
-         ░
-         ░
-         ░
-         ▼
-◄├┤░░░░░► 
-",
-                                                      output
-                                                     );
-        top.Dispose ();
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void DrawTextFormatter_Respects_The_Clip_Bounds ()
-    {
-        var rule = "0123456789";
-        Size size = new (40, 40);
-        var view = new View { Frame = new (Point.Empty, size) };
-
-        view.Add (
-                  new Label
-                  {
-                      Width = Dim.Fill (),
-                      Height = 1,
-                      Text = rule.Repeat (size.Width / rule.Length)
-                  }
-                 );
-
-        view.Add (
-                  new Label
-                  {
-                      Height = Dim.Fill (),
-                      Width = 1,
-                      Text = rule.Repeat (size.Height / rule.Length),
-                      TextDirection = TextDirection.TopBottom_LeftRight
-                  }
-                 );
-        view.Add (new Label { X = 1, Y = 1, Text = "[ Press me! ]" });
-
-        var scrollView = new ScrollView
-        {
-            X = 1,
-            Y = 1,
-            Width = 15,
-            Height = 10,
-            ShowHorizontalScrollIndicator = true,
-            ShowVerticalScrollIndicator = true
-        };
-        scrollView.SetContentSize (size);
-        scrollView.Add (view);
-        var win = new Window { X = 1, Y = 1, Width = 20, Height = 14 };
-        win.Add (scrollView);
-        var top = new Toplevel ();
-        top.Add (win);
-        RunState rs = Application.Begin (top);
-        Application.RunIteration(ref rs);
-
-        var expected = @"
- ┌──────────────────┐
- │                  │
- │ 01234567890123▲  │
- │ 1[ Press me! ]┬  │
- │ 2             │  │
- │ 3             ┴  │
- │ 4             ░  │
- │ 5             ░  │
- │ 6             ░  │
- │ 7             ░  │
- │ 8             ▼  │
- │ ◄├───┤░░░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 12345678901234▲  │
- │ [ Press me! ] ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄├───┤░░░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 23456789012345▲  │
- │  Press me! ]  ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄├────┤░░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 34567890123456▲  │
- │ Press me! ]   ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄├────┤░░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 45678901234567▲  │
- │ ress me! ]    ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄░├───┤░░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 56789012345678▲  │
- │ ess me! ]     ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄░├────┤░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 67890123456789▲  │
- │ ss me! ]      ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄░├────┤░░░░░►   │
- │                  │
- └──────────────────┘
-"
-            ;
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 78901234567890▲  │
- │ s me! ]       ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄░░├───┤░░░░░►   │
- │                  │
- └──────────────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.End.WithCtrl));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 67890123456789▲  │
- │               ┬  │
- │               │  │
- │               ┴  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ░  │
- │               ▼  │
- │ ◄░░░░░░░├───┤►   │
- │                  │
- └──────────────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.Home.WithCtrl));
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorDown));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 1[ Press me! ]▲  │
- │ 2             ┬  │
- │ 3             │  │
- │ 4             ┴  │
- │ 5             ░  │
- │ 6             ░  │
- │ 7             ░  │
- │ 8             ░  │
- │ 9             ▼  │
- │ ◄├───┤░░░░░░░►   │
- │                  │
- └──────────────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorDown));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 2             ▲  │
- │ 3             ┬  │
- │ 4             │  │
- │ 5             ┴  │
- │ 6             ░  │
- │ 7             ░  │
- │ 8             ░  │
- │ 9             ░  │
- │ 0             ▼  │
- │ ◄├───┤░░░░░░░►   │
- │                  │
- └──────────────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.CursorDown));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 3             ▲  │
- │ 4             ┬  │
- │ 5             │  │
- │ 6             ┴  │
- │ 7             ░  │
- │ 8             ░  │
- │ 9             ░  │
- │ 0             ░  │
- │ 1             ▼  │
- │ ◄├───┤░░░░░░░►   │
- │                  │
- └──────────────────┘
-";
-
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-        Assert.Equal (new (1, 1, 21, 14), pos);
-
-        Assert.True (scrollView.NewKeyDownEvent (Key.End));
-        Application.RunIteration (ref rs);
-
-        expected = @"
- ┌──────────────────┐
- │                  │
- │ 1             ▲  │
- │ 2             ░  │
- │ 3             ░  │
- │ 4             ░  │
- │ 5             ░  │
- │ 6             ░  │
- │ 7             ┬  │
- │ 8             ┴  │
- │ 9             ▼  │
- │ ◄├───┤░░░░░░░►   │
- │                  │
- └──────────────────┘
-";
-
-        TestHelpers.AssertDriverContentsAre (expected, output);
-
-        top.Dispose ();
-    }
-
-    // There still have an issue with lower right corner of the scroll view
-    [Fact]
-    [AutoInitShutdown]
-    public void Frame_And_Labels_Does_Not_Overspill_ScrollView ()
-    {
-        var sv = new ScrollView
-        {
-            X = 3,
-            Y = 3,
-            Width = 10,
-            Height = 10,
-            TabStop = TabBehavior.TabStop
-        };
-        sv.SetContentSize (new (50, 50));
-
-        for (var i = 0; i < 8; i++)
-        {
-            sv.Add (new CustomButton ("█", $"Button {i}", 20, 3) { Y = i * 3 });
-        }
-
-        var top = new Toplevel ();
-        top.Add (sv);
-        RunState rs = Application.Begin (top);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-   █████████▲
-   ██████But┬
-   █████████┴
-   ┌────────░
-   │     But░
-   └────────░
-   ┌────────░
-   │     But░
-   └────────▼
-   ◄├┤░░░░░► ",
-                                                      output
-                                                     );
-
-        sv.ContentOffset = new (5, 5);
-        Application.RunIteration (ref rs);
-
-        TestHelpers.AssertDriverContentsWithFrameAre (
-                                                      @"
-   ─────────▲
-   ─────────┬
-    Button 2│
-   ─────────┴
-   ─────────░
-    Button 3░
-   ─────────░
-   ─────────░
-    Button 4▼
-   ◄├─┤░░░░► ",
-                                                      output
-                                                     );
-        top.Dispose ();
-    }
-
-    [Fact]
-    public void KeyBindings_Command ()
-    {
-        var sv = new ScrollView { Width = 20, Height = 10 };
-        sv.SetContentSize (new (40, 20));
-
-        sv.Add (
-                new View { Width = 20, Height = 5 },
-                new View { X = 22, Y = 7, Width = 10, Height = 5 }
-               );
-
-        sv.BeginInit ();
-        sv.EndInit ();
-
-        Assert.True (sv.KeepContentAlwaysInViewport);
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorUp));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorDown));
-        Assert.Equal (new (0, -1), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorUp));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageUp));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageDown));
-        Point point0xMinus10 = new (0, -10);
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageDown));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorDown));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.V.WithAlt));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.V.WithCtrl));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorLeft));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorRight));
-        Assert.Equal (new (-1, -10), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorLeft));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageUp.WithCtrl));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
-        Point pointMinus20xMinus10 = new (-20, -10);
-        Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorRight));
-        Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.Home));
-        Point pointMinus20x0 = new (-20, 0);
-        Assert.Equal (pointMinus20x0, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.Home));
-        Assert.Equal (pointMinus20x0, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.End));
-        Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.End));
-        Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.Home.WithCtrl));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.Home.WithCtrl));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.End.WithCtrl));
-        Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.End.WithCtrl));
-        Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.Home));
-        Assert.Equal (pointMinus20x0, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.Home.WithCtrl));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-
-        sv.KeepContentAlwaysInViewport = false;
-        Assert.False (sv.KeepContentAlwaysInViewport);
-        Assert.True (sv.AutoHideScrollBars);
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorUp));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorDown));
-        Assert.Equal (new (0, -1), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorUp));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageUp));
-        Assert.Equal (Point.Empty, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageDown));
-        Assert.Equal (point0xMinus10, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageDown));
-        Point point0xMinus19 = new (0, -19);
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageDown));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorDown));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.V.WithAlt));
-        Assert.Equal (new (0, -9), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.V.WithCtrl));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorLeft));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorRight));
-        Assert.Equal (new (-1, -19), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.CursorLeft));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageUp.WithCtrl));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
-        Assert.Equal (new (-20, -19), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
-        Point pointMinus39xMinus19 = new (-39, -19);
-        Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
-        Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.CursorRight));
-        Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.PageUp.WithCtrl));
-        var pointMinus19xMinus19 = new Point (-19, -19);
-        Assert.Equal (pointMinus19xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.Home));
-        Assert.Equal (new (-19, 0), sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.Home));
-        Assert.Equal (new (-19, 0), sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.End));
-        Assert.Equal (pointMinus19xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.End));
-        Assert.Equal (pointMinus19xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.Home.WithCtrl));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.Home.WithCtrl));
-        Assert.Equal (point0xMinus19, sv.ContentOffset);
-        Assert.True (sv.NewKeyDownEvent (Key.End.WithCtrl));
-        Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
-        Assert.False (sv.NewKeyDownEvent (Key.End.WithCtrl));
-        Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
-    }
-
-    [Fact]
-    [AutoInitShutdown]
-    public void Remove_Added_View_Is_Allowed ()
-    {
-        var sv = new ScrollView { Width = 20, Height = 20 };
-        sv.SetContentSize (new (100, 100));
-
-        sv.Add (
-                new View { Width = Dim.Fill (), Height = Dim.Fill (50), Id = "View1" },
-                new View { Y = 51, Width = Dim.Fill (), Height = Dim.Fill (), Id = "View2" }
-               );
-
-        var top = new Toplevel ();
-        top.Add (sv);
-        Application.Begin (top);
-        Application.LayoutAndDrawToplevels ();
-
-        Assert.Equal (4, sv.Subviews.Count);
-        Assert.Equal (2, sv.Subviews [0].Subviews.Count);
-
-        sv.Remove (sv.Subviews [0].Subviews [1]);
-        Assert.Equal (4, sv.Subviews.Count);
-        Assert.Single (sv.Subviews [0].Subviews);
-        Assert.Equal ("View1", sv.Subviews [0].Subviews [0].Id);
-        top.Dispose ();
-    }
-
-    private class CustomButton : FrameView
-    {
-        private readonly Label labelFill;
-        private readonly Label labelText;
-
-        public CustomButton (string fill, string text, int width, int height)
-        {
-            Width = width;
-            Height = height;
-
-            labelFill = new () { Width = Dim.Fill (), Height = Dim.Fill (), Visible = false };
-
-            labelFill.SubviewsLaidOut += (s, e) =>
-                                        {
-                                            var fillText = new StringBuilder ();
-
-                                            for (var i = 0; i < labelFill.Viewport.Height; i++)
-                                            {
-                                                if (i > 0)
-                                                {
-                                                    fillText.AppendLine ("");
-                                                }
-
-                                                for (var j = 0; j < labelFill.Viewport.Width; j++)
-                                                {
-                                                    fillText.Append (fill);
-                                                }
-                                            }
-
-                                            labelFill.Text = fillText.ToString ();
-                                        };
-
-            labelText = new () { X = Pos.Center (), Y = Pos.Center (), Text = text };
-            Add (labelFill, labelText);
-            CanFocus = true;
-        }
-
-        protected override void OnHasFocusChanged (bool newHasFocus, [CanBeNull] View previousFocusedView, [CanBeNull] View focusedView)
-        {
-            if (newHasFocus)
-            {
-                Border.LineStyle = LineStyle.None;
-                Border.Thickness = new (0);
-                labelFill.Visible = true;
-            }
-            else
-            {
-                Border.LineStyle = LineStyle.Single;
-                Border.Thickness = new (1);
-                labelFill.Visible = false;
-            }
-        }
-    }
-#endif 
-}

+ 0 - 55
UnitTests/Views/ToplevelTests.cs

@@ -720,61 +720,6 @@ public partial class ToplevelTests (ITestOutputHelper output)
         top.Dispose ();
     }
 
-    [Fact]
-    [AutoInitShutdown]
-    public void Toplevel_Inside_ScrollView_MouseGrabView ()
-    {
-        var scrollView = new ScrollView
-        {
-            X = 3,
-            Y = 3,
-            Width = 40,
-            Height = 16
-        };
-        scrollView.SetContentSize (new (200, 100));
-        var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), Arrangement = ViewArrangement.Movable };
-        scrollView.Add (win);
-        Toplevel top = new ();
-        top.Add (scrollView);
-        Application.Begin (top);
-
-        Assert.Equal (new (0, 0, 80, 25), top.Frame);
-        Assert.Equal (new (3, 3, 40, 16), scrollView.Frame);
-        Assert.Equal (new (0, 0, 200, 100), scrollView.Subviews [0].Frame);
-        Assert.Equal (new (3, 3, 194, 94), win.Frame);
-
-        Application.RaiseMouseEvent (new () { ScreenPosition = new (6, 6), Flags = MouseFlags.Button1Pressed });
-        Assert.Equal (win.Border, Application.MouseGrabView);
-        Assert.Equal (new (3, 3, 194, 94), win.Frame);
-
-        Application.RaiseMouseEvent (new () { ScreenPosition = new (9, 9), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
-        Assert.Equal (win.Border, Application.MouseGrabView);
-        top.SetNeedsLayout ();
-        top.LayoutSubviews ();
-        Assert.Equal (new (6, 6, 191, 91), win.Frame);
-        Application.LayoutAndDraw ();
-
-        Application.RaiseMouseEvent (
-                                  new ()
-                                  {
-                                      ScreenPosition = new (5, 5), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
-                                  });
-        Assert.Equal (win.Border, Application.MouseGrabView);
-        top.SetNeedsLayout ();
-        top.LayoutSubviews ();
-        Assert.Equal (new (2, 2, 195, 95), win.Frame);
-        Application.LayoutAndDraw ();
-
-        Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 5), Flags = MouseFlags.Button1Released });
-
-        // ScrollView always grab the mouse when the container's subview OnMouseEnter don't want grab the mouse
-        Assert.Equal (scrollView, Application.MouseGrabView);
-
-        Application.RaiseMouseEvent (new () { ScreenPosition = new (4, 4), Flags = MouseFlags.ReportMousePosition });
-        Assert.Equal (scrollView, Application.MouseGrabView);
-        top.Dispose ();
-    }
-
     [Fact]
     [AutoInitShutdown]
     public void Window_Viewport_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom ()