Browse Source

WIP: Next set of View.App changes

Updated `SetClipToScreen`, `SetClip`, and `GetClip` methods to accept an `IDriver` parameter, replacing reliance on the global `Application.Driver`. This improves modularity, testability, and reduces implicit global state usage.

- Updated `Driver` property in `View` to use `App?.Driver` as fallback.
- Refactored `DimAuto` to use `App?.Screen.Size` with a default for unit tests.
- Updated all test cases to align with the new method signatures.
- Performed general cleanup for consistency and readability.
Tig 1 month ago
parent
commit
165c390777

+ 2 - 2
Terminal.Gui/App/ApplicationImpl.Screen.cs

@@ -168,9 +168,9 @@ public partial class ApplicationImpl
             Driver?.ClearContents ();
             Driver?.ClearContents ();
         }
         }
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Driver);
         View.Draw (tops, neededLayout || forceRedraw);
         View.Draw (tops, neededLayout || forceRedraw);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Driver);
         Driver?.Refresh ();
         Driver?.Refresh ();
     }
     }
 }
 }

+ 4 - 4
Terminal.Gui/ViewBase/Adornment/Margin.cs

@@ -58,7 +58,7 @@ public class Margin : Adornment
         if (Thickness != Thickness.Empty /*&& ShadowStyle != ShadowStyle.None*/)
         if (Thickness != Thickness.Empty /*&& ShadowStyle != ShadowStyle.None*/)
         {
         {
             // PERFORMANCE: How expensive are these clones?
             // PERFORMANCE: How expensive are these clones?
-            _cachedClip = GetClip ()?.Clone ();
+            _cachedClip = GetClip (Driver)?.Clone ();
         }
         }
     }
     }
 
 
@@ -80,10 +80,10 @@ public class Margin : Adornment
             if (view.Margin?.GetCachedClip () != null)
             if (view.Margin?.GetCachedClip () != null)
             {
             {
                 view.Margin!.NeedsDraw = true;
                 view.Margin!.NeedsDraw = true;
-                Region? saved = GetClip ();
-                View.SetClip (view.Margin!.GetCachedClip ());
+                Region? saved = GetClip (view.Driver);
+                View.SetClip (view.Driver, view.Margin!.GetCachedClip ());
                 view.Margin!.Draw ();
                 view.Margin!.Draw ();
-                View.SetClip (saved);
+                View.SetClip (view.Driver, saved);
                 view.Margin!.ClearCachedClip ();
                 view.Margin!.ClearCachedClip ();
             }
             }
 
 

+ 3 - 1
Terminal.Gui/ViewBase/Layout/DimAuto.cs

@@ -30,8 +30,10 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
         var textSize = 0;
         var textSize = 0;
         var maxCalculatedSize = 0;
         var maxCalculatedSize = 0;
 
 
+        // 2048 x 2048 supports unit testing where no App is running.
+        Size screenSize = us.App?.Screen.Size ?? new (2048, 2048);
         int autoMin = MinimumContentDim?.GetAnchor (superviewContentSize) ?? 0;
         int autoMin = MinimumContentDim?.GetAnchor (superviewContentSize) ?? 0;
-        int screenX4 = dimension == Dimension.Width ? Application.Screen.Width * 4 : Application.Screen.Height * 4;
+        int screenX4 = dimension == Dimension.Width ? screenSize.Width * 4 : screenSize.Height * 4;
         int autoMax = MaximumContentDim?.GetAnchor (superviewContentSize) ?? screenX4;
         int autoMax = MaximumContentDim?.GetAnchor (superviewContentSize) ?? screenX4;
 
 
         //Debug.WriteLineIf (autoMin > autoMax, "MinimumContentDim must be less than or equal to MaximumContentDim.");
         //Debug.WriteLineIf (autoMin > autoMax, "MinimumContentDim must be less than or equal to MaximumContentDim.");

+ 13 - 11
Terminal.Gui/ViewBase/View.Drawing.Clipping.cs

@@ -15,7 +15,7 @@ public partial class View
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     /// <returns>The current Clip.</returns>
     /// <returns>The current Clip.</returns>
-    public static Region? GetClip () { return Application.Driver?.Clip; }
+    public static Region? GetClip (IDriver? driver) => driver?.Clip;
 
 
     /// <summary>
     /// <summary>
     ///     Sets the Clip to the specified region.
     ///     Sets the Clip to the specified region.
@@ -26,18 +26,20 @@ public partial class View
     ///         region.
     ///         region.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
+    /// <param name="driver"></param>
     /// <param name="region"></param>
     /// <param name="region"></param>
-    public static void SetClip (Region? region)
+    public static void SetClip (IDriver? driver, Region? region)
     {
     {
-        if (Application.Driver is { } && region is { })
+        if (driver is { } && region is { })
         {
         {
-            Application.Driver.Clip = region;
+            driver.Clip = region;
         }
         }
     }
     }
 
 
     /// <summary>
     /// <summary>
     ///     Sets the Clip to be the rectangle of the screen.
     ///     Sets the Clip to be the rectangle of the screen.
     /// </summary>
     /// </summary>
+    /// <param name="driver"></param>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         There is a single clip region for the entire application. This method sets the clip region to the screen.
     ///         There is a single clip region for the entire application. This method sets the clip region to the screen.
@@ -50,13 +52,13 @@ public partial class View
     /// <returns>
     /// <returns>
     ///     The current Clip, which can be then re-applied <see cref="View.SetClip"/>
     ///     The current Clip, which can be then re-applied <see cref="View.SetClip"/>
     /// </returns>
     /// </returns>
-    public static Region? SetClipToScreen ()
+    public static Region? SetClipToScreen (IDriver? driver)
     {
     {
-        Region? previous = GetClip ();
+        Region? previous = GetClip (driver);
 
 
         if (Application.Driver is { })
         if (Application.Driver is { })
         {
         {
-            Application.Driver.Clip = new (Application.Screen);
+            Application.Driver.Clip = new (driver!.Screen);
         }
         }
 
 
         return previous;
         return previous;
@@ -103,7 +105,7 @@ public partial class View
             return null;
             return null;
         }
         }
 
 
-        Region previous = GetClip () ?? new (Application.Screen);
+        Region previous = GetClip (Driver) ?? new (Application.Screen);
 
 
         Region frameRegion = previous.Clone ();
         Region frameRegion = previous.Clone ();
 
 
@@ -117,7 +119,7 @@ public partial class View
             frameRegion.Exclude (adornment.Thickness.GetInside (FrameToScreen()));
             frameRegion.Exclude (adornment.Thickness.GetInside (FrameToScreen()));
         }
         }
 
 
-        SetClip (frameRegion);
+        SetClip (Driver, frameRegion);
 
 
         return previous;
         return previous;
     }
     }
@@ -150,7 +152,7 @@ public partial class View
             return null;
             return null;
         }
         }
 
 
-        Region previous = GetClip () ?? new (Application.Screen);
+        Region previous = GetClip (Driver) ?? new (Application.Screen);
 
 
         Region viewportRegion = previous.Clone ();
         Region viewportRegion = previous.Clone ();
 
 
@@ -170,7 +172,7 @@ public partial class View
             viewportRegion?.Exclude (adornment.Thickness.GetInside (viewport));
             viewportRegion?.Exclude (adornment.Thickness.GetInside (viewport));
         }
         }
 
 
-        SetClip (viewportRegion);
+        SetClip (Driver, viewportRegion);
 
 
         return previous;
         return previous;
     }
     }

+ 3 - 3
Terminal.Gui/ViewBase/View.Drawing.Primitives.cs

@@ -63,7 +63,7 @@ public partial class View
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         When the method returns, the draw position will be incremented by the number of columns
     ///         When the method returns, the draw position will be incremented by the number of columns
-    ///         <paramref name="str"/> required, unless the new column value is outside the <see cref="GetClip()"/> or <see cref="Application.Screen"/>.
+    ///         <paramref name="str"/> required, unless the new column value is outside the <see cref="GetClip"/> or <see cref="Application.Screen"/>.
     ///     </para>
     ///     </para>
     ///     <para>If <paramref name="str"/> requires more columns than are available, the output will be clipped.</para>
     ///     <para>If <paramref name="str"/> requires more columns than are available, the output will be clipped.</para>
     /// </remarks>
     /// </remarks>
@@ -142,7 +142,7 @@ public partial class View
         Attribute prev = SetAttribute (new (color ?? GetAttributeForRole (VisualRole.Normal).Background));
         Attribute prev = SetAttribute (new (color ?? GetAttributeForRole (VisualRole.Normal).Background));
         Driver.FillRect (toClear);
         Driver.FillRect (toClear);
         SetAttribute (prev);
         SetAttribute (prev);
-        SetClip (prevClip);
+        SetClip (Driver, prevClip);
     }
     }
 
 
     /// <summary>Fills the specified <see cref="Viewport"/>-relative rectangle.</summary>
     /// <summary>Fills the specified <see cref="Viewport"/>-relative rectangle.</summary>
@@ -158,7 +158,7 @@ public partial class View
         Region? prevClip = AddViewportToClip ();
         Region? prevClip = AddViewportToClip ();
         Rectangle toClear = ViewportToScreen (rect);
         Rectangle toClear = ViewportToScreen (rect);
         Driver.FillRect (toClear, rune);
         Driver.FillRect (toClear, rune);
-        SetClip (prevClip);
+        SetClip (Driver, prevClip);
     }
     }
 
 
 }
 }

+ 7 - 7
Terminal.Gui/ViewBase/View.Drawing.cs

@@ -51,7 +51,7 @@ public partial class View // Drawing APIs
         {
         {
             return;
             return;
         }
         }
-        Region? originalClip = GetClip ();
+        Region? originalClip = GetClip (Driver);
 
 
         // TODO: This can be further optimized by checking NeedsDraw below and only
         // TODO: This can be further optimized by checking NeedsDraw below and only
         // TODO: clearing, drawing text, drawing content, etc. if it is true.
         // TODO: clearing, drawing text, drawing content, etc. if it is true.
@@ -62,7 +62,7 @@ public partial class View // Drawing APIs
             // Note Margin with a Shadow is special-cased and drawn in a separate pass to support
             // Note Margin with a Shadow is special-cased and drawn in a separate pass to support
             // transparent shadows.
             // transparent shadows.
             DoDrawAdornments (originalClip);
             DoDrawAdornments (originalClip);
-            SetClip (originalClip);
+            SetClip (Driver, originalClip);
 
 
             // ------------------------------------
             // ------------------------------------
             // Clear the Viewport
             // Clear the Viewport
@@ -98,7 +98,7 @@ public partial class View // Drawing APIs
             // Draw the line canvas
             // Draw the line canvas
             // Restore the clip before rendering the line canvas and adornment subviews
             // Restore the clip before rendering the line canvas and adornment subviews
             // because they may draw outside the viewport.
             // because they may draw outside the viewport.
-            SetClip (originalClip);
+            SetClip (Driver, originalClip);
             originalClip = AddFrameToClip ();
             originalClip = AddFrameToClip ();
             DoRenderLineCanvas ();
             DoRenderLineCanvas ();
 
 
@@ -141,7 +141,7 @@ public partial class View // Drawing APIs
 
 
         // ------------------------------------
         // ------------------------------------
         // Reset the clip to what it was when we started
         // Reset the clip to what it was when we started
-        SetClip (originalClip);
+        SetClip (Driver, originalClip);
 
 
         // ------------------------------------
         // ------------------------------------
         // We're done drawing - The Clip is reset to what it was before we started.
         // We're done drawing - The Clip is reset to what it was before we started.
@@ -169,7 +169,7 @@ public partial class View // Drawing APIs
 
 
             Region? saved = Border?.AddFrameToClip ();
             Region? saved = Border?.AddFrameToClip ();
             Border?.DoDrawSubViews ();
             Border?.DoDrawSubViews ();
-            SetClip (saved);
+            SetClip (Driver, saved);
         }
         }
 
 
         if (Padding?.SubViews is { } && Padding.Thickness != Thickness.Empty)
         if (Padding?.SubViews is { } && Padding.Thickness != Thickness.Empty)
@@ -181,7 +181,7 @@ public partial class View // Drawing APIs
 
 
             Region? saved = Padding?.AddFrameToClip ();
             Region? saved = Padding?.AddFrameToClip ();
             Padding?.DoDrawSubViews ();
             Padding?.DoDrawSubViews ();
-            SetClip (saved);
+            SetClip (Driver, saved);
         }
         }
     }
     }
 
 
@@ -199,7 +199,7 @@ public partial class View // Drawing APIs
             clipAdornments?.Combine (Border!.Thickness.AsRegion (Border!.FrameToScreen ()), RegionOp.Union);
             clipAdornments?.Combine (Border!.Thickness.AsRegion (Border!.FrameToScreen ()), RegionOp.Union);
             clipAdornments?.Combine (Padding!.Thickness.AsRegion (Padding!.FrameToScreen ()), RegionOp.Union);
             clipAdornments?.Combine (Padding!.Thickness.AsRegion (Padding!.FrameToScreen ()), RegionOp.Union);
             clipAdornments?.Combine (originalClip, RegionOp.Intersect);
             clipAdornments?.Combine (originalClip, RegionOp.Intersect);
-            SetClip (clipAdornments);
+            SetClip (Driver, clipAdornments);
         }
         }
 
 
         if (Margin?.NeedsLayout == true)
         if (Margin?.NeedsLayout == true)

+ 12 - 10
Terminal.Gui/ViewBase/View.cs

@@ -51,7 +51,7 @@ public partial class View : IDisposable, ISupportInitializeNotification
 
 
     /// <summary>Pretty prints the View</summary>
     /// <summary>Pretty prints the View</summary>
     /// <returns></returns>
     /// <returns></returns>
-    public override string ToString () { return $"{GetType ().Name}({Id}){Frame}"; }
+    public override string ToString () => $"{GetType ().Name}({Id}){Frame}";
 
 
     /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
     /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
     /// <remarks>
     /// <remarks>
@@ -103,18 +103,16 @@ public partial class View : IDisposable, ISupportInitializeNotification
     /// <remarks>This property is not used internally.</remarks>
     /// <remarks>This property is not used internally.</remarks>
     public object? Data { get; set; }
     public object? Data { get; set; }
 
 
-
-
     /// <summary>Gets or sets an identifier for the view;</summary>
     /// <summary>Gets or sets an identifier for the view;</summary>
     /// <value>The identifier.</value>
     /// <value>The identifier.</value>
     /// <remarks>The id should be unique across all Views that share a SuperView.</remarks>
     /// <remarks>The id should be unique across all Views that share a SuperView.</remarks>
     public string Id { get; set; } = "";
     public string Id { get; set; } = "";
 
 
-
     private IApplication? _app;
     private IApplication? _app;
 
 
     /// <summary>
     /// <summary>
-    ///     Gets the <see cref="IApplication"/> instance this view is running in.
+    ///     Gets the <see cref="IApplication"/> instance this view is running in. If this view is at the top of the view
+    ///     hierarchy, returns <see langword="null"/>
     /// </summary>
     /// </summary>
     public IApplication? App
     public IApplication? App
     {
     {
@@ -123,9 +121,10 @@ public partial class View : IDisposable, ISupportInitializeNotification
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Gets the <see cref="IApplication"/> instance this view is running in. Used internally to allow overrides by <see cref="Adornment"/>.
+    ///     Gets the <see cref="IApplication"/> instance this view is running in. Used internally to allow overrides by
+    ///     <see cref="Adornment"/>.
     /// </summary>
     /// </summary>
-    /// <returns></returns>
+    /// <returns>If this view is at the top of the view hierarchy, returns <see langword="null"/>.</returns>
     protected virtual IApplication? GetApp () => _app ?? SuperView?.App;
     protected virtual IApplication? GetApp () => _app ?? SuperView?.App;
 
 
     private IDriver? _driver;
     private IDriver? _driver;
@@ -137,11 +136,14 @@ public partial class View : IDisposable, ISupportInitializeNotification
     /// </summary>
     /// </summary>
     internal IDriver? Driver
     internal IDriver? Driver
     {
     {
-        get => _driver ?? Application.Driver;
+        get => _driver ?? App?.Driver ?? Application.Driver;
         set => _driver = value;
         set => _driver = value;
     }
     }
 
 
-    /// <summary>Gets the screen buffer contents. This is a convenience property for Views that need direct access to the screen buffer.</summary>
+    /// <summary>
+    ///     Gets the screen buffer contents. This is a convenience property for Views that need direct access to the
+    ///     screen buffer.
+    /// </summary>
     protected Cell [,]? ScreenContents => Driver?.Contents;
     protected Cell [,]? ScreenContents => Driver?.Contents;
 
 
     /// <summary>Initializes a new instance of <see cref="View"/>.</summary>
     /// <summary>Initializes a new instance of <see cref="View"/>.</summary>
@@ -398,7 +400,7 @@ public partial class View : IDisposable, ISupportInitializeNotification
     }
     }
 
 
     /// <summary>Called when <see cref="Visible"/> is changing. Can be cancelled by returning <see langword="true"/>.</summary>
     /// <summary>Called when <see cref="Visible"/> is changing. Can be cancelled by returning <see langword="true"/>.</summary>
-    protected virtual bool OnVisibleChanging () { return false; }
+    protected virtual bool OnVisibleChanging () => false;
 
 
     /// <summary>
     /// <summary>
     ///     Raised when the <see cref="Visible"/> value is being changed. Can be cancelled by setting Cancel to
     ///     Raised when the <see cref="Visible"/> value is being changed. Can be cancelled by setting Cancel to

+ 2 - 2
Terminal.Gui/Views/Menuv1/Menu.cs

@@ -836,7 +836,7 @@ internal sealed class Menu : View
         RenderLineCanvas ();
         RenderLineCanvas ();
 
 
         // BUGBUG: Views should not change the clip. Doing so is an indcation of poor design or a bug in the framework.
         // BUGBUG: Views should not change the clip. Doing so is an indcation of poor design or a bug in the framework.
-        Region? savedClip = SetClipToScreen ();
+        Region? savedClip = SetClipToScreen (Driver);
 
 
         SetAttribute (GetAttributeForRole (VisualRole.Normal));
         SetAttribute (GetAttributeForRole (VisualRole.Normal));
 
 
@@ -1004,6 +1004,6 @@ internal sealed class Menu : View
             }
             }
         }
         }
 
 
-        SetClip (savedClip);
+        SetClip (Driver, savedClip);
     }
     }
 }
 }

+ 1 - 1
Tests/UnitTests/Application/CursorTests.cs

@@ -21,7 +21,7 @@ public class CursorTests
         {
         {
             if (TestLocation.HasValue && HasFocus)
             if (TestLocation.HasValue && HasFocus)
             {
             {
-                Driver.SetCursorVisibility (CursorVisibility.Default);
+                Driver?.SetCursorVisibility (CursorVisibility.Default);
             }
             }
             return TestLocation;
             return TestLocation;
         }
         }

+ 1 - 1
Tests/UnitTests/View/Adornment/AdornmentTests.cs

@@ -59,7 +59,7 @@ public class AdornmentTests (ITestOutputHelper output)
         Assert.Equal (6, view.Width);
         Assert.Equal (6, view.Width);
         Assert.Equal (3, view.Height);
         Assert.Equal (3, view.Height);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.Draw ();
         view.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (

+ 1 - 1
Tests/UnitTests/View/Adornment/BorderTests.cs

@@ -39,7 +39,7 @@ public class BorderTests (ITestOutputHelper output)
 
 
         view.CanFocus = true;
         view.CanFocus = true;
         view.SetFocus ();
         view.SetFocus ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.Draw ();
         view.Draw ();
         Assert.Equal (view.GetAttributeForRole (VisualRole.Focus), view.Border!.GetAttributeForRole (VisualRole.Focus));
         Assert.Equal (view.GetAttributeForRole (VisualRole.Focus), view.Border!.GetAttributeForRole (VisualRole.Focus));
         Assert.Equal (view.GetScheme ().Focus.Foreground, view.Border!.GetAttributeForRole (VisualRole.Focus).Foreground);
         Assert.Equal (view.GetScheme ().Focus.Foreground, view.Border!.GetAttributeForRole (VisualRole.Focus).Foreground);

+ 4 - 4
Tests/UnitTests/View/Draw/ClearViewportTests.cs

@@ -133,7 +133,7 @@ public class ClearViewportTests (ITestOutputHelper output)
  └─┘",
  └─┘",
                                                        output);
                                                        output);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
 
 
         view.ClearViewport ();
         view.ClearViewport ();
 
 
@@ -172,7 +172,7 @@ public class ClearViewportTests (ITestOutputHelper output)
  │X│
  │X│
  └─┘",
  └─┘",
                                                        output);
                                                        output);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.ClearViewport ();
         view.ClearViewport ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -203,7 +203,7 @@ public class ClearViewportTests (ITestOutputHelper output)
                                        }
                                        }
                                    }
                                    }
 
 
-                                   View.SetClip (savedClip);
+                                   View.SetClip (Application.Driver, savedClip);
                                    e.Cancel = true;
                                    e.Cancel = true;
                                };
                                };
         var top = new Toplevel ();
         var top = new Toplevel ();
@@ -268,7 +268,7 @@ public class ClearViewportTests (ITestOutputHelper output)
                                        }
                                        }
                                    }
                                    }
 
 
-                                   View.SetClip (savedClip);
+                                   View.SetClip (Application.Driver, savedClip);
                                    e.Cancel = true;
                                    e.Cancel = true;
                                };
                                };
         var top = new Toplevel ();
         var top = new Toplevel ();

+ 9 - 9
Tests/UnitTests/View/Draw/ClipTests.cs

@@ -91,7 +91,7 @@ public class ClipTests (ITestOutputHelper _output)
                                                        _output);
                                                        _output);
 
 
         Rectangle toFill = new (x, y, width, height);
         Rectangle toFill = new (x, y, width, height);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.FillRect (toFill);
         view.FillRect (toFill);
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -133,7 +133,7 @@ public class ClipTests (ITestOutputHelper _output)
                                                        _output);
                                                        _output);
         toFill = new (-1, -1, width + 1, height + 1);
         toFill = new (-1, -1, width + 1, height + 1);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.FillRect (toFill);
         view.FillRect (toFill);
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -154,7 +154,7 @@ public class ClipTests (ITestOutputHelper _output)
  └─┘",
  └─┘",
                                                        _output);
                                                        _output);
         toFill = new (0, 0, width * 2, height * 2);
         toFill = new (0, 0, width * 2, height * 2);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.FillRect (toFill);
         view.FillRect (toFill);
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -193,7 +193,7 @@ public class ClipTests (ITestOutputHelper _output)
         frameView.Border!.Thickness = new (1, 0, 0, 0);
         frameView.Border!.Thickness = new (1, 0, 0, 0);
 
 
         top.Add (frameView);
         top.Add (frameView);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Layout ();
         top.Layout ();
         top.Draw ();
         top.Draw ();
 
 
@@ -217,7 +217,7 @@ public class ClipTests (ITestOutputHelper _output)
 
 
         top.Add (view);
         top.Add (view);
         top.Layout ();
         top.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
 
 
         //                            012345678901234567890123456789012345678
         //                            012345678901234567890123456789012345678
@@ -258,13 +258,13 @@ public class ClipTests (ITestOutputHelper _output)
         view.Border!.Thickness = new (1);
         view.Border!.Thickness = new (1);
         view.BeginInit ();
         view.BeginInit ();
         view.EndInit ();
         view.EndInit ();
-        Assert.Equal (view.Frame, View.GetClip ()!.GetBounds ());
+        Assert.Equal (view.Frame, View.GetClip (Application.Driver)!.GetBounds ());
 
 
         // Act
         // Act
         view.AddViewportToClip ();
         view.AddViewportToClip ();
 
 
         // Assert
         // Assert
-        Assert.Equal (expectedClip, View.GetClip ()!.GetBounds ());
+        Assert.Equal (expectedClip, View.GetClip (Application.Driver)!.GetBounds ());
         view.Dispose ();
         view.Dispose ();
     }
     }
 
 
@@ -292,14 +292,14 @@ public class ClipTests (ITestOutputHelper _output)
         view.Border!.Thickness = new (1);
         view.Border!.Thickness = new (1);
         view.BeginInit ();
         view.BeginInit ();
         view.EndInit ();
         view.EndInit ();
-        Assert.Equal (view.Frame, View.GetClip ()!.GetBounds ());
+        Assert.Equal (view.Frame, View.GetClip (Application.Driver)!.GetBounds ());
         view.Viewport = view.Viewport with { X = 1, Y = 1 };
         view.Viewport = view.Viewport with { X = 1, Y = 1 };
 
 
         // Act
         // Act
         view.AddViewportToClip ();
         view.AddViewportToClip ();
 
 
         // Assert
         // Assert
-        Assert.Equal (expectedClip, View.GetClip ()!.GetBounds ());
+        Assert.Equal (expectedClip, View.GetClip (Application.Driver)!.GetBounds ());
         view.Dispose ();
         view.Dispose ();
     }
     }
 }
 }

+ 2 - 2
Tests/UnitTests/View/Draw/DrawTests.cs

@@ -760,7 +760,7 @@ At 0,0
         Assert.Equal (new (3, 3, 10, 1), view.Frame);
         Assert.Equal (new (3, 3, 10, 1), view.Frame);
         Assert.Equal (new (0, 0, 10, 1), view.Viewport);
         Assert.Equal (new (0, 0, 10, 1), view.Viewport);
         Assert.Equal (new (0, 0, 10, 1), view.NeedsDrawRect);
         Assert.Equal (new (0, 0, 10, 1), view.NeedsDrawRect);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -859,7 +859,7 @@ At 0,0
         Assert.Equal (new (1, 1, 10, 1), view.Frame);
         Assert.Equal (new (1, 1, 10, 1), view.Frame);
         Assert.Equal (new (0, 0, 10, 1), view.Viewport);
         Assert.Equal (new (0, 0, 10, 1), view.Viewport);
         Assert.Equal (new (0, 0, 10, 1), view.NeedsDrawRect);
         Assert.Equal (new (0, 0, 10, 1), view.NeedsDrawRect);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
 
 
         top.Draw ();
         top.Draw ();
 
 

+ 4 - 2
Tests/UnitTests/View/TextTests.cs

@@ -13,6 +13,7 @@ public class TextTests (ITestOutputHelper output)
     public void Setting_With_Height_Horizontal ()
     public void Setting_With_Height_Horizontal ()
     {
     {
         var top = new View { Width = 25, Height = 25 };
         var top = new View { Width = 25, Height = 25 };
+        top.App = ApplicationImpl.Instance;
 
 
         var label = new Label { Text = "Hello", /* Width = 10, Height = 2, */ ValidatePosDim = true };
         var label = new Label { Text = "Hello", /* Width = 10, Height = 2, */ ValidatePosDim = true };
         var viewX = new View { Text = "X", X = Pos.Right (label), Width = 1, Height = 1 };
         var viewX = new View { Text = "X", X = Pos.Right (label), Width = 1, Height = 1 };
@@ -39,7 +40,7 @@ Y
         Assert.Equal (new (0, 0, 10, 2), label.Frame);
         Assert.Equal (new (0, 0, 10, 2), label.Frame);
 
 
         top.LayoutSubViews ();
         top.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
 
 
         expected = @"
         expected = @"
@@ -1000,6 +1001,7 @@ w ";
     {
     {
         Application.Driver!.SetScreenSize (32, 32);
         Application.Driver!.SetScreenSize (32, 32);
         var top = new View { Width = 32, Height = 32 };
         var top = new View { Width = 32, Height = 32 };
+        top.App = ApplicationImpl.Instance;
 
 
         var text = $"First line{Environment.NewLine}Second line";
         var text = $"First line{Environment.NewLine}Second line";
         var horizontalView = new View { Width = 20, Height = 1, Text = text };
         var horizontalView = new View { Width = 20, Height = 1, Text = text };
@@ -1075,7 +1077,7 @@ w ";
         verticalView.Width = 2;
         verticalView.Width = 2;
         verticalView.TextFormatter.ConstrainToSize = new (2, 20);
         verticalView.TextFormatter.ConstrainToSize = new (2, 20);
         Assert.True (verticalView.TextFormatter.NeedsFormat);
         Assert.True (verticalView.TextFormatter.NeedsFormat);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         Assert.Equal (new (0, 3, 2, 20), verticalView.Frame);
         Assert.Equal (new (0, 3, 2, 20), verticalView.Frame);
 
 

+ 1 - 0
Tests/UnitTests/View/ViewTests.cs

@@ -332,6 +332,7 @@ public class ViewTests
     public void Test_Nested_Views_With_Height_Equal_To_One ()
     public void Test_Nested_Views_With_Height_Equal_To_One ()
     {
     {
         var v = new View { Width = 11, Height = 3 };
         var v = new View { Width = 11, Height = 3 };
+        v.App = ApplicationImpl.Instance;
 
 
         var top = new View { Width = Dim.Fill (), Height = 1 };
         var top = new View { Width = Dim.Fill (), Height = 1 };
         var bottom = new View { Width = Dim.Fill (), Height = 1, Y = 2 };
         var bottom = new View { Width = Dim.Fill (), Height = 1, Y = 2 };

+ 31 - 31
Tests/UnitTests/Views/AppendAutocompleteTests.cs

@@ -13,9 +13,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // f is typed and suggestion is "fish"
         // f is typed and suggestion is "fish"
         Application.RaiseKeyDownEvent ('f');
         Application.RaiseKeyDownEvent ('f');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
@@ -25,7 +25,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // Suggestion should disappear
         // Suggestion should disappear
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         DriverAssert.AssertDriverContentsAre ("f", output);
         DriverAssert.AssertDriverContentsAre ("f", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
 
 
@@ -46,9 +46,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // f is typed and suggestion is "fish"
         // f is typed and suggestion is "fish"
         Application.RaiseKeyDownEvent ('f');
         Application.RaiseKeyDownEvent ('f');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
@@ -63,9 +63,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // Should reappear when you press next letter
         // Should reappear when you press next letter
         Application.RaiseKeyDownEvent (Key.I);
         Application.RaiseKeyDownEvent (Key.I);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("fi", tf.Text);
         Assert.Equal ("fi", tf.Text);
@@ -82,9 +82,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // f is typed and suggestion is "fish"
         // f is typed and suggestion is "fish"
         Application.RaiseKeyDownEvent ('f');
         Application.RaiseKeyDownEvent ('f');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
@@ -92,18 +92,18 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         // When cycling autocomplete
         // When cycling autocomplete
         Application.RaiseKeyDownEvent (cycleKey);
         Application.RaiseKeyDownEvent (cycleKey);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("friend", output);
         DriverAssert.AssertDriverContentsAre ("friend", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
 
 
         // Should be able to cycle in circles endlessly
         // Should be able to cycle in circles endlessly
         Application.RaiseKeyDownEvent (cycleKey);
         Application.RaiseKeyDownEvent (cycleKey);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
@@ -118,9 +118,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // f is typed and suggestion is "fish"
         // f is typed and suggestion is "fish"
         Application.RaiseKeyDownEvent ('f');
         Application.RaiseKeyDownEvent ('f');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
@@ -129,7 +129,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         Application.RaiseKeyDownEvent (' ');
         Application.RaiseKeyDownEvent (' ');
         Application.RaiseKeyDownEvent (Key.CursorLeft);
         Application.RaiseKeyDownEvent (Key.CursorLeft);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("f", output);
         DriverAssert.AssertDriverContentsAre ("f", output);
         Assert.Equal ("f ", tf.Text);
         Assert.Equal ("f ", tf.Text);
@@ -144,16 +144,16 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // f is typed and suggestion is "fish"
         // f is typed and suggestion is "fish"
         Application.RaiseKeyDownEvent ('f');
         Application.RaiseKeyDownEvent ('f');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
 
 
         // x is typed and suggestion should disappear
         // x is typed and suggestion should disappear
         Application.RaiseKeyDownEvent (Key.X);
         Application.RaiseKeyDownEvent (Key.X);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("fx", output);
         DriverAssert.AssertDriverContentsAre ("fx", output);
         Assert.Equal ("fx", tf.Text);
         Assert.Equal ("fx", tf.Text);
@@ -170,9 +170,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator;
         var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator;
         generator.AllSuggestions = new() { "FISH" };
         generator.AllSuggestions = new() { "FISH" };
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("", output);
         DriverAssert.AssertDriverContentsAre ("", output);
         tf.NewKeyDownEvent (Key.M);
         tf.NewKeyDownEvent (Key.M);
@@ -182,16 +182,16 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         Assert.Equal ("my f", tf.Text);
         Assert.Equal ("my f", tf.Text);
 
 
         // Even though there is no match on case we should still get the suggestion
         // Even though there is no match on case we should still get the suggestion
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("my fISH", output);
         DriverAssert.AssertDriverContentsAre ("my fISH", output);
         Assert.Equal ("my f", tf.Text);
         Assert.Equal ("my f", tf.Text);
 
 
         // When tab completing the case of the whole suggestion should be applied
         // When tab completing the case of the whole suggestion should be applied
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("my FISH", output);
         DriverAssert.AssertDriverContentsAre ("my FISH", output);
         Assert.Equal ("my FISH", tf.Text);
         Assert.Equal ("my FISH", tf.Text);
@@ -208,24 +208,24 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator;
         var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator;
         generator.AllSuggestions = new() { "fish" };
         generator.AllSuggestions = new() { "fish" };
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("", output);
         DriverAssert.AssertDriverContentsAre ("", output);
 
 
         tf.NewKeyDownEvent (new ('f'));
         tf.NewKeyDownEvent (new ('f'));
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
 
 
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("fish", tf.Text);
         Assert.Equal ("fish", tf.Text);
@@ -250,9 +250,9 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
 
 
         // f is typed we should only see 'f' up to size of View (10)
         // f is typed we should only see 'f' up to size of View (10)
         Application.RaiseKeyDownEvent ('f');
         Application.RaiseKeyDownEvent ('f');
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre (expectRender, output);
         DriverAssert.AssertDriverContentsAre (expectRender, output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);

+ 7 - 7
Tests/UnitTests/Views/ComboBoxTests.cs

@@ -565,7 +565,7 @@ Three ",
         Assert.True (cb.IsShow);
         Assert.True (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverAttributesAre (
         DriverAssert.AssertDriverAttributesAre (
@@ -584,7 +584,7 @@ Three ",
         Assert.True (cb.IsShow);
         Assert.True (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverAttributesAre (
         DriverAssert.AssertDriverAttributesAre (
@@ -609,7 +609,7 @@ Three ",
         Assert.True (cb.IsShow);
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
         Assert.Equal ("Three", cb.Text);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverAttributesAre (
         DriverAssert.AssertDriverAttributesAre (
@@ -628,7 +628,7 @@ Three ",
         Assert.True (cb.IsShow);
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
         Assert.Equal ("Three", cb.Text);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverAttributesAre (
         DriverAssert.AssertDriverAttributesAre (
@@ -647,7 +647,7 @@ Three ",
         Assert.True (cb.IsShow);
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
         Assert.Equal ("Three", cb.Text);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverAttributesAre (
         DriverAssert.AssertDriverAttributesAre (
@@ -928,7 +928,7 @@ One
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
         Assert.Equal ("Two", cb.Text);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -944,7 +944,7 @@ Two
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
         Assert.Equal ("Three", cb.Text);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         cb.Draw ();
         cb.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (

+ 6 - 6
Tests/UnitTests/Views/GraphViewTests.cs

@@ -650,7 +650,7 @@ public class MultiBarSeriesTests
         fakeXAxis.LabelPoints.Clear ();
         fakeXAxis.LabelPoints.Clear ();
         gv.LayoutSubViews ();
         gv.LayoutSubViews ();
         gv.SetNeedsDraw ();
         gv.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         gv.Draw ();
         gv.Draw ();
 
 
         Assert.Equal (3, fakeXAxis.LabelPoints.Count);
         Assert.Equal (3, fakeXAxis.LabelPoints.Count);
@@ -1125,7 +1125,7 @@ public class TextAnnotationTests
         // user scrolls up one unit of graph space
         // user scrolls up one unit of graph space
         gv.ScrollOffset = new PointF (0, 1f);
         gv.ScrollOffset = new PointF (0, 1f);
         gv.SetNeedsDraw ();
         gv.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         gv.Draw ();
         gv.Draw ();
 
 
         // we expect the text annotation to go down one line since
         // we expect the text annotation to go down one line since
@@ -1222,7 +1222,7 @@ public class TextAnnotationTests
                             new TextAnnotation { Text = "hey!", ScreenPosition = new Point (3, 1) }
                             new TextAnnotation { Text = "hey!", ScreenPosition = new Point (3, 1) }
                            );
                            );
         gv.LayoutSubViews ();
         gv.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         gv.Draw ();
         gv.Draw ();
 
 
         var expected =
         var expected =
@@ -1238,7 +1238,7 @@ public class TextAnnotationTests
         // user scrolls up one unit of graph space
         // user scrolls up one unit of graph space
         gv.ScrollOffset = new PointF (0, 1f);
         gv.ScrollOffset = new PointF (0, 1f);
         gv.SetNeedsDraw ();
         gv.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         gv.Draw ();
         gv.Draw ();
 
 
         // we expect no change in the location of the annotation (only the axis label changes)
         // we expect no change in the location of the annotation (only the axis label changes)
@@ -1257,7 +1257,7 @@ public class TextAnnotationTests
         // user scrolls up one unit of graph space
         // user scrolls up one unit of graph space
         gv.ScrollOffset = new PointF (0, 1f);
         gv.ScrollOffset = new PointF (0, 1f);
         gv.SetNeedsDraw ();
         gv.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         gv.Draw ();
         gv.Draw ();
 
 
         // we expect no change in the location of the annotation (only the axis label changes)
         // we expect no change in the location of the annotation (only the axis label changes)
@@ -1528,7 +1528,7 @@ public class PathAnnotationTests
             // change the text and redraw
             // change the text and redraw
             view.Text = "ff1234";
             view.Text = "ff1234";
             mount.SetNeedsDraw ();
             mount.SetNeedsDraw ();
-            View.SetClipToScreen ();
+            View.SetClipToScreen (Application.Driver);
             mount.Draw ();
             mount.Draw ();
 
 
             // should have the new text rendered
             // should have the new text rendered

+ 9 - 2
Tests/UnitTests/Views/LabelTests.cs

@@ -301,7 +301,11 @@ e
     [SetupFakeApplication]
     [SetupFakeApplication]
     public void Full_Border ()
     public void Full_Border ()
     {
     {
-        var label = new Label { BorderStyle = LineStyle.Single, Text = "Test" };
+        var label = new Label
+        {
+            Driver = Application.Driver,
+            BorderStyle = LineStyle.Single, Text = "Test"
+        };
         label.BeginInit ();
         label.BeginInit ();
         label.EndInit ();
         label.EndInit ();
         label.SetRelativeLayout (Application.Screen.Size);
         label.SetRelativeLayout (Application.Screen.Size);
@@ -907,7 +911,10 @@ e
         label.Width = Dim.Fill () - text.Length;
         label.Width = Dim.Fill () - text.Length;
         label.Height = 0;
         label.Height = 0;
 
 
-        var win = new View { CanFocus = true, BorderStyle = LineStyle.Single, Width = Dim.Fill (), Height = Dim.Fill () };
+        var win = new View
+        {
+            CanFocus = true, BorderStyle = LineStyle.Single, Width = Dim.Fill (), Height = Dim.Fill ()
+        };
         win.Add (label);
         win.Add (label);
         win.BeginInit ();
         win.BeginInit ();
         win.EndInit ();
         win.EndInit ();

+ 24 - 24
Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs

@@ -698,7 +698,7 @@ public class MenuBarv1Tests (ITestOutputHelper output)
         Dialog.DefaultShadow = ShadowStyle.None;
         Dialog.DefaultShadow = ShadowStyle.None;
         Button.DefaultShadow = ShadowStyle.None;
         Button.DefaultShadow = ShadowStyle.None;
 
 
-        Assert.Equal (new (0, 0, 40, 15), View.GetClip ()!.GetBounds ());
+        Assert.Equal (new (0, 0, 40, 15), View.GetClip (Application.Driver)!.GetBounds ());
         DriverAssert.AssertDriverContentsWithFrameAre (@"", output);
         DriverAssert.AssertDriverContentsWithFrameAre (@"", output);
 
 
         List<string> items = new ()
         List<string> items = new ()
@@ -1594,7 +1594,7 @@ wo
 
 
         Assert.True (menu.NewMouseEvent (new () { Position = new (1, 0), Flags = MouseFlags.Button1Pressed, View = menu }));
         Assert.True (menu.NewMouseEvent (new () { Position = new (1, 0), Flags = MouseFlags.Button1Pressed, View = menu }));
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         top.Dispose ();
         top.Dispose ();
@@ -1692,7 +1692,7 @@ wo
                                                      );
                                                      );
 
 
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1804,7 +1804,7 @@ wo
                                                                );
                                                                );
 
 
                                                            Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
                                                            Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
-                                                           View.SetClipToScreen ();
+                                                           View.SetClipToScreen (Application.Driver);
                                                            top.Draw ();
                                                            top.Draw ();
 
 
                                                            DriverAssert.AssertDriverContentsWithFrameAre (
                                                            DriverAssert.AssertDriverContentsWithFrameAre (
@@ -2015,7 +2015,7 @@ wo
                                                            Assert.True (
                                                            Assert.True (
                                                                         ((MenuBar)top.SubViews.ElementAt (0))._openMenu.NewKeyDownEvent (Key.CursorRight)
                                                                         ((MenuBar)top.SubViews.ElementAt (0))._openMenu.NewKeyDownEvent (Key.CursorRight)
                                                                        );
                                                                        );
-                                                           View.SetClipToScreen ();
+                                                           View.SetClipToScreen (Application.Driver);
                                                            top.Draw ();
                                                            top.Draw ();
 
 
                                                            DriverAssert.AssertDriverContentsWithFrameAre (
                                                            DriverAssert.AssertDriverContentsWithFrameAre (
@@ -2092,14 +2092,14 @@ wo
         // Open second
         // Open second
         Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
         // Close menu
         // Close menu
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
 
 
@@ -2133,21 +2133,21 @@ wo
         // Open first
         // Open first
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
 
 
         // Open second
         // Open second
         Assert.True (top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         Application.Current.Draw ();
         Application.Current.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
         // Close menu
         // Close menu
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         top.Dispose ();
         top.Dispose ();
@@ -2216,7 +2216,7 @@ wo
         top.Add (menu);
         top.Add (menu);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
 
 
@@ -2224,7 +2224,7 @@ wo
         {
         {
             menu.OpenMenu (i);
             menu.OpenMenu (i);
             Assert.True (menu.IsMenuOpen);
             Assert.True (menu.IsMenuOpen);
-            View.SetClipToScreen ();
+            View.SetClipToScreen (Application.Driver);
             top.Draw ();
             top.Draw ();
             DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (i), output);
             DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (i), output);
         }
         }
@@ -2483,7 +2483,7 @@ Edit
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (isMenuClosed);
         Assert.False (isMenuClosed);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
 
 
         expected = @"
         expected = @"
@@ -2498,7 +2498,7 @@ Edit
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.True (menu.NewKeyDownEvent (menu.Key));
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
         Assert.True (isMenuClosed);
         Assert.True (isMenuClosed);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
 
 
         expected = @"
         expected = @"
@@ -2655,7 +2655,7 @@ Edit
         Assert.Equal (1, menu._selected);
         Assert.Equal (1, menu._selected);
         Assert.Equal (-1, menu._selectedSub);
         Assert.Equal (-1, menu._selectedSub);
         Assert.Null (menu._openSubMenu);
         Assert.Null (menu._openSubMenu);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
@@ -2663,7 +2663,7 @@ Edit
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (2), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (2), output);
 
 
@@ -2671,21 +2671,21 @@ Edit
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
 
 
         Assert.True (Application.RaiseKeyDownEvent (menu.Key));
         Assert.True (Application.RaiseKeyDownEvent (menu.Key));
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
         Assert.True (tf.HasFocus);
         Assert.True (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         top.Dispose ();
         top.Dispose ();
@@ -2756,7 +2756,7 @@ Edit
                     );
                     );
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
@@ -2767,7 +2767,7 @@ Edit
                     );
                     );
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (2), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (2), output);
 
 
@@ -2778,7 +2778,7 @@ Edit
                     );
                     );
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
 
 
@@ -2789,14 +2789,14 @@ Edit
                     );
                     );
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
 
 
         Assert.True (menu.NewMouseEvent (new () { Position = new (8, 0), Flags = MouseFlags.Button1Pressed, View = menu }));
         Assert.True (menu.NewMouseEvent (new () { Position = new (8, 0), Flags = MouseFlags.Button1Pressed, View = menu }));
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
         Assert.True (tf.HasFocus);
         Assert.True (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         top.Draw ();
         top.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output);
         top.Dispose ();
         top.Dispose ();

+ 3 - 3
Tests/UnitTests/Views/ProgressBarTests.cs

@@ -37,7 +37,7 @@ public class ProgressBarTests
         for (var i = 0; i <= pb.Frame.Width; i++)
         for (var i = 0; i <= pb.Frame.Width; i++)
         {
         {
             pb.Fraction += 0.2F;
             pb.Fraction += 0.2F;
-            View.SetClipToScreen ();
+            View.SetClipToScreen (Application.Driver);
             pb.Draw ();
             pb.Draw ();
 
 
             if (i == 0)
             if (i == 0)
@@ -175,7 +175,7 @@ public class ProgressBarTests
         for (var i = 0; i < 38; i++)
         for (var i = 0; i < 38; i++)
         {
         {
             pb.Pulse ();
             pb.Pulse ();
-            View.SetClipToScreen ();
+            View.SetClipToScreen (Application.Driver);
             pb.Draw ();
             pb.Draw ();
 
 
             if (i == 0)
             if (i == 0)
@@ -880,7 +880,7 @@ public class ProgressBarTests
         for (var i = 0; i < 38; i++)
         for (var i = 0; i < 38; i++)
         {
         {
             pb.Pulse ();
             pb.Pulse ();
-            View.SetClipToScreen ();
+            View.SetClipToScreen (Application.Driver);
             pb.Draw ();
             pb.Draw ();
 
 
             if (i == 0)
             if (i == 0)

+ 1 - 1
Tests/UnitTests/Views/SpinnerViewTests.cs

@@ -57,7 +57,7 @@ public class SpinnerViewTests (ITestOutputHelper output)
         DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
 
 
         view.AdvanceAnimation ();
         view.AdvanceAnimation ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         view.Draw ();
         view.Draw ();
 
 
         expected = "/";
         expected = "/";

+ 22 - 22
Tests/UnitTests/Views/TabViewTests.cs

@@ -664,7 +664,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tab2, tv.SubViews.First (v => v.Id.Contains ("tabRow")).MostFocused);
         Assert.Equal (tab2, tv.SubViews.First (v => v.Id.Contains ("tabRow")).MostFocused);
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -683,7 +683,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab1.DisplayText = "12345678910";
         tab1.DisplayText = "12345678910";
         tab2.DisplayText = "13";
         tab2.DisplayText = "13";
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -700,7 +700,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -717,7 +717,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "abcdefghijklmnopq";
         tab2.DisplayText = "abcdefghijklmnopq";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -810,7 +810,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tab2, tv.SubViews.First (v => v.Id.Contains ("tabRow")).MostFocused);
         Assert.Equal (tab2, tv.SubViews.First (v => v.Id.Contains ("tabRow")).MostFocused);
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -830,7 +830,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "13";
         tab2.DisplayText = "13";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -847,7 +847,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -865,7 +865,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "abcdefghijklmnopq";
         tab2.DisplayText = "abcdefghijklmnopq";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -910,7 +910,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.Height = 5;
         tv.Height = 5;
         tv.Layout ();
         tv.Layout ();
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -952,7 +952,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -972,7 +972,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "13";
         tab2.DisplayText = "13";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -989,7 +989,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1007,7 +1007,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "abcdefghijklmnopq";
         tab2.DisplayText = "abcdefghijklmnopq";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1049,7 +1049,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1144,7 +1144,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "13";
         tab2.DisplayText = "13";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1161,7 +1161,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1179,7 +1179,7 @@ public class TabViewTests (ITestOutputHelper output)
         tab2.DisplayText = "abcdefghijklmnopq";
         tab2.DisplayText = "abcdefghijklmnopq";
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1223,7 +1223,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1337,7 +1337,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1354,7 +1354,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab3;
         tv.SelectedTab = tab3;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1404,7 +1404,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab2;
         tv.SelectedTab = tab2;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (
@@ -1421,7 +1421,7 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab = tab3;
         tv.SelectedTab = tab3;
 
 
         tv.Layout ();
         tv.Layout ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (

+ 27 - 27
Tests/UnitTests/Views/TableViewTests.cs

@@ -722,7 +722,7 @@ public class TableViewTests (ITestOutputHelper output)
 
 
         // since A is now pushed off screen we get indicator showing
         // since A is now pushed off screen we get indicator showing
         // that user can scroll left to see first column
         // that user can scroll left to see first column
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         expected =
         expected =
@@ -737,7 +737,7 @@ public class TableViewTests (ITestOutputHelper output)
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         expected =
         expected =
@@ -796,7 +796,7 @@ public class TableViewTests (ITestOutputHelper output)
 
 
         // Scroll right
         // Scroll right
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         // Note that with SmoothHorizontalScrolling only a single new column
         // Note that with SmoothHorizontalScrolling only a single new column
@@ -844,7 +844,7 @@ public class TableViewTests (ITestOutputHelper output)
 
 
         // select last visible column
         // select last visible column
         tableView.SelectedColumn = 2; // column C
         tableView.SelectedColumn = 2; // column C
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         var expected =
         var expected =
@@ -856,7 +856,7 @@ public class TableViewTests (ITestOutputHelper output)
 
 
         // Scroll right
         // Scroll right
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
         tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.CursorRight });
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         // notice that without smooth scrolling we just update the first column
         // notice that without smooth scrolling we just update the first column
@@ -1974,7 +1974,7 @@ public class TableViewTests (ITestOutputHelper output)
 ◄─┼─┼─┤
 ◄─┼─┼─┤
 │2│3│4│";
 │2│3│4│";
         tableView.SetNeedsDraw ();
         tableView.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (expected, output);
         DriverAssert.AssertDriverContentsAre (expected, output);
@@ -1988,7 +1988,7 @@ public class TableViewTests (ITestOutputHelper output)
 ├─┼─┼─┤
 ├─┼─┼─┤
 │2│3│4│";
 │2│3│4│";
         tableView.SetNeedsDraw ();
         tableView.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (expected, output);
         DriverAssert.AssertDriverContentsAre (expected, output);
@@ -2004,7 +2004,7 @@ public class TableViewTests (ITestOutputHelper output)
         tableView.Style.ShowHorizontalHeaderUnderline = true;
         tableView.Style.ShowHorizontalHeaderUnderline = true;
         tableView.LayoutSubViews ();
         tableView.LayoutSubViews ();
         tableView.SetNeedsDraw ();
         tableView.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
 
 
         // normally we should have scroll indicators because DEF are of screen
         // normally we should have scroll indicators because DEF are of screen
@@ -2027,7 +2027,7 @@ public class TableViewTests (ITestOutputHelper output)
 ├─┼─┼─┤
 ├─┼─┼─┤
 │1│2│3│";
 │1│2│3│";
         tableView.SetNeedsDraw ();
         tableView.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tableView.Draw ();
         tableView.Draw ();
         DriverAssert.AssertDriverContentsAre (expected, output);
         DriverAssert.AssertDriverContentsAre (expected, output);
     }
     }
@@ -2600,7 +2600,7 @@ A B C
 
 
         Assert.True (pets.First ().IsPicked);
         Assert.True (pets.First ().IsPicked);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2620,7 +2620,7 @@ A B C
         Assert.True (pets.ElementAt (0).IsPicked);
         Assert.True (pets.ElementAt (0).IsPicked);
         Assert.True (pets.ElementAt (1).IsPicked);
         Assert.True (pets.ElementAt (1).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2640,7 +2640,7 @@ A B C
         Assert.False (pets.ElementAt (0).IsPicked);
         Assert.False (pets.ElementAt (0).IsPicked);
         Assert.True (pets.ElementAt (1).IsPicked);
         Assert.True (pets.ElementAt (1).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2668,7 +2668,7 @@ A B C
         wrapper.CheckedRows.Add (0);
         wrapper.CheckedRows.Add (0);
         wrapper.CheckedRows.Add (2);
         wrapper.CheckedRows.Add (2);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         var expected =
         var expected =
@@ -2692,7 +2692,7 @@ A B C
         Assert.Contains (2, wrapper.CheckedRows);
         Assert.Contains (2, wrapper.CheckedRows);
         Assert.Equal (3, wrapper.CheckedRows.Count);
         Assert.Equal (3, wrapper.CheckedRows.Count);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2708,7 +2708,7 @@ A B C
         // Untoggle the top 2
         // Untoggle the top 2
         tv.NewKeyDownEvent (Key.Space);
         tv.NewKeyDownEvent (Key.Space);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2737,7 +2737,7 @@ A B C
         tv.NewKeyDownEvent (Key.A.WithCtrl);
         tv.NewKeyDownEvent (Key.A.WithCtrl);
         tv.NewKeyDownEvent (Key.Space);
         tv.NewKeyDownEvent (Key.Space);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         var expected =
         var expected =
@@ -2757,7 +2757,7 @@ A B C
         // Untoggle all again
         // Untoggle all again
         tv.NewKeyDownEvent (Key.Space);
         tv.NewKeyDownEvent (Key.Space);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2798,7 +2798,7 @@ A B C
 
 
         Assert.True (pets.All (p => p.IsPicked));
         Assert.True (pets.All (p => p.IsPicked));
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         var expected =
         var expected =
@@ -2818,7 +2818,7 @@ A B C
         Assert.Empty (pets.Where (p => p.IsPicked));
         Assert.Empty (pets.Where (p => p.IsPicked));
 #pragma warning restore xUnit2029
 #pragma warning restore xUnit2029
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2845,7 +2845,7 @@ A B C
         var wrapper = new CheckBoxTableSourceWrapperByIndex (tv, tv.Table);
         var wrapper = new CheckBoxTableSourceWrapperByIndex (tv, tv.Table);
         tv.Table = wrapper;
         tv.Table = wrapper;
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         var expected =
         var expected =
@@ -2865,7 +2865,7 @@ A B C
 
 
         Assert.Single (wrapper.CheckedRows, 0);
         Assert.Single (wrapper.CheckedRows, 0);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2885,7 +2885,7 @@ A B C
         Assert.Contains (1, wrapper.CheckedRows);
         Assert.Contains (1, wrapper.CheckedRows);
         Assert.Equal (2, wrapper.CheckedRows.Count);
         Assert.Equal (2, wrapper.CheckedRows.Count);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2904,7 +2904,7 @@ A B C
 
 
         Assert.Single (wrapper.CheckedRows, 1);
         Assert.Single (wrapper.CheckedRows, 1);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2936,7 +2936,7 @@ A B C
         wrapper.UseRadioButtons = true;
         wrapper.UseRadioButtons = true;
 
 
         tv.Table = wrapper;
         tv.Table = wrapper;
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         var expected =
         var expected =
@@ -2959,7 +2959,7 @@ A B C
 
 
         Assert.True (pets.First ().IsPicked);
         Assert.True (pets.First ().IsPicked);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -2980,7 +2980,7 @@ A B C
         Assert.True (pets.ElementAt (1).IsPicked);
         Assert.True (pets.ElementAt (1).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -3001,7 +3001,7 @@ A B C
         Assert.False (pets.ElementAt (1).IsPicked);
         Assert.False (pets.ElementAt (1).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
         Assert.False (pets.ElementAt (2).IsPicked);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =

+ 8 - 8
Tests/UnitTests/Views/TextFieldTests.cs

@@ -123,13 +123,13 @@ public class TextFieldTests (ITestOutputHelper output)
 
 
         // Caption should appear when not focused and no text
         // Caption should appear when not focused and no text
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("Enter txt", output);
         DriverAssert.AssertDriverContentsAre ("Enter txt", output);
 
 
         // but disapear when text is added
         // but disapear when text is added
         tf.Text = content;
         tf.Text = content;
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre (content, output);
         DriverAssert.AssertDriverContentsAre (content, output);
         Application.Current.Dispose ();
         Application.Current.Dispose ();
@@ -147,14 +147,14 @@ public class TextFieldTests (ITestOutputHelper output)
         // Caption has no effect when focused
         // Caption has no effect when focused
         tf.Title = "Enter txt";
         tf.Title = "Enter txt";
         Assert.True (tf.HasFocus);
         Assert.True (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("", output);
         DriverAssert.AssertDriverContentsAre ("", output);
 
 
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
 
 
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("Enter txt", output);
         DriverAssert.AssertDriverContentsAre ("Enter txt", output);
         Application.Current.Dispose ();
         Application.Current.Dispose ();
@@ -173,7 +173,7 @@ public class TextFieldTests (ITestOutputHelper output)
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         
         
         // Verify the caption text is rendered
         // Verify the caption text is rendered
@@ -203,7 +203,7 @@ public class TextFieldTests (ITestOutputHelper output)
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         
         
         // The hotkey character 'F' should be rendered (without the underscore in the actual text)
         // The hotkey character 'F' should be rendered (without the underscore in the actual text)
@@ -237,7 +237,7 @@ public class TextFieldTests (ITestOutputHelper output)
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
         Assert.False (tf.HasFocus);
         Assert.False (tf.HasFocus);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
         
         
         // The underscore should not be rendered, 'T' should be underlined
         // The underscore should not be rendered, 'T' should be underlined
@@ -1641,7 +1641,7 @@ Les Misérables",
 
 
         // incorrect order will result with a wrong accent place
         // incorrect order will result with a wrong accent place
         tf.Text = "Les Mis" + char.ConvertFromUtf32 (int.Parse ("0301", NumberStyles.HexNumber)) + "erables";
         tf.Text = "Les Mis" + char.ConvertFromUtf32 (int.Parse ("0301", NumberStyles.HexNumber)) + "erables";
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tf.Draw ();
         tf.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (

+ 1 - 1
Tests/UnitTests/Views/TextViewTests.cs

@@ -6827,7 +6827,7 @@ line.
         tv.CursorPosition = new (6, 2);
         tv.CursorPosition = new (6, 2);
         Assert.Equal (new (5, 2), tv.CursorPosition);
         Assert.Equal (new (5, 2), tv.CursorPosition);
         top.LayoutSubViews ();
         top.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (
         DriverAssert.AssertDriverContentsWithFrameAre (

+ 7 - 7
Tests/UnitTests/Views/TreeTableSourceTests.cs

@@ -55,7 +55,7 @@ public class TreeTableSourceTests : IDisposable
         // when pressing right we should expand the top route
         // when pressing right we should expand the top route
         tv.NewKeyDownEvent (Key.CursorRight);
         tv.NewKeyDownEvent (Key.CursorRight);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -73,7 +73,7 @@ public class TreeTableSourceTests : IDisposable
         // when pressing left we should collapse the top route again
         // when pressing left we should collapse the top route again
         tv.NewKeyDownEvent (Key.CursorLeft);
         tv.NewKeyDownEvent (Key.CursorLeft);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -97,7 +97,7 @@ public class TreeTableSourceTests : IDisposable
 
 
         tv.Style.GetOrCreateColumnStyle (1).MinAcceptableWidth = 1;
         tv.Style.GetOrCreateColumnStyle (1).MinAcceptableWidth = 1;
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         var expected =
         var expected =
@@ -117,7 +117,7 @@ public class TreeTableSourceTests : IDisposable
 
 
         Assert.True (tv.NewMouseEvent (new MouseEventArgs { Position = new (2, 2), Flags = MouseFlags.Button1Clicked }));
         Assert.True (tv.NewMouseEvent (new MouseEventArgs { Position = new (2, 2), Flags = MouseFlags.Button1Clicked }));
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -142,7 +142,7 @@ public class TreeTableSourceTests : IDisposable
 
 
         // Clicking on the + again should collapse
         // Clicking on the + again should collapse
         tv.NewMouseEvent (new MouseEventArgs { Position = new (2, 2), Flags = MouseFlags.Button1Clicked });
         tv.NewMouseEvent (new MouseEventArgs { Position = new (2, 2), Flags = MouseFlags.Button1Clicked });
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -195,7 +195,7 @@ public class TreeTableSourceTests : IDisposable
 
 
         Application.RaiseKeyDownEvent (Key.CursorRight);
         Application.RaiseKeyDownEvent (Key.CursorRight);
 
 
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =
@@ -213,7 +213,7 @@ public class TreeTableSourceTests : IDisposable
 
 
         tv.NewKeyDownEvent (Key.CursorDown);
         tv.NewKeyDownEvent (Key.CursorDown);
         tv.NewKeyDownEvent (Key.Space);
         tv.NewKeyDownEvent (Key.Space);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         expected =
         expected =

+ 13 - 13
Tests/UnitTests/Views/TreeViewTests.cs

@@ -718,7 +718,7 @@ public class TreeViewTests (ITestOutputHelper output)
                                             );
                                             );
         tv.MaxDepth = 3;
         tv.MaxDepth = 3;
         tv.ExpandAll ();
         tv.ExpandAll ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         // Normal drawing of the tree view
         // Normal drawing of the tree view
@@ -757,7 +757,7 @@ public class TreeViewTests (ITestOutputHelper output)
                                             );
                                             );
         tv.MaxDepth = 5;
         tv.MaxDepth = 5;
         tv.ExpandAll ();
         tv.ExpandAll ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
 
 
         tv.Draw ();
         tv.Draw ();
 
 
@@ -785,7 +785,7 @@ public class TreeViewTests (ITestOutputHelper output)
 
 
         Assert.True (tv.CanExpand ("5"));
         Assert.True (tv.CanExpand ("5"));
         Assert.False (tv.IsExpanded ("5"));
         Assert.False (tv.IsExpanded ("5"));
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
 
 
         tv.Draw ();
         tv.Draw ();
 
 
@@ -840,7 +840,7 @@ public class TreeViewTests (ITestOutputHelper output)
         Assert.Null (tv.GetObjectOnRow (4));
         Assert.Null (tv.GetObjectOnRow (4));
 
 
         tv.Collapse (n1);
         tv.Collapse (n1);
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
 
 
         tv.Draw ();
         tv.Draw ();
 
 
@@ -877,7 +877,7 @@ public class TreeViewTests (ITestOutputHelper output)
 
 
         tv.SetScheme (new Scheme ());
         tv.SetScheme (new Scheme ());
         tv.LayoutSubViews ();
         tv.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -897,7 +897,7 @@ public class TreeViewTests (ITestOutputHelper output)
         tv.Collapse (n1);
         tv.Collapse (n1);
 
 
         tv.LayoutSubViews ();
         tv.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -915,7 +915,7 @@ public class TreeViewTests (ITestOutputHelper output)
         tv.ScrollOffsetVertical = 1;
         tv.ScrollOffsetVertical = 1;
 
 
         tv.LayoutSubViews ();
         tv.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -952,7 +952,7 @@ public class TreeViewTests (ITestOutputHelper output)
 
 
         tv.SetScheme (new Scheme ());
         tv.SetScheme (new Scheme ());
         tv.LayoutSubViews ();
         tv.LayoutSubViews ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         // Normal drawing of the tree view
         // Normal drawing of the tree view
@@ -1141,7 +1141,7 @@ oot two
 
 
         // matches nothing
         // matches nothing
         filter.Text = "asdfjhasdf";
         filter.Text = "asdfjhasdf";
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         // Normal drawing of the tree view
         // Normal drawing of the tree view
@@ -1152,7 +1152,7 @@ oot two
 
 
         // Matches everything
         // Matches everything
         filter.Text = "root";
         filter.Text = "root";
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -1167,7 +1167,7 @@ oot two
 
 
         // Matches 2 leaf nodes
         // Matches 2 leaf nodes
         filter.Text = "leaf";
         filter.Text = "leaf";
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -1181,7 +1181,7 @@ oot two
 
 
         // Matches 1 leaf nodes
         // Matches 1 leaf nodes
         filter.Text = "leaf 1";
         filter.Text = "leaf 1";
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -1253,7 +1253,7 @@ oot two
         // redraw now that the custom color
         // redraw now that the custom color
         // delegate is registered
         // delegate is registered
         tv.SetNeedsDraw ();
         tv.SetNeedsDraw ();
-        View.SetClipToScreen ();
+        View.SetClipToScreen (Application.Driver);
         tv.Draw ();
         tv.Draw ();
 
 
         // Same text
         // Same text