From 0900333e1268dfcf6184577f72c233ef9f1675b9 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 08:12:50 -0800 Subject: [PATCH] Reamed Bounds -> Viewport - more rename --- Terminal.Gui/Application.cs | 10 +-- Terminal.Gui/Drawing/LineCanvas.cs | 18 ++--- Terminal.Gui/Text/TextFormatter.cs | 82 +++++++++++----------- Terminal.Gui/View/Adornment/Adornment.cs | 4 +- Terminal.Gui/View/Adornment/Border.cs | 2 +- Terminal.Gui/View/Layout/ViewLayout.cs | 53 +++++++------- Terminal.Gui/View/ViewDrawing.cs | 40 +++-------- Terminal.Gui/Views/ComboBox.cs | 2 +- Terminal.Gui/Views/Line.cs | 2 +- Terminal.Gui/Views/Menu/ContextMenu.cs | 4 +- Terminal.Gui/Views/Menu/Menu.cs | 14 ++-- Terminal.Gui/Views/Menu/MenuBar.cs | 14 ++-- Terminal.Gui/Views/ProgressBar.cs | 4 +- Terminal.Gui/Views/ScrollView.cs | 2 +- Terminal.Gui/Views/TabView.cs | 8 +-- Terminal.Gui/Views/TextField.cs | 4 +- Terminal.Gui/Views/TileView.cs | 4 +- UICatalog/Scenarios/CharacterMap.cs | 2 +- UICatalog/Scenarios/Notepad.cs | 2 +- UICatalog/Scenarios/ViewExperiments.cs | 4 +- UnitTests/View/Adornment/AdornmentTests.cs | 2 +- UnitTests/View/Adornment/ToScreenTests.cs | 38 +++++----- UnitTests/View/Layout/ScreenToTests.cs | 6 +- UnitTests/View/Layout/ToScreenTests.cs | 14 ++-- UnitTests/View/NavigationTests.cs | 68 +++++++++--------- UnitTests/Views/ToplevelTests.cs | 2 +- 26 files changed, 192 insertions(+), 213 deletions(-) diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index e84ae835c..1b016166f 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -1422,7 +1422,7 @@ public static partial class Application if (MouseGrabView.Viewport.Contains (viewRelativeMouseEvent.X, viewRelativeMouseEvent.Y) is false) { - // The mouse has moved outside the bounds of the view that + // The mouse has moved outside the Viewport of the view that // grabbed the mouse, so we tell the view that last got // OnMouseEnter the mouse is leaving // BUGBUG: That sentence makes no sense. Either I'm missing something or this logic is flawed. @@ -1476,14 +1476,14 @@ public static partial class Application View = view }; } - else if (view.BoundsToScreen (view.Viewport).Contains (a.MouseEvent.X, a.MouseEvent.Y)) + else if (view.ViewportToScreen (view.Viewport).Contains (a.MouseEvent.X, a.MouseEvent.Y)) { - Point boundsPoint = view.ScreenToBounds (a.MouseEvent.X, a.MouseEvent.Y); + Point viewportLocation = view.ScreenToViewport (a.MouseEvent.X, a.MouseEvent.Y); me = new MouseEvent { - X = boundsPoint.X, - Y = boundsPoint.Y, + X = viewportLocation.X, + Y = viewportLocation.Y, Flags = a.MouseEvent.Flags, ScreenPosition = new (a.MouseEvent.X, a.MouseEvent.Y), View = view diff --git a/Terminal.Gui/Drawing/LineCanvas.cs b/Terminal.Gui/Drawing/LineCanvas.cs index fb9167ec5..108559b71 100644 --- a/Terminal.Gui/Drawing/LineCanvas.cs +++ b/Terminal.Gui/Drawing/LineCanvas.cs @@ -48,7 +48,7 @@ public class LineCanvas : IDisposable // TODO: Add other resolvers }; - private Rectangle _cachedBounds; + private Rectangle _cachedViewport; /// Creates a new instance. public LineCanvas () @@ -71,11 +71,11 @@ public class LineCanvas : IDisposable { get { - if (_cachedBounds.IsEmpty) + if (_cachedViewport.IsEmpty) { if (_lines.Count == 0) { - return _cachedBounds; + return _cachedViewport; } Rectangle bounds = _lines [0].Viewport; @@ -94,10 +94,10 @@ public class LineCanvas : IDisposable }; } - _cachedBounds = bounds; + _cachedViewport = bounds; } - return _cachedBounds; + return _cachedViewport; } } @@ -134,7 +134,7 @@ public class LineCanvas : IDisposable Attribute? attribute = default ) { - _cachedBounds = Rectangle.Empty; + _cachedViewport = Rectangle.Empty; _lines.Add (new StraightLine (start, length, orientation, style, attribute)); } @@ -142,14 +142,14 @@ public class LineCanvas : IDisposable /// public void AddLine (StraightLine line) { - _cachedBounds = Rectangle.Empty; + _cachedViewport = Rectangle.Empty; _lines.Add (line); } /// Clears all lines from the LineCanvas. public void Clear () { - _cachedBounds = Rectangle.Empty; + _cachedViewport = Rectangle.Empty; _lines.Clear (); } @@ -157,7 +157,7 @@ public class LineCanvas : IDisposable /// Clears any cached states from the canvas Call this method if you make changes to lines that have already been /// added. /// - public void ClearCache () { _cachedBounds = Rectangle.Empty; } + public void ClearCache () { _cachedViewport = Rectangle.Empty; } /// /// Evaluates the lines that have been added to the canvas and returns a map containing the glyphs and their diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs index 86fc2ca85..cde82ce67 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -73,8 +73,8 @@ public class TextFormatter } /// - /// Determines if the bounds width will be used or only the text width will be used, - /// If all the bounds area will be filled with whitespaces and the same background color + /// Determines if the viewport width will be used or only the text width will be used, + /// If all the viewport area will be filled with whitespaces and the same background color /// showing a perfect rectangle. /// public bool FillRemaining { get; set; } @@ -202,17 +202,17 @@ public class TextFormatter /// Causes the text to be formatted (references ). Sets to /// false. /// - /// Specifies the screen-relative location and maximum size for drawing the text. + /// Specifies the screen-relative location and maximum size for drawing the text. /// The color to use for all text except the hotkey /// The color to use to draw the hotkey - /// Specifies the screen-relative location and maximum container size. + /// Specifies the screen-relative location and maximum container size. /// The console driver currently used by the application. /// public void Draw ( - Rectangle bounds, + Rectangle viewport, Attribute normalColor, Attribute hotColor, - Rectangle containerBounds = default, + Rectangle maximum = default, ConsoleDriver driver = null ) { @@ -240,24 +240,24 @@ public class TextFormatter } bool isVertical = IsVerticalDirection (Direction); - Rectangle maxBounds = bounds; + Rectangle maxBounds = viewport; if (driver is { }) { // INTENT: What, exactly, is the intent of this? - maxBounds = containerBounds == default (Rectangle) - ? bounds + maxBounds = maximum == default (Rectangle) + ? viewport : new ( - Math.Max (containerBounds.X, bounds.X), - Math.Max (containerBounds.Y, bounds.Y), + Math.Max (maximum.X, viewport.X), + Math.Max (maximum.Y, viewport.Y), Math.Max ( - Math.Min (containerBounds.Width, containerBounds.Right - bounds.Left), + Math.Min (maximum.Width, maximum.Right - viewport.Left), 0 ), Math.Max ( Math.Min ( - containerBounds.Height, - containerBounds.Bottom - bounds.Top + maximum.Height, + maximum.Bottom - viewport.Top ), 0 ) @@ -269,11 +269,11 @@ public class TextFormatter return; } - int lineOffset = !isVertical && bounds.Y < 0 ? Math.Abs (bounds.Y) : 0; + int lineOffset = !isVertical && viewport.Y < 0 ? Math.Abs (viewport.Y) : 0; for (int line = lineOffset; line < linesFormatted.Count; line++) { - if ((isVertical && line > bounds.Width) || (!isVertical && line > bounds.Height)) + if ((isVertical && line > viewport.Width) || (!isVertical && line > viewport.Height)) { continue; } @@ -305,14 +305,14 @@ public class TextFormatter if (isVertical) { int runesWidth = GetWidestLineLength (linesFormatted, line, TabWidth); - x = bounds.Right - runesWidth; - CursorPosition = bounds.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); + x = viewport.Right - runesWidth; + CursorPosition = viewport.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); } else { int runesWidth = StringExtensions.ToString (runes).GetColumns (); - x = bounds.Right - runesWidth; - CursorPosition = bounds.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); + x = viewport.Right - runesWidth; + CursorPosition = viewport.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); } } else if (Alignment is TextAlignment.Left or TextAlignment.Justified) @@ -322,11 +322,11 @@ public class TextFormatter int runesWidth = line > 0 ? GetWidestLineLength (linesFormatted, 0, line, TabWidth) : 0; - x = bounds.Left + runesWidth; + x = viewport.Left + runesWidth; } else { - x = bounds.Left; + x = viewport.Left; } CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; @@ -336,16 +336,16 @@ public class TextFormatter if (isVertical) { int runesWidth = GetWidestLineLength (linesFormatted, line, TabWidth); - x = bounds.Left + line + (bounds.Width - runesWidth) / 2; + x = viewport.Left + line + (viewport.Width - runesWidth) / 2; - CursorPosition = (bounds.Width - runesWidth) / 2 + (_hotKeyPos > -1 ? _hotKeyPos : 0); + CursorPosition = (viewport.Width - runesWidth) / 2 + (_hotKeyPos > -1 ? _hotKeyPos : 0); } else { int runesWidth = StringExtensions.ToString (runes).GetColumns (); - x = bounds.Left + (bounds.Width - runesWidth) / 2; + x = viewport.Left + (viewport.Width - runesWidth) / 2; - CursorPosition = (bounds.Width - runesWidth) / 2 + (_hotKeyPos > -1 ? _hotKeyPos : 0); + CursorPosition = (viewport.Width - runesWidth) / 2 + (_hotKeyPos > -1 ? _hotKeyPos : 0); } } else @@ -358,35 +358,35 @@ public class TextFormatter { if (isVertical) { - y = bounds.Bottom - runes.Length; + y = viewport.Bottom - runes.Length; } else { - y = bounds.Bottom - linesFormatted.Count + line; + y = viewport.Bottom - linesFormatted.Count + line; } } else if (VerticalAlignment is VerticalTextAlignment.Top or VerticalTextAlignment.Justified) { if (isVertical) { - y = bounds.Top; + y = viewport.Top; } else { - y = bounds.Top + line; + y = viewport.Top + line; } } else if (VerticalAlignment == VerticalTextAlignment.Middle) { if (isVertical) { - int s = (bounds.Height - runes.Length) / 2; - y = bounds.Top + s; + int s = (viewport.Height - runes.Length) / 2; + y = viewport.Top + s; } else { - int s = (bounds.Height - linesFormatted.Count) / 2; - y = bounds.Top + line + s; + int s = (viewport.Height - linesFormatted.Count) / 2; + y = viewport.Top + line + s; } } else @@ -394,9 +394,9 @@ public class TextFormatter throw new ArgumentOutOfRangeException ($"{nameof (VerticalAlignment)}"); } - int colOffset = bounds.X < 0 ? Math.Abs (bounds.X) : 0; - int start = isVertical ? bounds.Top : bounds.Left; - int size = isVertical ? bounds.Height : bounds.Width; + int colOffset = viewport.X < 0 ? Math.Abs (viewport.X) : 0; + int start = isVertical ? viewport.Top : viewport.Left; + int size = isVertical ? viewport.Height : viewport.Width; int current = start + colOffset; List lastZeroWidthPos = null; Rune rune = default; @@ -422,15 +422,15 @@ public class TextFormatter break; } - if ((!isVertical && current - start > maxBounds.Left + maxBounds.Width - bounds.X + colOffset) - || (isVertical && idx > maxBounds.Top + maxBounds.Height - bounds.Y)) + if ((!isVertical && current - start > maxBounds.Left + maxBounds.Width - viewport.X + colOffset) + || (isVertical && idx > maxBounds.Top + maxBounds.Height - viewport.Y)) { break; } } - //if ((!isVertical && idx > maxBounds.Left + maxBounds.Width - bounds.X + colOffset) - // || (isVertical && idx > maxBounds.Top + maxBounds.Height - bounds.Y)) + //if ((!isVertical && idx > maxBounds.Left + maxBounds.Width - viewport.X + colOffset) + // || (isVertical && idx > maxBounds.Top + maxBounds.Height - viewport.Y)) // break; diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index 785f72782..56900f3ec 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -146,7 +146,7 @@ public class Adornment : View return; } - Rectangle screenBounds = BoundsToScreen (contentArea); + Rectangle screenBounds = ViewportToScreen (contentArea); Attribute normalAttr = GetNormalColor (); Driver.SetAttribute (normalAttr); @@ -297,7 +297,7 @@ public class Adornment : View _dragPosition = new Point (mouseEvent.X, mouseEvent.Y); - Point parentLoc = Parent.SuperView?.ScreenToBounds (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y) ?? mouseEvent.ScreenPosition; + Point parentLoc = Parent.SuperView?.ScreenToViewport (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y) ?? mouseEvent.ScreenPosition; GetLocationEnsuringFullVisibility ( Parent, diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index 23174acb3..54692d594 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -194,7 +194,7 @@ public class Border : Adornment } //Driver.SetAttribute (Colors.ColorSchemes ["Error"].Normal); - Rectangle screenBounds = BoundsToScreen (contentArea); + Rectangle screenBounds = ViewportToScreen (contentArea); //OnDrawSubviews (bounds); diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 057dcf56c..838127c45 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -101,10 +101,10 @@ public partial class View return ret; } - Point boundsOffset = super.GetBoundsOffset (); - boundsOffset.Offset(super.Frame.X, super.Frame.Y); - ret.X += boundsOffset.X; - ret.Y += boundsOffset.Y; + Point viewportOffset = super.GetViewportOffset (); + viewportOffset.Offset(super.Frame.X, super.Frame.Y); + ret.X += viewportOffset.X; + ret.Y += viewportOffset.Y; super = super.SuperView; } @@ -120,7 +120,7 @@ public partial class View /// Screen-relative row. public virtual Point ScreenToFrame (int x, int y) { - Point superViewBoundsOffset = SuperView?.GetBoundsOffset () ?? Point.Empty; + Point superViewBoundsOffset = SuperView?.GetViewportOffset () ?? Point.Empty; if (SuperView is null) { superViewBoundsOffset.Offset (x - Frame.X, y - Frame.Y); @@ -287,10 +287,12 @@ public partial class View #region Viewport /// - /// The bounds represent the View-relative rectangle used for this view; the area inside the view where - /// subviews and content are presented. + /// The viewport represents the location and size of the View's content that can be seen by the end-user at a given time. + /// The location is specified in coordinates relative to the top-left corner of the area of the View within the + /// , and and is normally 0, 0. Non-zero + /// values for the location indicate the visible area is offset into the View's virtual . /// - /// The rectangle describing the location and size of the area where the views' subviews and content are drawn. + /// The rectangle describing the location and size of the area where the views' subviews and content are visible. /// /// /// If is the value of Viewport is indeterminate until @@ -298,18 +300,13 @@ public partial class View /// called. /// /// - /// Updates to the Viewport updates , and has the same effect as updating the + /// Updates to the Viewport size updates , and has the same effect as updating the /// . /// /// - /// Altering the Viewport will eventually (when the view is next laid out) cause the + /// Altering the Viewport size will eventually (when the view is next laid out) cause the /// and methods to be called. /// - /// - /// Because coordinates are relative to the upper-left corner of the , the - /// coordinates of the upper-left corner of the rectangle returned by this property are (0,0). Use this property to - /// obtain the size of the area of the view for tasks such as drawing the view's contents. - /// /// public virtual Rectangle Viewport { @@ -363,25 +360,25 @@ public partial class View } /// Converts a -relative rectangle to a screen-relative rectangle. - public Rectangle BoundsToScreen (in Rectangle bounds) + public Rectangle ViewportToScreen (in Rectangle bounds) { // Translate bounds to Frame (our SuperView's Viewport-relative coordinates) Rectangle screen = FrameToScreen (); - Point boundsOffset = GetBoundsOffset (); - screen.Offset (boundsOffset.X + bounds.X, boundsOffset.Y + bounds.Y); + Point viewportOffset = GetViewportOffset (); + screen.Offset (viewportOffset.X + bounds.X, viewportOffset.Y + bounds.Y); return new (screen.Location, bounds.Size); } - /// Converts a screen-relative coordinate to a bounds-relative coordinate. + /// Converts a screen-relative coordinate to a Viewport-relative coordinate. /// The coordinate relative to this view's . /// Screen-relative column. /// Screen-relative row. - public Point ScreenToBounds (int x, int y) + public Point ScreenToViewport (int x, int y) { - Point boundsOffset = GetBoundsOffset (); + Point viewportOffset = GetViewportOffset (); Point screen = ScreenToFrame (x, y); - screen.Offset (-boundsOffset.X, -boundsOffset.Y); + screen.Offset (-viewportOffset.X, -viewportOffset.Y); return screen; } @@ -390,7 +387,7 @@ public partial class View /// Helper to get the X and Y offset of the Viewport from the Frame. This is the sum of the Left and Top properties /// of , and . /// - public Point GetBoundsOffset () { return Padding is null ? Point.Empty : Padding.Thickness.GetInside (Padding.Frame).Location; } + public Point GetViewportOffset () { return Padding is null ? Point.Empty : Padding.Thickness.GetInside (Padding.Frame).Location; } #endregion Viewport @@ -698,18 +695,18 @@ public partial class View found = start.Padding; } - Point boundsOffset = start.GetBoundsOffset (); + Point viewportOffset = start.GetViewportOffset (); if (found is { }) { start = found; - boundsOffset = found.Parent.Frame.Location; + viewportOffset = found.Parent.Frame.Location; } if (start.InternalSubviews is { Count: > 0 }) { - int startOffsetX = x - (start.Frame.X + boundsOffset.X); - int startOffsetY = y - (start.Frame.Y + boundsOffset.Y); + int startOffsetX = x - (start.Frame.X + viewportOffset.X); + int startOffsetY = y - (start.Frame.Y + viewportOffset.Y); for (int i = start.InternalSubviews.Count - 1; i >= 0; i--) { @@ -925,7 +922,7 @@ public partial class View foreach (View v in ordered) { - LayoutSubview (v, new (GetBoundsOffset (), Viewport.Size)); + LayoutSubview (v, new (GetViewportOffset (), Viewport.Size)); } // If the 'to' is rooted to 'from' and the layoutstyle is Computed it's a special-case. diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 284db73c6..911a745db 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -98,7 +98,7 @@ public partial class View // Clamp the region to the bounds of the view contentArea = Rectangle.Intersect (contentArea, Viewport); - Driver.FillRect (BoundsToScreen (contentArea)); + Driver.FillRect (ViewportToScreen (contentArea)); Driver.SetAttribute (prev); } @@ -113,7 +113,7 @@ public partial class View /// . /// /// - public Rectangle ClipToBounds () + public Rectangle ClipToViewport () { if (Driver is null) { @@ -121,7 +121,7 @@ public partial class View } Rectangle previous = Driver.Clip; - Driver.Clip = Rectangle.Intersect (previous, BoundsToScreen (Viewport)); + Driver.Clip = Rectangle.Intersect (previous, ViewportToScreen (Viewport)); return previous; } @@ -153,7 +153,7 @@ public partial class View OnDrawAdornments (); - Rectangle prevClip = ClipToBounds (); + Rectangle prevClip = ClipToViewport (); if (ColorScheme is { }) { @@ -326,7 +326,7 @@ public partial class View return; } - Rectangle screen = BoundsToScreen (new (col, row, 0, 0)); + Rectangle screen = ViewportToScreen (new (col, row, 0, 0)); Driver?.Move (screen.X, screen.Y); } @@ -354,18 +354,18 @@ public partial class View } /// Enables overrides to draw infinitely scrolled content and/or a background behind added controls. - /// + /// /// The view-relative rectangle describing the currently visible viewport into the /// /// /// This method will be called before any subviews added with have been drawn. - public virtual void OnDrawContent (Rectangle contentArea) + public virtual void OnDrawContent (Rectangle viewport) { if (NeedsDisplay) { if (SuperView is { }) { - Clear (contentArea); + Clear (viewport); } if (!string.IsNullOrEmpty (TextFormatter.Text)) @@ -378,7 +378,7 @@ public partial class View // This should NOT clear TextFormatter?.Draw ( - BoundsToScreen (contentArea), + ViewportToScreen (viewport), HasFocus ? GetFocusColor () : GetNormalColor (), HasFocus ? ColorScheme.HotFocus : GetHotNormalColor (), Rectangle.Empty @@ -418,7 +418,7 @@ public partial class View /// Enables overrides after completed drawing infinitely scrolled content and/or a background behind removed /// controls. /// - /// + /// /// The view-relative rectangle describing the currently visible viewport into the /// /// @@ -426,7 +426,7 @@ public partial class View /// This method will be called after any subviews removed with have been completed /// drawing. /// - public virtual void OnDrawContentComplete (Rectangle contentArea) { DrawContentComplete?.Invoke (this, new (contentArea)); } + public virtual void OnDrawContentComplete (Rectangle viewport) { DrawContentComplete?.Invoke (this, new (viewport)); } // TODO: Make this cancelable /// @@ -558,22 +558,4 @@ public partial class View _needsDisplayRect = Rectangle.Empty; SubViewNeedsDisplay = false; } - - // INTENT: Isn't this just intersection? It isn't used anyway. - // Clips a rectangle in screen coordinates to the dimensions currently available on the screen - internal Rectangle ScreenClip (Rectangle regionScreen) - { - int x = regionScreen.X < 0 ? 0 : regionScreen.X; - int y = regionScreen.Y < 0 ? 0 : regionScreen.Y; - - int w = regionScreen.X + regionScreen.Width >= Driver.Cols - ? Driver.Cols - regionScreen.X - : regionScreen.Width; - - int h = regionScreen.Y + regionScreen.Height >= Driver.Rows - ? Driver.Rows - regionScreen.Y - : regionScreen.Height; - - return new (x, y, w, h); - } } diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index a08e1a361..188c8dab1 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -494,7 +494,7 @@ public class ComboBox : View _listview.Clear (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty); _listview.TabStop = false; SuperView?.SendSubviewToBack (this); - Rectangle rect = _listview.BoundsToScreen (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty); + Rectangle rect = _listview.ViewportToScreen (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty); SuperView?.SetNeedsDisplay (rect); OnCollapsed (); } diff --git a/Terminal.Gui/Views/Line.cs b/Terminal.Gui/Views/Line.cs index 9fe92ae7a..ffc6224d4 100644 --- a/Terminal.Gui/Views/Line.cs +++ b/Terminal.Gui/Views/Line.cs @@ -26,7 +26,7 @@ public class Line : View lc = adornment.Parent.LineCanvas; } lc.AddLine ( - BoundsToScreen (contentArea).Location, + ViewportToScreen (contentArea).Location, Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height, Orientation, BorderStyle diff --git a/Terminal.Gui/Views/Menu/ContextMenu.cs b/Terminal.Gui/Views/Menu/ContextMenu.cs index 4fa133164..6ee004f1b 100644 --- a/Terminal.Gui/Views/Menu/ContextMenu.cs +++ b/Terminal.Gui/Views/Menu/ContextMenu.cs @@ -147,7 +147,7 @@ public sealed class ContextMenu : IDisposable if (Host is { }) { - Point pos = Host.BoundsToScreen (frame).Location; + Point pos = Host.ViewportToScreen (frame).Location; pos.Y += Host.Frame.Height - 1; if (position != pos) @@ -184,7 +184,7 @@ public sealed class ContextMenu : IDisposable } else { - Point pos = Host.BoundsToScreen (frame).Location; + Point pos = Host.ViewportToScreen (frame).Location; position.Y = pos.Y - rect.Height - 1; } } diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 65a3081d5..9eb743409 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -724,7 +724,7 @@ internal sealed class Menu : View throw new InvalidOperationException ("This shouldn't running on a invisible menu!"); } - Point boundsPoint = ScreenToBounds (a.MouseEvent.X, a.MouseEvent.Y); + Point boundsPoint = ScreenToViewport (a.MouseEvent.X, a.MouseEvent.Y); var me = new MouseEvent { X = boundsPoint.X, @@ -776,7 +776,7 @@ internal sealed class Menu : View continue; } - if (BoundsToScreen (Viewport).Y + i >= Driver.Rows) + if (ViewportToScreen (Viewport).Y + i >= Driver.Rows) { break; } @@ -808,7 +808,7 @@ internal sealed class Menu : View continue; } - if (BoundsToScreen (Viewport).X + p >= Driver.Cols) + if (ViewportToScreen (Viewport).X + p >= Driver.Cols) { break; } @@ -873,7 +873,7 @@ internal sealed class Menu : View textToDraw = item.Title; } - Rectangle screen = BoundsToScreen (new (new (0 , i), Size.Empty)); + Rectangle screen = ViewportToScreen (new (new (0 , i), Size.Empty)); if (screen.X < Driver.Cols) { Driver.Move (screen.X + 1, screen.Y); @@ -891,10 +891,10 @@ internal sealed class Menu : View // The -3 is left/right border + one space (not sure what for) tf.Draw ( - BoundsToScreen (new (1, i, Frame.Width - 3, 1)), + ViewportToScreen (new (1, i, Frame.Width - 3, 1)), i == _currentChild ? ColorScheme.Focus : GetNormalColor (), i == _currentChild ? ColorScheme.HotFocus : ColorScheme.HotNormal, - SuperView?.BoundsToScreen (SuperView.Viewport) ?? Rectangle.Empty + SuperView?.ViewportToScreen (SuperView.Viewport) ?? Rectangle.Empty ); } else @@ -911,7 +911,7 @@ internal sealed class Menu : View ? item.Help.GetColumns () : item.Help.GetColumns () + item.ShortcutTag.GetColumns () + 2; int col = Frame.Width - l - 3; - screen = BoundsToScreen (new (new (col, i), Size.Empty)); + screen = ViewportToScreen (new (new (col, i), Size.Empty)); if (screen.X < Driver.Cols) { diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index 1abe33e82..6266ec41f 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -827,11 +827,11 @@ public class MenuBar : View Rectangle superViewFrame = SuperView is null ? Driver.Viewport : SuperView.Frame; View sv = SuperView is null ? Application.Current : SuperView; - Point boundsOffset = sv.GetBoundsOffset (); + Point viewportOffset = sv.GetViewportOffset (); return new ( - superViewFrame.X - sv.Frame.X - boundsOffset.X, - superViewFrame.Y - sv.Frame.Y - boundsOffset.Y + superViewFrame.X - sv.Frame.X - viewportOffset.X, + superViewFrame.Y - sv.Frame.Y - viewportOffset.Y ); } @@ -844,9 +844,9 @@ public class MenuBar : View { Rectangle screen = Driver.Viewport; Rectangle currentFrame = Application.Current.Frame; - Point boundsOffset = Application.Top.GetBoundsOffset (); + Point viewportOffset = Application.Top.GetViewportOffset (); - return new (screen.X - currentFrame.X - boundsOffset.X, screen.Y - currentFrame.Y - boundsOffset.Y); + return new (screen.X - currentFrame.X - viewportOffset.X, screen.Y - currentFrame.Y - viewportOffset.Y); } internal void NextMenu (bool isSubMenu = false, bool ignoreUseSubMenusSingleFrame = false) @@ -1320,7 +1320,7 @@ public class MenuBar : View if (mi.IsTopLevel) { - Rectangle screen = BoundsToScreen (new (new (0, i), Size.Empty)); + Rectangle screen = ViewportToScreen (new (new (0, i), Size.Empty)); var menu = new Menu { Host = this, X = screen.X, Y = screen.Y, BarItems = mi }; menu.Run (mi.Action); menu.Dispose (); @@ -1684,7 +1684,7 @@ public class MenuBar : View { if (Menus [i].IsTopLevel) { - Rectangle screen = BoundsToScreen (new (new (0, i), Size.Empty)); + Rectangle screen = ViewportToScreen (new (new (0, i), Size.Empty)); var menu = new Menu { Host = this, X = screen.X, Y = screen.Y, BarItems = Menus [i] }; menu.Run (Menus [i].Action); menu.Dispose (); diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 65bbb616a..4d25b9f8a 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -190,10 +190,10 @@ public class ProgressBar : View } tf?.Draw ( - BoundsToScreen (Viewport), + ViewportToScreen (Viewport), attr, ColorScheme.Normal, - SuperView?.BoundsToScreen (SuperView.Viewport) ?? default (Rectangle) + SuperView?.ViewportToScreen (SuperView.Viewport) ?? default (Rectangle) ); } } diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs index ddeede202..89bb19a79 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -339,7 +339,7 @@ public class ScrollView : View { SetViewsNeedsDisplay (); - Rectangle savedClip = ClipToBounds (); + Rectangle savedClip = ClipToViewport (); // TODO: It's bad practice for views to always clear a view. It negates clipping. Clear (contentArea); diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 7ff5eca7d..8e811fa75 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -317,7 +317,7 @@ public class TabView : View if (Tabs.Any ()) { - Rectangle savedClip = ClipToBounds (); + Rectangle savedClip = ClipToViewport (); _tabsBar.OnDrawContent (contentArea); _contentView.SetNeedsDisplay (); _contentView.Draw (); @@ -683,7 +683,7 @@ public class TabView : View for (var i = 0; i < tabLocations.Length; i++) { View tab = tabLocations [i].Tab; - Rectangle vts = tab.BoundsToScreen (tab.Viewport); + Rectangle vts = tab.ViewportToScreen (tab.Viewport); var lc = new LineCanvas (); int selectedOffset = _host.Style.ShowTopLine && tabLocations [i].IsSelected ? 0 : 1; @@ -1115,7 +1115,7 @@ public class TabView : View int lastSelectedTab = !_host.Style.ShowTopLine && i == selectedTab ? 1 : _host.Style.TabsOnBottom ? 1 : 0; - Rectangle tabsBarVts = BoundsToScreen (Viewport); + Rectangle tabsBarVts = ViewportToScreen (Viewport); int lineLength = tabsBarVts.Right - vts.Right; // Right horizontal line @@ -1314,7 +1314,7 @@ public class TabView : View } tab.TextFormatter.Draw ( - tab.BoundsToScreen (tab.Viewport), + tab.ViewportToScreen (tab.Viewport), prevAttr, ColorScheme.HotNormal ); diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index e3e0f56f1..5697da185 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -1196,8 +1196,8 @@ public class TextField : View int pos = _cursorPosition - ScrollOffset + Math.Min (Frame.X, 0); int offB = OffSetBackground (); - Rectangle containerFrame = SuperView?.BoundsToScreen (SuperView.Viewport) ?? default (Rectangle); - Rectangle thisFrame = BoundsToScreen (Viewport); + Rectangle containerFrame = SuperView?.ViewportToScreen (SuperView.Viewport) ?? default (Rectangle); + Rectangle thisFrame = ViewportToScreen (Viewport); if (pos > -1 && col >= pos diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 593882052..1344b2d4b 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -217,7 +217,7 @@ public class TileView : View { bool isRoot = _splitterLines.Contains (line); - Rectangle screen = line.BoundsToScreen (Rectangle.Empty); + Rectangle screen = line.ViewportToScreen (Rectangle.Empty); Point origin = ScreenToFrame (screen.X, screen.Y); int length = line.Orientation == Orientation.Horizontal ? line.Frame.Width : line.Frame.Height; @@ -837,7 +837,7 @@ public class TileView : View /// public Point GetLocalCoordinateForTitle (TileView intoCoordinateSpace) { - Rectangle screen = Tile.ContentView.BoundsToScreen (Rectangle.Empty); + Rectangle screen = Tile.ContentView.ViewportToScreen (Rectangle.Empty); return intoCoordinateSpace.ScreenToFrame (screen.X, screen.Y - 1); } diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 424de7882..2d6d814fc 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -564,7 +564,7 @@ internal class CharMap : ScrollView ) ); - Rectangle oldClip = ClipToBounds (); + Rectangle oldClip = ClipToViewport (); if (ShowHorizontalScrollIndicator) { diff --git a/UICatalog/Scenarios/Notepad.cs b/UICatalog/Scenarios/Notepad.cs index 85aa23f30..d1928b0b4 100644 --- a/UICatalog/Scenarios/Notepad.cs +++ b/UICatalog/Scenarios/Notepad.cs @@ -350,7 +350,7 @@ public class Notepad : Scenario ); } - Rectangle screen = ((View)sender).BoundsToScreen (new (e.MouseEvent.X, e.MouseEvent.Y, 0, 0)); + Rectangle screen = ((View)sender).ViewportToScreen (new (e.MouseEvent.X, e.MouseEvent.Y, 0, 0)); var contextMenu = new ContextMenu { Position = screen.Location, MenuItems = items }; diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index 8fe1a5503..4fb593471 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -223,8 +223,8 @@ public class ViewExperiments : Scenario view.Frame } .Viewport: { view.Viewport - } .BoundsOffset: { - view.GetBoundsOffset () + } .viewportOffset: { + view.GetViewportOffset () }\n .Padding.Frame: { view.Padding.Frame } .Padding.Viewport: { diff --git a/UnitTests/View/Adornment/AdornmentTests.cs b/UnitTests/View/Adornment/AdornmentTests.cs index 8d8752742..199636d71 100644 --- a/UnitTests/View/Adornment/AdornmentTests.cs +++ b/UnitTests/View/Adornment/AdornmentTests.cs @@ -105,7 +105,7 @@ public class AdornmentTests (ITestOutputHelper output) Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Margin.Viewport); Assert.Null (parent.Margin.SuperView); - Rectangle boundsAsScreen = parent.Margin.BoundsToScreen (new Rectangle (1, 2, 5, 5)); + Rectangle boundsAsScreen = parent.Margin.ViewportToScreen (new Rectangle (1, 2, 5, 5)); Assert.Equal (new Rectangle (2, 4, 5, 5), boundsAsScreen); } diff --git a/UnitTests/View/Adornment/ToScreenTests.cs b/UnitTests/View/Adornment/ToScreenTests.cs index 518b38f76..4a550f7c7 100644 --- a/UnitTests/View/Adornment/ToScreenTests.cs +++ b/UnitTests/View/Adornment/ToScreenTests.cs @@ -3,7 +3,7 @@ namespace Terminal.Gui.ViewTests; /// -/// Test the and methods. +/// Test the and methods. /// DOES NOT TEST View.xxxToScreen methods. Those are in ./View/Layout/ToScreenTests.cs /// /// @@ -251,9 +251,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output) view.Frame = frame; // Act - var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); - var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0)); - var paddingScreen = view.Padding.BoundsToScreen (new (boundsX, 0, 0, 0)); + var marginScreen = view.Margin.ViewportToScreen (new (boundsX, 0, 0, 0)); + var borderScreen = view.Border.ViewportToScreen (new (boundsX, 0, 0, 0)); + var paddingScreen = view.Padding.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, marginScreen.X); @@ -292,9 +292,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output) Assert.Equal(4, view.Viewport.Width); // Act - var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); - var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0)); - var paddingScreen = view.Padding.BoundsToScreen (new (boundsX, 0, 0, 0)); + var marginScreen = view.Margin.ViewportToScreen (new (boundsX, 0, 0, 0)); + var borderScreen = view.Border.ViewportToScreen (new (boundsX, 0, 0, 0)); + var paddingScreen = view.Padding.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, marginScreen.X); @@ -338,9 +338,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); - var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0)); - var paddingScreen = view.Padding.BoundsToScreen (new (boundsX, 0, 0, 0)); + var marginScreen = view.Margin.ViewportToScreen (new (boundsX, 0, 0, 0)); + var borderScreen = view.Border.ViewportToScreen (new (boundsX, 0, 0, 0)); + var paddingScreen = view.Padding.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, marginScreen.X); @@ -385,9 +385,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); - var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0)); - var paddingScreen = view.Padding.BoundsToScreen (new (boundsX, 0, 0, 0)); + var marginScreen = view.Margin.ViewportToScreen (new (boundsX, 0, 0, 0)); + var borderScreen = view.Border.ViewportToScreen (new (boundsX, 0, 0, 0)); + var paddingScreen = view.Padding.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, marginScreen.X); @@ -441,9 +441,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); - var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0)); - var paddingScreen = view.Padding.BoundsToScreen (new (boundsX, 0, 0, 0)); + var marginScreen = view.Margin.ViewportToScreen (new (boundsX, 0, 0, 0)); + var borderScreen = view.Border.ViewportToScreen (new (boundsX, 0, 0, 0)); + var paddingScreen = view.Padding.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, marginScreen.X); @@ -502,9 +502,9 @@ public class AdornmentToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); - var borderScreen = view.Border.BoundsToScreen (new (boundsX, 0, 0, 0)); - var paddingScreen = view.Padding.BoundsToScreen (new (boundsX, 0, 0, 0)); + var marginScreen = view.Margin.ViewportToScreen (new (boundsX, 0, 0, 0)); + var borderScreen = view.Border.ViewportToScreen (new (boundsX, 0, 0, 0)); + var paddingScreen = view.Padding.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, marginScreen.X); diff --git a/UnitTests/View/Layout/ScreenToTests.cs b/UnitTests/View/Layout/ScreenToTests.cs index 6295417a4..b7a54aa33 100644 --- a/UnitTests/View/Layout/ScreenToTests.cs +++ b/UnitTests/View/Layout/ScreenToTests.cs @@ -32,7 +32,7 @@ public class ScreenToTests BorderStyle = LineStyle.Single }; - Point actual = view.ScreenToBounds (x, y); + Point actual = view.ScreenToViewport (x, y); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -54,7 +54,7 @@ public class ScreenToTests { var view = new View { X = viewX, Y = viewY, Width = 10, Height = 10 }; - Point actual = view.ScreenToBounds (x, y); + Point actual = view.ScreenToViewport (x, y); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -103,7 +103,7 @@ public class ScreenToTests var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 }; super.Add (view); - Point actual = view.ScreenToBounds (x, y); + Point actual = view.ScreenToViewport (x, y); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } diff --git a/UnitTests/View/Layout/ToScreenTests.cs b/UnitTests/View/Layout/ToScreenTests.cs index a31715776..057dcf585 100644 --- a/UnitTests/View/Layout/ToScreenTests.cs +++ b/UnitTests/View/Layout/ToScreenTests.cs @@ -3,7 +3,7 @@ namespace Terminal.Gui.ViewTests; /// -/// Test the and methods. +/// Test the and methods. /// DOES NOT TEST Adornment.xxxToScreen methods. Those are in ./Adornment/ToScreenTests.cs /// /// @@ -222,7 +222,7 @@ public class ToScreenTests (ITestOutputHelper output) view.Frame = frame; // Act - var screen = view.BoundsToScreen (new (boundsX, 0, 0, 0)); + var screen = view.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, screen.X); @@ -254,7 +254,7 @@ public class ToScreenTests (ITestOutputHelper output) view.Frame = frame; // Act - var screen = view.BoundsToScreen (new (boundsX, 0, 0, 0)); + var screen = view.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, screen.X); @@ -296,7 +296,7 @@ public class ToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var screen = view.BoundsToScreen (new (boundsX, 0, 0, 0)); + var screen = view.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, screen.X); @@ -339,7 +339,7 @@ public class ToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var screen = view.BoundsToScreen (new (boundsX, 0, 0, 0)); + var screen = view.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, screen.X); @@ -391,7 +391,7 @@ public class ToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var screen = view.BoundsToScreen (new (boundsX, 0, 0, 0)); + var screen = view.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, screen.X); @@ -445,7 +445,7 @@ public class ToScreenTests (ITestOutputHelper output) superView.LayoutSubviews (); // Act - var screen = view.BoundsToScreen (new (boundsX, 0, 0, 0)); + var screen = view.ViewportToScreen (new (boundsX, 0, 0, 0)); // Assert Assert.Equal (expectedX, screen.X); diff --git a/UnitTests/View/NavigationTests.cs b/UnitTests/View/NavigationTests.cs index 7df35b0e3..efbc41a49 100644 --- a/UnitTests/View/NavigationTests.cs +++ b/UnitTests/View/NavigationTests.cs @@ -841,19 +841,19 @@ public class NavigationTests // top Assert.Equal (Point.Empty, top.ScreenToFrame (0, 0)); - Rectangle screen = top.Margin.BoundsToScreen (new (0, 0, 0, 0)); + Rectangle screen = top.Margin.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); - screen = top.Border.BoundsToScreen (new (0, 0, 0, 0)); + screen = top.Border.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); - screen = top.Padding.BoundsToScreen (new (0, 0, 0, 0)); + screen = top.Padding.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = top.BoundsToScreen (new (0, 0, 0, 0)); + screen = top.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = top.BoundsToScreen (new (-1, -1, 0, 0)); + screen = top.ViewportToScreen (new (-1, -1, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); var found = View.FindDeepestView (top, 0, 0); @@ -862,7 +862,7 @@ public class NavigationTests Assert.Equal (0, found.Frame.X); Assert.Equal (0, found.Frame.Y); Assert.Equal (new Point (3, 2), top.ScreenToFrame (3, 2)); - screen = top.BoundsToScreen (new (3, 2, 0, 0)); + screen = top.ViewportToScreen (new (3, 2, 0, 0)); Assert.Equal (4, screen.X); Assert.Equal (3, screen.Y); found = View.FindDeepestView (top, screen.X, screen.Y); @@ -874,14 +874,14 @@ public class NavigationTests //Assert.Equal (3, found.FrameToScreen ().X); //Assert.Equal (2, found.FrameToScreen ().Y); Assert.Equal (new Point (13, 2), top.ScreenToFrame (13, 2)); - screen = top.BoundsToScreen (new (12, 2, 0, 0)); + screen = top.ViewportToScreen (new (12, 2, 0, 0)); Assert.Equal (13, screen.X); Assert.Equal (3, screen.Y); found = View.FindDeepestView (top, screen.X, screen.Y); Assert.Equal (view, found); //Assert.Equal (9, found.FrameToScreen ().X); //Assert.Equal (0, found.FrameToScreen ().Y); - screen = top.BoundsToScreen (new (13, 2, 0, 0)); + screen = top.ViewportToScreen (new (13, 2, 0, 0)); Assert.Equal (14, screen.X); Assert.Equal (3, screen.Y); found = View.FindDeepestView (top, 13, 2); @@ -889,7 +889,7 @@ public class NavigationTests //Assert.Equal (13, found.FrameToScreen ().X); //Assert.Equal (2, found.FrameToScreen ().Y); Assert.Equal (new Point (14, 3), top.ScreenToFrame (14, 3)); - screen = top.BoundsToScreen (new (14, 3, 0, 0)); + screen = top.ViewportToScreen (new (14, 3, 0, 0)); Assert.Equal (15, screen.X); Assert.Equal (4, screen.Y); found = View.FindDeepestView (top, 14, 3); @@ -899,40 +899,40 @@ public class NavigationTests // view Assert.Equal (new Point (-4, -3), view.ScreenToFrame (0, 0)); - screen = view.Margin.BoundsToScreen (new (-3, -2, 0, 0)); + screen = view.Margin.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.Border.BoundsToScreen (new (-3, -2, 0, 0)); + screen = view.Border.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.Padding.BoundsToScreen (new (-3, -2, 0, 0)); + screen = view.Padding.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.BoundsToScreen (new (-3, -2, 0, 0)); + screen = view.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.BoundsToScreen (new (-4, -3, 0, 0)); + screen = view.ViewportToScreen (new (-4, -3, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); found = View.FindDeepestView (top, 0, 0); Assert.Equal (top.Border, found); Assert.Equal (new Point (-1, -1), view.ScreenToFrame (3, 2)); - screen = view.BoundsToScreen (new (0, 0, 0, 0)); + screen = view.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (4, screen.X); Assert.Equal (3, screen.Y); found = View.FindDeepestView (top, 4, 3); Assert.Equal (view, found); Assert.Equal (new Point (9, -1), view.ScreenToFrame (13, 2)); - screen = view.BoundsToScreen (new (10, 0, 0, 0)); + screen = view.ViewportToScreen (new (10, 0, 0, 0)); Assert.Equal (14, screen.X); Assert.Equal (3, screen.Y); found = View.FindDeepestView (top, 14, 3); Assert.Equal (top, found); Assert.Equal (new Point (10, 0), view.ScreenToFrame (14, 3)); - screen = view.BoundsToScreen (new (11, 1, 0, 0)); + screen = view.ViewportToScreen (new (11, 1, 0, 0)); Assert.Equal (15, screen.X); Assert.Equal (4, screen.Y); found = View.FindDeepestView (top, 15, 4); @@ -995,80 +995,80 @@ public class NavigationTests // top Assert.Equal (new Point (-3, -2), top.ScreenToFrame (0, 0)); - Rectangle screen = top.Margin.BoundsToScreen (new (-3, -2, 0, 0)); + Rectangle screen = top.Margin.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); - screen = top.Border.BoundsToScreen (new (-3, -2, 0, 0)); + screen = top.Border.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); - screen = top.Padding.BoundsToScreen (new (-3, -2, 0, 0)); + screen = top.Padding.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = top.BoundsToScreen (new (-3, -2, 0, 0)); + screen = top.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = top.BoundsToScreen (new (-4, -3, 0, 0)); + screen = top.ViewportToScreen (new (-4, -3, 0, 0)); Assert.Equal (0, screen.X); Assert.Equal (0, screen.Y); var found = View.FindDeepestView (top, -4, -3); Assert.Null (found); Assert.Equal (Point.Empty, top.ScreenToFrame (3, 2)); - screen = top.BoundsToScreen (new (0, 0, 0, 0)); + screen = top.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (4, screen.X); Assert.Equal (3, screen.Y); Assert.Equal (top.Border, View.FindDeepestView (top, 3, 2)); //Assert.Equal (0, found.FrameToScreen ().X); //Assert.Equal (0, found.FrameToScreen ().Y); Assert.Equal (new Point (10, 0), top.ScreenToFrame (13, 2)); - screen = top.BoundsToScreen (new (10, 0, 0, 0)); + screen = top.ViewportToScreen (new (10, 0, 0, 0)); Assert.Equal (14, screen.X); Assert.Equal (3, screen.Y); Assert.Equal (top.Border, View.FindDeepestView (top, 13, 2)); //Assert.Equal (10, found.FrameToScreen ().X); //Assert.Equal (0, found.FrameToScreen ().Y); Assert.Equal (new Point (11, 1), top.ScreenToFrame (14, 3)); - screen = top.BoundsToScreen (new (11, 1, 0, 0)); + screen = top.ViewportToScreen (new (11, 1, 0, 0)); Assert.Equal (15, screen.X); Assert.Equal (4, screen.Y); Assert.Equal (top, View.FindDeepestView (top, 14, 3)); // view Assert.Equal (new Point (-7, -5), view.ScreenToFrame (0, 0)); - screen = view.Margin.BoundsToScreen (new (-6, -4, 0, 0)); + screen = view.Margin.ViewportToScreen (new (-6, -4, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.Border.BoundsToScreen (new (-6, -4, 0, 0)); + screen = view.Border.ViewportToScreen (new (-6, -4, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.Padding.BoundsToScreen (new (-6, -4, 0, 0)); + screen = view.Padding.ViewportToScreen (new (-6, -4, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); - screen = view.BoundsToScreen (new (-6, -4, 0, 0)); + screen = view.ViewportToScreen (new (-6, -4, 0, 0)); Assert.Equal (1, screen.X); Assert.Equal (1, screen.Y); Assert.Null (View.FindDeepestView (top, 1, 1)); Assert.Equal (new Point (-4, -3), view.ScreenToFrame (3, 2)); - screen = view.BoundsToScreen (new (-3, -2, 0, 0)); + screen = view.ViewportToScreen (new (-3, -2, 0, 0)); Assert.Equal (4, screen.X); Assert.Equal (3, screen.Y); Assert.Equal (top, View.FindDeepestView (top, 4, 3)); Assert.Equal (new Point (-1, -1), view.ScreenToFrame (6, 4)); - screen = view.BoundsToScreen (new (0, 0, 0, 0)); + screen = view.ViewportToScreen (new (0, 0, 0, 0)); Assert.Equal (7, screen.X); Assert.Equal (5, screen.Y); Assert.Equal (view, View.FindDeepestView (top, 7, 5)); Assert.Equal (new Point (6, -1), view.ScreenToFrame (13, 4)); - screen = view.BoundsToScreen (new (7, 0, 0, 0)); + screen = view.ViewportToScreen (new (7, 0, 0, 0)); Assert.Equal (14, screen.X); Assert.Equal (5, screen.Y); Assert.Equal (view, View.FindDeepestView (top, 14, 5)); Assert.Equal (new Point (7, -2), view.ScreenToFrame (14, 3)); - screen = view.BoundsToScreen (new (8, -1, 0, 0)); + screen = view.ViewportToScreen (new (8, -1, 0, 0)); Assert.Equal (15, screen.X); Assert.Equal (4, screen.Y); Assert.Equal (top, View.FindDeepestView (top, 15, 4)); Assert.Equal (new Point (16, -2), view.ScreenToFrame (23, 3)); - screen = view.BoundsToScreen (new (17, -1, 0, 0)); + screen = view.ViewportToScreen (new (17, -1, 0, 0)); Assert.Equal (24, screen.X); Assert.Equal (4, screen.Y); Assert.Null (View.FindDeepestView (top, 24, 4)); diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index e13d2dcc7..f4e4cb9ee 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1805,7 +1805,7 @@ public class ToplevelTests btnPopup.Accept += (s, e) => { - Rectangle viewToScreen = btnPopup.BoundsToScreen (top.Frame); + Rectangle viewToScreen = btnPopup.ViewportToScreen (top.Frame); var viewAddedToTop = new View {