Procházet zdrojové kódy

Merged (Rebased) continous button PR

Tig před 1 rokem
rodič
revize
ba429cffc2

+ 28 - 7
Terminal.Gui/Application.cs

@@ -99,7 +99,7 @@ public static partial class Application
         // Don't dispose the Top. It's up to caller dispose it
         // Don't dispose the Top. It's up to caller dispose it
         if (Top is { })
         if (Top is { })
         {
         {
-            
+
             Debug.Assert (Top.WasDisposed);
             Debug.Assert (Top.WasDisposed);
 
 
             // If End wasn't called _cachedRunStateToplevel may be null
             // If End wasn't called _cachedRunStateToplevel may be null
@@ -642,7 +642,7 @@ public static partial class Application
     public static void Run (Toplevel view, Func<Exception, bool> errorHandler = null, ConsoleDriver driver = null)
     public static void Run (Toplevel view, Func<Exception, bool> errorHandler = null, ConsoleDriver driver = null)
     {
     {
         ArgumentNullException.ThrowIfNull (view);
         ArgumentNullException.ThrowIfNull (view);
-        
+
         if (_initialized)
         if (_initialized)
         {
         {
             if (Driver is null)
             if (Driver is null)
@@ -1482,7 +1482,7 @@ public static partial class Application
             {
             {
                 X = frameLoc.X,
                 X = frameLoc.X,
                 Y = frameLoc.Y,
                 Y = frameLoc.Y,
-                Flags = a.MouseEvent.Flags,
+                Flags = mouseEvent.Flags,
                 ScreenPosition = new (mouseEvent.X, mouseEvent.Y),
                 ScreenPosition = new (mouseEvent.X, mouseEvent.Y),
                 View = MouseGrabView
                 View = MouseGrabView
             };
             };
@@ -1550,7 +1550,7 @@ public static partial class Application
                 View = view
                 View = view
             };
             };
         }
         }
-        else if (view.ViewportToScreen (Rectangle.Empty with {Size = view.Viewport.Size}).Contains (mouseEvent.X, mouseEvent.Y))
+        else if (view.ViewportToScreen (Rectangle.Empty with { Size = view.Viewport.Size }).Contains (mouseEvent.X, mouseEvent.Y))
         {
         {
             Point viewportLocation = view.ScreenToViewport (mouseEvent.X, mouseEvent.Y);
             Point viewportLocation = view.ScreenToViewport (mouseEvent.X, mouseEvent.Y);
 
 
@@ -1590,16 +1590,37 @@ public static partial class Application
 
 
         //Debug.WriteLine ($"OnMouseEvent: ({a.MouseEvent.X},{a.MouseEvent.Y}) - {a.MouseEvent.Flags}");
         //Debug.WriteLine ($"OnMouseEvent: ({a.MouseEvent.X},{a.MouseEvent.Y}) - {a.MouseEvent.Flags}");
 
 
-        while (view is {} && !view.NewMouseEvent (me) == false)
+        while (view.NewMouseEvent (me) != true)
         {
         {
-            if (view is Adornment ad)
+            if (MouseGrabView is { })
+            {
+                break;
+            }
+
+            if (view is Adornment adornmentView)
             {
             {
-                view = ad.Parent.SuperView;
+                view = adornmentView.Parent.SuperView;
             }
             }
             else
             else
             {
             {
                 view = view.SuperView;
                 view = view.SuperView;
             }
             }
+
+            if (view is null)
+            {
+                break;
+            }
+
+            Point boundsPoint = view.ScreenToViewport (mouseEvent.X, mouseEvent.Y);
+
+            me = new ()
+            {
+                X = boundsPoint.X,
+                Y = boundsPoint.Y,
+                Flags = mouseEvent.Flags,
+                ScreenPosition = new (mouseEvent.X, mouseEvent.Y),
+                View = view
+            };
         }
         }
 
 
         BringOverlappedTopToFront ();
         BringOverlappedTopToFront ();

+ 1 - 1
Terminal.Gui/Input/Mouse.cs

@@ -138,7 +138,7 @@ public class MouseEvent
     ///         mouse has moved.
     ///         mouse has moved.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         Calculated and processed in <see cref="Application.OnMouseEvent(MouseEventEventArgs)"/>.
+    ///         Calculated and processed in <see cref="Application.OnMouseEvent(MouseEvent)"/>.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     public Point ScreenPosition { get; set; }
     public Point ScreenPosition { get; set; }

+ 0 - 101
Terminal.Gui/View/Adornment/Adornment.cs

@@ -232,107 +232,6 @@ public class Adornment : View
         return base.OnMouseEnter (mouseEvent);
         return base.OnMouseEnter (mouseEvent);
     }
     }
 
 
-    /// <summary>Called when a mouse event occurs within the Adornment.</summary>
-    /// <remarks>
-    ///     <para>
-    ///         The coordinates are relative to <see cref="View.Viewport"/>.
-    ///     </para>
-    ///     <para>
-    ///         A mouse click on the Adornment will cause the Parent to focus.
-    ///     </para>
-    ///     <para>
-    ///         A mouse drag on the Adornment will cause the Parent to move.
-    ///     </para>
-    /// </remarks>
-    /// <param name="mouseEvent"></param>
-    /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
-    protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
-    {
-        if (Parent is null)
-        {
-            return false;
-        }
-
-        var args = new MouseEventEventArgs (mouseEvent);
-
-        if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked))
-        {
-            if (Parent.CanFocus && !Parent.HasFocus)
-            {
-                Parent.SetFocus ();
-                Parent.SetNeedsDisplay ();
-            }
-
-            return OnMouseClick (args);
-        }
-
-        if (!Parent.CanFocus || !Parent.Arrangement.HasFlag (ViewArrangement.Movable))
-        {
-            return false;
-        }
-
-        // BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/3312
-        if (!_dragPosition.HasValue && mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
-        {
-            Parent.SetFocus ();
-            Application.BringOverlappedTopToFront ();
-
-            // Only start grabbing if the user clicks in the Thickness area
-            // Adornment.Contains takes Parent SuperView=relative coords.
-            if (Contains (mouseEvent.X + Parent.Frame.X + Frame.X, mouseEvent.Y+ Parent.Frame.Y + Frame.Y))
-            {
-                // Set the start grab point to the Frame coords
-                _startGrabPoint = new (mouseEvent.X + Frame.X, mouseEvent.Y + Frame.Y);
-                _dragPosition = new (mouseEvent.X, mouseEvent.Y);
-                Application.GrabMouse (this);
-            }
-
-            return mouseEvent.Handled = true;
-        }
-
-        if (mouseEvent.Flags is (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition))
-        {
-            if (Application.MouseGrabView == this && _dragPosition.HasValue)
-            {
-                if (Parent.SuperView is null)
-                {
-                    // Redraw the entire app window.
-                    Application.Top.SetNeedsDisplay ();
-                }
-                else
-                {
-                    Parent.SuperView.SetNeedsDisplay ();
-                }
-
-                _dragPosition = new Point (mouseEvent.X, mouseEvent.Y);
-
-                Point parentLoc = Parent.SuperView?.ScreenToViewport (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y) ?? mouseEvent.ScreenPosition;
-
-                GetLocationEnsuringFullVisibility (
-                                     Parent,
-                                     parentLoc.X - _startGrabPoint.X,
-                                     parentLoc.Y - _startGrabPoint.Y,
-                                     out int nx,
-                                     out int ny,
-                                     out _
-                                    );
-
-                Parent.X = nx;
-                Parent.Y = ny;
-
-                return mouseEvent.Handled = true;
-            }
-        }
-
-        if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Released) && _dragPosition.HasValue)
-        {
-            _dragPosition = null;
-            Application.UngrabMouse ();
-        }
-
-        return false;
-    }
-
     /// <inheritdoc/>
     /// <inheritdoc/>
     protected internal override bool OnMouseLeave (MouseEvent mouseEvent)
     protected internal override bool OnMouseLeave (MouseEvent mouseEvent)
     {
     {

+ 1 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -264,7 +264,7 @@ public class Border : Adornment
 
 
                 _dragPosition = new Point (mouseEvent.X, mouseEvent.Y);
                 _dragPosition = new Point (mouseEvent.X, mouseEvent.Y);
 
 
-                Point parentLoc = Parent.SuperView?.ScreenToBounds (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y) ?? mouseEvent.ScreenPosition;
+                Point parentLoc = Parent.SuperView?.ScreenToViewport (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y) ?? mouseEvent.ScreenPosition;
 
 
                 GetLocationEnsuringFullVisibility (
                 GetLocationEnsuringFullVisibility (
                                      Parent,
                                      Parent,

+ 136 - 202
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -1,4 +1,5 @@
 using System.Diagnostics;
 using System.Diagnostics;
+using System.IO.Compression;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
@@ -42,10 +43,10 @@ public partial class View
     /// <summary>Gets or sets the absolute location and dimension of the view.</summary>
     /// <summary>Gets or sets the absolute location and dimension of the view.</summary>
     /// <value>
     /// <value>
     ///     The rectangle describing absolute location and dimension of the view, in coordinates relative to the
     ///     The rectangle describing absolute location and dimension of the view, in coordinates relative to the
-    ///     <see cref="SuperView"/>'s <see cref="Bounds"/>.
+    ///     <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
     /// </value>
     /// </value>
     /// <remarks>
     /// <remarks>
-    ///     <para>Frame is relative to the <see cref="SuperView"/>'s <see cref="Bounds"/>.</para>
+    ///     <para>Frame is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.</para>
     ///     <para>
     ///     <para>
     ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to the
     ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to the
     ///         values of the corresponding properties of the <paramref name="value"/> parameter.
     ///         values of the corresponding properties of the <paramref name="value"/> parameter.
@@ -63,6 +64,11 @@ public partial class View
         get => _frame;
         get => _frame;
         set
         set
         {
         {
+            if (_frame == value)
+            {
+                return;
+            }
+
             _frame = value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) };
             _frame = value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) };
 
 
             // If Frame gets set, by definition, the View is now LayoutStyle.Absolute, so
             // If Frame gets set, by definition, the View is now LayoutStyle.Absolute, so
@@ -73,12 +79,9 @@ public partial class View
             _height = _frame.Height;
             _height = _frame.Height;
 
 
             // TODO: Figure out if the below can be optimized.
             // TODO: Figure out if the below can be optimized.
-            if (IsInitialized /*|| LayoutStyle == LayoutStyle.Absolute*/)
+            if (IsInitialized)
             {
             {
-                LayoutAdornments ();
-                SetTextFormatterSize ();
-                SetNeedsLayout ();
-                SetNeedsDisplay ();
+                OnResizeNeeded ();
             }
             }
         }
         }
     }
     }
@@ -101,34 +104,36 @@ public partial class View
                 return ret;
                 return ret;
             }
             }
 
 
-            Point boundsOffset = super.GetBoundsOffset ();
-            boundsOffset.Offset(super.Frame.X, super.Frame.Y);
-            ret.X += boundsOffset.X;
-            ret.Y += boundsOffset.Y;
+            Point viewportOffset = super.GetViewportOffsetFromFrame ();
+            viewportOffset.Offset (super.Frame.X - super.Viewport.X, super.Frame.Y - super.Viewport.Y);
+            ret.X += viewportOffset.X;
+            ret.Y += viewportOffset.Y;
             super = super.SuperView;
             super = super.SuperView;
         }
         }
-
         return ret;
         return ret;
     }
     }
 
 
     /// <summary>
     /// <summary>
     ///     Converts a screen-relative coordinate to a Frame-relative coordinate. Frame-relative means relative to the
     ///     Converts a screen-relative coordinate to a Frame-relative coordinate. Frame-relative means relative to the
-    ///     View's <see cref="SuperView"/>'s <see cref="Bounds"/>.
+    ///     View's <see cref="SuperView"/>'s <see cref="Viewport"/>.
     /// </summary>
     /// </summary>
-    /// <returns>The coordinate relative to the <see cref="SuperView"/>'s <see cref="Bounds"/>.</returns>
+    /// <returns>The coordinate relative to the <see cref="SuperView"/>'s <see cref="Viewport"/>.</returns>
     /// <param name="x">Screen-relative column.</param>
     /// <param name="x">Screen-relative column.</param>
     /// <param name="y">Screen-relative row.</param>
     /// <param name="y">Screen-relative row.</param>
     public virtual Point ScreenToFrame (int x, int y)
     public virtual Point ScreenToFrame (int x, int y)
     {
     {
-        Point superViewBoundsOffset = SuperView?.GetBoundsOffset () ?? Point.Empty;
+        Point superViewViewportOffset = SuperView?.GetViewportOffsetFromFrame () ?? Point.Empty;
+
         if (SuperView is null)
         if (SuperView is null)
         {
         {
-            superViewBoundsOffset.Offset (x - Frame.X, y - Frame.Y);
-            return superViewBoundsOffset;
-        }
+            superViewViewportOffset.Offset (x - Frame.X, y - Frame.Y);
 
 
-        var frame = SuperView.ScreenToFrame (x - superViewBoundsOffset.X, y - superViewBoundsOffset.Y);
+            return superViewViewportOffset;
+        }
+        superViewViewportOffset.Offset (-SuperView.Viewport.X, -SuperView.Viewport.Y);
+        Point frame = SuperView.ScreenToFrame (x - superViewViewportOffset.X, y - superViewViewportOffset.Y);
         frame.Offset (-Frame.X, -Frame.Y);
         frame.Offset (-Frame.X, -Frame.Y);
+
         return frame;
         return frame;
     }
     }
 
 
@@ -138,13 +143,16 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
+    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///     </para>
+    ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
-    ///         initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Rectangle)"/> has been
+    ///         initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Size)"/> has been
     ///         called.
     ///         called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will eventually (when the view is next drawn) cause the
     ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="LayoutSubview(View, Rectangle)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
@@ -157,7 +165,13 @@ public partial class View
         get => VerifyIsInitialized (_x, nameof (X));
         get => VerifyIsInitialized (_x, nameof (X));
         set
         set
         {
         {
+            if (Equals (_x, value))
+            {
+                return;
+            }
+
             _x = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (X)} cannot be null");
             _x = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (X)} cannot be null");
+
             OnResizeNeeded ();
             OnResizeNeeded ();
         }
         }
     }
     }
@@ -168,13 +182,16 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
+    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///     </para>
+    ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
-    ///         initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Rectangle)"/> has been
+    ///         initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Size)"/> has been
     ///         called.
     ///         called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will eventually (when the view is next drawn) cause the
     ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="LayoutSubview(View, Rectangle)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
@@ -187,6 +204,11 @@ public partial class View
         get => VerifyIsInitialized (_y, nameof (Y));
         get => VerifyIsInitialized (_y, nameof (Y));
         set
         set
         {
         {
+            if (Equals (_y, value))
+            {
+                return;
+            }
+
             _y = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Y)} cannot be null");
             _y = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Y)} cannot be null");
             OnResizeNeeded ();
             OnResizeNeeded ();
         }
         }
@@ -198,13 +220,16 @@ public partial class View
     /// <value>The <see cref="Dim"/> object representing the height of the view (the number of rows).</value>
     /// <value>The <see cref="Dim"/> object representing the height of the view (the number of rows).</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
+    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///     </para>
+    ///     <para>
     ///         If set to a relative value (e.g. <see cref="Dim.Fill(int)"/>) the value is indeterminate until the view has
     ///         If set to a relative value (e.g. <see cref="Dim.Fill(int)"/>) the value is indeterminate until the view has
-    ///         been initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Rectangle)"/> has been
+    ///         been initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Size)"/> has been
     ///         called.
     ///         called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will eventually (when the view is next drawn) cause the
     ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="LayoutSubview(View, Rectangle)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
@@ -217,6 +242,11 @@ public partial class View
         get => VerifyIsInitialized (_height, nameof (Height));
         get => VerifyIsInitialized (_height, nameof (Height));
         set
         set
         {
         {
+            if (Equals (_height, value))
+            {
+                return;
+            }
+
             _height = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Height)} cannot be null");
             _height = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Height)} cannot be null");
 
 
             if (AutoSize)
             if (AutoSize)
@@ -245,13 +275,16 @@ public partial class View
     /// <value>The <see cref="Dim"/> object representing the width of the view (the number of columns).</value>
     /// <value>The <see cref="Dim"/> object representing the width of the view (the number of columns).</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
+    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///     </para>
+    ///     <para>
     ///         If set to a relative value (e.g. <see cref="Dim.Fill(int)"/>) the value is indeterminate until the view has
     ///         If set to a relative value (e.g. <see cref="Dim.Fill(int)"/>) the value is indeterminate until the view has
-    ///         been initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Rectangle)"/> has been
+    ///         been initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout(Size)"/> has been
     ///         called.
     ///         called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will eventually (when the view is next drawn) cause the
     ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="LayoutSubview(View, Rectangle)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
@@ -264,6 +297,11 @@ public partial class View
         get => VerifyIsInitialized (_width, nameof (Width));
         get => VerifyIsInitialized (_width, nameof (Width));
         set
         set
         {
         {
+            if (Equals (_width, value))
+            {
+                return;
+            }
+
             _width = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Width)} cannot be null");
             _width = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Width)} cannot be null");
 
 
             if (AutoSize)
             if (AutoSize)
@@ -284,123 +322,13 @@ public partial class View
 
 
     #endregion Frame
     #endregion Frame
 
 
-    #region Bounds
-
-    /// <summary>
-    ///     The bounds represent the View-relative rectangle used for this view; the area inside the view where
-    ///     subviews and content are presented.
-    /// </summary>
-    /// <value>The rectangle describing the location and size of the area where the views' subviews and content are drawn.</value>
-    /// <remarks>
-    ///     <para>
-    ///         If <see cref="LayoutStyle"/> is <see cref="LayoutStyle.Computed"/> the value of Bounds is indeterminate until
-    ///         the view has been initialized ( <see cref="IsInitialized"/> is true) and <see cref="LayoutSubviews"/> has been
-    ///         called.
-    ///     </para>
-    ///     <para>
-    ///         Updates to the Bounds updates <see cref="Frame"/>, and has the same effect as updating the
-    ///         <see cref="Frame"/>.
-    ///     </para>
-    ///     <para>
-    ///         Altering the Bounds will eventually (when the view is next laid out) cause the
-    ///         <see cref="LayoutSubview(View, Rectangle)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
-    ///     </para>
-    ///     <para>
-    ///         Because <see cref="Bounds"/> coordinates are relative to the upper-left corner of the <see cref="View"/>, the
-    ///         coordinates of the upper-left corner of the rectangle returned by this property are (0,0). Use this property to
-    ///         obtain the size of the area of the view for tasks such as drawing the view's contents.
-    ///     </para>
-    /// </remarks>
-    public virtual Rectangle Bounds
-    {
-        get
-        {
-#if DEBUG
-            if (LayoutStyle == LayoutStyle.Computed && !IsInitialized)
-            {
-                Debug.WriteLine (
-                                 $"WARNING: Bounds is being accessed before the View has been initialized. This is likely a bug in {this}"
-                                );
-            }
-#endif // DEBUG
-
-            if (Margin is null || Border is null || Padding is null)
-            {
-                // CreateAdornments has not been called yet.
-                return Rectangle.Empty with { Size = Frame.Size };
-            }
-
-            Thickness totalThickness = GetAdornmentsThickness ();
-
-            return Rectangle.Empty with
-            {
-                Size = new (
-                            Math.Max (0, Frame.Size.Width - totalThickness.Horizontal),
-                            Math.Max (0, Frame.Size.Height - totalThickness.Vertical))
-            };
-        }
-        set
-        {
-            // TODO: Should we enforce Bounds.X/Y == 0? The code currently ignores value.X/Y which is
-            // TODO: correct behavior, but is silent. Perhaps an exception?
-#if DEBUG
-            if (value.Location != Point.Empty)
-            {
-                Debug.WriteLine (
-                                 $"WARNING: Bounds.Location must always be 0,0. Location ({value.Location}) is ignored. {this}"
-                                );
-            }
-#endif // DEBUG
-            Thickness totalThickness = GetAdornmentsThickness ();
-
-            Frame = Frame with
-            {
-                Size = new (
-                            value.Size.Width + totalThickness.Horizontal,
-                            value.Size.Height + totalThickness.Vertical)
-            };
-        }
-    }
-
-    /// <summary>Converts a <see cref="Bounds"/>-relative rectangle to a screen-relative rectangle.</summary>
-    public Rectangle BoundsToScreen (in Rectangle bounds)
-    {
-        // Translate bounds to Frame (our SuperView's Bounds-relative coordinates)
-        Rectangle screen = FrameToScreen ();
-        Point boundsOffset = GetBoundsOffset ();
-        screen.Offset (boundsOffset.X + bounds.X, boundsOffset.Y + bounds.Y);
-
-        return new (screen.Location, bounds.Size);
-    }
-
-    /// <summary>Converts a screen-relative coordinate to a bounds-relative coordinate.</summary>
-    /// <returns>The coordinate relative to this view's <see cref="Bounds"/>.</returns>
-    /// <param name="x">Screen-relative column.</param>
-    /// <param name="y">Screen-relative row.</param>
-    public Point ScreenToBounds (int x, int y)
-    {
-        Point boundsOffset = GetBoundsOffset ();
-        Point screen = ScreenToFrame (x, y);
-        screen.Offset (-boundsOffset.X, -boundsOffset.Y);
-
-        return screen;
-    }
-
-    /// <summary>
-    ///     Helper to get the X and Y offset of the Bounds from the Frame. This is the sum of the Left and Top properties
-    ///     of <see cref="Margin"/>, <see cref="Border"/> and <see cref="Padding"/>.
-    /// </summary>
-    public Point GetBoundsOffset () { return Padding is null ? Point.Empty : Padding.Thickness.GetInside (Padding.Frame).Location; }
-
-    #endregion Bounds
-
     #region AutoSize
     #region AutoSize
 
 
     private bool _autoSize;
     private bool _autoSize;
 
 
     /// <summary>
     /// <summary>
     ///     Gets or sets a flag that determines whether the View will be automatically resized to fit the <see cref="Text"/>
     ///     Gets or sets a flag that determines whether the View will be automatically resized to fit the <see cref="Text"/>
-    ///     within <see cref="Bounds"/>.
+    ///     within <see cref="Viewport"/>.
     ///     <para>
     ///     <para>
     ///         The default is <see langword="false"/>. Set to <see langword="true"/> to turn on AutoSize. If
     ///         The default is <see langword="false"/>. Set to <see langword="true"/> to turn on AutoSize. If
     ///         <see langword="true"/> then <see cref="Width"/> and <see cref="Height"/> will be used if <see cref="Text"/> can
     ///         <see langword="true"/> then <see cref="Width"/> and <see cref="Height"/> will be used if <see cref="Text"/> can
@@ -573,7 +501,7 @@ public partial class View
     /// <summary>Resizes the View to fit the specified size. Factors in the HotKey.</summary>
     /// <summary>Resizes the View to fit the specified size. Factors in the HotKey.</summary>
     /// <remarks>ResizeBoundsToFit can only be called when AutoSize is true (or being set to true).</remarks>
     /// <remarks>ResizeBoundsToFit can only be called when AutoSize is true (or being set to true).</remarks>
     /// <param name="size"></param>
     /// <param name="size"></param>
-    /// <returns>whether the Bounds was changed or not</returns>
+    /// <returns>whether the Viewport was changed or not</returns>
     private bool ResizeBoundsToFit (Size size)
     private bool ResizeBoundsToFit (Size size)
     {
     {
         //if (AutoSize == false) {
         //if (AutoSize == false) {
@@ -598,7 +526,7 @@ public partial class View
 
 
         if (boundsChanged)
         if (boundsChanged)
         {
         {
-            Bounds = new (Bounds.X, Bounds.Y, canSizeW ? rW : Bounds.Width, canSizeH ? rH : Bounds.Height);
+            Viewport = new (Viewport.X, Viewport.Y, canSizeW ? rW : Viewport.Width, canSizeH ? rH : Viewport.Height);
         }
         }
 
 
         return boundsChanged;
         return boundsChanged;
@@ -647,25 +575,20 @@ public partial class View
 
 
     #endregion Layout Engine
     #endregion Layout Engine
 
 
-    internal bool LayoutNeeded { get; private set; } = true;
-
     /// <summary>
     /// <summary>
-    /// Indicates whether the specified SuperView-relative coordinates are within the View's <see cref="Frame"/>.
+    ///     Indicates whether the specified SuperView-relative coordinates are within the View's <see cref="Frame"/>.
     /// </summary>
     /// </summary>
     /// <param name="x">SuperView-relative X coordinate.</param>
     /// <param name="x">SuperView-relative X coordinate.</param>
     /// <param name="y">SuperView-relative Y coordinate.</param>
     /// <param name="y">SuperView-relative Y coordinate.</param>
     /// <returns><see langword="true"/> if the specified SuperView-relative coordinates are within the View.</returns>
     /// <returns><see langword="true"/> if the specified SuperView-relative coordinates are within the View.</returns>
-    public virtual bool Contains (int x, int y)
-    {
-        return Frame.Contains (x, y);
-    }
+    public virtual bool Contains (int x, int y) { return Frame.Contains (x, y); }
 
 
 #nullable enable
 #nullable enable
     /// <summary>Finds the first Subview of <paramref name="start"/> that is visible at the provided location.</summary>
     /// <summary>Finds the first Subview of <paramref name="start"/> that is visible at the provided location.</summary>
     /// <remarks>
     /// <remarks>
-    /// <para>
-    ///     Used to determine what view the mouse is over.
-    /// </para>
+    ///     <para>
+    ///         Used to determine what view the mouse is over.
+    ///     </para>
     /// </remarks>
     /// </remarks>
     /// <param name="start">The view to scope the search by.</param>
     /// <param name="start">The view to scope the search by.</param>
     /// <param name="x"><paramref name="start"/>.SuperView-relative X coordinate.</param>
     /// <param name="x"><paramref name="start"/>.SuperView-relative X coordinate.</param>
@@ -698,27 +621,27 @@ public partial class View
             found = start.Padding;
             found = start.Padding;
         }
         }
 
 
-        Point boundsOffset = start.GetBoundsOffset ();
+        Point viewportOffset = start.GetViewportOffsetFromFrame ();
 
 
         if (found is { })
         if (found is { })
         {
         {
             start = found;
             start = found;
-            boundsOffset = found.Parent.Frame.Location;
+            viewportOffset = found.Parent.Frame.Location;
         }
         }
 
 
         if (start.InternalSubviews is { Count: > 0 })
         if (start.InternalSubviews is { Count: > 0 })
         {
         {
-            int startOffsetX = x - (start.Frame.X + boundsOffset.X);
-            int startOffsetY = y - (start.Frame.Y + boundsOffset.Y);
+            int startOffsetX = x - (start.Frame.X + viewportOffset.X);
+            int startOffsetY = y - (start.Frame.Y + viewportOffset.Y);
 
 
             for (int i = start.InternalSubviews.Count - 1; i >= 0; i--)
             for (int i = start.InternalSubviews.Count - 1; i >= 0; i--)
             {
             {
                 View nextStart = start.InternalSubviews [i];
                 View nextStart = start.InternalSubviews [i];
 
 
-                if (nextStart.Visible && nextStart.Contains (startOffsetX, startOffsetY))
+                if (nextStart.Visible && nextStart.Contains (startOffsetX + start.Viewport.X, startOffsetY + start.Viewport.Y))
                 {
                 {
                     // TODO: Remove recursion
                     // TODO: Remove recursion
-                    return FindDeepestView (nextStart, startOffsetX, startOffsetY) ?? nextStart;
+                    return FindDeepestView (nextStart, startOffsetX + start.Viewport.X, startOffsetY + start.Viewport.Y) ?? nextStart;
                 }
                 }
             }
             }
         }
         }
@@ -728,7 +651,7 @@ public partial class View
 #nullable restore
 #nullable restore
 
 
     /// <summary>
     /// <summary>
-    ///     Gets a new location of the <see cref="View"/> that is within the Bounds of the <paramref name="viewToMove"/>'s
+    ///     Gets a new location of the <see cref="View"/> that is within the Viewport of the <paramref name="viewToMove"/>'s
     ///     <see cref="View.SuperView"/> (e.g. for dragging a Window). The `out` parameters are the new X and Y coordinates.
     ///     <see cref="View.SuperView"/> (e.g. for dragging a Window). The `out` parameters are the new X and Y coordinates.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
@@ -757,6 +680,7 @@ public partial class View
     {
     {
         int maxDimension;
         int maxDimension;
         View superView;
         View superView;
+        statusBar = null;
 
 
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
         {
         {
@@ -765,8 +689,8 @@ public partial class View
         }
         }
         else
         else
         {
         {
-            // Use the SuperView's Bounds, not Frame
-            maxDimension = viewToMove.SuperView.Bounds.Width;
+            // Use the SuperView's Viewport, not Frame
+            maxDimension = viewToMove.SuperView.Viewport.Width;
             superView = viewToMove.SuperView;
             superView = viewToMove.SuperView;
         }
         }
 
 
@@ -791,7 +715,8 @@ public partial class View
         }
         }
 
 
         //System.Diagnostics.Debug.WriteLine ($"nx:{nx}, rWidth:{rWidth}");
         //System.Diagnostics.Debug.WriteLine ($"nx:{nx}, rWidth:{rWidth}");
-        bool menuVisible, statusVisible;
+        bool menuVisible = false;
+        bool statusVisible = false;
 
 
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
         {
         {
@@ -801,12 +726,15 @@ public partial class View
         {
         {
             View t = viewToMove.SuperView;
             View t = viewToMove.SuperView;
 
 
-            while (t is not Toplevel)
+            while (t is { } and not Toplevel)
             {
             {
                 t = t.SuperView;
                 t = t.SuperView;
             }
             }
 
 
-            menuVisible = ((Toplevel)t).MenuBar?.Visible == true;
+            if (t is Toplevel toplevel)
+            {
+                menuVisible = toplevel.MenuBar?.Visible == true;
+            }
         }
         }
 
 
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
@@ -829,13 +757,16 @@ public partial class View
         {
         {
             View t = viewToMove.SuperView;
             View t = viewToMove.SuperView;
 
 
-            while (t is not Toplevel)
+            while (t is { } and not Toplevel)
             {
             {
                 t = t.SuperView;
                 t = t.SuperView;
             }
             }
 
 
-            statusVisible = ((Toplevel)t).StatusBar?.Visible == true;
-            statusBar = ((Toplevel)t).StatusBar;
+            if (t is Toplevel toplevel)
+            {
+                statusVisible = toplevel.StatusBar?.Visible == true;
+                statusBar = toplevel.StatusBar;
+            }
         }
         }
 
 
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
         if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
@@ -844,7 +775,7 @@ public partial class View
         }
         }
         else
         else
         {
         {
-            maxDimension = statusVisible ? viewToMove.SuperView.Frame.Height - 1 : viewToMove.SuperView.Frame.Height;
+            maxDimension = statusVisible ? viewToMove.SuperView.Viewport.Height - 1 : viewToMove.SuperView.Viewport.Height;
         }
         }
 
 
         if (superView.Margin is { } && superView == viewToMove.SuperView)
         if (superView.Margin is { } && superView == viewToMove.SuperView)
@@ -912,8 +843,8 @@ public partial class View
 
 
         LayoutAdornments ();
         LayoutAdornments ();
 
 
-        Rectangle oldBounds = Bounds;
-        OnLayoutStarted (new () { OldBounds = oldBounds });
+        Rectangle oldViewport = Viewport;
+        OnLayoutStarted (new () { OldViewport = oldViewport });
 
 
         SetTextFormatterSize ();
         SetTextFormatterSize ();
 
 
@@ -925,7 +856,7 @@ public partial class View
 
 
         foreach (View v in ordered)
         foreach (View v in ordered)
         {
         {
-            LayoutSubview (v, new (GetBoundsOffset (), Bounds.Size));
+            LayoutSubview (v, ContentSize);
         }
         }
 
 
         // If the 'to' is rooted to 'from' and the layoutstyle is Computed it's a special-case.
         // If the 'to' is rooted to 'from' and the layoutstyle is Computed it's a special-case.
@@ -934,13 +865,19 @@ public partial class View
         {
         {
             foreach ((View from, View to) in edges)
             foreach ((View from, View to) in edges)
             {
             {
-                LayoutSubview (to, from.Frame);
+                LayoutSubview (to, from.ContentSize);
             }
             }
         }
         }
 
 
         LayoutNeeded = false;
         LayoutNeeded = false;
 
 
-        OnLayoutComplete (new () { OldBounds = oldBounds });
+        OnLayoutComplete (new () { OldViewport = oldViewport });
+    }
+    private void LayoutSubview (View v, Size contentSize)
+    {
+        v.SetRelativeLayout (contentSize);
+        v.LayoutSubviews ();
+        v.LayoutNeeded = false;
     }
     }
 
 
     /// <summary>Indicates that the view does not need to be laid out.</summary>
     /// <summary>Indicates that the view does not need to be laid out.</summary>
@@ -972,12 +909,12 @@ public partial class View
     {
     {
         // TODO: Identify a real-world use-case where this API should be virtual. 
         // TODO: Identify a real-world use-case where this API should be virtual. 
         // TODO: Until then leave it `internal` and non-virtual
         // TODO: Until then leave it `internal` and non-virtual
-        // First try SuperView.Bounds, then Application.Top, then Driver.Bounds.
+        // First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
         // Finally, if none of those are valid, use int.MaxValue (for Unit tests).
         // Finally, if none of those are valid, use int.MaxValue (for Unit tests).
-        Rectangle relativeBounds = SuperView is { IsInitialized: true } ? SuperView.Bounds :
-                                   Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.Bounds :
-                                   Application.Driver?.Bounds ?? new Rectangle (0, 0, int.MaxValue, int.MaxValue);
-        SetRelativeLayout (relativeBounds);
+        Size contentSize = SuperView is { IsInitialized: true } ? SuperView.ContentSize :
+                           Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.ContentSize :
+                           Application.Driver?.Screen.Size ?? new (int.MaxValue, int.MaxValue);
+        SetRelativeLayout (contentSize);
 
 
         // TODO: Determine what, if any of the below is actually needed here.
         // TODO: Determine what, if any of the below is actually needed here.
         if (IsInitialized)
         if (IsInitialized)
@@ -993,6 +930,7 @@ public partial class View
             SetNeedsLayout ();
             SetNeedsLayout ();
         }
         }
     }
     }
+    internal bool LayoutNeeded { get; private set; } = true;
 
 
     /// <summary>
     /// <summary>
     ///     Sets the internal <see cref="LayoutNeeded"/> flag for this View and all of it's subviews and it's SuperView.
     ///     Sets the internal <see cref="LayoutNeeded"/> flag for this View and all of it's subviews and it's SuperView.
@@ -1017,15 +955,22 @@ public partial class View
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Applies the view's position (<see cref="X"/>, <see cref="Y"/>) and dimension (<see cref="Width"/>, and
-    ///     <see cref="Height"/>) to <see cref="Frame"/>, given a rectangle describing the SuperView's Bounds (nominally the
-    ///     same as <c>this.SuperView.Bounds</c>).
+    ///     Adjusts <see cref="Frame"/> given the SuperView's ContentSize (nominally the same as
+    ///     <c>this.SuperView.ContentSize</c>)
+    ///     and the position (<see cref="X"/>, <see cref="Y"/>) and dimension (<see cref="Width"/>, and
+    ///     <see cref="Height"/>).
     /// </summary>
     /// </summary>
-    /// <param name="superviewBounds">
-    ///     The rectangle describing the SuperView's Bounds (nominally the same as
-    ///     <c>this.SuperView.Bounds</c>).
+    /// <remarks>
+    /// <para>
+    /// If <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, or <see cref="Height"/> are
+    /// absolute, they will be updated to reflect the new size and position of the view. Otherwise, they
+    /// are left unchanged.
+    /// </para>
+    /// </remarks>
+    /// <param name="superviewContentSize">
+    ///     The size of the SuperView's content (nominally the same as <c>this.SuperView.ContentSize</c>).
     /// </param>
     /// </param>
-    internal void SetRelativeLayout (Rectangle superviewBounds)
+    internal void SetRelativeLayout (Size superviewContentSize)
     {
     {
         Debug.Assert (_x is { });
         Debug.Assert (_x is { });
         Debug.Assert (_y is { });
         Debug.Assert (_y is { });
@@ -1047,13 +992,13 @@ public partial class View
         // TODO: View.AutoSize stuff is removed.
         // TODO: View.AutoSize stuff is removed.
 
 
         // Returns the new dimension (width or height) and location (x or y) for the View given
         // Returns the new dimension (width or height) and location (x or y) for the View given
-        //   the superview's Bounds
+        //   the superview's Viewport
         //   the current Pos (View.X or View.Y)
         //   the current Pos (View.X or View.Y)
         //   the current Dim (View.Width or View.Height)
         //   the current Dim (View.Width or View.Height)
         // This method is called recursively if pos is Pos.PosCombine
         // This method is called recursively if pos is Pos.PosCombine
         (int newLocation, int newDimension) GetNewLocationAndDimension (
         (int newLocation, int newDimension) GetNewLocationAndDimension (
             bool width,
             bool width,
-            Rectangle superviewBounds,
+            Size superviewContentSize,
             Pos pos,
             Pos pos,
             Dim dim,
             Dim dim,
             int autosizeDimension
             int autosizeDimension
@@ -1115,7 +1060,7 @@ public partial class View
             }
             }
 
 
             int newDimension, newLocation;
             int newDimension, newLocation;
-            int superviewDimension = width ? superviewBounds.Width : superviewBounds.Height;
+            int superviewDimension = width ? superviewContentSize.Width : superviewContentSize.Height;
 
 
             // Determine new location
             // Determine new location
             switch (pos)
             switch (pos)
@@ -1139,7 +1084,7 @@ public partial class View
 
 
                     (left, newDimension) = GetNewLocationAndDimension (
                     (left, newDimension) = GetNewLocationAndDimension (
                                                                        width,
                                                                        width,
-                                                                       superviewBounds,
+                                                                       superviewContentSize,
                                                                        combine._left,
                                                                        combine._left,
                                                                        dim,
                                                                        dim,
                                                                        autosizeDimension
                                                                        autosizeDimension
@@ -1147,7 +1092,7 @@ public partial class View
 
 
                     (right, newDimension) = GetNewLocationAndDimension (
                     (right, newDimension) = GetNewLocationAndDimension (
                                                                         width,
                                                                         width,
-                                                                        superviewBounds,
+                                                                        superviewContentSize,
                                                                         combine._right,
                                                                         combine._right,
                                                                         dim,
                                                                         dim,
                                                                         autosizeDimension
                                                                         autosizeDimension
@@ -1189,10 +1134,10 @@ public partial class View
         }
         }
 
 
         // horizontal/width
         // horizontal/width
-        (newX, newW) = GetNewLocationAndDimension (true, superviewBounds, _x, _width, autosize.Width);
+        (newX, newW) = GetNewLocationAndDimension (true, superviewContentSize, _x, _width, autosize.Width);
 
 
         // vertical/height
         // vertical/height
-        (newY, newH) = GetNewLocationAndDimension (false, superviewBounds, _y, _height, autosize.Height);
+        (newY, newH) = GetNewLocationAndDimension (false, superviewContentSize, _y, _height, autosize.Height);
 
 
         Rectangle r = new (newX, newY, newW, newH);
         Rectangle r = new (newX, newY, newW, newH);
 
 
@@ -1413,17 +1358,6 @@ public partial class View
         return result;
         return result;
     } // TopologicalSort
     } // TopologicalSort
 
 
-    private void LayoutSubview (View v, Rectangle contentArea)
-    {
-        //if (v.LayoutStyle == LayoutStyle.Computed) {
-        v.SetRelativeLayout (contentArea);
-
-        //}
-
-        v.LayoutSubviews ();
-        v.LayoutNeeded = false;
-    }
-
     #region Diagnostics
     #region Diagnostics
 
 
     // Diagnostics to highlight when Width or Height is read before the view has been initialized
     // Diagnostics to highlight when Width or Height is read before the view has been initialized
@@ -1464,4 +1398,4 @@ public partial class View
     public bool ValidatePosDim { get; set; }
     public bool ValidatePosDim { get; set; }
 
 
     #endregion
     #endregion
-}
+}

+ 2 - 2
Terminal.Gui/View/ViewMouse.cs

@@ -172,7 +172,7 @@ public partial class View
             // If mouse is still in bounds, click
             // If mouse is still in bounds, click
             if (!WantContinuousButtonPressed && Viewport.Contains (mouseEvent.X, mouseEvent.Y))
             if (!WantContinuousButtonPressed && Viewport.Contains (mouseEvent.X, mouseEvent.Y))
             {
             {
-                return OnMouseClick (mouseEvent);
+                return OnMouseClick (new(mouseEvent));
             }
             }
 
 
             return mouseEvent.Handled = true;
             return mouseEvent.Handled = true;
@@ -194,7 +194,7 @@ public partial class View
                     SetFocus ();
                     SetFocus ();
                 }
                 }
 
 
-                args.Handled = true;
+                mouseEvent.Handled = true;
             }
             }
 
 
             if (Viewport.Contains (mouseEvent.X, mouseEvent.Y))
             if (Viewport.Contains (mouseEvent.X, mouseEvent.Y))

+ 1 - 1
UnitTests/Text/AutocompleteTests.cs

@@ -50,7 +50,7 @@ This a long line and against TextView.
         }
         }
 
 
         Assert.True (
         Assert.True (
-                     tv.OnMouseEvent (
+                     tv.NewMouseEvent (
                                     new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed }
                                     new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed }
                                    )
                                    )
                     );
                     );

+ 1 - 1
UnitTests/View/MouseTests.cs

@@ -529,7 +529,7 @@ public class MouseTests (ITestOutputHelper output)
         int disablingHighlight = 0;
         int disablingHighlight = 0;
         view.EnablingHighlight += View_EnablingHighlight;
         view.EnablingHighlight += View_EnablingHighlight;
         view.DisablingHighlight += View_DisablingHighlight;
         view.DisablingHighlight += View_DisablingHighlight;
-        bool inViewport = view.Bounds.Contains (x, 0);
+        bool inViewport = view.Viewport.Contains (x, 0);
 
 
         // Start at 0,0 ; in viewport
         // Start at 0,0 ; in viewport
         view.NewMouseEvent (new () { X = 0, Flags = MouseFlags.Button1Pressed });
         view.NewMouseEvent (new () { X = 0, Flags = MouseFlags.Button1Pressed });