From f6ff36968e70f59c206b73f5e7c562e955ffa50e Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 07:30:27 -0800 Subject: [PATCH 1/8] Reamed Bounds -> ViewPort to see how it feels --- Terminal.Gui/Application.cs | 4 +- Terminal.Gui/Input/Mouse.cs | 6 +- .../Text/Autocomplete/AppendAutocomplete.cs | 2 +- .../Text/Autocomplete/PopupAutocomplete.cs | 22 ++--- Terminal.Gui/Text/TextFormatter.cs | 2 +- Terminal.Gui/View/Adornment/Adornment.cs | 6 +- Terminal.Gui/View/Adornment/Padding.cs | 2 +- Terminal.Gui/View/Layout/ViewLayout.cs | 30 +++---- Terminal.Gui/View/View.cs | 4 +- Terminal.Gui/View/ViewAdornments.cs | 6 +- Terminal.Gui/View/ViewDrawing.cs | 38 ++++----- Terminal.Gui/View/ViewMouse.cs | 20 ++--- Terminal.Gui/View/ViewText.cs | 34 ++++---- Terminal.Gui/Views/ColorPicker.cs | 6 +- Terminal.Gui/Views/ComboBox.cs | 30 +++---- Terminal.Gui/Views/Dialog.cs | 8 +- Terminal.Gui/Views/FileDialog.cs | 16 ++-- Terminal.Gui/Views/GraphView/Annotations.cs | 14 ++-- Terminal.Gui/Views/GraphView/Axis.cs | 30 +++---- Terminal.Gui/Views/GraphView/GraphView.cs | 16 ++-- Terminal.Gui/Views/GraphView/Series.cs | 2 +- Terminal.Gui/Views/HexView.cs | 6 +- Terminal.Gui/Views/LineView.cs | 2 +- Terminal.Gui/Views/ListView.cs | 28 +++---- Terminal.Gui/Views/Menu/Menu.cs | 12 +-- Terminal.Gui/Views/MessageBox.cs | 2 +- Terminal.Gui/Views/ProgressBar.cs | 16 ++-- Terminal.Gui/Views/ScrollBarView.cs | 48 +++++------ Terminal.Gui/Views/ScrollView.cs | 32 ++++---- Terminal.Gui/Views/Slider.cs | 30 +++---- Terminal.Gui/Views/TabView.cs | 14 ++-- .../Views/TableView/ListTableSource.cs | 8 +- Terminal.Gui/Views/TableView/TableView.cs | 40 +++++----- Terminal.Gui/Views/TextField.cs | 12 +-- Terminal.Gui/Views/TextValidateField.cs | 8 +- Terminal.Gui/Views/TileView.cs | 40 +++++----- Terminal.Gui/Views/Toplevel.cs | 8 +- Terminal.Gui/Views/TreeView/TreeView.cs | 26 +++--- UICatalog/Scenarios/ASCIICustomButton.cs | 4 +- UICatalog/Scenarios/Animation.cs | 6 +- .../Scenarios/BackgroundWorkerCollection.cs | 2 +- UICatalog/Scenarios/CharacterMap.cs | 18 ++--- UICatalog/Scenarios/ComputedLayout.cs | 8 +- UICatalog/Scenarios/Editor.cs | 4 +- UICatalog/Scenarios/GraphViewExample.cs | 4 +- UICatalog/Scenarios/ProgressBarStyles.cs | 2 +- UICatalog/Scenarios/Scrolling.cs | 12 +-- UICatalog/Scenarios/Snake.cs | 2 +- UICatalog/Scenarios/ViewExperiments.cs | 6 +- UICatalog/Scenarios/VkeyPacketSimulator.cs | 12 +-- UnitTests/Drawing/LineCanvasTests.cs | 8 +- UnitTests/UICatalog/ScenarioTests.cs | 2 +- UnitTests/View/Adornment/AdornmentTests.cs | 32 ++++---- UnitTests/View/Adornment/ToScreenTests.cs | 2 +- UnitTests/View/DrawTests.cs | 10 +-- UnitTests/View/Layout/AbsoluteLayoutTests.cs | 48 +++++------ UnitTests/View/Layout/BoundsTests.cs | 8 +- UnitTests/View/Layout/DimTests.cs | 6 +- UnitTests/View/Layout/PosTests.cs | 8 +- .../View/Layout/SetRelativeLayoutTests.cs | 16 ++-- UnitTests/View/SubviewTests.cs | 8 +- UnitTests/View/Text/AutoSizeFalseTests.cs | 6 +- UnitTests/View/Text/AutoSizeTrueTests.cs | 14 ++-- UnitTests/View/ViewTests.cs | 58 +++++++------- UnitTests/Views/ButtonTests.cs | 12 +-- UnitTests/Views/ComboBoxTests.cs | 36 ++++----- UnitTests/Views/GraphViewTests.cs | 46 +++++------ UnitTests/Views/LabelTests.cs | 10 +-- UnitTests/Views/ScrollBarViewTests.cs | 56 ++++++------- UnitTests/Views/ScrollViewTests.cs | 10 +-- UnitTests/Views/StatusBarTests.cs | 4 +- UnitTests/Views/TableViewTests.cs | 80 +++++++++---------- UnitTests/Views/TextValidateFieldTests.cs | 2 +- UnitTests/Views/TextViewTests.cs | 12 +-- UnitTests/Views/ToplevelTests.cs | 2 +- UnitTests/Views/TreeTableSourceTests.cs | 2 +- UnitTests/Views/TreeViewTests.cs | 6 +- UnitTests/Views/WindowTests.cs | 6 +- 78 files changed, 610 insertions(+), 610 deletions(-) diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index b2d2cbe367..94cfb81547 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -1420,7 +1420,7 @@ internal static void OnMouseEvent (MouseEventEventArgs a) View = view }; - if (MouseGrabView.Bounds.Contains (viewRelativeMouseEvent.X, viewRelativeMouseEvent.Y) is false) + if (MouseGrabView.Viewport.Contains (viewRelativeMouseEvent.X, viewRelativeMouseEvent.Y) is false) { // The mouse has moved outside the bounds of the view that // grabbed the mouse, so we tell the view that last got @@ -1476,7 +1476,7 @@ internal static void OnMouseEvent (MouseEventEventArgs a) View = view }; } - else if (view.BoundsToScreen (view.Bounds).Contains (a.MouseEvent.X, a.MouseEvent.Y)) + else if (view.BoundsToScreen (view.Viewport).Contains (a.MouseEvent.X, a.MouseEvent.Y)) { Point boundsPoint = view.ScreenToBounds (a.MouseEvent.X, a.MouseEvent.Y); diff --git a/Terminal.Gui/Input/Mouse.cs b/Terminal.Gui/Input/Mouse.cs index f8225c9bf2..0661fe09a6 100644 --- a/Terminal.Gui/Input/Mouse.cs +++ b/Terminal.Gui/Input/Mouse.cs @@ -116,10 +116,10 @@ public class MouseEvent /// The View at the location for the mouse event. public View View { get; set; } - /// The X position of the mouse in -relative coordinates. + /// The X position of the mouse in -relative coordinates. public int X { get; set; } - /// The Y position of the mouse in -relative coordinates. + /// The Y position of the mouse in -relative coordinates. public int Y { get; set; } /// @@ -133,7 +133,7 @@ public class MouseEvent /// /// /// - /// The and properties are always -relative. When the mouse is grabbed by a view, + /// The and properties are always -relative. When the mouse is grabbed by a view, /// provides the mouse position screen-relative coordinates, enabling the grabbed view to know how much the /// mouse has moved. /// diff --git a/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs index ba5fbed5a4..76d74f512d 100644 --- a/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs @@ -117,7 +117,7 @@ public override void RenderOverlay (Point renderAt) Suggestion suggestion = Suggestions.ElementAt (SelectedIdx); string fragment = suggestion.Replacement.Substring (suggestion.Remove); - int spaceAvailable = textField.Bounds.Width - textField.Text.GetColumns (); + int spaceAvailable = textField.Viewport.Width - textField.Text.GetColumns (); int spaceRequired = fragment.EnumerateRunes ().Sum (c => c.GetColumns ()); if (spaceAvailable < spaceRequired) diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs index 84ea483657..e76aa8a2d0 100644 --- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs @@ -271,13 +271,13 @@ public override void RenderOverlay (Point renderAt) if (PopupInsideContainer) { // don't overspill vertically - height = Math.Min (HostControl.Bounds.Height - renderAt.Y, MaxHeight); + height = Math.Min (HostControl.Viewport.Height - renderAt.Y, MaxHeight); // There is no space below, lets see if can popup on top - if (height < Suggestions.Count && HostControl.Bounds.Height - renderAt.Y >= height) + if (height < Suggestions.Count && HostControl.Viewport.Height - renderAt.Y >= height) { // Verifies that the upper limit available is greater than the lower limit - if (renderAt.Y > HostControl.Bounds.Height - renderAt.Y) + if (renderAt.Y > HostControl.Viewport.Height - renderAt.Y) { renderAt.Y = Math.Max (renderAt.Y - Math.Min (Suggestions.Count + 1, MaxHeight + 1), 0); height = Math.Min (Math.Min (Suggestions.Count, MaxHeight), LastPopupPos.Value.Y - 1); @@ -287,13 +287,13 @@ public override void RenderOverlay (Point renderAt) else { // don't overspill vertically - height = Math.Min (Math.Min (top.Bounds.Height - HostControl.Frame.Bottom, MaxHeight), Suggestions.Count); + height = Math.Min (Math.Min (top.Viewport.Height - HostControl.Frame.Bottom, MaxHeight), Suggestions.Count); // There is no space below, lets see if can popup on top if (height < Suggestions.Count && HostControl.Frame.Y - top.Frame.Y >= height) { // Verifies that the upper limit available is greater than the lower limit - if (HostControl.Frame.Y > top.Bounds.Height - HostControl.Frame.Y) + if (HostControl.Frame.Y > top.Viewport.Height - HostControl.Frame.Y) { renderAt.Y = Math.Max (HostControl.Frame.Y - Math.Min (Suggestions.Count, MaxHeight), 0); height = Math.Min (Math.Min (Suggestions.Count, MaxHeight), HostControl.Frame.Y); @@ -323,34 +323,34 @@ public override void RenderOverlay (Point renderAt) if (PopupInsideContainer) { // don't overspill horizontally, let's see if can be displayed on the left - if (width > HostControl.Bounds.Width - renderAt.X) + if (width > HostControl.Viewport.Width - renderAt.X) { // Verifies that the left limit available is greater than the right limit - if (renderAt.X > HostControl.Bounds.Width - renderAt.X) + if (renderAt.X > HostControl.Viewport.Width - renderAt.X) { renderAt.X -= Math.Min (width, LastPopupPos.Value.X); width = Math.Min (width, LastPopupPos.Value.X); } else { - width = Math.Min (width, HostControl.Bounds.Width - renderAt.X); + width = Math.Min (width, HostControl.Viewport.Width - renderAt.X); } } } else { // don't overspill horizontally, let's see if can be displayed on the left - if (width > top.Bounds.Width - (renderAt.X + HostControl.Frame.X)) + if (width > top.Viewport.Width - (renderAt.X + HostControl.Frame.X)) { // Verifies that the left limit available is greater than the right limit - if (renderAt.X + HostControl.Frame.X > top.Bounds.Width - (renderAt.X + HostControl.Frame.X)) + if (renderAt.X + HostControl.Frame.X > top.Viewport.Width - (renderAt.X + HostControl.Frame.X)) { renderAt.X -= Math.Min (width, LastPopupPos.Value.X); width = Math.Min (width, LastPopupPos.Value.X); } else { - width = Math.Min (width, top.Bounds.Width - renderAt.X); + width = Math.Min (width, top.Viewport.Width - renderAt.X); } } } diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs index 6168c53f01..86fc2ca85c 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -30,7 +30,7 @@ public TextAlignment Alignment /// Gets or sets whether the should be automatically changed to fit the . /// - /// Used by to resize the view's to fit . + /// Used by to resize the view's to fit . /// /// AutoSize is ignored if and /// are used. diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index 5fe40cab9a..74348cfeeb 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -1,7 +1,7 @@ namespace Terminal.Gui; /// -/// Adornments are a special form of that appear outside the : +/// Adornments are a special form of that appear outside the : /// , , and . They are defined using the /// class, which specifies the thickness of the sides of a rectangle. /// @@ -109,7 +109,7 @@ internal override void LayoutAdornments () /// Gets the rectangle that describes the area of the Adornment. The Location is always (0,0). /// The size is the size of the . /// - public override Rectangle Bounds + public override Rectangle Viewport { get => Frame with { Location = Point.Empty }; set => throw new InvalidOperationException ("It makes no sense to set Bounds of a Thickness."); @@ -231,7 +231,7 @@ protected internal override bool OnMouseEnter (MouseEvent mouseEvent) /// Called when a mouse event occurs within the Adornment. /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// /// A mouse click on the Adornment will cause the Parent to focus. diff --git a/Terminal.Gui/View/Adornment/Padding.cs b/Terminal.Gui/View/Adornment/Padding.cs index 3c2a645c12..206f87bf41 100644 --- a/Terminal.Gui/View/Adornment/Padding.cs +++ b/Terminal.Gui/View/Adornment/Padding.cs @@ -42,7 +42,7 @@ public override ColorScheme ColorScheme /// Called when a mouse event occurs within the Padding. /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// /// A mouse click on the Padding will cause the Parent to focus. diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index af1e417a95..18ab7c5631 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -42,10 +42,10 @@ public partial class View /// Gets or sets the absolute location and dimension of the view. /// /// The rectangle describing absolute location and dimension of the view, in coordinates relative to the - /// 's . + /// 's . /// /// - /// Frame is relative to the 's . + /// Frame is relative to the 's . /// /// Setting Frame will set , , , and to the /// values of the corresponding properties of the parameter. @@ -113,9 +113,9 @@ public virtual Rectangle FrameToScreen () /// /// Converts a screen-relative coordinate to a Frame-relative coordinate. Frame-relative means relative to the - /// View's 's . + /// View's 's . /// - /// The coordinate relative to the 's . + /// The coordinate relative to the 's . /// Screen-relative column. /// Screen-relative row. public virtual Point ScreenToFrame (int x, int y) @@ -306,12 +306,12 @@ public Dim Width /// and methods to be called. /// /// - /// Because coordinates are relative to the upper-left corner of the , the + /// 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 Bounds + public virtual Rectangle Viewport { get { @@ -362,7 +362,7 @@ public virtual Rectangle Bounds } } - /// Converts a -relative rectangle to a screen-relative rectangle. + /// Converts a -relative rectangle to a screen-relative rectangle. public Rectangle BoundsToScreen (in Rectangle bounds) { // Translate bounds to Frame (our SuperView's Bounds-relative coordinates) @@ -374,7 +374,7 @@ public Rectangle BoundsToScreen (in Rectangle bounds) } /// Converts a screen-relative coordinate to a bounds-relative coordinate. - /// The coordinate relative to this view's . + /// The coordinate relative to this view's . /// Screen-relative column. /// Screen-relative row. public Point ScreenToBounds (int x, int y) @@ -400,7 +400,7 @@ public Point ScreenToBounds (int x, int y) /// /// Gets or sets a flag that determines whether the View will be automatically resized to fit the - /// within . + /// within . /// /// The default is . Set to to turn on AutoSize. If /// then and will be used if can @@ -598,7 +598,7 @@ private bool ResizeBoundsToFit (Size size) if (boundsChanged) { - Bounds = new (Bounds.X, Bounds.Y, canSizeW ? rW : Bounds.Width, canSizeH ? rH : Bounds.Height); + Viewport = new (Viewport.X, Viewport.Y, canSizeW ? rW : Viewport.Width, canSizeH ? rH : Viewport.Height); } return boundsChanged; @@ -766,7 +766,7 @@ out StatusBar statusBar else { // Use the SuperView's Bounds, not Frame - maxDimension = viewToMove.SuperView.Bounds.Width; + maxDimension = viewToMove.SuperView.Viewport.Width; superView = viewToMove.SuperView; } @@ -912,7 +912,7 @@ public virtual void LayoutSubviews () LayoutAdornments (); - Rectangle oldBounds = Bounds; + Rectangle oldBounds = Viewport; OnLayoutStarted (new () { OldBounds = oldBounds }); SetTextFormatterSize (); @@ -925,7 +925,7 @@ public virtual void LayoutSubviews () foreach (View v in ordered) { - LayoutSubview (v, new (GetBoundsOffset (), Bounds.Size)); + LayoutSubview (v, new (GetBoundsOffset (), Viewport.Size)); } // If the 'to' is rooted to 'from' and the layoutstyle is Computed it's a special-case. @@ -974,8 +974,8 @@ internal void OnResizeNeeded () // TODO: Until then leave it `internal` and non-virtual // First try SuperView.Bounds, then Application.Top, then Driver.Bounds. // Finally, if none of those are valid, use int.MaxValue (for Unit tests). - Rectangle relativeBounds = SuperView is { IsInitialized: true } ? SuperView.Bounds : - Application.Top is { } && Application.Top.IsInitialized ? Application.Top.Bounds : + Rectangle relativeBounds = SuperView is { IsInitialized: true } ? SuperView.Viewport : + Application.Top is { } && Application.Top.IsInitialized ? Application.Top.Viewport : Application.Driver?.Bounds ?? new Rectangle (0, 0, int.MaxValue, int.MaxValue); SetRelativeLayout (relativeBounds); diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs index c78d327f5a..84b30e3bdf 100644 --- a/Terminal.Gui/View/View.cs +++ b/Terminal.Gui/View/View.cs @@ -52,7 +52,7 @@ namespace Terminal.Gui; /// To create a View using Absolute layout, call a constructor that takes a Rect parameter to specify the /// absolute position and size or simply set ). To create a View using Computed layout use /// a constructor that does not take a Rect parameter and set the X, Y, Width and Height properties on the view to -/// non-absolute values. Both approaches use coordinates that are relative to the of the +/// non-absolute values. Both approaches use coordinates that are relative to the of the /// the View is added to. /// /// @@ -73,7 +73,7 @@ namespace Terminal.Gui; /// a View can be accessed with the property. /// /// -/// To flag a region of the View's to be redrawn call +/// To flag a region of the View's to be redrawn call /// . /// To flag the entire view for redraw call . /// diff --git a/Terminal.Gui/View/ViewAdornments.cs b/Terminal.Gui/View/ViewAdornments.cs index 5cf0364394..53a0f3ffc4 100644 --- a/Terminal.Gui/View/ViewAdornments.cs +++ b/Terminal.Gui/View/ViewAdornments.cs @@ -39,7 +39,7 @@ private void DisposeAdornments () /// /// The that enables separation of a View from other SubViews of the same - /// SuperView. The margin offsets the from the . + /// SuperView. The margin offsets the from the . /// /// /// @@ -55,7 +55,7 @@ private void DisposeAdornments () public Margin Margin { get; private set; } /// - /// The that offsets the from the . + /// The that offsets the from the . /// The Border provides the space for a visual border (drawn using /// line-drawing glyphs) and the Title. The Border expands inward; in other words if `Border.Thickness.Top == 2` the /// border and title will take up the first row and the second row will be filled with spaces. @@ -113,7 +113,7 @@ public LineStyle BorderStyle } /// - /// The inside of the view that offsets the + /// The inside of the view that offsets the /// from the . /// /// diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 7bc9f5b2d4..0107ca1ad9 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -80,11 +80,11 @@ public void AddRune (int col, int row, Rune ch) Driver.AddRune (ch); } - /// Clears with the normal background. + /// Clears with the normal background. /// - public void Clear () { Clear (Bounds); } + public void Clear () { Clear (Viewport); } - /// Clears the specified -relative rectangle with the normal background. + /// Clears the specified -relative rectangle with the normal background. /// /// The Bounds-relative rectangle to clear. public void Clear (Rectangle contentArea) @@ -97,19 +97,19 @@ public void Clear (Rectangle contentArea) Attribute prev = Driver.SetAttribute (GetNormalColor ()); // Clamp the region to the bounds of the view - contentArea = Rectangle.Intersect (contentArea, Bounds); + contentArea = Rectangle.Intersect (contentArea, Viewport); Driver.FillRect (BoundsToScreen (contentArea)); Driver.SetAttribute (prev); } - /// Expands the 's clip region to include . + /// Expands the 's clip region to include . /// /// The current screen-relative clip region, which can be then re-applied by setting /// . /// /// /// - /// If and do not intersect, the clip region will be set to + /// If and do not intersect, the clip region will be set to /// . /// /// @@ -121,7 +121,7 @@ public Rectangle ClipToBounds () } Rectangle previous = Driver.Clip; - Driver.Clip = Rectangle.Intersect (previous, BoundsToScreen (Bounds)); + Driver.Clip = Rectangle.Intersect (previous, BoundsToScreen (Viewport)); return previous; } @@ -132,7 +132,7 @@ public Rectangle ClipToBounds () /// /// /// - /// Always use (view-relative) when calling , NOT + /// Always use (view-relative) when calling , NOT /// (superview-relative). /// /// @@ -162,12 +162,12 @@ public void Draw () } // Invoke DrawContentEvent - var dev = new DrawEventArgs (Bounds); + var dev = new DrawEventArgs (Viewport); DrawContent?.Invoke (this, dev); if (!dev.Cancel) { - OnDrawContent (Bounds); + OnDrawContent (Viewport); } if (Driver is { }) @@ -178,7 +178,7 @@ public void Draw () OnRenderLineCanvas (); // Invoke DrawContentCompleteEvent - OnDrawContentComplete (Bounds); + OnDrawContentComplete (Viewport); // BUGBUG: v2 - We should be able to use View.SetClip here and not have to resort to knowing Driver details. ClearLayoutNeeded (); @@ -346,9 +346,9 @@ public virtual bool OnDrawAdornments () // Each of these renders lines to either this View's LineCanvas // Those lines will be finally rendered in OnRenderLineCanvas - Margin?.OnDrawContent (Margin.Bounds); - Border?.OnDrawContent (Border.Bounds); - Padding?.OnDrawContent (Padding.Bounds); + Margin?.OnDrawContent (Margin.Viewport); + Border?.OnDrawContent (Border.Viewport); + Padding?.OnDrawContent (Padding.Viewport); return true; } @@ -483,7 +483,7 @@ public virtual bool OnRenderLineCanvas () return true; } - /// Sets the area of this view needing to be redrawn to . + /// Sets the area of this view needing to be redrawn to . /// /// If the view has not been initialized ( is ), this method /// does nothing. @@ -492,7 +492,7 @@ public void SetNeedsDisplay () { if (IsInitialized) { - SetNeedsDisplay (Bounds); + SetNeedsDisplay (Viewport); } } @@ -525,9 +525,9 @@ public virtual void SetNeedsDisplay (Rectangle region) _superView?.SetSubViewNeedsDisplay (); - Margin?.SetNeedsDisplay (Margin.Bounds); - Border?.SetNeedsDisplay (Border.Bounds); - Padding?.SetNeedsDisplay (Padding.Bounds); + Margin?.SetNeedsDisplay (Margin.Viewport); + Border?.SetNeedsDisplay (Border.Viewport); + Padding?.SetNeedsDisplay (Padding.Viewport); foreach (View subview in Subviews) { diff --git a/Terminal.Gui/View/ViewMouse.cs b/Terminal.Gui/View/ViewMouse.cs index 90422ecec6..6ef2c783c0 100644 --- a/Terminal.Gui/View/ViewMouse.cs +++ b/Terminal.Gui/View/ViewMouse.cs @@ -12,7 +12,7 @@ public partial class View /// Event fired when a mouse event occurs. /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// public event EventHandler MouseEvent; @@ -24,24 +24,24 @@ public partial class View /// to see which button was clicked. /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// public event EventHandler MouseClick; - /// Event fired when the mouse moves into the View's . + /// Event fired when the mouse moves into the View's . public event EventHandler MouseEnter; - /// Event fired when the mouse leaves the View's . + /// Event fired when the mouse leaves the View's . public event EventHandler MouseLeave; // TODO: OnMouseEnter should not be public virtual, but protected. /// - /// Called when the mouse enters the View's . The view will now receive mouse events until the mouse leaves + /// Called when the mouse enters the View's . The view will now receive mouse events until the mouse leaves /// the view. At which time, will be called. /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// /// , if the event was handled, otherwise. @@ -65,11 +65,11 @@ protected internal virtual bool OnMouseEnter (MouseEvent mouseEvent) // TODO: OnMouseLeave should not be public virtual, but protected. /// - /// Called when the mouse has moved out of the View's . The view will no longer receive mouse events (until the + /// Called when the mouse has moved out of the View's . The view will no longer receive mouse events (until the /// mouse moves within the view again and is called). /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// /// , if the event was handled, otherwise. @@ -92,10 +92,10 @@ protected internal virtual bool OnMouseLeave (MouseEvent mouseEvent) } // TODO: OnMouseEvent should not be public virtual, but protected. - /// Called when a mouse event occurs within the view's . + /// Called when a mouse event occurs within the view's . /// /// - /// The coordinates are relative to . + /// The coordinates are relative to . /// /// /// diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 598e2c76be..911f72938a 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -30,10 +30,10 @@ public virtual bool PreserveTrailingSpaces /// and . /// /// - /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height + /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height /// is 1, the text will be clipped. /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// When the text changes, the is fired. /// public virtual string Text @@ -80,7 +80,7 @@ public void OnTextChanged (string oldValue, string newValue) /// redisplay the . /// /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// /// The text alignment. public virtual TextAlignment TextAlignment @@ -99,7 +99,7 @@ public virtual TextAlignment TextAlignment /// . /// /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// /// The text alignment. public virtual TextDirection TextDirection @@ -120,7 +120,7 @@ public virtual TextDirection TextDirection /// redisplay the . /// /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// /// The text alignment. public virtual VerticalTextAlignment VerticalTextAlignment @@ -134,7 +134,7 @@ public virtual VerticalTextAlignment VerticalTextAlignment } /// - /// Gets the Frame dimensions required to fit within using the text + /// Gets the Frame dimensions required to fit within using the text /// specified by the property and accounting for any /// characters. /// @@ -146,8 +146,8 @@ public Size GetAutoSize () if (IsInitialized) { - x = Bounds.X; - y = Bounds.Y; + x = Viewport.X; + y = Viewport.Y; } Rectangle rect = TextFormatter.CalcRect (x, y, TextFormatter.Text, TextFormatter.Direction); @@ -225,7 +225,7 @@ internal Size GetSizeNeededForTextWithoutHotKey () } /// - /// Internal API. Sets .Size to the current size, adjusted for + /// Internal API. Sets .Size to the current size, adjusted for /// . /// /// @@ -244,14 +244,14 @@ internal void SetTextFormatterSize () if (string.IsNullOrEmpty (TextFormatter.Text)) { - TextFormatter.Size = Bounds.Size; + TextFormatter.Size = Viewport.Size; return; } TextFormatter.Size = new ( - Bounds.Size.Width + GetHotKeySpecifierLength (), - Bounds.Size.Height + GetHotKeySpecifierLength (false) + Viewport.Size.Width + GetHotKeySpecifierLength (), + Viewport.Size.Height + GetHotKeySpecifierLength (false) ); } @@ -324,7 +324,7 @@ bool GetMinimumSizeOfText (out Size sizeRequired) return false; } - sizeRequired = Bounds.Size; + sizeRequired = Viewport.Size; if (AutoSize || string.IsNullOrEmpty (TextFormatter.Text)) { @@ -338,9 +338,9 @@ bool GetMinimumSizeOfText (out Size sizeRequired) // TODO: v2 - This uses frame.Width; it should only use Bounds if (_frame.Width < colWidth - && (Width is null || (Bounds.Width >= 0 && Width is Dim.DimAbsolute && Width.Anchor (0) >= 0 && Width.Anchor (0) < colWidth))) + && (Width is null || (Viewport.Width >= 0 && Width is Dim.DimAbsolute && Width.Anchor (0) >= 0 && Width.Anchor (0) < colWidth))) { - sizeRequired = new (colWidth, Bounds.Height); + sizeRequired = new (colWidth, Viewport.Height); return true; } @@ -349,7 +349,7 @@ bool GetMinimumSizeOfText (out Size sizeRequired) default: if (_frame.Height < 1 && (Height is null || (Height is Dim.DimAbsolute && Height.Anchor (0) == 0))) { - sizeRequired = new (Bounds.Width, 1); + sizeRequired = new (Viewport.Width, 1); return true; } @@ -392,7 +392,7 @@ private void UpdateTextDirection (TextDirection newDirection) } else if (AutoSize && directionChanged && IsAdded) { - ResizeBoundsToFit (Bounds.Size); + ResizeBoundsToFit (Viewport.Size); } SetTextFormatterSize (); diff --git a/Terminal.Gui/Views/ColorPicker.cs b/Terminal.Gui/Views/ColorPicker.cs index e1f8179a51..249c44cff6 100644 --- a/Terminal.Gui/Views/ColorPicker.cs +++ b/Terminal.Gui/Views/ColorPicker.cs @@ -98,7 +98,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) SetFocus (); - if (me.X > Bounds.Width || me.Y > Bounds.Height) + if (me.X > Viewport.Width || me.Y > Viewport.Height) { return true; } @@ -164,9 +164,9 @@ public override void OnDrawContent (Rectangle contentArea) Driver.SetAttribute (HasFocus ? ColorScheme.Focus : GetNormalColor ()); var colorIndex = 0; - for (var y = 0; y < Bounds.Height / BoxHeight; y++) + for (var y = 0; y < Viewport.Height / BoxHeight; y++) { - for (var x = 0; x < Bounds.Width / BoxWidth; x++) + for (var x = 0; x < Viewport.Width / BoxWidth; x++) { int foregroundColorIndex = y == 0 ? colorIndex + _cols : colorIndex - _cols; Driver.SetAttribute (new Attribute ((ColorName)foregroundColorIndex, (ColorName)colorIndex)); diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index 9d151f465f..a08e1a361a 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -245,8 +245,8 @@ public virtual bool Expand () /// protected internal override bool OnMouseEvent (MouseEvent me) { - if (me.X == Bounds.Right - 1 - && me.Y == Bounds.Top + if (me.X == Viewport.Right - 1 + && me.Y == Viewport.Top && me.Flags == MouseFlags.Button1Pressed && _autoHide) { @@ -294,7 +294,7 @@ public override void OnDrawContent (Rectangle contentArea) } Driver.SetAttribute (ColorScheme.Focus); - Move (Bounds.Right - 1, 0); + Move (Viewport.Right - 1, 0); Driver.AddRune (Glyphs.DownArrow); } @@ -401,15 +401,15 @@ private bool ActivateSelected () /// private int CalculatetHeight () { - if (!IsInitialized || Bounds.Height == 0) + if (!IsInitialized || Viewport.Height == 0) { return 0; } return Math.Min ( - Math.Max (Bounds.Height - 1, _minimumHeight - 1), + Math.Max (Viewport.Height - 1, _minimumHeight - 1), _searchset?.Count > 0 ? _searchset.Count : - IsShow ? Math.Max (Bounds.Height - 1, _minimumHeight - 1) : 0 + IsShow ? Math.Max (Viewport.Height - 1, _minimumHeight - 1) : 0 ); } @@ -491,10 +491,10 @@ private void HideList () } Reset (true); - _listview.Clear (_listview.IsInitialized ? _listview.Bounds : Rectangle.Empty); + _listview.Clear (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty); _listview.TabStop = false; SuperView?.SendSubviewToBack (this); - Rectangle rect = _listview.BoundsToScreen (_listview.IsInitialized ? _listview.Bounds : Rectangle.Empty); + Rectangle rect = _listview.BoundsToScreen (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty); SuperView?.SetNeedsDisplay (rect); OnCollapsed (); } @@ -607,18 +607,18 @@ private bool PageUp () private void ProcessLayout () { - if (Bounds.Height < _minimumHeight && (Height is null || Height is Dim.DimAbsolute)) + if (Viewport.Height < _minimumHeight && (Height is null || Height is Dim.DimAbsolute)) { Height = _minimumHeight; } - if ((!_autoHide && Bounds.Width > 0 && _search.Frame.Width != Bounds.Width) - || (_autoHide && Bounds.Width > 0 && _search.Frame.Width != Bounds.Width - 1)) + if ((!_autoHide && Viewport.Width > 0 && _search.Frame.Width != Viewport.Width) + || (_autoHide && Viewport.Width > 0 && _search.Frame.Width != Viewport.Width - 1)) { - _search.Width = _listview.Width = _autoHide ? Bounds.Width - 1 : Bounds.Width; + _search.Width = _listview.Width = _autoHide ? Viewport.Width - 1 : Viewport.Width; _listview.Height = CalculatetHeight (); - _search.SetRelativeLayout (Bounds); - _listview.SetRelativeLayout (Bounds); + _search.SetRelativeLayout (Viewport); + _listview.SetRelativeLayout (Viewport); } } @@ -761,7 +761,7 @@ private void SetValue (object text, bool isFromSelectedItem = false) private void ShowList () { _listview.SetSource (_searchset); - _listview.Clear (Bounds); // Ensure list shrinks in Dialog as you type + _listview.Clear (Viewport); // Ensure list shrinks in Dialog as you type _listview.Height = CalculatetHeight (); SuperView?.BringSubviewToFront (this); } diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index 7b821bf131..c6d04a2533 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -165,7 +165,7 @@ private void LayoutButtons () { case ButtonAlignments.Center: // Center Buttons - shiftLeft = (Bounds.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1; + shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1; for (int i = _buttons.Count - 1; i >= 0; i--) { @@ -178,7 +178,7 @@ private void LayoutButtons () } else { - button.X = Bounds.Width - shiftLeft; + button.X = Viewport.Width - shiftLeft; } button.Y = Pos.AnchorEnd (1); @@ -190,7 +190,7 @@ private void LayoutButtons () // Justify Buttons // leftmost and rightmost buttons are hard against edges. The rest are evenly spaced. - var spacing = (int)Math.Ceiling ((double)(Bounds.Width - buttonsWidth) / (_buttons.Count - 1)); + var spacing = (int)Math.Ceiling ((double)(Viewport.Width - buttonsWidth) / (_buttons.Count - 1)); for (int i = _buttons.Count - 1; i >= 0; i--) { @@ -206,7 +206,7 @@ private void LayoutButtons () if (i == 0) { // first (leftmost) button - int left = Bounds.Width; + int left = Viewport.Width; button.X = Pos.AnchorEnd (left); } else diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index f36099d291..118e4437d9 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -414,16 +414,16 @@ public override void OnDrawContent (Rectangle contentArea) if (!string.IsNullOrWhiteSpace (_feedback)) { int feedbackWidth = _feedback.EnumerateRunes ().Sum (c => c.GetColumns ()); - int feedbackPadLeft = (Bounds.Width - feedbackWidth) / 2 - 1; + int feedbackPadLeft = (Viewport.Width - feedbackWidth) / 2 - 1; - feedbackPadLeft = Math.Min (Bounds.Width, feedbackPadLeft); + feedbackPadLeft = Math.Min (Viewport.Width, feedbackPadLeft); feedbackPadLeft = Math.Max (0, feedbackPadLeft); - int feedbackPadRight = Bounds.Width - (feedbackPadLeft + feedbackWidth + 2); - feedbackPadRight = Math.Min (Bounds.Width, feedbackPadRight); + int feedbackPadRight = Viewport.Width - (feedbackPadLeft + feedbackWidth + 2); + feedbackPadRight = Math.Min (Viewport.Width, feedbackPadRight); feedbackPadRight = Math.Max (0, feedbackPadRight); - Move (0, Bounds.Height / 2); + Move (0, Viewport.Height / 2); Driver.SetAttribute (new Attribute (Color.Red, ColorScheme.Normal.Background)); Driver.AddStr (new string (' ', feedbackPadLeft)); @@ -773,9 +773,9 @@ private int CalculateOkButtonPosX () return 0; } - return Bounds.Width - - _btnOk.Bounds.Width - - _btnCancel.Bounds.Width + return Viewport.Width + - _btnOk.Viewport.Width + - _btnCancel.Viewport.Width - 1 // TODO: Fiddle factor, seems the Bounds are wrong for someone diff --git a/Terminal.Gui/Views/GraphView/Annotations.cs b/Terminal.Gui/Views/GraphView/Annotations.cs index 1a77a49496..25d2d02035 100644 --- a/Terminal.Gui/Views/GraphView/Annotations.cs +++ b/Terminal.Gui/Views/GraphView/Annotations.cs @@ -18,7 +18,7 @@ public interface IAnnotation /// /// Called once after series have been rendered (or before if is true). Use - /// to draw and to avoid drawing outside of graph + /// to draw and to avoid drawing outside of graph /// /// void Render (GraphView graph); @@ -70,7 +70,7 @@ public void Render (GraphView graph) protected void DrawText (GraphView graph, int x, int y) { // the draw point is out of control bounds - if (!graph.Bounds.Contains (new Point (x, y))) + if (!graph.Viewport.Contains (new Point (x, y))) { return; } @@ -83,7 +83,7 @@ protected void DrawText (GraphView graph, int x, int y) graph.Move (x, y); - int availableWidth = graph.Bounds.Width - x; + int availableWidth = graph.Viewport.Width - x; if (availableWidth <= 0) { @@ -127,7 +127,7 @@ public LegendAnnotation (Rectangle legendBounds) /// Returns false i.e. Legends render after series public bool BeforeSeries => false; - /// Draws the Legend and all entries into the area within + /// Draws the Legend and all entries into the area within /// public void Render (GraphView graph) { @@ -165,13 +165,13 @@ public void Render (GraphView graph) // add the text Move (1, linesDrawn); - string str = TextFormatter.ClipOrPad (entry.Item2, Bounds.Width - 1); + string str = TextFormatter.ClipOrPad (entry.Item2, Viewport.Width - 1); Application.Driver.AddStr (str); linesDrawn++; // Legend has run out of space - if (linesDrawn >= Bounds.Height) + if (linesDrawn >= Viewport.Height) { break; } @@ -182,7 +182,7 @@ public void Render (GraphView graph) /// The symbol appearing on the graph that should appear in the legend /// /// Text to render on this line of the legend. Will be truncated if outside of Legend - /// + /// /// public void AddEntry (GraphCellToRender graphCellToRender, string text) { _entries.Add (Tuple.Create (graphCellToRender, text)); } } diff --git a/Terminal.Gui/Views/GraphView/Axis.cs b/Terminal.Gui/Views/GraphView/Axis.cs index 8d0389b371..32addb6489 100644 --- a/Terminal.Gui/Views/GraphView/Axis.cs +++ b/Terminal.Gui/Views/GraphView/Axis.cs @@ -113,7 +113,7 @@ public override void DrawAxisLabel (GraphView graph, int screenPosition, string string toRender = text; // this is how much space is left - int xSpaceAvailable = graph.Bounds.Width - drawAtX; + int xSpaceAvailable = graph.Viewport.Width - drawAtX; // There is no space for the label at all! if (xSpaceAvailable <= 0) @@ -127,7 +127,7 @@ public override void DrawAxisLabel (GraphView graph, int screenPosition, string toRender = toRender.Substring (0, xSpaceAvailable); } - graph.Move (drawAtX, Math.Min (y + 1, graph.Bounds.Height - 1)); + graph.Move (drawAtX, Math.Min (y + 1, graph.Viewport.Height - 1)); driver.AddStr (toRender); } } @@ -140,7 +140,7 @@ public override void DrawAxisLabels (GraphView graph) return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; IEnumerable labels = GetLabels (graph, bounds); @@ -155,12 +155,12 @@ public override void DrawAxisLabels (GraphView graph) string toRender = Text; // if label is too long - if (toRender.Length > graph.Bounds.Width) + if (toRender.Length > graph.Viewport.Width) { - toRender = toRender.Substring (0, graph.Bounds.Width); + toRender = toRender.Substring (0, graph.Viewport.Width); } - graph.Move (graph.Bounds.Width / 2 - toRender.Length / 2, graph.Bounds.Height - 1); + graph.Move (graph.Viewport.Width / 2 - toRender.Length / 2, graph.Viewport.Height - 1); Application.Driver.AddStr (toRender); } } @@ -174,7 +174,7 @@ public override void DrawAxisLine (GraphView graph) return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; graph.Move (0, 0); @@ -212,7 +212,7 @@ public int GetAxisYPosition (GraphView graph) // float the X axis so that it accurately represents the origin of the graph // but anchor it to top/bottom if the origin is offscreen - return Math.Min (Math.Max (0, origin.Y), graph.Bounds.Height - ((int)graph.MarginBottom + 1)); + return Math.Min (Math.Max (0, origin.Y), graph.Viewport.Height - ((int)graph.MarginBottom + 1)); } /// Draws a horizontal axis line at the given , screen coordinates @@ -317,7 +317,7 @@ public override void DrawAxisLabels (GraphView graph) return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; IEnumerable labels = GetLabels (graph, bounds); foreach (AxisIncrementToRender label in labels) @@ -331,13 +331,13 @@ public override void DrawAxisLabels (GraphView graph) string toRender = Text; // if label is too long - if (toRender.Length > graph.Bounds.Height) + if (toRender.Length > graph.Viewport.Height) { - toRender = toRender.Substring (0, graph.Bounds.Height); + toRender = toRender.Substring (0, graph.Viewport.Height); } // Draw it 1 letter at a time vertically down row 0 of the control - int startDrawingAtY = graph.Bounds.Height / 2 - toRender.Length / 2; + int startDrawingAtY = graph.Viewport.Height / 2 - toRender.Length / 2; for (var i = 0; i < toRender.Length; i++) { @@ -356,7 +356,7 @@ public override void DrawAxisLine (GraphView graph) return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; int x = GetAxisXPosition (graph); @@ -385,7 +385,7 @@ public int GetAxisXPosition (GraphView graph) // float the Y axis so that it accurately represents the origin of the graph // but anchor it to left/right if the origin is offscreen - return Math.Min (Math.Max ((int)graph.MarginLeft, origin.X), graph.Bounds.Width - 1); + return Math.Min (Math.Max ((int)graph.MarginLeft, origin.X), graph.Viewport.Width - 1); } /// Draws a vertical axis line at the given , screen coordinates @@ -409,7 +409,7 @@ private int GetAxisYEnd (GraphView graph) return graph.GraphSpaceToScreen (new PointF (0, Minimum.Value)).Y; } - return graph.Bounds.Height; + return graph.Viewport.Height; } private IEnumerable GetLabels (GraphView graph, Rectangle bounds) diff --git a/Terminal.Gui/Views/GraphView/GraphView.cs b/Terminal.Gui/Views/GraphView/GraphView.cs index 30b902286b..2c9cbc7691 100644 --- a/Terminal.Gui/Views/GraphView/GraphView.cs +++ b/Terminal.Gui/Views/GraphView/GraphView.cs @@ -192,7 +192,7 @@ public Point GraphSpaceToScreen (PointF location) (int)((location.X - ScrollOffset.X) / CellSize.X) + (int)MarginLeft, // screen coordinates are top down while graph coordinates are bottom up - Bounds.Height - 1 - (int)MarginBottom - (int)((location.Y - ScrollOffset.Y) / CellSize.Y) + Viewport.Height - 1 - (int)MarginBottom - (int)((location.Y - ScrollOffset.Y) / CellSize.Y) ); } @@ -209,10 +209,10 @@ public override void OnDrawContent (Rectangle contentArea) Move (0, 0); // clear all old content - for (var i = 0; i < Bounds.Height; i++) + for (var i = 0; i < Viewport.Height; i++) { Move (0, i); - Driver.AddStr (new string (' ', Bounds.Width)); + Driver.AddStr (new string (' ', Viewport.Width)); } // If there is no data do not display a graph @@ -222,8 +222,8 @@ public override void OnDrawContent (Rectangle contentArea) } // The drawable area of the graph (anything that isn't in the margins) - int graphScreenWidth = Bounds.Width - (int)MarginLeft; - int graphScreenHeight = Bounds.Height - (int)MarginBottom; + int graphScreenWidth = Viewport.Width - (int)MarginLeft; + int graphScreenHeight = Viewport.Height - (int)MarginBottom; // if the margins take up the full draw bounds don't render if (graphScreenWidth < 0 || graphScreenHeight < 0) @@ -287,10 +287,10 @@ public override bool OnEnter (View view) } /// Scrolls the graph down 1 page. - public void PageDown () { Scroll (0, -1 * CellSize.Y * Bounds.Height); } + public void PageDown () { Scroll (0, -1 * CellSize.Y * Viewport.Height); } /// Scrolls the graph up 1 page. - public void PageUp () { Scroll (0, CellSize.Y * Bounds.Height); } + public void PageUp () { Scroll (0, CellSize.Y * Viewport.Height); } /// /// Clears all settings configured on the graph and resets all properties to default values ( @@ -316,7 +316,7 @@ public RectangleF ScreenToGraphSpace (int col, int row) { return new ( ScrollOffset.X + (col - MarginLeft) * CellSize.X, - ScrollOffset.Y + (Bounds.Height - (row + MarginBottom + 1)) * CellSize.Y, + ScrollOffset.Y + (Viewport.Height - (row + MarginBottom + 1)) * CellSize.Y, CellSize.X, CellSize.Y ); diff --git a/Terminal.Gui/Views/GraphView/Series.cs b/Terminal.Gui/Views/GraphView/Series.cs index 673419b161..c117bd0a24 100644 --- a/Terminal.Gui/Views/GraphView/Series.cs +++ b/Terminal.Gui/Views/GraphView/Series.cs @@ -192,7 +192,7 @@ public virtual void DrawSeries (GraphView graph, Rectangle drawBounds, Rectangle screenStart.X = graph.AxisY.GetAxisXPosition (graph); // dont draw bar off the right of the control - screenEnd.X = Math.Min (graph.Bounds.Width - 1, screenEnd.X); + screenEnd.X = Math.Min (graph.Viewport.Width - 1, screenEnd.X); // if bar is off the screen if (screenStart.Y < 0 || screenStart.Y > drawBounds.Height - graph.MarginBottom) diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs index a9a7f0aad8..5f994a4ced 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -373,7 +373,7 @@ public override void OnDrawContent (Rectangle contentArea) { Rectangle lineRect = new (0, line, frame.Width, 1); - if (!Bounds.Contains (lineRect)) + if (!Viewport.Contains (lineRect)) { continue; } @@ -611,9 +611,9 @@ private void HexView_LayoutComplete (object sender, LayoutEventArgs e) // Small buffers will just show the position, with the bsize field value (4 bytes) bytesPerLine = bsize; - if (Bounds.Width - displayWidth > 17) + if (Viewport.Width - displayWidth > 17) { - bytesPerLine = bsize * ((Bounds.Width - displayWidth) / 18); + bytesPerLine = bsize * ((Viewport.Width - displayWidth) / 18); } } diff --git a/Terminal.Gui/Views/LineView.cs b/Terminal.Gui/Views/LineView.cs index 2f43411139..23df0387d8 100644 --- a/Terminal.Gui/Views/LineView.cs +++ b/Terminal.Gui/Views/LineView.cs @@ -63,7 +63,7 @@ public override void OnDrawContent (Rectangle contentArea) int hLineWidth = Math.Max (1, Glyphs.HLine.GetColumns ()); - int dEnd = Orientation == Orientation.Horizontal ? Bounds.Width : Bounds.Height; + int dEnd = Orientation == Orientation.Horizontal ? Viewport.Width : Viewport.Height; for (var d = 0; d < dEnd; d += hLineWidth) { diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 132be32131..321e97fc5d 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -318,9 +318,9 @@ public void EnsureSelectedItemVisible () { _top = Math.Max (_selected, 0); } - else if (Bounds.Height > 0 && _selected >= _top + Bounds.Height) + else if (Viewport.Height > 0 && _selected >= _top + Viewport.Height) { - _top = Math.Max (_selected - Bounds.Height + 1, 0); + _top = Math.Max (_selected - Viewport.Height + 1, 0); } LayoutStarted -= ListView_LayoutStarted; @@ -399,7 +399,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) if (me.Y + _top >= _source.Count || me.Y + _top < 0 - || me.Y + _top > _top + Bounds.Height) + || me.Y + _top > _top + Viewport.Height) { return true; } @@ -449,7 +449,7 @@ public virtual bool MoveDown () //can move by down by one. _selected++; - if (_selected >= _top + Bounds.Height) + if (_selected >= _top + Viewport.Height) { _top++; } @@ -466,9 +466,9 @@ public virtual bool MoveDown () OnSelectedChanged (); SetNeedsDisplay (); } - else if (_selected >= _top + Bounds.Height) + else if (_selected >= _top + Viewport.Height) { - _top = Math.Max (_source.Count - Bounds.Height, 0); + _top = Math.Max (_source.Count - Viewport.Height, 0); SetNeedsDisplay (); } @@ -483,7 +483,7 @@ public virtual bool MoveEnd () { _selected = _source.Count - 1; - if (_top + _selected > Bounds.Height - 1) + if (_top + _selected > Viewport.Height - 1) { _top = Math.Max (_selected, 0); } @@ -517,7 +517,7 @@ public virtual bool MoveHome () /// public virtual bool MovePageDown () { - int n = _selected + Bounds.Height; + int n = _selected + Viewport.Height; if (n >= _source.Count) { @@ -528,7 +528,7 @@ public virtual bool MovePageDown () { _selected = n; - if (_source.Count >= Bounds.Height) + if (_source.Count >= Viewport.Height) { _top = Math.Max (_selected, 0); } @@ -548,7 +548,7 @@ public virtual bool MovePageDown () /// public virtual bool MovePageUp () { - int n = _selected - Bounds.Height; + int n = _selected - Viewport.Height; if (n < 0) { @@ -598,9 +598,9 @@ public virtual bool MoveUp () { _top = Math.Max (_selected, 0); } - else if (_selected > _top + Bounds.Height) + else if (_selected > _top + Viewport.Height) { - _top = Math.Max (_selected - Bounds.Height + 1, 0); + _top = Math.Max (_selected - Viewport.Height + 1, 0); } OnSelectedChanged (); @@ -623,7 +623,7 @@ public override void OnDrawContent (Rectangle contentArea) Attribute current = ColorScheme.Focus; Driver.SetAttribute (current); Move (0, 0); - Rectangle f = Bounds; + Rectangle f = Viewport; int item = _top; bool focused = HasFocus; int col = _allowsMarking ? 2 : 0; @@ -768,7 +768,7 @@ public override void PositionCursor () } else { - Move (Bounds.Width - 1, _selected - _top); + Move (Viewport.Width - 1, _selected - _top); } } diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 0cc365595f..65a3081d58 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -769,14 +769,14 @@ public override void OnDrawContent (Rectangle contentArea) OnDrawAdornments (); OnRenderLineCanvas (); - for (int i = Bounds.Y; i < _barItems.Children.Length; i++) + for (int i = Viewport.Y; i < _barItems.Children.Length; i++) { if (i < 0) { continue; } - if (BoundsToScreen (Bounds).Y + i >= Driver.Rows) + if (BoundsToScreen (Viewport).Y + i >= Driver.Rows) { break; } @@ -800,7 +800,7 @@ public override void OnDrawContent (Rectangle contentArea) Driver.SetAttribute (DetermineColorSchemeFor (item, i)); - for (int p = Bounds.X; p < Frame.Width - 2; p++) + for (int p = Viewport.X; p < Frame.Width - 2; p++) { // This - 2 is for the border if (p < 0) @@ -808,7 +808,7 @@ public override void OnDrawContent (Rectangle contentArea) continue; } - if (BoundsToScreen (Bounds).X + p >= Driver.Cols) + if (BoundsToScreen (Viewport).X + p >= Driver.Cols) { break; } @@ -894,7 +894,7 @@ public override void OnDrawContent (Rectangle contentArea) BoundsToScreen (new (1, i, Frame.Width - 3, 1)), i == _currentChild ? ColorScheme.Focus : GetNormalColor (), i == _currentChild ? ColorScheme.HotFocus : ColorScheme.HotNormal, - SuperView?.BoundsToScreen (SuperView.Bounds) ?? Rectangle.Empty + SuperView?.BoundsToScreen (SuperView.Viewport) ?? Rectangle.Empty ); } else @@ -937,7 +937,7 @@ private void Current_DrawContentComplete (object sender, DrawEventArgs e) { if (Visible) { - OnDrawContent (Bounds); + OnDrawContent (Viewport); } } diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 16395760a1..27aa3a054e 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -394,7 +394,7 @@ params string [] buttons } // TODO: replace with Dim.Fit when implemented - Rectangle maxBounds = d.SuperView?.Bounds ?? Application.Top.Bounds; + Rectangle maxBounds = d.SuperView?.Viewport ?? Application.Top.Viewport; Thickness adornmentsThickness = d.GetAdornmentsThickness (); diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 189533ee60..8609872999 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -151,7 +151,7 @@ public override void OnDrawContent (Rectangle contentArea) if (_isActivity) { - for (var i = 0; i < Bounds.Width; i++) + for (var i = 0; i < Viewport.Width; i++) { if (Array.IndexOf (_activityPos, i) != -1) { @@ -165,15 +165,15 @@ public override void OnDrawContent (Rectangle contentArea) } else { - var mid = (int)(_fraction * Bounds.Width); + var mid = (int)(_fraction * Viewport.Width); int i; - for (i = 0; (i < mid) & (i < Bounds.Width); i++) + for (i = 0; (i < mid) & (i < Viewport.Width); i++) { Driver.AddRune (SegmentCharacter); } - for (; i < Bounds.Width; i++) + for (; i < Viewport.Width; i++) { Driver.AddRune ((Rune)' '); } @@ -190,10 +190,10 @@ public override void OnDrawContent (Rectangle contentArea) } tf?.Draw ( - BoundsToScreen (Bounds), + BoundsToScreen (Viewport), attr, ColorScheme.Normal, - SuperView?.BoundsToScreen (SuperView.Bounds) ?? default (Rectangle) + SuperView?.BoundsToScreen (SuperView.Viewport) ?? default (Rectangle) ); } } @@ -244,13 +244,13 @@ public void Pulse () _delta = 1; } - else if (_activityPos [0] >= Bounds.Width) + else if (_activityPos [0] >= Viewport.Width) { if (_bidirectionalMarquee) { for (var i = 0; i < _activityPos.Length; i++) { - _activityPos [i] = Bounds.Width + i - 2; + _activityPos [i] = Viewport.Width + i - 2; } _delta = -1; diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs index 92fcbd505b..e42524fd14 100644 --- a/Terminal.Gui/Views/ScrollBarView.cs +++ b/Terminal.Gui/Views/ScrollBarView.cs @@ -152,14 +152,14 @@ public bool KeepContentAlwaysInViewport _keepContentAlwaysInViewport = value; var pos = 0; - if (value && !_vertical && _position + Host.Bounds.Width > _size) + if (value && !_vertical && _position + Host.Viewport.Width > _size) { - pos = _size - Host.Bounds.Width + (_showBothScrollIndicator ? 1 : 0); + pos = _size - Host.Viewport.Width + (_showBothScrollIndicator ? 1 : 0); } - if (value && _vertical && _position + Host.Bounds.Height > _size) + if (value && _vertical && _position + Host.Viewport.Height > _size) { - pos = _size - Host.Bounds.Height + (_showBothScrollIndicator ? 1 : 0); + pos = _size - Host.Viewport.Height + (_showBothScrollIndicator ? 1 : 0); } if (pos != 0) @@ -301,7 +301,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) } int location = _vertical ? mouseEvent.Y : mouseEvent.X; - int barsize = _vertical ? Bounds.Height : Bounds.Width; + int barsize = _vertical ? Viewport.Height : Viewport.Width; int posTopLeftTee = _vertical ? _posTopTee + 1 : _posLeftTee + 1; int posBottomRightTee = _vertical ? _posBottomTee + 1 : _posRightTee + 1; barsize -= 2; @@ -461,7 +461,7 @@ public override void OnDrawContent (Rectangle contentArea) return; } - if (Size == 0 || (_vertical && Bounds.Height == 0) || (!_vertical && Bounds.Width == 0)) + if (Size == 0 || (_vertical && Viewport.Height == 0) || (!_vertical && Viewport.Width == 0)) { return; } @@ -470,13 +470,13 @@ public override void OnDrawContent (Rectangle contentArea) if (_vertical) { - if (Bounds.Right < Bounds.Width - 1) + if (Viewport.Right < Viewport.Width - 1) { return; } - int col = Bounds.Width - 1; - int bh = Bounds.Height; + int col = Viewport.Width - 1; + int bh = Viewport.Height; Rune special; if (bh < 4) @@ -486,7 +486,7 @@ public override void OnDrawContent (Rectangle contentArea) Move (col, 0); - if (Bounds.Height == 1) + if (Viewport.Height == 1) { Driver.AddRune (Glyphs.Diamond); } @@ -495,15 +495,15 @@ public override void OnDrawContent (Rectangle contentArea) Driver.AddRune (Glyphs.UpArrow); } - if (Bounds.Height == 3) + if (Viewport.Height == 3) { Move (col, 1); Driver.AddRune (Glyphs.Diamond); } - if (Bounds.Height > 1) + if (Viewport.Height > 1) { - Move (col, Bounds.Height - 1); + Move (col, Viewport.Height - 1); Driver.AddRune (Glyphs.DownArrow); } } @@ -572,23 +572,23 @@ public override void OnDrawContent (Rectangle contentArea) if (!hasTopTee) { - Move (col, Bounds.Height - 2); + Move (col, Viewport.Height - 2); Driver.AddRune (Glyphs.TopTee); } - Move (col, Bounds.Height - 1); + Move (col, Viewport.Height - 1); Driver.AddRune (Glyphs.DownArrow); } } else { - if (Bounds.Bottom < Bounds.Height - 1) + if (Viewport.Bottom < Viewport.Height - 1) { return; } - int row = Bounds.Height - 1; - int bw = Bounds.Width; + int row = Viewport.Height - 1; + int bw = Viewport.Width; Rune special; if (bw < 4) @@ -663,7 +663,7 @@ public override void OnDrawContent (Rectangle contentArea) if (!hasLeftTee) { - Move (Bounds.Width - 2, row); + Move (Viewport.Width - 2, row); Driver.AddRune (Glyphs.LeftTee); } @@ -685,7 +685,7 @@ public override bool OnEnter (View view) internal bool CanScroll (int n, out int max, bool isVertical = false) { - if (Host?.Bounds.IsEmpty != false) + if (Host?.Viewport.IsEmpty != false) { max = 0; @@ -706,7 +706,7 @@ internal bool CanScroll (int n, out int max, bool isVertical = false) private bool CheckBothScrollBars (ScrollBarView scrollBarView, bool pending = false) { - int barsize = scrollBarView._vertical ? scrollBarView.Bounds.Height : scrollBarView.Bounds.Width; + int barsize = scrollBarView._vertical ? scrollBarView.Viewport.Height : scrollBarView.Viewport.Width; if (barsize == 0 || barsize >= scrollBarView._size) { @@ -845,15 +845,15 @@ private void CreateBottomRightCorner (View host) private int GetBarsize (bool isVertical) { - if (Host?.Bounds.IsEmpty != false) + if (Host?.Viewport.IsEmpty != false) { return 0; } return isVertical ? KeepContentAlwaysInViewport - ? Host.Bounds.Height + (_showBothScrollIndicator ? -2 : -1) + ? Host.Viewport.Height + (_showBothScrollIndicator ? -2 : -1) : 0 : - KeepContentAlwaysInViewport ? Host.Bounds.Width + (_showBothScrollIndicator ? -2 : -1) : 0; + KeepContentAlwaysInViewport ? Host.Viewport.Width + (_showBothScrollIndicator ? -2 : -1) : 0; } private void Host_EnabledChanged (object sender, EventArgs e) diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs index 35b213f569..ddeede202a 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -83,10 +83,10 @@ public ScrollView () AddCommand (Command.ScrollDown, () => ScrollDown (1)); AddCommand (Command.ScrollLeft, () => ScrollLeft (1)); AddCommand (Command.ScrollRight, () => ScrollRight (1)); - AddCommand (Command.PageUp, () => ScrollUp (Bounds.Height)); - AddCommand (Command.PageDown, () => ScrollDown (Bounds.Height)); - AddCommand (Command.PageLeft, () => ScrollLeft (Bounds.Width)); - AddCommand (Command.PageRight, () => ScrollRight (Bounds.Width)); + AddCommand (Command.PageUp, () => ScrollUp (Viewport.Height)); + AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height)); + AddCommand (Command.PageLeft, () => ScrollLeft (Viewport.Width)); + AddCommand (Command.PageRight, () => ScrollRight (Viewport.Width)); AddCommand (Command.TopHome, () => ScrollUp (_contentSize.Height)); AddCommand (Command.BottomEnd, () => ScrollDown (_contentSize.Height)); AddCommand (Command.LeftHome, () => ScrollLeft (_contentSize.Width)); @@ -210,26 +210,26 @@ public bool KeepContentAlwaysInViewport _horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value; Point p = default; - if (value && -_contentOffset.X + Bounds.Width > _contentSize.Width) + if (value && -_contentOffset.X + Viewport.Width > _contentSize.Width) { p = new Point ( - _contentSize.Width - Bounds.Width + (_showVerticalScrollIndicator ? 1 : 0), + _contentSize.Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0), -_contentOffset.Y ); } - if (value && -_contentOffset.Y + Bounds.Height > _contentSize.Height) + if (value && -_contentOffset.Y + Viewport.Height > _contentSize.Height) { if (p == default (Point)) { p = new Point ( -_contentOffset.X, - _contentSize.Height - Bounds.Height + (_showHorizontalScrollIndicator ? 1 : 0) + _contentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0) ); } else { - p.Y = _contentSize.Height - Bounds.Height + (_showHorizontalScrollIndicator ? 1 : 0); + p.Y = _contentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0); } } @@ -612,7 +612,7 @@ private void ShowHideScrollBars () bool v = false, h = false; var p = false; - if (Bounds.Height == 0 || Bounds.Height > _contentSize.Height) + if (Viewport.Height == 0 || Viewport.Height > _contentSize.Height) { if (ShowVerticalScrollIndicator) { @@ -621,7 +621,7 @@ private void ShowHideScrollBars () v = false; } - else if (Bounds.Height > 0 && Bounds.Height == _contentSize.Height) + else if (Viewport.Height > 0 && Viewport.Height == _contentSize.Height) { p = true; } @@ -635,7 +635,7 @@ private void ShowHideScrollBars () v = true; } - if (Bounds.Width == 0 || Bounds.Width > _contentSize.Width) + if (Viewport.Width == 0 || Viewport.Width > _contentSize.Width) { if (ShowHorizontalScrollIndicator) { @@ -644,7 +644,7 @@ private void ShowHideScrollBars () h = false; } - else if (Bounds.Width > 0 && Bounds.Width == _contentSize.Width && p) + else if (Viewport.Width > 0 && Viewport.Width == _contentSize.Width && p) { if (ShowHorizontalScrollIndicator) { @@ -696,13 +696,13 @@ private void ShowHideScrollBars () if (v) { - _vertical.SetRelativeLayout (Bounds); + _vertical.SetRelativeLayout (Viewport); _vertical.Draw (); } if (h) { - _horizontal.SetRelativeLayout (Bounds); + _horizontal.SetRelativeLayout (Viewport); _horizontal.Draw (); } @@ -710,7 +710,7 @@ private void ShowHideScrollBars () if (v && h) { - _contentBottomRightCorner.SetRelativeLayout (Bounds); + _contentBottomRightCorner.SetRelativeLayout (Viewport); _contentBottomRightCorner.Draw (); } } diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index 7500037246..08a4815549 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -669,11 +669,11 @@ internal void CalcSpacingConfig () // Calculate the size of the slider based on the size of the SuperView's Bounds. if (_config._sliderOrientation == Orientation.Horizontal) { - size = int.Min (SuperView.Bounds.Width, CalcBestLength ()); + size = int.Min (SuperView.Viewport.Width, CalcBestLength ()); } else { - size = int.Min (SuperView.Bounds.Height, CalcBestLength ()); + size = int.Min (SuperView.Viewport.Height, CalcBestLength ()); } } else @@ -689,11 +689,11 @@ internal void CalcSpacingConfig () // Fit Slider to the Bounds if (_config._sliderOrientation == Orientation.Horizontal) { - size = Bounds.Width; + size = Viewport.Width; } else { - size = Bounds.Height; + size = Viewport.Height; } } @@ -777,15 +777,15 @@ public void SetBoundsBestFit () if (_config._sliderOrientation == Orientation.Horizontal) { - Bounds = new ( - Bounds.Location, + Viewport = new ( + Viewport.Location, new ( int.Min ( - SuperView.Bounds.Width - adornmentsThickness.Horizontal, + SuperView.Viewport.Width - adornmentsThickness.Horizontal, CalcBestLength () ), int.Min ( - SuperView.Bounds.Height - adornmentsThickness.Vertical, + SuperView.Viewport.Height - adornmentsThickness.Vertical, CalcThickness () ) ) @@ -793,15 +793,15 @@ public void SetBoundsBestFit () } else { - Bounds = new ( - Bounds.Location, + Viewport = new ( + Viewport.Location, new ( int.Min ( - SuperView.Bounds.Width - adornmentsThickness.Horizontal, + SuperView.Viewport.Width - adornmentsThickness.Horizontal, CalcThickness () ), int.Min ( - SuperView.Bounds.Height - adornmentsThickness.Vertical, + SuperView.Viewport.Height - adornmentsThickness.Vertical, CalcBestLength () ) ) @@ -988,7 +988,7 @@ public override void PositionCursor () if (TryGetPositionByOption (FocusedOption, out (int x, int y) position)) { - if (IsInitialized && Bounds.Contains (position.x, position.y)) + if (IsInitialized && Viewport.Contains (position.x, position.y)) { Move (position.x, position.y); } @@ -1073,7 +1073,7 @@ private string AlignText (string text, int width, TextAlignment textAlignment) private void DrawSlider () { // TODO: be more surgical on clear - Clear (Bounds); + Clear (Viewport); // Attributes @@ -1241,7 +1241,7 @@ private void DrawSlider () } } - int remaining = isVertical ? Bounds.Height - y : Bounds.Width - x; + int remaining = isVertical ? Viewport.Height - y : Viewport.Width - x; // Right Spacing if (_config._showEndSpacing) diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 88689e2c5e..7ff5eca7d6 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -297,7 +297,7 @@ public void EnsureSelectedTabIsVisible () } // if current viewport does not include the selected tab - if (!CalculateViewport (Bounds).Any (r => Equals (SelectedTab, r.Tab))) + if (!CalculateViewport (Viewport).Any (r => Equals (SelectedTab, r.Tab))) { // Set scroll offset so the first tab rendered is the TabScrollOffset = Math.Max (0, Tabs.IndexOf (SelectedTab)); @@ -659,7 +659,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) public override void OnDrawContent (Rectangle contentArea) { - _host._tabLocations = _host.CalculateViewport (Bounds).ToArray (); + _host._tabLocations = _host.CalculateViewport (Viewport).ToArray (); // clear any old text Clear (contentArea); @@ -683,7 +683,7 @@ public override void OnDrawContentComplete (Rectangle contentArea) for (var i = 0; i < tabLocations.Length; i++) { View tab = tabLocations [i].Tab; - Rectangle vts = tab.BoundsToScreen (tab.Bounds); + Rectangle vts = tab.BoundsToScreen (tab.Viewport); var lc = new LineCanvas (); int selectedOffset = _host.Style.ShowTopLine && tabLocations [i].IsSelected ? 0 : 1; @@ -1115,7 +1115,7 @@ public override void OnDrawContentComplete (Rectangle contentArea) int lastSelectedTab = !_host.Style.ShowTopLine && i == selectedTab ? 1 : _host.Style.TabsOnBottom ? 1 : 0; - Rectangle tabsBarVts = BoundsToScreen (Bounds); + Rectangle tabsBarVts = BoundsToScreen (Viewport); int lineLength = tabsBarVts.Right - vts.Right; // Right horizontal line @@ -1238,7 +1238,7 @@ private void RenderTabLine () View selected = null; int topLine = _host.Style.ShowTopLine ? 1 : 0; - int width = Bounds.Width; + int width = Viewport.Width; foreach (TabToRender toRender in tabLocations) { @@ -1314,7 +1314,7 @@ private void RenderTabLine () } tab.TextFormatter.Draw ( - tab.BoundsToScreen (tab.Bounds), + tab.BoundsToScreen (tab.Viewport), prevAttr, ColorScheme.HotNormal ); @@ -1360,7 +1360,7 @@ private void RenderUnderline () // if there are more tabs to the right not visible if (ShouldDrawRightScrollIndicator ()) { - _rightScrollIndicator.X = Bounds.Width - 1; + _rightScrollIndicator.X = Viewport.Width - 1; _rightScrollIndicator.Y = y; // indicate that diff --git a/Terminal.Gui/Views/TableView/ListTableSource.cs b/Terminal.Gui/Views/TableView/ListTableSource.cs index 8695155019..1286e2660a 100644 --- a/Terminal.Gui/Views/TableView/ListTableSource.cs +++ b/Terminal.Gui/Views/TableView/ListTableSource.cs @@ -109,12 +109,12 @@ private int CalculateColumns () if (Style.Orientation == Orientation.Vertical != Style.ScrollParallel) { - float f = (float)_tableView.Bounds.Height - _tableView.GetHeaderHeight (); + float f = (float)_tableView.Viewport.Height - _tableView.GetHeaderHeight (); cols = (int)Math.Ceiling (Count / f); } else { - cols = (int)Math.Ceiling (((float)_tableView.Bounds.Width - 1) / colWidth) - 2; + cols = (int)Math.Ceiling (((float)_tableView.Viewport.Width - 1) / colWidth) - 2; } return cols > 1 ? cols : 1; @@ -179,7 +179,7 @@ private DataTable CreateTable (int cols = 1) private void TableView_DrawContent (object sender, DrawEventArgs e) { - if (!_tableView.Bounds.Equals (_lastBounds) + if (!_tableView.Viewport.Equals (_lastBounds) || _tableView.MaxCellWidth != _lastMaxCellWidth || _tableView.MinCellWidth != _lastMinCellWidth || Style != _lastStyle @@ -188,7 +188,7 @@ private void TableView_DrawContent (object sender, DrawEventArgs e) DataTable = CreateTable (CalculateColumns ()); } - _lastBounds = _tableView.Bounds; + _lastBounds = _tableView.Viewport; _lastMinCellWidth = _tableView.MaxCellWidth; _lastMaxCellWidth = _tableView.MaxCellWidth; _lastStyle = Style; diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 3525471681..d444af67ae 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -483,7 +483,7 @@ public ITableSource Table return null; } - IEnumerable viewPort = CalculateViewport (Bounds); + IEnumerable viewPort = CalculateViewport (Viewport); int headerHeight = GetHeaderHeightIfAny (); @@ -502,7 +502,7 @@ public ITableSource Table } // the cell is way down below the scroll area and off the screen - if (tableRow > RowOffset + (Bounds.Height - headerHeight)) + if (tableRow > RowOffset + (Viewport.Height - headerHeight)) { return null; } @@ -577,7 +577,7 @@ public void EnsureSelectedCellIsVisible () return; } - ColumnToRender [] columnsToRender = CalculateViewport (Bounds).ToArray (); + ColumnToRender [] columnsToRender = CalculateViewport (Viewport).ToArray (); int headerHeight = GetHeaderHeightIfAny (); //if we have scrolled too far to the left @@ -595,7 +595,7 @@ public void EnsureSelectedCellIsVisible () while (SelectedColumn > columnsToRender.Max (r => r.Column)) { ColumnOffset++; - columnsToRender = CalculateViewport (Bounds).ToArray (); + columnsToRender = CalculateViewport (Viewport).ToArray (); // if we are already scrolled to the last column then break // this will prevent any theoretical infinite loop @@ -612,9 +612,9 @@ public void EnsureSelectedCellIsVisible () } //if we have scrolled too far down - if (SelectedRow >= RowOffset + (Bounds.Height - headerHeight)) + if (SelectedRow >= RowOffset + (Viewport.Height - headerHeight)) { - RowOffset = SelectedRow - (Bounds.Height - headerHeight) + 1; + RowOffset = SelectedRow - (Viewport.Height - headerHeight) + 1; } //if we have scrolled too far up @@ -906,12 +906,12 @@ public override void OnDrawContent (Rectangle contentArea) scrollLeftPoint = null; // What columns to render at what X offset in viewport - ColumnToRender [] columnsToRender = CalculateViewport (Bounds).ToArray (); + ColumnToRender [] columnsToRender = CalculateViewport (Viewport).ToArray (); Driver.SetAttribute (GetNormalColor ()); //invalidate current row (prevents scrolling around leaving old characters in the frame - Driver.AddStr (new string (' ', Bounds.Width)); + Driver.AddStr (new string (' ', Viewport.Width)); var line = 0; @@ -925,7 +925,7 @@ public override void OnDrawContent (Rectangle contentArea) */ if (Style.ShowHorizontalHeaderOverline) { - RenderHeaderOverline (line, Bounds.Width, columnsToRender); + RenderHeaderOverline (line, Viewport.Width, columnsToRender); line++; } @@ -937,7 +937,7 @@ public override void OnDrawContent (Rectangle contentArea) if (Style.ShowHorizontalHeaderUnderline) { - RenderHeaderUnderline (line, Bounds.Width, columnsToRender); + RenderHeaderUnderline (line, Viewport.Width, columnsToRender); line++; } } @@ -945,9 +945,9 @@ public override void OnDrawContent (Rectangle contentArea) int headerLinesConsumed = line; //render the cells - for (; line < Bounds.Height; line++) + for (; line < Viewport.Height; line++) { - ClearLine (line, Bounds.Width); + ClearLine (line, Viewport.Width); //work out what Row to render int rowToRender = RowOffset + (line - headerLinesConsumed); @@ -963,7 +963,7 @@ public override void OnDrawContent (Rectangle contentArea) { if (rowToRender == Table.Rows && Style.ShowHorizontalBottomline) { - RenderBottomLine (line, Bounds.Width, columnsToRender); + RenderBottomLine (line, Viewport.Width, columnsToRender); } continue; @@ -1001,7 +1001,7 @@ public override bool OnProcessKeyDown (Key keyEvent) /// true to extend the current selection (if any) instead of replacing public void PageDown (bool extend) { - ChangeSelectionByOffset (0, Bounds.Height - GetHeaderHeightIfAny (), extend); + ChangeSelectionByOffset (0, Viewport.Height - GetHeaderHeightIfAny (), extend); Update (); } @@ -1009,7 +1009,7 @@ public void PageDown (bool extend) /// true to extend the current selection (if any) instead of replacing public void PageUp (bool extend) { - ChangeSelectionByOffset (0, -(Bounds.Height - GetHeaderHeightIfAny ()), extend); + ChangeSelectionByOffset (0, -(Viewport.Height - GetHeaderHeightIfAny ()), extend); Update (); } @@ -1073,7 +1073,7 @@ public override void PositionCursor () return null; } - IEnumerable viewPort = CalculateViewport (Bounds); + IEnumerable viewPort = CalculateViewport (Viewport); int headerHeight = GetHeaderHeightIfAny (); @@ -1658,7 +1658,7 @@ private void RenderHeaderMidline (int row, ColumnToRender [] columnsToRender) // Renders something like: // │ArithmeticComparator│chi │Healthboard│Interpretation│Labnumber│ - ClearLine (row, Bounds.Width); + ClearLine (row, Viewport.Width); //render start of line if (style.ShowVerticalHeaderLines) @@ -1688,7 +1688,7 @@ private void RenderHeaderMidline (int row, ColumnToRender [] columnsToRender) //render end of line if (style.ShowVerticalHeaderLines) { - AddRune (Bounds.Width - 1, row, Glyphs.VLine); + AddRune (Viewport.Width - 1, row, Glyphs.VLine); } } @@ -1846,7 +1846,7 @@ private void RenderRow (int row, int rowToRender, ColumnToRender [] columnsToRen } Driver.SetAttribute (color); - Driver.AddStr (new string (' ', Bounds.Width)); + Driver.AddStr (new string (' ', Viewport.Width)); // Render cells for each visible header for the current row for (var i = 0; i < columnsToRender.Length; i++) @@ -1955,7 +1955,7 @@ private void RenderRow (int row, int rowToRender, ColumnToRender [] columnsToRen //render start and end of line AddRune (0, row, Glyphs.VLine); - AddRune (Bounds.Width - 1, row, Glyphs.VLine); + AddRune (Viewport.Width - 1, row, Glyphs.VLine); } } diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index e97a27ec51..1d9d0fd2c5 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -1196,8 +1196,8 @@ public override void PositionCursor () int pos = _cursorPosition - ScrollOffset + Math.Min (Frame.X, 0); int offB = OffSetBackground (); - Rectangle containerFrame = SuperView?.BoundsToScreen (SuperView.Bounds) ?? default (Rectangle); - Rectangle thisFrame = BoundsToScreen (Bounds); + Rectangle containerFrame = SuperView?.BoundsToScreen (SuperView.Viewport) ?? default (Rectangle); + Rectangle thisFrame = BoundsToScreen (Viewport); if (pos > -1 && col >= pos @@ -1878,9 +1878,9 @@ private void RenderCaption () Move (0, 0); string render = Caption; - if (render.GetColumns () > Bounds.Width) + if (render.GetColumns () > Viewport.Width) { - render = render [..Bounds.Width]; + render = render [..Viewport.Width]; } Driver.AddStr (render); @@ -1941,9 +1941,9 @@ private void TextField_Initialized (object sender, EventArgs e) { _cursorPosition = Text.GetRuneCount (); - if (Bounds.Width > 0) + if (Viewport.Width > 0) { - ScrollOffset = _cursorPosition > Bounds.Width + 1 ? _cursorPosition - Bounds.Width + 1 : 0; + ScrollOffset = _cursorPosition > Viewport.Width + 1 ? _cursorPosition - Viewport.Width + 1 : 0; } Autocomplete.HostControl = this; diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index a86cd910f5..ad12ea2581 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -537,7 +537,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed)) { - int c = _provider.Cursor (mouseEvent.X - GetMargins (Bounds.Width).left); + int c = _provider.Cursor (mouseEvent.X - GetMargins (Viewport.Width).left); if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && Text.Length > 0) { @@ -568,7 +568,7 @@ public override void OnDrawContent (Rectangle contentArea) Color bgcolor = !IsValid ? new Color (Color.BrightRed) : ColorScheme.Focus.Background; var textColor = new Attribute (ColorScheme.Focus.Foreground, bgcolor); - (int margin_left, int margin_right) = GetMargins (Bounds.Width); + (int margin_left, int margin_right) = GetMargins (Viewport.Width); Move (0, 0); @@ -642,7 +642,7 @@ public override bool OnProcessKeyDown (Key a) /// public override void PositionCursor () { - (int left, _) = GetMargins (Bounds.Width); + (int left, _) = GetMargins (Viewport.Width); // Fixed = true, is for inputs that have fixed width, like masked ones. // Fixed = false, is for normal input. @@ -660,7 +660,7 @@ public override void PositionCursor () Move (curPos, 0); } - if (curPos < 0 || curPos >= Bounds.Width) + if (curPos < 0 || curPos >= Viewport.Width) { Application.Driver.SetCursorVisibility (CursorVisibility.Invisible); } diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 8ef1c5b4aa..5938820520 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -156,7 +156,7 @@ public override void LayoutSubviews () return; } - Rectangle contentArea = Bounds; + Rectangle contentArea = Viewport; if (HasBorder ()) { @@ -195,19 +195,19 @@ public override void OnDrawContent (Rectangle contentArea) { if (HasBorder ()) { - lc.AddLine (Point.Empty, Bounds.Width, Orientation.Horizontal, LineStyle); - lc.AddLine (Point.Empty, Bounds.Height, Orientation.Vertical, LineStyle); + lc.AddLine (Point.Empty, Viewport.Width, Orientation.Horizontal, LineStyle); + lc.AddLine (Point.Empty, Viewport.Height, Orientation.Vertical, LineStyle); lc.AddLine ( - new Point (Bounds.Width - 1, Bounds.Height - 1), - -Bounds.Width, + new Point (Viewport.Width - 1, Viewport.Height - 1), + -Viewport.Width, Orientation.Horizontal, LineStyle ); lc.AddLine ( - new Point (Bounds.Width - 1, Bounds.Height - 1), - -Bounds.Height, + new Point (Viewport.Width - 1, Viewport.Height - 1), + -Viewport.Height, Orientation.Vertical, LineStyle ); @@ -241,7 +241,7 @@ public override void OnDrawContent (Rectangle contentArea) Driver.SetAttribute (ColorScheme.Normal); - foreach (KeyValuePair p in lc.GetMap (Bounds)) + foreach (KeyValuePair p in lc.GetMap (Viewport)) { AddRune (p.Key.X, p.Key.Y, p.Value); } @@ -423,7 +423,7 @@ public bool SetSplitterPos (int idx, Pos value) ); } - int fullSpace = _orientation == Orientation.Vertical ? Bounds.Width : Bounds.Height; + int fullSpace = _orientation == Orientation.Vertical ? Viewport.Width : Viewport.Height; if (fullSpace != 0 && !IsValidNewSplitterPos (idx, value, fullSpace)) { @@ -806,14 +806,14 @@ private void Setup (Rectangle contentArea) tile.ContentView.X = i == 0 ? contentArea.X : Pos.Right (visibleSplitterLines [i - 1]); tile.ContentView.Y = contentArea.Y; tile.ContentView.Height = contentArea.Height; - tile.ContentView.Width = GetTileWidthOrHeight (i, Bounds.Width, visibleTiles, visibleSplitterLines); + tile.ContentView.Width = GetTileWidthOrHeight (i, Viewport.Width, visibleTiles, visibleSplitterLines); } else { tile.ContentView.X = contentArea.X; tile.ContentView.Y = i == 0 ? contentArea.Y : Pos.Bottom (visibleSplitterLines [i - 1]); tile.ContentView.Width = contentArea.Width; - tile.ContentView.Height = GetTileWidthOrHeight (i, Bounds.Height, visibleTiles, visibleSplitterLines); + tile.ContentView.Height = GetTileWidthOrHeight (i, Viewport.Height, visibleTiles, visibleSplitterLines); } } } @@ -845,7 +845,7 @@ internal string GetTrimmedTitle () { Dim spaceDim = Tile.ContentView.Width; - int spaceAbs = spaceDim.Anchor (Parent.Bounds.Width); + int spaceAbs = spaceDim.Anchor (Parent.Viewport.Width); var title = $" {Tile.Title} "; @@ -893,7 +893,7 @@ public void DrawSplitterSymbol () { if (dragPosition is { } || CanFocus) { - Point location = moveRuneRenderLocation ?? new Point (Bounds.Width / 2, Bounds.Height / 2); + Point location = moveRuneRenderLocation ?? new Point (Viewport.Width / 2, Viewport.Height / 2); AddRune (location.X, location.Y, Glyphs.Diamond); } @@ -919,7 +919,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { moveRuneRenderLocation = new Point ( 0, - Math.Max (1, Math.Min (Bounds.Height - 2, mouseEvent.Y)) + Math.Max (1, Math.Min (Viewport.Height - 2, mouseEvent.Y)) ); } } @@ -943,7 +943,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { int dx = mouseEvent.X - dragPosition.Value.X; Parent.SetSplitterPos (Idx, Offset (X, dx)); - moveRuneRenderLocation = new Point (0, Math.Max (1, Math.Min (Bounds.Height - 2, mouseEvent.Y))); + moveRuneRenderLocation = new Point (0, Math.Max (1, Math.Min (Viewport.Height - 2, mouseEvent.Y))); } Parent.SetNeedsDisplay (); @@ -988,7 +988,7 @@ public override void PositionCursor () { base.PositionCursor (); - Point location = moveRuneRenderLocation ?? new Point (Bounds.Width / 2, Bounds.Height / 2); + Point location = moveRuneRenderLocation ?? new Point (Viewport.Width / 2, Viewport.Height / 2); Move (location.X, location.Y); } @@ -1032,10 +1032,10 @@ private bool FinalisePosition (Pos oldValue, Pos newValue) { if (Orientation == Orientation.Horizontal) { - return Parent.SetSplitterPos (Idx, ConvertToPosFactor (newValue, Parent.Bounds.Height)); + return Parent.SetSplitterPos (Idx, ConvertToPosFactor (newValue, Parent.Viewport.Height)); } - return Parent.SetSplitterPos (Idx, ConvertToPosFactor (newValue, Parent.Bounds.Width)); + return Parent.SetSplitterPos (Idx, ConvertToPosFactor (newValue, Parent.Viewport.Width)); } return Parent.SetSplitterPos (Idx, newValue); @@ -1071,8 +1071,8 @@ private Pos Offset (Pos pos, int delta) { int posAbsolute = pos.Anchor ( Orientation == Orientation.Horizontal - ? Parent.Bounds.Height - : Parent.Bounds.Width + ? Parent.Viewport.Height + : Parent.Viewport.Width ); return posAbsolute + delta; diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index ed0a11501e..60f264984f 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -268,12 +268,12 @@ public override void OnDrawContent (Rectangle contentArea) { foreach (Toplevel top in Application.OverlappedChildren.AsEnumerable ().Reverse ()) { - if (top.Frame.IntersectsWith (Bounds)) + if (top.Frame.IntersectsWith (Viewport)) { if (top != this && !top.IsCurrentTop && !OutsideTopFrame (top) && top.Visible) { top.SetNeedsLayout (); - top.SetNeedsDisplay (top.Bounds); + top.SetNeedsDisplay (top.Viewport); top.Draw (); top.OnRenderLineCanvas (); } @@ -284,10 +284,10 @@ public override void OnDrawContent (Rectangle contentArea) // This should not be here, but in base foreach (View view in Subviews) { - if (view.Frame.IntersectsWith (Bounds) && !OutsideTopFrame (this)) + if (view.Frame.IntersectsWith (Viewport) && !OutsideTopFrame (this)) { //view.SetNeedsLayout (); - view.SetNeedsDisplay (view.Bounds); + view.SetNeedsDisplay (view.Viewport); view.SetSubViewNeedsDisplay (); } } diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs index 941948737b..ef15270021 100644 --- a/Terminal.Gui/Views/TreeView/TreeView.cs +++ b/Terminal.Gui/Views/TreeView/TreeView.cs @@ -742,10 +742,10 @@ public void EnsureVisible (T model) //if user has scrolled up too far to see their selection ScrollOffsetVertical = idx; } - else if (idx >= ScrollOffsetVertical + Bounds.Height - leaveSpace) + else if (idx >= ScrollOffsetVertical + Viewport.Height - leaveSpace) { //if user has scrolled off bottom of visible tree - ScrollOffsetVertical = Math.Max (0, idx + 1 - (Bounds.Height - leaveSpace)); + ScrollOffsetVertical = Math.Max (0, idx + 1 - (Viewport.Height - leaveSpace)); } } @@ -868,12 +868,12 @@ public int GetContentWidth (bool visible) } // If control has no height to it then there is no visible area for content - if (Bounds.Height == 0) + if (Viewport.Height == 0) { return 0; } - return map.Skip (ScrollOffsetVertical).Take (Bounds.Height).Max (b => b.GetWidth (Driver)); + return map.Skip (ScrollOffsetVertical).Take (Viewport.Height).Max (b => b.GetWidth (Driver)); } return map.Max (b => b.GetWidth (Driver)); @@ -886,13 +886,13 @@ public int GetContentWidth (bool visible) /// If you have screen coordinates then use to translate these into the client area of /// the . /// - /// The row of the of the . + /// The row of the of the . /// The object currently displayed on this row or null. public T GetObjectOnRow (int row) { return HitTest (row)?.Model; } /// /// - /// Returns the Y coordinate within the of the tree at which + /// Returns the Y coordinate within the of the tree at which /// would be displayed or null if it is not currently exposed (e.g. its parent is collapsed). /// /// @@ -967,7 +967,7 @@ public void GoTo (T toSelect) public void GoToEnd () { IReadOnlyCollection> map = BuildLineMap (); - ScrollOffsetVertical = Math.Max (0, map.Count - Bounds.Height + 1); + ScrollOffsetVertical = Math.Max (0, map.Count - Viewport.Height + 1); SelectedObject = map.LastOrDefault ()?.Model; SetNeedsDisplay (); @@ -1129,12 +1129,12 @@ protected internal override bool OnMouseEvent (MouseEvent me) /// Moves the selection down by the height of the control (1 page). /// True if the navigation should add the covered nodes to the selected current selection. /// - public void MovePageDown (bool expandSelection = false) { AdjustSelection (Bounds.Height, expandSelection); } + public void MovePageDown (bool expandSelection = false) { AdjustSelection (Viewport.Height, expandSelection); } /// Moves the selection up by the height of the control (1 page). /// True if the navigation should add the covered nodes to the selected current selection. /// - public void MovePageUp (bool expandSelection = false) { AdjustSelection (-Bounds.Height, expandSelection); } + public void MovePageUp (bool expandSelection = false) { AdjustSelection (-Viewport.Height, expandSelection); } /// /// This event is raised when an object is activated e.g. by double clicking or pressing @@ -1160,7 +1160,7 @@ public override void OnDrawContent (Rectangle contentArea) IReadOnlyCollection> map = BuildLineMap (); - for (var line = 0; line < Bounds.Height; line++) + for (var line = 0; line < Viewport.Height; line++) { int idxToRender = ScrollOffsetVertical + line; @@ -1168,14 +1168,14 @@ public override void OnDrawContent (Rectangle contentArea) if (idxToRender < map.Count) { // Render the line - map.ElementAt (idxToRender).Draw (Driver, ColorScheme, line, Bounds.Width); + map.ElementAt (idxToRender).Draw (Driver, ColorScheme, line, Viewport.Width); } else { // Else clear the line to prevent stale symbols due to scrolling etc Move (0, line); Driver.SetAttribute (GetNormalColor ()); - Driver.AddStr (new string (' ', Bounds.Width)); + Driver.AddStr (new string (' ', Viewport.Width)); } } } @@ -1247,7 +1247,7 @@ public override void PositionCursor () int idx = map.IndexOf (b => b.Model.Equals (SelectedObject)); // if currently selected line is visible - if (idx - ScrollOffsetVertical >= 0 && idx - ScrollOffsetVertical < Bounds.Height) + if (idx - ScrollOffsetVertical >= 0 && idx - ScrollOffsetVertical < Viewport.Height) { Move (0, idx - ScrollOffsetVertical); } diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs index c597b18d9f..6fbdaf4acb 100644 --- a/UICatalog/Scenarios/ASCIICustomButton.cs +++ b/UICatalog/Scenarios/ASCIICustomButton.cs @@ -79,14 +79,14 @@ public void CustomInitialize () var fillText = new StringBuilder (); - for (var i = 0; i < Bounds.Height; i++) + for (var i = 0; i < Viewport.Height; i++) { if (i > 0) { fillText.AppendLine (""); } - for (var j = 0; j < Bounds.Width; j++) + for (var j = 0; j < Viewport.Width; j++) { fillText.Append ("█"); } diff --git a/UICatalog/Scenarios/Animation.cs b/UICatalog/Scenarios/Animation.cs index b5c875519f..db91439d77 100644 --- a/UICatalog/Scenarios/Animation.cs +++ b/UICatalog/Scenarios/Animation.cs @@ -167,12 +167,12 @@ public override void OnDrawContent (Rectangle contentArea) { base.OnDrawContent (contentArea); - if (oldSize != Bounds) + if (oldSize != Viewport) { // Invalidate cached images now size has changed matchSizes = new Image [frameCount]; brailleCache = new string [frameCount]; - oldSize = Bounds; + oldSize = Viewport; } Image imgScaled = matchSizes [currentFrame]; @@ -183,7 +183,7 @@ public override void OnDrawContent (Rectangle contentArea) Image imgFull = fullResImages [currentFrame]; // keep aspect ratio - int newSize = Math.Min (Bounds.Width, Bounds.Height); + int newSize = Math.Min (Viewport.Width, Viewport.Height); // generate one matchSizes [currentFrame] = imgScaled = imgFull.Clone ( diff --git a/UICatalog/Scenarios/BackgroundWorkerCollection.cs b/UICatalog/Scenarios/BackgroundWorkerCollection.cs index 9445c226fb..eebc86d4f1 100644 --- a/UICatalog/Scenarios/BackgroundWorkerCollection.cs +++ b/UICatalog/Scenarios/BackgroundWorkerCollection.cs @@ -285,7 +285,7 @@ public StagingUIController () LayoutStarted += (s, e) => { int btnsWidth = _start.Frame.Width + _close.Frame.Width + 2 - 1; - int shiftLeft = Math.Max ((Bounds.Width - btnsWidth) / 2 - 2, 0); + int shiftLeft = Math.Max ((Viewport.Width - btnsWidth) / 2 - 2, 0); shiftLeft += _close.Frame.Width + 1; _close.X = Pos.AnchorEnd (shiftLeft); diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 4921ccd711..fa90d8539f 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -373,7 +373,7 @@ public CharMap () Command.PageUp, () => { - int page = (Bounds.Height / _rowHeight - 1) * 16; + int page = (Viewport.Height / _rowHeight - 1) * 16; SelectedCodePoint -= Math.Min (page, SelectedCodePoint); return true; @@ -384,7 +384,7 @@ public CharMap () Command.PageDown, () => { - int page = (Bounds.Height / _rowHeight - 1) * 16; + int page = (Viewport.Height / _rowHeight - 1) * 16; SelectedCodePoint += Math.Min (page, MaxCodePoint - SelectedCodePoint); return true; @@ -457,7 +457,7 @@ public int SelectedCodePoint int row = SelectedCodePoint / 16 * _rowHeight; int col = SelectedCodePoint % 16 * COLUMN_WIDTH; - int height = Bounds.Height - (ShowHorizontalScrollIndicator ? 2 : 1); + int height = Viewport.Height - (ShowHorizontalScrollIndicator ? 2 : 1); if (row + ContentOffset.Y < 0) { @@ -473,7 +473,7 @@ public int SelectedCodePoint ); } - int width = Bounds.Width / COLUMN_WIDTH * COLUMN_WIDTH - (ShowVerticalScrollIndicator ? RowLabelWidth + 1 : RowLabelWidth); + int width = Viewport.Width / COLUMN_WIDTH * COLUMN_WIDTH - (ShowVerticalScrollIndicator ? RowLabelWidth + 1 : RowLabelWidth); if (col + ContentOffset.X < 0) { @@ -559,8 +559,8 @@ public override void OnDrawContentComplete (Rectangle contentArea) Rectangle viewport = new ( ContentOffset, new ( - Math.Max (Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0), - Math.Max (Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0), 0) + Math.Max (Viewport.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0), + Math.Max (Viewport.Height - (ShowHorizontalScrollIndicator ? 1 : 0), 0) ) ); @@ -608,7 +608,7 @@ public override void OnDrawContentComplete (Rectangle contentArea) int firstColumnX = viewport.X + RowLabelWidth; - for (var y = 1; y < Bounds.Height; y++) + for (var y = 1; y < Viewport.Height; y++) { // What row is this? int row = (y - ContentOffset.Y - 1) / _rowHeight; @@ -733,9 +733,9 @@ public override void PositionCursor () { if (HasFocus && Cursor.X >= RowLabelWidth - && Cursor.X < Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0) + && Cursor.X < Viewport.Width - (ShowVerticalScrollIndicator ? 1 : 0) && Cursor.Y > 0 - && Cursor.Y < Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0)) + && Cursor.Y < Viewport.Height - (ShowHorizontalScrollIndicator ? 1 : 0)) { Driver.SetCursorVisibility (_cursor); Move (Cursor.X, Cursor.Y); diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index f15fc77267..ead701305a 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -56,12 +56,12 @@ public override void Setup () Application.Top.LayoutComplete += (s, a) => { horizontalRuler.Text = - rule.Repeat ((int)Math.Ceiling (horizontalRuler.Bounds.Width / (double)rule.Length)) [ - ..horizontalRuler.Bounds.Width]; + rule.Repeat ((int)Math.Ceiling (horizontalRuler.Viewport.Width / (double)rule.Length)) [ + ..horizontalRuler.Viewport.Width]; verticalRuler.Text = - vrule.Repeat ((int)Math.Ceiling (verticalRuler.Bounds.Height * 2 / (double)rule.Length)) - [..(verticalRuler.Bounds.Height * 2)]; + vrule.Repeat ((int)Math.Ceiling (verticalRuler.Viewport.Height * 2 / (double)rule.Length)) + [..(verticalRuler.Viewport.Height * 2)]; }; Application.Top.Add (verticalRuler); diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs index 01cbb7c87d..94561b0140 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -758,8 +758,8 @@ private void CreateFindReplace (bool isFind = true) _winDialog = new Window { Title = isFind ? "Find" : "Replace", - X = Win.Bounds.Width / 2 - 30, - Y = Win.Bounds.Height / 2 - 10, + X = Win.Viewport.Width / 2 - 30, + Y = Win.Viewport.Height / 2 - 10, ColorScheme = Colors.ColorSchemes ["TopLevel"] }; diff --git a/UICatalog/Scenarios/GraphViewExample.cs b/UICatalog/Scenarios/GraphViewExample.cs index 8ca960a23a..caef010a10 100644 --- a/UICatalog/Scenarios/GraphViewExample.cs +++ b/UICatalog/Scenarios/GraphViewExample.cs @@ -254,7 +254,7 @@ private void MultiBarGraph () _graphView.AxisY.Minimum = 0; - var legend = new LegendAnnotation (new Rectangle (_graphView.Bounds.Width - 20, 0, 20, 5)); + var legend = new LegendAnnotation (new Rectangle (_graphView.Viewport.Width - 20, 0, 20, 5)); legend.AddEntry ( new GraphCellToRender (stiple, series.SubSeries.ElementAt (0).OverrideBarColor), @@ -872,7 +872,7 @@ private void SetupPopulationPyramid () _graphView.Annotations.Add (new TextAnnotation { Text = "M", ScreenPosition = new Point (0, 10) }); _graphView.Annotations.Add ( - new TextAnnotation { Text = "F", ScreenPosition = new Point (_graphView.Bounds.Width - 1, 10) } + new TextAnnotation { Text = "F", ScreenPosition = new Point (_graphView.Viewport.Width - 1, 10) } ); _graphView.SetNeedsDisplay (); diff --git a/UICatalog/Scenarios/ProgressBarStyles.cs b/UICatalog/Scenarios/ProgressBarStyles.cs index 44b2875b1b..0d3f93fe9e 100644 --- a/UICatalog/Scenarios/ProgressBarStyles.cs +++ b/UICatalog/Scenarios/ProgressBarStyles.cs @@ -70,7 +70,7 @@ ColorName ChooseColor (string text, ColorName colorName) dialog.X = pbList.Frame.X; dialog.Y = pbList.Frame.Height; - dialog.Bounds = new Rectangle (0, 0, colorPicker.Frame.Width, colorPicker.Frame.Height); + dialog.Viewport = new Rectangle (0, 0, colorPicker.Frame.Width, colorPicker.Frame.Height); Application.Top.LayoutSubviews (); }; diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs index dd07728035..8bdda1cb31 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -67,17 +67,17 @@ public override void Setup () void Top_Loaded (object sender, EventArgs args) { horizontalRuler.Text = - rule.Repeat ((int)Math.Ceiling (horizontalRuler.Bounds.Width / (double)rule.Length)) [ - ..horizontalRuler.Bounds.Width] + rule.Repeat ((int)Math.Ceiling (horizontalRuler.Viewport.Width / (double)rule.Length)) [ + ..horizontalRuler.Viewport.Width] + "\n" + "| ".Repeat ( - (int)Math.Ceiling (horizontalRuler.Bounds.Width / (double)rule.Length) + (int)Math.Ceiling (horizontalRuler.Viewport.Width / (double)rule.Length) ) [ - ..horizontalRuler.Bounds.Width]; + ..horizontalRuler.Viewport.Width]; verticalRuler.Text = - vrule.Repeat ((int)Math.Ceiling (verticalRuler.Bounds.Height * 2 / (double)rule.Length)) - [..(verticalRuler.Bounds.Height * 2)]; + vrule.Repeat ((int)Math.Ceiling (verticalRuler.Viewport.Height * 2 / (double)rule.Length)) + [..(verticalRuler.Viewport.Height * 2)]; Application.Top.Loaded -= Top_Loaded; } diff --git a/UICatalog/Scenarios/Snake.cs b/UICatalog/Scenarios/Snake.cs index 5c08962f22..2938addcf3 100644 --- a/UICatalog/Scenarios/Snake.cs +++ b/UICatalog/Scenarios/Snake.cs @@ -341,7 +341,7 @@ public override void OnDrawContent (Rectangle contentArea) ); } - foreach (KeyValuePair p in canvas.GetMap (Bounds)) + foreach (KeyValuePair p in canvas.GetMap (Viewport)) { AddRune (p.Key.X, p.Key.Y, p.Value); } diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index f1303e0bfe..159dd75879 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -218,17 +218,17 @@ public override void Setup () $"Container.Frame: { Application.Top.Frame } .Bounds: { - Application.Top.Bounds + Application.Top.Viewport }\nView.Frame: { view.Frame } .Bounds: { - view.Bounds + view.Viewport } .BoundsOffset: { view.GetBoundsOffset () }\n .Padding.Frame: { view.Padding.Frame } .Padding.Bounds: { - view.Padding.Bounds + view.Padding.Viewport }"; }; diff --git a/UICatalog/Scenarios/VkeyPacketSimulator.cs b/UICatalog/Scenarios/VkeyPacketSimulator.cs index 37ffced397..bdcfc6feaa 100644 --- a/UICatalog/Scenarios/VkeyPacketSimulator.cs +++ b/UICatalog/Scenarios/VkeyPacketSimulator.cs @@ -265,20 +265,20 @@ void Win_LayoutComplete (object sender, LayoutEventArgs obj) inputHorizontalRuler.Text = outputHorizontalRuler.Text = ruler.Repeat ( (int)Math.Ceiling ( - inputHorizontalRuler.Bounds.Width + inputHorizontalRuler.Viewport.Width / (double)ruler.Length ) ) [ - ..inputHorizontalRuler.Bounds.Width]; + ..inputHorizontalRuler.Viewport.Width]; inputVerticalRuler.Height = tvInput.Frame.Height + 1; inputVerticalRuler.Text = - ruler.Repeat ((int)Math.Ceiling (inputVerticalRuler.Bounds.Height / (double)ruler.Length)) [ - ..inputVerticalRuler.Bounds.Height]; + ruler.Repeat ((int)Math.Ceiling (inputVerticalRuler.Viewport.Height / (double)ruler.Length)) [ + ..inputVerticalRuler.Viewport.Height]; outputVerticalRuler.Text = - ruler.Repeat ((int)Math.Ceiling (outputVerticalRuler.Bounds.Height / (double)ruler.Length)) [ - ..outputVerticalRuler.Bounds.Height]; + ruler.Repeat ((int)Math.Ceiling (outputVerticalRuler.Viewport.Height / (double)ruler.Length)) [ + ..outputVerticalRuler.Viewport.Height]; } Win.LayoutComplete += Win_LayoutComplete; diff --git a/UnitTests/Drawing/LineCanvasTests.cs b/UnitTests/Drawing/LineCanvasTests.cs index c2fb7c39ee..35968090b3 100644 --- a/UnitTests/Drawing/LineCanvasTests.cs +++ b/UnitTests/Drawing/LineCanvasTests.cs @@ -293,7 +293,7 @@ string expected View v = GetCanvas (out LineCanvas lc); v.Width = 10; v.Height = 10; - v.Bounds = new Rectangle (0, 0, 10, 10); + v.Viewport = new Rectangle (0, 0, 10, 10); lc.AddLine (new Point (x1, y1), len1, o1, s1); lc.AddLine (new Point (x2, y2), len2, o2, s2); @@ -990,7 +990,7 @@ string expected View v = GetCanvas (out LineCanvas lc); v.Width = 10; v.Height = 10; - v.Bounds = new Rectangle (0, 0, 10, 10); + v.Viewport = new Rectangle (0, 0, 10, 10); lc.AddLine (new Point (x1, y1), length, o1, s1); @@ -1304,7 +1304,7 @@ public void Zero_Length_Intersections () /// private View GetCanvas (out LineCanvas canvas, int offsetX = 0, int offsetY = 0) { - var v = new View { Width = 10, Height = 5, Bounds = new Rectangle (0, 0, 10, 5) }; + var v = new View { Width = 10, Height = 5, Viewport = new Rectangle (0, 0, 10, 5) }; Application.Top.Add (v); Application.Begin (Application.Top); @@ -1312,7 +1312,7 @@ private View GetCanvas (out LineCanvas canvas, int offsetX = 0, int offsetY = 0) v.DrawContentComplete += (s, e) => { - v.Clear (v.Bounds); + v.Clear (v.Viewport); foreach (KeyValuePair p in canvasCopy.GetMap ()) { diff --git a/UnitTests/UICatalog/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs index 6a2b7803fa..0e23dc4bc8 100644 --- a/UnitTests/UICatalog/ScenarioTests.cs +++ b/UnitTests/UICatalog/ScenarioTests.cs @@ -254,7 +254,7 @@ public void Run_All_Views_Tester_Scenario () _hostPane.Remove (_curView); _curView.Dispose (); _curView = null; - _hostPane.Clear (_hostPane.Bounds); + _hostPane.Clear (_hostPane.Viewport); } _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]); diff --git a/UnitTests/View/Adornment/AdornmentTests.cs b/UnitTests/View/Adornment/AdornmentTests.cs index 1d6e5b6e04..8d8752742d 100644 --- a/UnitTests/View/Adornment/AdornmentTests.cs +++ b/UnitTests/View/Adornment/AdornmentTests.cs @@ -21,25 +21,25 @@ public void Bounds_Location_Always_Empty_Size_Correct () view.EndInit (); Assert.Equal (new (1, 2, 20, 20), view.Frame); - Assert.Equal (new (0, 0, 20, 20), view.Bounds); + Assert.Equal (new (0, 0, 20, 20), view.Viewport); var marginThickness = 1; view.Margin.Thickness = new (marginThickness); - Assert.Equal (new (0, 0, 18, 18), view.Bounds); + Assert.Equal (new (0, 0, 18, 18), view.Viewport); var borderThickness = 2; view.Border.Thickness = new (borderThickness); - Assert.Equal (new (0, 0, 14, 14), view.Bounds); + Assert.Equal (new (0, 0, 14, 14), view.Viewport); var paddingThickness = 3; view.Padding.Thickness = new Thickness (paddingThickness); - Assert.Equal (new (0, 0, 8, 8), view.Bounds); + Assert.Equal (new (0, 0, 8, 8), view.Viewport); - Assert.Equal (new (0, 0, view.Margin.Frame.Width, view.Margin.Frame.Height), view.Margin.Bounds); + Assert.Equal (new (0, 0, view.Margin.Frame.Width, view.Margin.Frame.Height), view.Margin.Viewport); - Assert.Equal (new (0, 0, view.Border.Frame.Width, view.Border.Frame.Height), view.Border.Bounds); + Assert.Equal (new (0, 0, view.Border.Frame.Width, view.Border.Frame.Height), view.Border.Viewport); - Assert.Equal (new (0, 0, view.Padding.Frame.Width , view.Padding.Frame.Height), view.Padding.Bounds); + Assert.Equal (new (0, 0, view.Padding.Frame.Width , view.Padding.Frame.Height), view.Padding.Viewport); } // Test that Adornment.Bounds_get override returns Frame.Size minus Thickness @@ -87,7 +87,7 @@ public void Bounds_Width_Is_Frame_Width (int thickness, int x, int y, int w, int Assert.Equal (new Rectangle (x, y, w, h), adornment.Frame); var expectedBounds = new Rectangle (0, 0, w, h); - Assert.Equal (expectedBounds, adornment.Bounds); + Assert.Equal (expectedBounds, adornment.Viewport); } // Test that Adornment.Bounds_get override uses Parent not SuperView @@ -100,9 +100,9 @@ public void BoundsToScreen_Uses_Parent_Not_SuperView () parent.EndInit (); Assert.Equal (new Rectangle (1, 2, 10, 10), parent.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Margin.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Margin.Bounds); + 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)); @@ -133,7 +133,7 @@ public void Frames_are_Parent_SuperView_Relative () view.EndInit (); Assert.Equal (new Rectangle (1, 2, 20, 31), view.Frame); - Assert.Equal (new Rectangle (0, 0, 8, 19), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 8, 19), view.Viewport); // Margin.Frame is always the same as the view frame Assert.Equal (new Rectangle (0, 0, 20, 31), view.Margin.Frame); @@ -246,9 +246,9 @@ public void FrameToScreen_Uses_Parent_Not_SuperView () parent.EndInit (); Assert.Equal (new Rectangle (1, 2, 10, 10), parent.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Margin.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Margin.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Margin.Viewport); Assert.Null (parent.Margin.SuperView); Assert.Equal (new Rectangle (1, 2, 10, 10), parent.Margin.FrameToScreen ()); @@ -284,7 +284,7 @@ public void GetAdornmentsThickness () public void Setting_Bounds_Throws () { var adornment = new Adornment (null); - Assert.Throws (() => adornment.Bounds = new Rectangle (1, 2, 3, 4)); + Assert.Throws (() => adornment.Viewport = new Rectangle (1, 2, 3, 4)); } [Fact] @@ -309,11 +309,11 @@ public void Setting_Thickness_Changes_Parent_Bounds () parent.EndInit (); Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Viewport); parent.Margin.Thickness = new Thickness (1); Assert.Equal (new Rectangle (0, 0, 10, 10), parent.Frame); - Assert.Equal (new Rectangle (0, 0, 8, 8), parent.Bounds); + Assert.Equal (new Rectangle (0, 0, 8, 8), parent.Viewport); } [Fact] diff --git a/UnitTests/View/Adornment/ToScreenTests.cs b/UnitTests/View/Adornment/ToScreenTests.cs index bc45086480..ddc5aa300c 100644 --- a/UnitTests/View/Adornment/ToScreenTests.cs +++ b/UnitTests/View/Adornment/ToScreenTests.cs @@ -289,7 +289,7 @@ public void BoundsToScreen_NoSuperView_WithAdornments (int frameX, int boundsX, // Total thickness is 3 (view.Bounds will be Frame.Width - 6) view.Frame = frame; - Assert.Equal(4, view.Bounds.Width); + Assert.Equal(4, view.Viewport.Width); // Act var marginScreen = view.Margin.BoundsToScreen (new (boundsX, 0, 0, 0)); diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index e29d5f6628..9b616ad7be 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -235,7 +235,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds () view.SetRelativeLayout (Application.Driver.Bounds); Assert.Equal (new (0,0,2,2), view.Frame); - Assert.Equal (Rectangle.Empty, view.Bounds); + Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -260,7 +260,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Bottom () view.SetRelativeLayout (Application.Driver.Bounds); Assert.Equal (new (0,0,2,1), view.Frame); - Assert.Equal (Rectangle.Empty, view.Bounds); + Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -278,7 +278,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Left () view.SetRelativeLayout (Application.Driver.Bounds); Assert.Equal (new (0,0,1,2), view.Frame); - Assert.Equal (Rectangle.Empty, view.Bounds); + Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -303,7 +303,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Right () view.SetRelativeLayout (Application.Driver.Bounds); Assert.Equal (new (0,0,1,2), view.Frame); - Assert.Equal (Rectangle.Empty, view.Bounds); + Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -329,7 +329,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Top () view.SetRelativeLayout (Application.Driver.Bounds); Assert.Equal (new (0,0,2,1), view.Frame); - Assert.Equal (Rectangle.Empty, view.Bounds); + Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); diff --git a/UnitTests/View/Layout/AbsoluteLayoutTests.cs b/UnitTests/View/Layout/AbsoluteLayoutTests.cs index 2f4b27fea5..1936704539 100644 --- a/UnitTests/View/Layout/AbsoluteLayoutTests.cs +++ b/UnitTests/View/Layout/AbsoluteLayoutTests.cs @@ -31,7 +31,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); @@ -46,7 +46,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); @@ -62,7 +62,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (10), v.X); Assert.Equal (Pos.At (20), v.Y); @@ -77,7 +77,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (10), v.X); Assert.Equal (Pos.At (20), v.Y); @@ -101,7 +101,7 @@ public void AbsoluteLayout_Change_Height_or_Width_Absolute () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); @@ -136,7 +136,7 @@ public void AbsoluteLayout_Change_X_or_Y_Absolute () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ()); Assert.Equal ($"Absolute({newFrame.Y})", v.Y.ToString ()); @@ -250,7 +250,7 @@ public void AbsoluteLayout_Constructor () Assert.Equal ( new Rectangle (0, 0, frame.Width, frame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (0), v.X); Assert.Equal (Pos.At (0), v.Y); @@ -265,7 +265,7 @@ public void AbsoluteLayout_Constructor () Assert.Equal ( new Rectangle (0, 0, frame.Width, frame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); @@ -279,7 +279,7 @@ public void AbsoluteLayout_Constructor () Assert.Equal ( new Rectangle (0, 0, frame.Width, frame.Height), - v.Bounds + v.Viewport ); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); @@ -294,7 +294,7 @@ public void AbsoluteLayout_Constructor () // That is correct it should be 0,0 because AutoSize is false // and the size wasn't set on the initializer Assert.Equal (new Rectangle (frame.X, frame.Y, 0, 0), v.Frame); - Assert.Equal (new Rectangle (0, 0, 0, 0), v.Bounds); // With Absolute Bounds *is* deterministic before Layout + Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (0), v.Width); @@ -304,7 +304,7 @@ public void AbsoluteLayout_Constructor () v = new View (); Assert.True (v.LayoutStyle == LayoutStyle.Absolute); Assert.Equal (new Rectangle (0, 0, 0, 0), v.Frame); - Assert.Equal (new Rectangle (0, 0, 0, 0), v.Bounds); // With Absolute Bounds *is* deterministic before Layout + Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (0), v.X); Assert.Equal (Pos.At (0), v.Y); Assert.Equal (Dim.Sized (0), v.Width); @@ -314,7 +314,7 @@ public void AbsoluteLayout_Constructor () v = new View { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height }; Assert.True (v.LayoutStyle == LayoutStyle.Absolute); Assert.Equal (new Rectangle (frame.X, frame.Y, 3, 4), v.Frame); - Assert.Equal (new Rectangle (0, 0, 3, 4), v.Bounds); // With Absolute Bounds *is* deterministic before Layout + Assert.Equal (new Rectangle (0, 0, 3, 4), v.Viewport); // With Absolute Bounds *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (3), v.Width); @@ -353,8 +353,8 @@ public void AbsoluteLayout_Setting_Bounds_Location_NotEmpty () var frame = new Rectangle (1, 2, 3, 4); var newBounds = new Rectangle (10, 20, 30, 40); var view = new View { Frame = frame }; - view.Bounds = newBounds; - Assert.Equal (new Rectangle (0, 0, 30, 40), view.Bounds); + view.Viewport = newBounds; + Assert.Equal (new Rectangle (0, 0, 30, 40), view.Viewport); Assert.Equal (new Rectangle (1, 2, 30, 40), view.Frame); } @@ -367,21 +367,21 @@ public void AbsoluteLayout_Setting_Bounds_Sets_Frame () var v = new View { Frame = frame }; Assert.True (v.LayoutStyle == LayoutStyle.Absolute); - v.Bounds = newBounds; + v.Viewport = newBounds; Assert.True (v.LayoutStyle == LayoutStyle.Absolute); - Assert.Equal (newBounds, v.Bounds); + Assert.Equal (newBounds, v.Viewport); Assert.Equal (new Rectangle (1, 2, newBounds.Width, newBounds.Height), v.Frame); - Assert.Equal (new Rectangle (0, 0, newBounds.Width, newBounds.Height), v.Bounds); + Assert.Equal (new Rectangle (0, 0, newBounds.Width, newBounds.Height), v.Viewport); Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (30), v.Width); Assert.Equal (Dim.Sized (40), v.Height); newBounds = new Rectangle (0, 0, 3, 4); - v.Bounds = newBounds; - Assert.Equal (newBounds, v.Bounds); + v.Viewport = newBounds; + Assert.Equal (newBounds, v.Viewport); Assert.Equal (new Rectangle (1, 2, newBounds.Width, newBounds.Height), v.Frame); - Assert.Equal (new Rectangle (0, 0, newBounds.Width, newBounds.Height), v.Bounds); + Assert.Equal (new Rectangle (0, 0, newBounds.Width, newBounds.Height), v.Viewport); Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (3), v.Width); @@ -390,7 +390,7 @@ public void AbsoluteLayout_Setting_Bounds_Sets_Frame () v.BorderStyle = LineStyle.Single; // Bounds should shrink - Assert.Equal (new Rectangle (0, 0, 1, 2), v.Bounds); + Assert.Equal (new Rectangle (0, 0, 1, 2), v.Viewport); // Frame should not change Assert.Equal (new Rectangle (1, 2, 3, 4), v.Frame); @@ -401,12 +401,12 @@ public void AbsoluteLayout_Setting_Bounds_Sets_Frame () // Now set bounds bigger as before newBounds = new Rectangle (0, 0, 3, 4); - v.Bounds = newBounds; - Assert.Equal (newBounds, v.Bounds); + v.Viewport = newBounds; + Assert.Equal (newBounds, v.Viewport); // Frame grows because there's now a border Assert.Equal (new Rectangle (1, 2, 5, 6), v.Frame); - Assert.Equal (new Rectangle (0, 0, newBounds.Width, newBounds.Height), v.Bounds); + Assert.Equal (new Rectangle (0, 0, newBounds.Width, newBounds.Height), v.Viewport); Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (5), v.Width); diff --git a/UnitTests/View/Layout/BoundsTests.cs b/UnitTests/View/Layout/BoundsTests.cs index 2a4c3e5c6a..69bb1d87b1 100644 --- a/UnitTests/View/Layout/BoundsTests.cs +++ b/UnitTests/View/Layout/BoundsTests.cs @@ -3,7 +3,7 @@ namespace Terminal.Gui.ViewTests; /// -/// Test the . +/// Test the . /// DOES NOT TEST Adornment.Bounds methods. Those are in ./Adornment/BoundsTests.cs /// /// @@ -28,7 +28,7 @@ public void Get_Bounds_NoSuperView_WithoutAdornments (int x, int expectedW) view.EndInit(); // Act - var bounds = view.Bounds; + var bounds = view.Viewport; // Assert Assert.Equal(expectedW, bounds.Width); @@ -85,7 +85,7 @@ public void Get_Bounds_NestedSuperView_WithAdornments (int frameX, int borderThi superSuperView.LayoutSubviews (); // Act - var bounds = view.Bounds; + var bounds = view.Viewport; // Assert Assert.Equal (expectedW, bounds.Width); @@ -144,7 +144,7 @@ public void Get_Bounds_NestedSuperView_WithAdornments_WithBorder (int frameX, in superSuperView.LayoutSubviews (); // Act - var bounds = view.Bounds; + var bounds = view.Viewport; // Assert Assert.Equal (expectedW, bounds.Width); diff --git a/UnitTests/View/Layout/DimTests.cs b/UnitTests/View/Layout/DimTests.cs index 367a2c65de..c700c6dbec 100644 --- a/UnitTests/View/Layout/DimTests.cs +++ b/UnitTests/View/Layout/DimTests.cs @@ -39,7 +39,7 @@ public void Dim_Add_Operator () if (k.KeyCode == KeyCode.Enter) { field.Text = $"Label {count}"; - var label = new Label { X = 0, Y = view.Bounds.Height, /*Width = 20,*/ Text = field.Text }; + var label = new Label { X = 0, Y = view.Viewport.Height, /*Width = 20,*/ Text = field.Text }; view.Add (label); Assert.Equal ($"Label {count}", label.Text); Assert.Equal ($"Absolute({count})", label.Y.ToString ()); @@ -112,7 +112,7 @@ public void Dim_Subtract_Operator () for (var i = 0; i < count; i++) { field.Text = $"Label {i}"; - var label = new Label { X = 0, Y = view.Bounds.Height, /*Width = 20,*/ Text = field.Text }; + var label = new Label { X = 0, Y = view.Viewport.Height, /*Width = 20,*/ Text = field.Text }; view.Add (label); Assert.Equal ($"Label {i}", label.Text); Assert.Equal ($"Absolute({i})", label.Y.ToString ()); @@ -667,7 +667,7 @@ public void Only_DimAbsolute_And_DimFactor_As_A_Different_Procedure_For_Assignin Assert.Equal (50, v4.Frame.Width); Assert.Equal (50, v4.Frame.Height); #if DEBUG - Assert.Equal ($"Combine(View(Width,Button(v1){v1.Frame})-View(Width,Button(v3){v3.Bounds}))", v5.Width.ToString ()); + Assert.Equal ($"Combine(View(Width,Button(v1){v1.Frame})-View(Width,Button(v3){v3.Viewport}))", v5.Width.ToString ()); #else Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Bounds}))", v5.Height.ToString ( )); #endif diff --git a/UnitTests/View/Layout/PosTests.cs b/UnitTests/View/Layout/PosTests.cs index 644e4580e3..5fb9cf7823 100644 --- a/UnitTests/View/Layout/PosTests.cs +++ b/UnitTests/View/Layout/PosTests.cs @@ -116,11 +116,11 @@ public void AnchorEnd_View_And_Button () var b = $"{CM.Glyphs.LeftBracket} Ok {CM.Glyphs.RightBracket}"; var frame = new FrameView { Width = 18, Height = 3 }; - Assert.Equal (16, frame.Bounds.Width); + Assert.Equal (16, frame.Viewport.Width); Button btn = null; - int Btn_Width () { return btn?.Bounds.Width ?? 0; } + int Btn_Width () { return btn?.Viewport.Width ?? 0; } btn = new Button { Text = "Ok", X = Pos.AnchorEnd () - Pos.Function (Btn_Width) }; @@ -140,13 +140,13 @@ public void AnchorEnd_View_And_Button () frame.EndInit (); frame.Draw (); - Assert.Equal (6, btn.Bounds.Width); + Assert.Equal (6, btn.Viewport.Width); Assert.Equal (10, btn.Frame.X); // frame.Bounds.Width (16) - btn.Frame.Width (6) = 10 Assert.Equal (0, btn.Frame.Y); Assert.Equal (6, btn.Frame.Width); Assert.Equal (1, btn.Frame.Height); - Assert.Equal (9, view.Bounds.Width); // frame.Bounds.Width (16) - Dim.Fill (1) - Dim.Function (6) = 9 + Assert.Equal (9, view.Viewport.Width); // frame.Bounds.Width (16) - Dim.Fill (1) - Dim.Function (6) = 9 Assert.Equal (0, view.Frame.X); Assert.Equal (0, view.Frame.Y); Assert.Equal (9, view.Frame.Width); diff --git a/UnitTests/View/Layout/SetRelativeLayoutTests.cs b/UnitTests/View/Layout/SetRelativeLayoutTests.cs index cfd0288208..24e23dbed1 100644 --- a/UnitTests/View/Layout/SetRelativeLayoutTests.cs +++ b/UnitTests/View/Layout/SetRelativeLayoutTests.cs @@ -54,10 +54,10 @@ public void DimFill_Is_Honored () Assert.Equal (1, view.Frame.Y); Assert.Equal (79, view.Frame.Width); Assert.Equal (24, view.Frame.Height); - Assert.Equal (0, view.Bounds.X); - Assert.Equal (0, view.Bounds.Y); - Assert.Equal (79, view.Bounds.Width); - Assert.Equal (24, view.Bounds.Height); + Assert.Equal (0, view.Viewport.X); + Assert.Equal (0, view.Viewport.Y); + Assert.Equal (79, view.Viewport.Width); + Assert.Equal (24, view.Viewport.Height); view.X = 0; view.Y = 0; @@ -68,10 +68,10 @@ public void DimFill_Is_Honored () Assert.Equal (0, view.Frame.Y); Assert.Equal (80, view.Frame.Width); Assert.Equal (25, view.Frame.Height); - Assert.Equal (0, view.Bounds.X); - Assert.Equal (0, view.Bounds.Y); - Assert.Equal (80, view.Bounds.Width); - Assert.Equal (25, view.Bounds.Height); + Assert.Equal (0, view.Viewport.X); + Assert.Equal (0, view.Viewport.Y); + Assert.Equal (80, view.Viewport.Width); + Assert.Equal (25, view.Viewport.Height); } [Fact] diff --git a/UnitTests/View/SubviewTests.cs b/UnitTests/View/SubviewTests.cs index d4f730c958..0d7bff9fa7 100644 --- a/UnitTests/View/SubviewTests.cs +++ b/UnitTests/View/SubviewTests.cs @@ -151,8 +151,8 @@ public void Initialized_Event_Comparing_With_Added_Event () winAddedToTop.Initialized += (s, e) => { wc++; - Assert.Equal (top.Bounds.Width, winAddedToTop.Frame.Width); - Assert.Equal (top.Bounds.Height, winAddedToTop.Frame.Height); + Assert.Equal (top.Viewport.Width, winAddedToTop.Frame.Width); + Assert.Equal (top.Viewport.Height, winAddedToTop.Frame.Height); }; v1AddedToWin.Initialized += (s, e) => @@ -258,8 +258,8 @@ public void Initialized_Event_Will_Be_Invoked_When_Added_Dynamically () w.Initialized += (s, e) => { wc++; - Assert.Equal (t.Bounds.Width, w.Frame.Width); - Assert.Equal (t.Bounds.Height, w.Frame.Height); + Assert.Equal (t.Viewport.Width, w.Frame.Width); + Assert.Equal (t.Viewport.Height, w.Frame.Height); }; v1.Initialized += (s, e) => diff --git a/UnitTests/View/Text/AutoSizeFalseTests.cs b/UnitTests/View/Text/AutoSizeFalseTests.cs index 2c31095224..85a0d5f861 100644 --- a/UnitTests/View/Text/AutoSizeFalseTests.cs +++ b/UnitTests/View/Text/AutoSizeFalseTests.cs @@ -145,7 +145,7 @@ public void AutoSize_False_ResizeView_Is_Always_False () Rectangle expectedViewBounds = new (0, 0, 0, 0); Assert.False (view.AutoSize); - Assert.Equal (expectedViewBounds, view.Bounds); + Assert.Equal (expectedViewBounds, view.Viewport); super.Dispose (); } @@ -162,7 +162,7 @@ public void AutoSize_False_ResizeView_With_Dim_Fill_After_IsInitialized () Rectangle expectedViewBounds = new (0, 0, 30, 80); Assert.False (view.AutoSize); - Assert.Equal (expectedViewBounds, view.Bounds); + Assert.Equal (expectedViewBounds, view.Viewport); Assert.False (view.IsInitialized); super.BeginInit (); @@ -170,7 +170,7 @@ public void AutoSize_False_ResizeView_With_Dim_Fill_After_IsInitialized () Assert.True (view.IsInitialized); Assert.False (view.AutoSize); - Assert.Equal (expectedViewBounds, view.Bounds); + Assert.Equal (expectedViewBounds, view.Viewport); } [Fact] diff --git a/UnitTests/View/Text/AutoSizeTrueTests.cs b/UnitTests/View/Text/AutoSizeTrueTests.cs index 00ec2208a0..14b61b25a3 100644 --- a/UnitTests/View/Text/AutoSizeTrueTests.cs +++ b/UnitTests/View/Text/AutoSizeTrueTests.cs @@ -587,7 +587,7 @@ public void AutoSize_Dim_Add_Operator_With_Text () field.Text = $"Label {count}"; // Label is AutoSize = true - var label = new Label { Text = field.Text, X = 0, Y = view.Bounds.Height /*, Width = 10*/ }; + var label = new Label { Text = field.Text, X = 0, Y = view.Viewport.Height /*, Width = 10*/ }; view.Add (label); Assert.Equal ($"Label {count}", label.Text); Assert.Equal ($"Absolute({count + 1})", label.Y.ToString ()); @@ -871,7 +871,7 @@ public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_In Assert.True (label.AutoSize); Rectangle expectedLabelBounds = Rectangle.Empty; - Assert.Equal (expectedLabelBounds, label.Bounds); + Assert.Equal (expectedLabelBounds, label.Viewport); Assert.True (label.AutoSize); label.Text = "First line\nSecond line"; @@ -879,7 +879,7 @@ public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_In expectedLabelBounds = new (0, 0, 11, 2); Assert.True (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Bounds); + Assert.Equal (expectedLabelBounds, label.Viewport); label.AutoSize = false; label.Width = Dim.Fill (); @@ -891,7 +891,7 @@ public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_In // Height set to 2. expectedLabelBounds = new (0, 0, 28, 2); Assert.False (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Bounds); + Assert.Equal (expectedLabelBounds, label.Viewport); label.Text = "First changed line\nSecond changed line\nNew line"; win.LayoutSubviews (); @@ -901,7 +901,7 @@ public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_In // #3127: After: (0,0,28,2) because setting Text leaves Height set to 2. expectedLabelBounds = new (0, 0, 28, 2); Assert.False (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Bounds); + Assert.Equal (expectedLabelBounds, label.Viewport); label.AutoSize = true; @@ -911,7 +911,7 @@ public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_In // and height 3 because the text has 3 lines expectedLabelBounds = new (0, 0, 19, 3); Assert.True (label.AutoSize); - Assert.Equal (expectedLabelBounds, label.Bounds); + Assert.Equal (expectedLabelBounds, label.Viewport); } [Fact] @@ -1494,7 +1494,7 @@ public void AutoSize_True_ResizeView_With_Dim_Absolute () Assert.True (label.AutoSize); Rectangle expectedLabelBounds = new (0, 0, 8, 1); - Assert.Equal (expectedLabelBounds, label.Bounds); + Assert.Equal (expectedLabelBounds, label.Viewport); super.Dispose (); } diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index 133c1f19eb..c133622619 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -18,13 +18,13 @@ public void Clear_Bounds_Can_Use_Driver_AddRune_Or_AddStr_Methods () view.DrawContent += (s, e) => { Rectangle savedClip = Application.Driver.Clip; - Application.Driver.Clip = new Rectangle (1, 1, view.Bounds.Width, view.Bounds.Height); + Application.Driver.Clip = new Rectangle (1, 1, view.Viewport.Width, view.Viewport.Height); - for (var row = 0; row < view.Bounds.Height; row++) + for (var row = 0; row < view.Viewport.Height; row++) { Application.Driver.Move (1, row + 1); - for (var col = 0; col < view.Bounds.Width; col++) + for (var col = 0; col < view.Viewport.Width; col++) { Application.Driver.AddStr ($"{col}"); } @@ -53,7 +53,7 @@ public void Clear_Bounds_Can_Use_Driver_AddRune_Or_AddStr_Methods () Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); Assert.Equal (new Rectangle (0, 0, 20, 10), pos); - view.Clear (view.Bounds); + view.Clear (view.Viewport); expected = @" ┌──────────────────┐ @@ -80,13 +80,13 @@ public void Clear_Can_Use_Driver_AddRune_Or_AddStr_Methods () view.DrawContent += (s, e) => { Rectangle savedClip = Application.Driver.Clip; - Application.Driver.Clip = new Rectangle (1, 1, view.Bounds.Width, view.Bounds.Height); + Application.Driver.Clip = new Rectangle (1, 1, view.Viewport.Width, view.Viewport.Height); - for (var row = 0; row < view.Bounds.Height; row++) + for (var row = 0; row < view.Viewport.Height; row++) { Application.Driver.Move (1, row + 1); - for (var col = 0; col < view.Bounds.Width; col++) + for (var col = 0; col < view.Viewport.Width; col++) { Application.Driver.AddStr ($"{col}"); } @@ -115,7 +115,7 @@ public void Clear_Can_Use_Driver_AddRune_Or_AddStr_Methods () Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); Assert.Equal (new Rectangle (0, 0, 20, 10), pos); - view.Clear (view.Bounds); + view.Clear (view.Viewport); expected = @" ┌──────────────────┐ @@ -248,7 +248,7 @@ A text with some long width view.Frame = new Rectangle (3, 3, 10, 1); Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame); Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect); top.Draw (); @@ -297,7 +297,7 @@ A text with some long width view.Width = 10; view.Height = 1; Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect); top.Draw (); @@ -344,7 +344,7 @@ A text with some long width view.Frame = new Rectangle (1, 1, 10, 1); Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame); Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect); top.Draw (); @@ -391,7 +391,7 @@ A text with some long width view.Width = 10; view.Height = 1; Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect); top.Draw (); @@ -555,7 +555,7 @@ A text with some long width ); view.Frame = new Rectangle (3, 3, 10, 1); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect); view.Draw (); @@ -604,7 +604,7 @@ A text with some long width view.Width = 10; view.Height = 1; Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect); view.Draw (); @@ -651,7 +651,7 @@ A text with some long width view.Frame = new Rectangle (1, 1, 10, 1); Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame); Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect); view.Draw (); @@ -700,7 +700,7 @@ A text with some long width view.Width = 10; view.Height = 1; Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame); - Assert.Equal (new Rectangle (0, 0, 10, 1), view.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport); Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect); view.Draw (); @@ -748,10 +748,10 @@ public void New_Initializes () Assert.True (r.Visible); Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle); - Assert.Equal ($"View(){r.Bounds}", r.ToString ()); + Assert.Equal ($"View(){r.Viewport}", r.ToString ()); Assert.False (r.CanFocus); Assert.False (r.HasFocus); - Assert.Equal (new Rectangle (0, 0, 0, 0), r.Bounds); + Assert.Equal (new Rectangle (0, 0, 0, 0), r.Viewport); Assert.Equal (new Rectangle (0, 0, 0, 0), r.Frame); Assert.Null (r.Focused); Assert.Null (r.ColorScheme); @@ -773,10 +773,10 @@ public void New_Initializes () r = new View { Frame = Rectangle.Empty }; Assert.NotNull (r); Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle); - Assert.Equal ($"View(){r.Bounds}", r.ToString ()); + Assert.Equal ($"View(){r.Viewport}", r.ToString ()); Assert.False (r.CanFocus); Assert.False (r.HasFocus); - Assert.Equal (new Rectangle (0, 0, 0, 0), r.Bounds); + Assert.Equal (new Rectangle (0, 0, 0, 0), r.Viewport); Assert.Equal (new Rectangle (0, 0, 0, 0), r.Frame); Assert.Null (r.Focused); Assert.Null (r.ColorScheme); @@ -801,7 +801,7 @@ public void New_Initializes () Assert.Equal ($"View(){r.Frame}", r.ToString ()); Assert.False (r.CanFocus); Assert.False (r.HasFocus); - Assert.Equal (new Rectangle (0, 0, 3, 4), r.Bounds); + Assert.Equal (new Rectangle (0, 0, 3, 4), r.Viewport); Assert.Equal (new Rectangle (1, 2, 3, 4), r.Frame); Assert.Null (r.Focused); Assert.Null (r.ColorScheme); @@ -832,7 +832,7 @@ public void New_Initializes () r.EndInit (); Assert.False (r.CanFocus); Assert.False (r.HasFocus); - Assert.Equal (new Rectangle (0, 0, 1, 13), r.Bounds); + Assert.Equal (new Rectangle (0, 0, 1, 13), r.Viewport); Assert.Equal (new Rectangle (0, 0, 1, 13), r.Frame); Assert.Null (r.Focused); Assert.Null (r.ColorScheme); @@ -929,8 +929,8 @@ public void View_With_No_Difference_Between_An_Object_Initializer_Compute_And_A_ Assert.Equal (4, view.Height); Assert.False (view.Frame.IsEmpty); Assert.Equal (new Rectangle (1, 2, 3, 4), view.Frame); - Assert.False (view.Bounds.IsEmpty); - Assert.Equal (new Rectangle (0, 0, 3, 4), view.Bounds); + Assert.False (view.Viewport.IsEmpty); + Assert.Equal (new Rectangle (0, 0, 3, 4), view.Viewport); view.LayoutSubviews (); @@ -939,7 +939,7 @@ public void View_With_No_Difference_Between_An_Object_Initializer_Compute_And_A_ Assert.Equal (3, view.Width); Assert.Equal (4, view.Height); Assert.False (view.Frame.IsEmpty); - Assert.False (view.Bounds.IsEmpty); + Assert.False (view.Viewport.IsEmpty); super.Dispose (); #if DEBUG_IDISPOSABLE @@ -953,7 +953,7 @@ public void View_With_No_Difference_Between_An_Object_Initializer_Compute_And_A_ Assert.Equal (0, view.Width); Assert.Equal (0, view.Height); Assert.True (view.Frame.IsEmpty); - Assert.True (view.Bounds.IsEmpty); + Assert.True (view.Viewport.IsEmpty); view.Dispose (); // Object Initializer @@ -963,7 +963,7 @@ public void View_With_No_Difference_Between_An_Object_Initializer_Compute_And_A_ Assert.Equal (0, view.Width); Assert.Equal (0, view.Height); Assert.False (view.Frame.IsEmpty); - Assert.True (view.Bounds.IsEmpty); + Assert.True (view.Viewport.IsEmpty); view.Dispose (); // Default Constructor and post assignment equivalent to Object Initializer @@ -983,8 +983,8 @@ public void View_With_No_Difference_Between_An_Object_Initializer_Compute_And_A_ Assert.Equal (4, view.Height); Assert.False (view.Frame.IsEmpty); Assert.Equal (new Rectangle (1, 2, 3, 4), view.Frame); - Assert.False (view.Bounds.IsEmpty); - Assert.Equal (new Rectangle (0, 0, 3, 4), view.Bounds); + Assert.False (view.Viewport.IsEmpty); + Assert.Equal (new Rectangle (0, 0, 3, 4), view.Viewport); super.Dispose (); } diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs index 72d9e9cd34..b912469016 100644 --- a/UnitTests/Views/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -432,14 +432,14 @@ public void Constructors_Defaults () Assert.Equal (TextAlignment.Centered, btn.TextAlignment); Assert.Equal ('_', btn.HotKeySpecifier.Value); Assert.True (btn.CanFocus); - Assert.Equal (new Rectangle (0, 0, 4, 1), btn.Bounds); + Assert.Equal (new Rectangle (0, 0, 4, 1), btn.Viewport); Assert.Equal (new Rectangle (0, 0, 4, 1), btn.Frame); Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text); Assert.False (btn.IsDefault); Assert.Equal (TextAlignment.Centered, btn.TextAlignment); Assert.Equal ('_', btn.HotKeySpecifier.Value); Assert.True (btn.CanFocus); - Assert.Equal (new Rectangle (0, 0, 4, 1), btn.Bounds); + Assert.Equal (new Rectangle (0, 0, 4, 1), btn.Viewport); Assert.Equal (new Rectangle (0, 0, 4, 1), btn.Frame); Assert.Equal (string.Empty, btn.Title); @@ -478,7 +478,7 @@ public void Constructors_Defaults () Assert.True (btn.IsDefault); Assert.Equal (TextAlignment.Centered, btn.TextAlignment); Assert.True (btn.CanFocus); - Assert.Equal (new Rectangle (0, 0, 10, 1), btn.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 1), btn.Viewport); Assert.Equal (new Rectangle (0, 0, 10, 1), btn.Frame); Assert.Equal (KeyCode.T, btn.HotKey); @@ -521,7 +521,7 @@ public void Constructors_Defaults () "; TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); - Assert.Equal (new Rectangle (0, 0, 9, 1), btn.Bounds); + Assert.Equal (new Rectangle (0, 0, 9, 1), btn.Viewport); Assert.Equal (new Rectangle (1, 2, 9, 1), btn.Frame); } @@ -762,7 +762,7 @@ public void Update_Only_On_Or_After_Initialize () Assert.True (btn.IsInitialized); Assert.Equal ("Say Hello 你", btn.Text); Assert.Equal ($"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text); - Assert.Equal (new Rectangle (0, 0, 16, 1), btn.Bounds); + Assert.Equal (new Rectangle (0, 0, 16, 1), btn.Viewport); var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}"; var expected = @$" @@ -799,7 +799,7 @@ public void Update_Parameterless_Only_On_Or_After_Initialize () Assert.True (btn.IsInitialized); Assert.Equal ("Say Hello 你", btn.Text); Assert.Equal ($"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text); - Assert.Equal (new Rectangle (0, 0, 16, 1), btn.Bounds); + Assert.Equal (new Rectangle (0, 0, 16, 1), btn.Viewport); var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}"; var expected = @$" diff --git a/UnitTests/Views/ComboBoxTests.cs b/UnitTests/Views/ComboBoxTests.cs index 1a38b80d49..6e6724e2e9 100644 --- a/UnitTests/Views/ComboBoxTests.cs +++ b/UnitTests/Views/ComboBoxTests.cs @@ -144,7 +144,7 @@ public void HideDropdownListOnClick_False_OpenSelectedItem_With_Mouse_And_Key_Cu Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -200,7 +200,7 @@ public void HideDropdownListOnClick_False_OpenSelectedItem_With_Mouse_And_Key_F4 Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -236,7 +236,7 @@ public void Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -292,7 +292,7 @@ public void HideDropdownListOnClick_Gets_Sets () Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -337,7 +337,7 @@ cb.Subviews [1] Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); @@ -354,7 +354,7 @@ cb.Subviews [1] Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("Three", selected); @@ -392,14 +392,14 @@ public void HideDropdownListOnClick_True_Colapse_On_Click_Outside_Frame () Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.True ( cb.Subviews [1] .OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } ) ); Assert.Equal ("", selected); @@ -423,7 +423,7 @@ cb.Subviews [1] Assert.True ( cb.Subviews [1] .OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } ) ); Assert.Equal ("", selected); @@ -447,7 +447,7 @@ cb.Subviews [1] Assert.True ( cb.Subviews [1] .OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } ) ); Assert.Equal ("", selected); @@ -471,7 +471,7 @@ cb.Subviews [1] Assert.True ( cb.Subviews [1] .OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked } ) ); Assert.Equal ("", selected); @@ -509,7 +509,7 @@ public void HideDropdownListOnClick_True_Highlight_Current_Item () Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -665,7 +665,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -677,7 +677,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -687,7 +687,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -699,7 +699,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -726,7 +726,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_Cur Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); @@ -782,7 +782,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_F4 Assert.True ( cb.OnMouseEvent ( - new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } + new MouseEvent { X = cb.Viewport.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed } ) ); Assert.Equal ("", selected); diff --git a/UnitTests/Views/GraphViewTests.cs b/UnitTests/Views/GraphViewTests.cs index 7362e7cf18..bd27070e97 100644 --- a/UnitTests/Views/GraphViewTests.cs +++ b/UnitTests/Views/GraphViewTests.cs @@ -61,7 +61,7 @@ public void CellSizeZero () gv.EndInit (); gv.ColorScheme = new ColorScheme (); - gv.Bounds = new Rectangle (0, 0, 50, 30); + gv.Viewport = new Rectangle (0, 0, 50, 30); gv.Series.Add (new ScatterSeries { Points = new List { new (1, 1) } }); gv.CellSize = new PointF (0, 5); var ex = Assert.Throws (() => gv.Draw ()); @@ -85,7 +85,7 @@ public static GraphView GetGraph () gv.ColorScheme = new ColorScheme (); gv.MarginBottom = 1; gv.MarginLeft = 1; - gv.Bounds = new Rectangle (0, 0, 10, 5); + gv.Viewport = new Rectangle (0, 0, 10, 5); return gv; } @@ -128,7 +128,7 @@ public void TestReversing_ScreenToGraphSpace () var gv = new GraphView (); gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 50, 30); + gv.Viewport = new Rectangle (0, 0, 50, 30); // How much graph space each cell of the console depicts gv.CellSize = new PointF (0.1f, 0.25f); @@ -141,9 +141,9 @@ public void TestReversing_ScreenToGraphSpace () // Start the graph at 80 gv.ScrollOffset = new PointF (0, 80); - for (var x = 0; x < gv.Bounds.Width; x++) + for (var x = 0; x < gv.Viewport.Width; x++) { - for (var y = 0; y < gv.Bounds.Height; y++) + for (var y = 0; y < gv.Viewport.Height; y++) { RectangleF graphSpace = gv.ScreenToGraphSpace (x, y); @@ -199,7 +199,7 @@ public void ScreenToGraphSpace_DefaultCellSize () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // origin should be bottom left RectangleF botLeft = gv.ScreenToGraphSpace (0, 9); @@ -221,7 +221,7 @@ public void ScreenToGraphSpace_DefaultCellSize_WithMargin () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // origin should be bottom left RectangleF botLeft = gv.ScreenToGraphSpace (0, 9); @@ -261,7 +261,7 @@ public void ScreenToGraphSpace_CustomCellSize () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // Each cell of screen measures 5 units in graph data model vertically and 1/4 horizontally gv.CellSize = new PointF (0.25f, 5); @@ -293,7 +293,7 @@ public void GraphSpaceToScreen_DefaultCellSize () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // origin should be bottom left Point botLeft = gv.GraphSpaceToScreen (new PointF (0, 0)); @@ -313,7 +313,7 @@ public void GraphSpaceToScreen_DefaultCellSize_WithMargin () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // origin should be bottom left Point botLeft = gv.GraphSpaceToScreen (new PointF (0, 0)); @@ -343,7 +343,7 @@ public void GraphSpaceToScreen_ScrollOffset () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); //graph is scrolled to present chart space -5 to 5 in both axes gv.ScrollOffset = new PointF (-5, -5); @@ -366,7 +366,7 @@ public void GraphSpaceToScreen_CustomCellSize () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // Each cell of screen is responsible for rendering 5 units in graph data model // vertically and 1/4 horizontally @@ -407,7 +407,7 @@ public void GraphSpaceToScreen_CustomCellSize_WithScrollOffset () gv.BeginInit (); gv.EndInit (); - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); // Each cell of screen is responsible for rendering 5 units in graph data model // vertically and 1/4 horizontally @@ -449,7 +449,7 @@ public void Series_GetsPassedCorrectBounds_AllAtOnce () gv.BeginInit (); gv.EndInit (); gv.ColorScheme = new ColorScheme (); - gv.Bounds = new Rectangle (0, 0, 50, 30); + gv.Viewport = new Rectangle (0, 0, 50, 30); var fullGraphBounds = RectangleF.Empty; var graphScreenBounds = Rectangle.Empty; @@ -501,7 +501,7 @@ public void Series_GetsPassedCorrectBounds_AllAtOnce_LargeCellSize () gv.BeginInit (); gv.EndInit (); gv.ColorScheme = new ColorScheme (); - gv.Bounds = new Rectangle (0, 0, 50, 30); + gv.Viewport = new Rectangle (0, 0, 50, 30); // the larger the cell size the more condensed (smaller) the graph space is gv.CellSize = new PointF (2, 5); @@ -641,7 +641,7 @@ public void TestRendering_MultibarSeries () // y axis goes from 0.1 to 1 across 10 console rows // x axis goes from 0 to 20 across 20 console columns - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); gv.CellSize = new PointF (1f, 0.1f); gv.MarginBottom = 1; gv.MarginLeft = 1; @@ -873,7 +873,7 @@ private GraphView GetGraph (out FakeBarSeries series, out FakeHAxis axisX, out F // y axis goes from 0.1 to 1 across 10 console rows // x axis goes from 0 to 10 across 20 console columns - gv.Bounds = new Rectangle (0, 0, 20, 10); + gv.Viewport = new Rectangle (0, 0, 20, 10); gv.CellSize = new PointF (0.5f, 0.1f); gv.Series.Add (series = new FakeBarSeries ()); @@ -914,7 +914,7 @@ private GraphView GetGraph (out FakeHAxis axisX, out FakeVAxis axisY) var gv = new GraphView (); gv.ColorScheme = new ColorScheme (); - gv.Bounds = new Rectangle (0, 0, 50, 30); + gv.Viewport = new Rectangle (0, 0, 50, 30); // graph can't be completely empty or it won't draw gv.Series.Add (new ScatterSeries ()); @@ -1298,19 +1298,19 @@ public class LegendTests public void Constructors_Defaults () { var legend = new LegendAnnotation (); - Assert.Equal (Rectangle.Empty, legend.Bounds); + Assert.Equal (Rectangle.Empty, legend.Viewport); Assert.Equal (Rectangle.Empty, legend.Frame); Assert.Equal (LineStyle.Single, legend.BorderStyle); Assert.False (legend.BeforeSeries); var bounds = new Rectangle (1, 2, 10, 3); legend = new LegendAnnotation (bounds); - Assert.Equal (new Rectangle (0, 0, 8, 1), legend.Bounds); + Assert.Equal (new Rectangle (0, 0, 8, 1), legend.Viewport); Assert.Equal (bounds, legend.Frame); Assert.Equal (LineStyle.Single, legend.BorderStyle); Assert.False (legend.BeforeSeries); legend.BorderStyle = LineStyle.None; - Assert.Equal (new Rectangle (0, 0, 10, 3), legend.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 3), legend.Viewport); Assert.Equal (bounds, legend.Frame); } @@ -1549,7 +1549,7 @@ public void ViewChangeText_RendersCorrectly (bool useFill) public void XAxisLabels_With_MarginLeft () { GraphViewTests.InitFakeDriver (); - var gv = new GraphView { ColorScheme = new ColorScheme (), Bounds = new Rectangle (0, 0, 10, 7) }; + var gv = new GraphView { ColorScheme = new ColorScheme (), Viewport = new Rectangle (0, 0, 10, 7) }; gv.CellSize = new PointF (1, 0.5f); gv.AxisY.Increment = 1; @@ -1591,7 +1591,7 @@ 0 5 public void YAxisLabels_With_MarginBottom () { GraphViewTests.InitFakeDriver (); - var gv = new GraphView { ColorScheme = new ColorScheme (), Bounds = new Rectangle (0, 0, 10, 7) }; + var gv = new GraphView { ColorScheme = new ColorScheme (), Viewport = new Rectangle (0, 0, 10, 7) }; gv.CellSize = new PointF (1, 0.5f); gv.AxisY.Increment = 1; diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index 94d9f60683..ab99e9ddfa 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -458,7 +458,7 @@ public void Update_Only_On_Or_After_Initialize () Assert.True (label.IsInitialized); Assert.Equal ("Say Hello 你", label.Text); Assert.Equal ("Say Hello 你", label.TextFormatter.Text); - Assert.Equal (new Rectangle (0, 0, 12, 1), label.Bounds); + Assert.Equal (new Rectangle (0, 0, 12, 1), label.Viewport); var expected = @" ┌────────────────────────────┐ @@ -488,7 +488,7 @@ public void Update_Parameterless_Only_On_Or_After_Initialize () Assert.True (label.IsInitialized); Assert.Equal ("Say Hello 你", label.Text); Assert.Equal ("Say Hello 你", label.TextFormatter.Text); - Assert.Equal (new Rectangle (0, 0, 12, 1), label.Bounds); + Assert.Equal (new Rectangle (0, 0, 12, 1), label.Viewport); var expected = @" ┌────────────────────────────┐ @@ -512,7 +512,7 @@ public void Full_Border () Application.Begin (Application.Top); Assert.Equal (new (0, 0, 6, 3), label.Frame); - Assert.Equal (new (0, 0, 4, 1), label.Bounds); + Assert.Equal (new (0, 0, 4, 1), label.Viewport); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -534,7 +534,7 @@ public void With_Top_Margin_Without_Top_Border () Application.Begin (Application.Top); Assert.Equal (new (0, 0, 6, 3), label.Frame); - Assert.Equal (new (0, 0, 4, 1), label.Bounds); + Assert.Equal (new (0, 0, 4, 1), label.Viewport); Application.Begin (Application.Top); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -555,7 +555,7 @@ public void Without_Top_Border () Application.Begin (Application.Top); Assert.Equal (new (0, 0, 6, 2), label.Frame); - Assert.Equal (new (0, 0, 4, 1), label.Bounds); + Assert.Equal (new (0, 0, 4, 1), label.Viewport); Application.Begin (Application.Top); TestHelpers.AssertDriverContentsWithFrameAre ( diff --git a/UnitTests/Views/ScrollBarViewTests.cs b/UnitTests/Views/ScrollBarViewTests.cs index eafe135df1..4422a133bd 100644 --- a/UnitTests/Views/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -23,13 +23,13 @@ public void AutoHideScrollBars_Check () Assert.True (_scrollBar.ShowScrollIndicator); Assert.True (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); - Assert.Equal (1, _scrollBar.Bounds.Width); + Assert.Equal (1, _scrollBar.Viewport.Width); Assert.Equal ( $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))", _scrollBar.Height.ToString () ); - Assert.Equal (24, _scrollBar.Bounds.Height); + Assert.Equal (24, _scrollBar.Viewport.Height); Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator); Assert.True (_scrollBar.OtherScrollBarView.Visible); @@ -37,22 +37,22 @@ public void AutoHideScrollBars_Check () $"Combine(View(Width,HostView(){_hostView.Frame})-Absolute(1))", _scrollBar.OtherScrollBarView.Width.ToString () ); - Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width); + Assert.Equal (79, _scrollBar.OtherScrollBarView.Viewport.Width); Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ()); - Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); + Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height); _hostView.Lines = 10; _hostView.Draw (); Assert.False (_scrollBar.ShowScrollIndicator); Assert.False (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); - Assert.Equal (1, _scrollBar.Bounds.Width); + Assert.Equal (1, _scrollBar.Viewport.Width); Assert.Equal ( $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))", _scrollBar.Height.ToString () ); - Assert.Equal (24, _scrollBar.Bounds.Height); + Assert.Equal (24, _scrollBar.Viewport.Height); Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator); Assert.True (_scrollBar.OtherScrollBarView.Visible); @@ -60,22 +60,22 @@ public void AutoHideScrollBars_Check () $"View(Width,HostView(){_hostView.Frame})", _scrollBar.OtherScrollBarView.Width.ToString () ); - Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width); + Assert.Equal (80, _scrollBar.OtherScrollBarView.Viewport.Width); Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ()); - Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); + Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height); _hostView.Cols = 60; _hostView.Draw (); Assert.False (_scrollBar.ShowScrollIndicator); Assert.False (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); - Assert.Equal (1, _scrollBar.Bounds.Width); + Assert.Equal (1, _scrollBar.Viewport.Width); Assert.Equal ( $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))", _scrollBar.Height.ToString () ); - Assert.Equal (24, _scrollBar.Bounds.Height); + Assert.Equal (24, _scrollBar.Viewport.Height); Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator); Assert.False (_scrollBar.OtherScrollBarView.Visible); @@ -83,22 +83,22 @@ public void AutoHideScrollBars_Check () $"View(Width,HostView(){_hostView.Frame})", _scrollBar.OtherScrollBarView.Width.ToString () ); - Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width); + Assert.Equal (80, _scrollBar.OtherScrollBarView.Viewport.Width); Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ()); - Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); + Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height); _hostView.Lines = 40; _hostView.Draw (); Assert.True (_scrollBar.ShowScrollIndicator); Assert.True (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); - Assert.Equal (1, _scrollBar.Bounds.Width); + Assert.Equal (1, _scrollBar.Viewport.Width); Assert.Equal ( $"View(Height,HostView(){_hostView.Frame})", _scrollBar.Height.ToString () ); - Assert.Equal (25, _scrollBar.Bounds.Height); + Assert.Equal (25, _scrollBar.Viewport.Height); Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator); Assert.False (_scrollBar.OtherScrollBarView.Visible); @@ -106,22 +106,22 @@ public void AutoHideScrollBars_Check () $"View(Width,HostView(){_hostView.Frame})", _scrollBar.OtherScrollBarView.Width.ToString () ); - Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width); + Assert.Equal (80, _scrollBar.OtherScrollBarView.Viewport.Width); Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ()); - Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); + Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height); _hostView.Cols = 120; _hostView.Draw (); Assert.True (_scrollBar.ShowScrollIndicator); Assert.True (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); - Assert.Equal (1, _scrollBar.Bounds.Width); + Assert.Equal (1, _scrollBar.Viewport.Width); Assert.Equal ( $"Combine(View(Height,HostView(){_hostView.Frame})-Absolute(1))", _scrollBar.Height.ToString () ); - Assert.Equal (24, _scrollBar.Bounds.Height); + Assert.Equal (24, _scrollBar.Viewport.Height); Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator); Assert.True (_scrollBar.OtherScrollBarView.Visible); @@ -129,9 +129,9 @@ public void AutoHideScrollBars_Check () $"Combine(View(Width,HostView(){_hostView.Frame})-Absolute(1))", _scrollBar.OtherScrollBarView.Width.ToString () ); - Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width); + Assert.Equal (79, _scrollBar.OtherScrollBarView.Viewport.Width); Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ()); - Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); + Assert.Equal (1, _scrollBar.OtherScrollBarView.Viewport.Height); } [Fact] @@ -499,7 +499,7 @@ public void newScrollBarView.Position, newScrollBarView.Size - listView.TopItem - + (listView.TopItem - listView.Bounds.Height) + + (listView.TopItem - listView.Viewport.Height) ); Assert.Equal (newScrollBarView.Position, listView.TopItem); Assert.Equal (27, newScrollBarView.Position); @@ -960,7 +960,7 @@ public void Hosting_Two_Vertical_ScrollBarView_Throws_ArgumentException () public void Internal_Tests () { Toplevel top = Application.Top; - Assert.Equal (new Rectangle (0, 0, 80, 25), top.Bounds); + Assert.Equal (new Rectangle (0, 0, 80, 25), top.Viewport); var view = new View { Width = Dim.Fill (), Height = Dim.Fill () }; top.Add (view); var sbv = new ScrollBarView (view, true); @@ -1037,10 +1037,10 @@ public void KeepContentAlwaysInViewport_True () AddHandlers (); - Assert.Equal (80, _hostView.Bounds.Width); - Assert.Equal (25, _hostView.Bounds.Height); - Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width); - Assert.Equal (24, _scrollBar.Bounds.Height); + Assert.Equal (80, _hostView.Viewport.Width); + Assert.Equal (25, _hostView.Viewport.Height); + Assert.Equal (79, _scrollBar.OtherScrollBarView.Viewport.Width); + Assert.Equal (24, _scrollBar.Viewport.Height); Assert.Equal (30, _scrollBar.Size); Assert.Equal (100, _scrollBar.OtherScrollBarView.Size); Assert.True (_scrollBar.ShowScrollIndicator); @@ -1049,7 +1049,7 @@ public void KeepContentAlwaysInViewport_True () Assert.True (_scrollBar.OtherScrollBarView.Visible); _scrollBar.Position = 50; - Assert.Equal (_scrollBar.Position, _scrollBar.Size - _scrollBar.Bounds.Height); + Assert.Equal (_scrollBar.Position, _scrollBar.Size - _scrollBar.Viewport.Height); Assert.Equal (_scrollBar.Position, _hostView.Top); Assert.Equal (6, _scrollBar.Position); Assert.Equal (6, _hostView.Top); @@ -1062,7 +1062,7 @@ public void KeepContentAlwaysInViewport_True () Assert.Equal ( _scrollBar.OtherScrollBarView.Position, - _scrollBar.OtherScrollBarView.Size - _scrollBar.OtherScrollBarView.Bounds.Width + _scrollBar.OtherScrollBarView.Size - _scrollBar.OtherScrollBarView.Viewport.Width ); Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left); Assert.Equal (21, _scrollBar.OtherScrollBarView.Position); diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs index fcaab57609..b94f5c7745 100644 --- a/UnitTests/Views/ScrollViewTests.cs +++ b/UnitTests/Views/ScrollViewTests.cs @@ -34,7 +34,7 @@ public void AutoHideScrollBars_False_ShowHorizontalScrollIndicator_ShowVerticalS Application.Top.Add (sv); Application.Begin (Application.Top); - Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Viewport); Assert.False (sv.AutoHideScrollBars); Assert.True (sv.ShowHorizontalScrollIndicator); @@ -58,9 +58,9 @@ public void AutoHideScrollBars_False_ShowHorizontalScrollIndicator_ShowVerticalS ); sv.ShowHorizontalScrollIndicator = false; - Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Viewport); sv.ShowVerticalScrollIndicator = true; - Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Bounds); + Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Viewport); Assert.False (sv.AutoHideScrollBars); Assert.False (sv.ShowHorizontalScrollIndicator); @@ -1081,14 +1081,14 @@ public CustomButton (string fill, string text, int width, int height) { var fillText = new StringBuilder (); - for (var i = 0; i < labelFill.Bounds.Height; i++) + for (var i = 0; i < labelFill.Viewport.Height; i++) { if (i > 0) { fillText.AppendLine (""); } - for (var j = 0; j < labelFill.Bounds.Width; j++) + for (var j = 0; j < labelFill.Viewport.Width; j++) { fillText.Append (fill); } diff --git a/UnitTests/Views/StatusBarTests.cs b/UnitTests/Views/StatusBarTests.cs index 1deb7a0be8..e4a325967e 100644 --- a/UnitTests/Views/StatusBarTests.cs +++ b/UnitTests/Views/StatusBarTests.cs @@ -99,7 +99,7 @@ public void Redraw_Output () ); Application.Top.Add (sb); - sb.OnDrawContent (sb.Bounds); + sb.OnDrawContent (sb.Viewport); var expected = @$" ^O Open { @@ -121,7 +121,7 @@ public void Redraw_Output_CTRLQ () } ); Application.Top.Add (sb); - sb.OnDrawContent (sb.Bounds); + sb.OnDrawContent (sb.Viewport); var expected = @$" CTRL-O Open { diff --git a/UnitTests/Views/TableViewTests.cs b/UnitTests/Views/TableViewTests.cs index b90f42b116..649e347a1d 100644 --- a/UnitTests/Views/TableViewTests.cs +++ b/UnitTests/Views/TableViewTests.cs @@ -125,7 +125,7 @@ public void DeleteRow_SelectAll_AdjustsSelectionToPreventOverrun () // create a 4 by 4 table var tableView = new TableView { - Table = BuildTable (4, 4, out DataTable dt), MultiSelect = true, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (4, 4, out DataTable dt), MultiSelect = true, Viewport = new Rectangle (0, 0, 10, 5) }; tableView.BeginInit (); tableView.EndInit (); @@ -152,7 +152,7 @@ public void DeleteRow_SelectLastRow_AdjustsSelectionToPreventOverrun () // create a 4 by 4 table var tableView = new TableView { - Table = BuildTable (4, 4, out DataTable dt), MultiSelect = true, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (4, 4, out DataTable dt), MultiSelect = true, Viewport = new Rectangle (0, 0, 10, 5) }; tableView.BeginInit (); tableView.EndInit (); @@ -180,7 +180,7 @@ public void EnsureValidScrollOffsets_LoadSmallerTable () var tableView = new TableView (); tableView.BeginInit (); tableView.EndInit (); - tableView.Bounds = new Rectangle (0, 0, 25, 10); + tableView.Viewport = new Rectangle (0, 0, 25, 10); Assert.Equal (0, tableView.RowOffset); Assert.Equal (0, tableView.ColumnOffset); @@ -237,7 +237,7 @@ public void GetAllSelectedCells_SingleCellSelected_ReturnsOne (bool multiSelect) { var tableView = new TableView { - Table = BuildTable (3, 3), MultiSelect = multiSelect, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (3, 3), MultiSelect = multiSelect, Viewport = new Rectangle (0, 0, 10, 5) }; tableView.BeginInit (); tableView.EndInit (); @@ -253,7 +253,7 @@ public void GetAllSelectedCells_SquareSelection_FullRowSelect () { var tableView = new TableView { - Table = BuildTable (3, 3), MultiSelect = true, FullRowSelect = true, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (3, 3), MultiSelect = true, FullRowSelect = true, Viewport = new Rectangle (0, 0, 10, 5) }; tableView.BeginInit (); tableView.EndInit (); @@ -280,7 +280,7 @@ public void GetAllSelectedCells_SquareSelection_ReturnsFour () { var tableView = new TableView { - Table = BuildTable (3, 3), MultiSelect = true, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (3, 3), MultiSelect = true, Viewport = new Rectangle (0, 0, 10, 5) }; tableView.BeginInit (); tableView.EndInit (); @@ -305,7 +305,7 @@ public void GetAllSelectedCells_TwoIsolatedSelections_ReturnsSix () { var tableView = new TableView { - Table = BuildTable (20, 20), MultiSelect = true, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (20, 20), MultiSelect = true, Viewport = new Rectangle (0, 0, 10, 5) }; tableView.BeginInit (); tableView.EndInit (); @@ -423,7 +423,7 @@ public void LongColumnTest () tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 25 characters can be printed into table - tableView.Bounds = new Rectangle (0, 0, 25, 5); + tableView.Viewport = new Rectangle (0, 0, 25, 5); tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -524,7 +524,7 @@ public void LongColumnTest () var driver = (FakeDriver)Application.Driver; driver.ClearContents (); - tableView.Bounds = new Rectangle (0, 0, 9, 5); + tableView.Viewport = new Rectangle (0, 0, 9, 5); tableView.LayoutSubviews (); tableView.Draw (); @@ -541,7 +541,7 @@ public void LongColumnTest () // setting width to 10 leaves just enough space for the column to // meet MinAcceptableWidth of 5. Column width includes terminator line // symbol (e.g. ┤ or │) - tableView.Bounds = new Rectangle (0, 0, 10, 5); + tableView.Viewport = new Rectangle (0, 0, 10, 5); tableView.LayoutSubviews (); tableView.Draw (); @@ -554,7 +554,7 @@ public void LongColumnTest () "; TestHelpers.AssertDriverContentsAre (expected, output); - tableView.Bounds = new Rectangle (0, 0, 25, 5); + tableView.Viewport = new Rectangle (0, 0, 25, 5); // revert style change style.MinAcceptableWidth = TableView.DefaultMinAcceptableWidth; @@ -601,7 +601,7 @@ public void PageDown_ExcludesHeaders () { var tableView = new TableView { - Table = BuildTable (25, 50), MultiSelect = true, Bounds = new Rectangle (0, 0, 10, 5) + Table = BuildTable (25, 50), MultiSelect = true, Viewport = new Rectangle (0, 0, 10, 5) }; // Header should take up 2 lines @@ -637,7 +637,7 @@ public void Redraw_EmptyTable () { var tableView = new TableView (); tableView.ColorScheme = new ColorScheme (); - tableView.Bounds = new Rectangle (0, 0, 25, 10); + tableView.Viewport = new Rectangle (0, 0, 25, 10); // Set a table with 1 column tableView.Table = BuildTable (1, 50, out DataTable dt); @@ -659,7 +659,7 @@ public void ScrollDown_OneLineAtATime () tableView.Table = BuildTable (25, 50); // 1 header + 4 rows visible - tableView.Bounds = new Rectangle (0, 0, 25, 5); + tableView.Viewport = new Rectangle (0, 0, 25, 5); tableView.Style.ShowHorizontalHeaderUnderline = false; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -686,7 +686,7 @@ public void ScrollIndicators () tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 3 columns are visibile - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -764,7 +764,7 @@ public void ScrollRight_SmoothScrolling () tableView.LayoutSubviews (); // 3 columns are visibile - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = false; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -827,7 +827,7 @@ public void ScrollRight_WithoutSmoothScrolling () tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 3 columns are visibile - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = false; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -944,7 +944,7 @@ public void ShowHorizontalBottomLine_NoCellLines () tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 3 columns are visibile - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -975,7 +975,7 @@ public void ShowHorizontalBottomLine_WithVerticalCellLines () tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 3 columns are visibile - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -1044,7 +1044,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused) tv.LayoutSubviews (); // width exactly matches the max col widths - tv.Bounds = new Rectangle (0, 0, 5, 4); + tv.Viewport = new Rectangle (0, 0, 5, 4); // Create a style for column B ColumnStyle bStyle = tv.Style.GetOrCreateColumnStyle (1); @@ -1141,7 +1141,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused) tv.LayoutSubviews (); // width exactly matches the max col widths - tv.Bounds = new Rectangle (0, 0, 5, 4); + tv.Viewport = new Rectangle (0, 0, 5, 4); var rowHighlight = new ColorScheme { @@ -1235,7 +1235,7 @@ public void TableView_ColorTests_FocusedOrNot (bool focused) tv.LayoutSubviews (); // width exactly matches the max col widths - tv.Bounds = new Rectangle (0, 0, 5, 4); + tv.Viewport = new Rectangle (0, 0, 5, 4); // private method for forcing the view to be focused/not focused MethodInfo setFocusMethod = @@ -1282,7 +1282,7 @@ public void TableView_ColorTests_InvertSelectedCellFirstCharacter (bool focused) tv.LayoutSubviews (); // width exactly matches the max col widths - tv.Bounds = new Rectangle (0, 0, 5, 4); + tv.Viewport = new Rectangle (0, 0, 5, 4); // private method for forcing the view to be focused/not focused MethodInfo setFocusMethod = @@ -1354,7 +1354,7 @@ public void TableView_ExpandLastColumn_False_ExactBounds () tv.Style.ExpandLastColumn = false; // width exactly matches the max col widths - tv.Bounds = new Rectangle (0, 0, 5, 4); + tv.Viewport = new Rectangle (0, 0, 5, 4); tv.Draw (); @@ -1398,7 +1398,7 @@ public void TableView_ExpandLastColumn_True () public void TableView_ShowHeadersFalse_AllLines () { TableView tv = GetABCDEFTableView (out _); - tv.Bounds = new Rectangle (0, 0, 5, 5); + tv.Viewport = new Rectangle (0, 0, 5, 5); tv.Style.ShowHeaders = false; tv.Style.ShowHorizontalHeaderOverline = true; @@ -1422,7 +1422,7 @@ public void TableView_ShowHeadersFalse_AllLines () public void TableView_ShowHeadersFalse_AndNoHeaderLines () { TableView tv = GetABCDEFTableView (out _); - tv.Bounds = new Rectangle (0, 0, 5, 5); + tv.Viewport = new Rectangle (0, 0, 5, 5); tv.Style.ShowHeaders = false; tv.Style.ShowHorizontalHeaderOverline = false; @@ -1441,7 +1441,7 @@ public void TableView_ShowHeadersFalse_AndNoHeaderLines () public void TableView_ShowHeadersFalse_OverlineTrue () { TableView tv = GetABCDEFTableView (out _); - tv.Bounds = new Rectangle (0, 0, 5, 5); + tv.Viewport = new Rectangle (0, 0, 5, 5); tv.Style.ShowHeaders = false; tv.Style.ShowHorizontalHeaderOverline = true; @@ -1461,7 +1461,7 @@ public void TableView_ShowHeadersFalse_OverlineTrue () public void TableView_ShowHeadersFalse_UnderlineTrue () { TableView tv = GetABCDEFTableView (out _); - tv.Bounds = new Rectangle (0, 0, 5, 5); + tv.Viewport = new Rectangle (0, 0, 5, 5); tv.Style.ShowHeaders = false; tv.Style.ShowHorizontalHeaderOverline = false; @@ -1588,7 +1588,7 @@ public void Test_CollectionNavigator () { var tv = new TableView (); tv.ColorScheme = Colors.ColorSchemes ["TopLevel"]; - tv.Bounds = new Rectangle (0, 0, 50, 7); + tv.Viewport = new Rectangle (0, 0, 50, 7); tv.Table = new EnumerableTableSource ( new [] { "fish", "troll", "trap", "zoo" }, @@ -2219,7 +2219,7 @@ public void TestEnumerableDataSource_BasicTypes () { var tv = new TableView (); tv.ColorScheme = Colors.ColorSchemes ["TopLevel"]; - tv.Bounds = new Rectangle (0, 0, 50, 6); + tv.Viewport = new Rectangle (0, 0, 50, 6); tv.Table = new EnumerableTableSource ( new [] { typeof (string), typeof (int), typeof (float) }, @@ -2253,7 +2253,7 @@ public void TestFullRowSelect_AlwaysUseNormalColorForVerticalCellLines () TableView tv = GetTwoRowSixColumnTable (out DataTable dt); dt.Rows.Add (1, 2, 3, 4, 5, 6); - tv.Bounds = new Rectangle (0, 0, 7, 6); + tv.Viewport = new Rectangle (0, 0, 7, 6); tv.Frame = new Rectangle (0, 0, 7, 6); tv.LayoutSubviews (); @@ -2269,7 +2269,7 @@ public void TestFullRowSelect_AlwaysUseNormalColorForVerticalCellLines () // should select that row Assert.Equal (2, tv.SelectedRow); - tv.OnDrawContent (tv.Bounds); + tv.OnDrawContent (tv.Viewport); var expected = @" @@ -2310,7 +2310,7 @@ public void TestFullRowSelect_SelectionColorDoesNotStop_WhenShowVerticalCellLine dt.Rows.Add (1, 2, 3, 4, 5, 6); tv.LayoutSubviews (); - tv.Bounds = new Rectangle (0, 0, 7, 6); + tv.Viewport = new Rectangle (0, 0, 7, 6); tv.FullRowSelect = true; tv.Style.ShowVerticalCellLines = false; @@ -2362,7 +2362,7 @@ public void TestFullRowSelect_SelectionColorStopsAtTableEdge_WithCellLines () TableView tv = GetTwoRowSixColumnTable (out DataTable dt); dt.Rows.Add (1, 2, 3, 4, 5, 6); - tv.Bounds = new Rectangle (0, 0, 7, 6); + tv.Viewport = new Rectangle (0, 0, 7, 6); tv.Frame = new Rectangle (0, 0, 7, 6); tv.LayoutSubviews (); @@ -2377,7 +2377,7 @@ public void TestFullRowSelect_SelectionColorStopsAtTableEdge_WithCellLines () // should select that row Assert.Equal (2, tv.SelectedRow); - tv.OnDrawContent (tv.Bounds); + tv.OnDrawContent (tv.Viewport); var expected = @" @@ -2425,7 +2425,7 @@ public void TestListTableSource (Orientation orient, bool parallel) //tv.BeginInit (); tv.EndInit (); tv.ColorScheme = Colors.ColorSchemes ["TopLevel"]; - tv.Bounds = new Rectangle (0, 0, 25, 4); + tv.Viewport = new Rectangle (0, 0, 25, 4); tv.Style = new TableStyle { @@ -3194,7 +3194,7 @@ private TableView GetABCDEFTableView (out DataTable dt) tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 3 columns are visible - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = false; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -3218,7 +3218,7 @@ private TableView GetPetTable (out EnumerableTableSource source) { var tv = new TableView (); tv.ColorScheme = Colors.ColorSchemes ["TopLevel"]; - tv.Bounds = new Rectangle (0, 0, 25, 6); + tv.Viewport = new Rectangle (0, 0, 25, 6); List pets = new () { @@ -3248,7 +3248,7 @@ private TableView GetTwoRowSixColumnTable (out DataTable dt) tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; // 3 columns are visible - tableView.Bounds = new Rectangle (0, 0, 7, 5); + tableView.Viewport = new Rectangle (0, 0, 7, 5); tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.Style.ShowHorizontalHeaderOverline = false; tableView.Style.AlwaysShowHeaders = true; @@ -3277,7 +3277,7 @@ private TableView SetUpMiniTable (out DataTable dt) var tv = new TableView (); tv.BeginInit (); tv.EndInit (); - tv.Bounds = new Rectangle (0, 0, 10, 4); + tv.Viewport = new Rectangle (0, 0, 10, 4); dt = new DataTable (); dt.Columns.Add ("A"); diff --git a/UnitTests/Views/TextValidateFieldTests.cs b/UnitTests/Views/TextValidateFieldTests.cs index 981c83a279..ea65f7eeae 100644 --- a/UnitTests/Views/TextValidateFieldTests.cs +++ b/UnitTests/Views/TextValidateFieldTests.cs @@ -71,7 +71,7 @@ public void Default_Width_Is_Always_Equal_To_The_Provider_DisplayText_Length () // A-Alphanumeric, required. a-Alphanumeric, optional. var field = new TextValidateField { Provider = new NetMaskedTextProvider ("999 000 LLL >LLL |AAA aaa") }; - Assert.Equal (field.Bounds.Width, field.Provider.DisplayText.Length); + Assert.Equal (field.Viewport.Width, field.Provider.DisplayText.Length); Assert.NotEqual (field.Provider.DisplayText.Length, field.Provider.Text.Length); Assert.Equal (new string (' ', field.Text.Length), field.Provider.Text); } diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index fdbe0e789b..f71cb99783 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -63,7 +63,7 @@ public void BackTab_Test_Follow_By_Tab () Application.Iteration += (s, a) => { - int width = _textView.Bounds.Width - 1; + int width = _textView.Viewport.Width - 1; Assert.Equal (30, width + 1); Assert.Equal (10, _textView.Height); _textView.Text = ""; @@ -7111,7 +7111,7 @@ public void Tab_Test_Follow_By_BackTab () Application.Iteration += (s, a) => { - int width = _textView.Bounds.Width - 1; + int width = _textView.Viewport.Width - 1; Assert.Equal (30, width + 1); Assert.Equal (10, _textView.Height); _textView.Text = ""; @@ -7152,7 +7152,7 @@ public void Tab_Test_Follow_By_BackTab_With_Text () Application.Iteration += (s, a) => { - int width = _textView.Bounds.Width - 1; + int width = _textView.Viewport.Width - 1; Assert.Equal (30, width + 1); Assert.Equal (10, _textView.Height); var col = 0; @@ -7193,7 +7193,7 @@ public void Tab_Test_Follow_By_CursorLeft_And_Then_Follow_By_CursorRight () Application.Iteration += (s, a) => { - int width = _textView.Bounds.Width - 1; + int width = _textView.Viewport.Width - 1; Assert.Equal (30, width + 1); Assert.Equal (10, _textView.Height); _textView.Text = ""; @@ -7243,7 +7243,7 @@ public void Tab_Test_Follow_By_CursorLeft_And_Then_Follow_By_CursorRight_With_Te Application.Iteration += (s, a) => { - int width = _textView.Bounds.Width - 1; + int width = _textView.Viewport.Width - 1; Assert.Equal (30, width + 1); Assert.Equal (10, _textView.Height); Assert.Equal ("TAB to jump between text fields.", _textView.Text); @@ -7295,7 +7295,7 @@ public void Tab_Test_Follow_By_Home_And_Then_Follow_By_End_And_Then_Follow_By_Ba Application.Iteration += (s, a) => { - int width = _textView.Bounds.Width - 1; + int width = _textView.Viewport.Width - 1; Assert.Equal (30, width + 1); Assert.Equal (10, _textView.Height); var col = 0; diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 9eaee637f5..e13d2dcc71 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1360,7 +1360,7 @@ void view_LayoutStarted (object sender, LayoutEventArgs e) Assert.Equal (new (1, 3, 10, 5), view.Frame); Assert.Equal (new (0, 0, 10, 5), view._needsDisplayRect); - view.OnDrawContent (view.Bounds); + view.OnDrawContent (view.Viewport); view.Frame = new (1, 3, 10, 5); Assert.Equal (new (1, 3, 10, 5), view.Frame); Assert.Equal (new (0, 0, 10, 5), view._needsDisplayRect); diff --git a/UnitTests/Views/TreeTableSourceTests.cs b/UnitTests/Views/TreeTableSourceTests.cs index 68d006f35a..f572e529a3 100644 --- a/UnitTests/Views/TreeTableSourceTests.cs +++ b/UnitTests/Views/TreeTableSourceTests.cs @@ -227,7 +227,7 @@ private TableView GetTreeTable (out TreeView tree) var tableView = new TableView (); tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; tableView.ColorScheme = Colors.ColorSchemes ["TopLevel"]; - tableView.Bounds = new Rectangle (0, 0, 40, 6); + tableView.Viewport = new Rectangle (0, 0, 40, 6); tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.Style.ShowHorizontalHeaderOverline = false; diff --git a/UnitTests/Views/TreeViewTests.cs b/UnitTests/Views/TreeViewTests.cs index 5b180870b6..843612898e 100644 --- a/UnitTests/Views/TreeViewTests.cs +++ b/UnitTests/Views/TreeViewTests.cs @@ -30,7 +30,7 @@ public void ContentWidth_BiggerAfterExpand () tree.BeginInit (); tree.EndInit (); - tree.Bounds = new Rectangle (0, 0, 10, 10); + tree.Viewport = new Rectangle (0, 0, 10, 10); InitFakeDriver (); @@ -60,7 +60,7 @@ public void ContentWidth_VisibleVsAll () tree.EndInit (); // control only allows 1 row to be viewed at once - tree.Bounds = new Rectangle (0, 0, 20, 1); + tree.Viewport = new Rectangle (0, 0, 20, 1); InitFakeDriver (); @@ -234,7 +234,7 @@ public void GoTo_OnlyAppliesToExposedObjects () tree.EndInit (); // Make tree bounds 1 in height so that EnsureVisible always requires updating scroll offset - tree.Bounds = new Rectangle (0, 0, 50, 1); + tree.Viewport = new Rectangle (0, 0, 50, 1); Assert.Null (tree.SelectedObject); Assert.Equal (0, tree.ScrollOffsetVertical); diff --git a/UnitTests/Views/WindowTests.cs b/UnitTests/Views/WindowTests.cs index 83e4b0822d..a6e6765aec 100644 --- a/UnitTests/Views/WindowTests.cs +++ b/UnitTests/Views/WindowTests.cs @@ -135,7 +135,7 @@ public void New_Initializes () Assert.Equal ($"Window(){defaultWindow.Frame}", defaultWindow.ToString ()); Assert.True (defaultWindow.CanFocus); Assert.False (defaultWindow.HasFocus); - Assert.Equal (new Rectangle (0, 0, 2147483645, 2147483645), defaultWindow.Bounds); + Assert.Equal (new Rectangle (0, 0, 2147483645, 2147483645), defaultWindow.Viewport); Assert.Equal (new Rectangle (0, 0, 2147483647, 2147483647), defaultWindow.Frame); Assert.Null (defaultWindow.Focused); Assert.NotNull (defaultWindow.ColorScheme); @@ -168,7 +168,7 @@ public void New_Initializes () #endif Assert.True (windowWithFrameRectEmpty.CanFocus); Assert.False (windowWithFrameRectEmpty.HasFocus); - Assert.Equal (Rectangle.Empty, windowWithFrameRectEmpty.Bounds); + Assert.Equal (Rectangle.Empty, windowWithFrameRectEmpty.Viewport); Assert.Equal (Rectangle.Empty, windowWithFrameRectEmpty.Frame); Assert.Null (windowWithFrameRectEmpty.Focused); Assert.NotNull (windowWithFrameRectEmpty.ColorScheme); @@ -201,7 +201,7 @@ public void New_Initializes () #endif Assert.True (windowWithFrame1234.CanFocus); Assert.False (windowWithFrame1234.HasFocus); - Assert.Equal (new (0, 0, 1, 2), windowWithFrame1234.Bounds); + Assert.Equal (new (0, 0, 1, 2), windowWithFrame1234.Viewport); Assert.Equal (new (1, 2, 3, 4), windowWithFrame1234.Frame); Assert.Null (windowWithFrame1234.Focused); Assert.NotNull (windowWithFrame1234.ColorScheme); From 3a40dec24992573b9e33b8b354aa90476a11adc7 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 07:39:12 -0800 Subject: [PATCH 2/8] Reamed Bounds -> Viewport in comments --- Terminal.Gui/Application.cs | 6 +-- Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs | 2 +- Terminal.Gui/Drawing/LineCanvas.cs | 22 +++++------ Terminal.Gui/Drawing/StraightLine.cs | 4 +- Terminal.Gui/View/Adornment/Adornment.cs | 2 +- Terminal.Gui/View/Layout/ViewLayout.cs | 40 ++++++++++---------- Terminal.Gui/View/View.cs | 2 +- Terminal.Gui/View/ViewDrawing.cs | 8 ++-- Terminal.Gui/View/ViewText.cs | 6 +-- Terminal.Gui/Views/FileDialog.cs | 2 +- Terminal.Gui/Views/GraphView/Annotations.cs | 2 +- Terminal.Gui/Views/HexView.cs | 12 +++--- Terminal.Gui/Views/Menu/ContextMenu.cs | 2 +- Terminal.Gui/Views/Menu/MenuBar.cs | 4 +- Terminal.Gui/Views/ProgressBar.cs | 2 +- Terminal.Gui/Views/Slider.cs | 8 ++-- Terminal.Gui/Views/TextField.cs | 2 +- Terminal.Gui/Views/Toplevel.cs | 2 +- UICatalog/Scenarios/Buttons.cs | 2 +- UICatalog/Scenarios/CharacterMap.cs | 8 ++-- UICatalog/Scenarios/ViewExperiments.cs | 6 +-- UnitTests/Application/MouseTests.cs | 6 +-- UnitTests/Drawing/LineCanvasTests.cs | 36 +++++++++--------- UnitTests/Drawing/StraightLineTests.cs | 4 +- UnitTests/View/Adornment/ToScreenTests.cs | 2 +- UnitTests/View/DrawTests.cs | 10 ++--- UnitTests/View/Layout/AbsoluteLayoutTests.cs | 28 +++++++------- UnitTests/View/Layout/BoundsTests.cs | 2 +- UnitTests/View/Layout/DimTests.cs | 2 +- UnitTests/View/Layout/PosTests.cs | 4 +- UnitTests/View/SubviewTests.cs | 36 +++++++++--------- UnitTests/View/ViewTests.cs | 2 +- UnitTests/Views/ScrollBarViewTests.cs | 2 +- UnitTests/Views/TextViewTests.cs | 2 +- 34 files changed, 140 insertions(+), 140 deletions(-) diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index 94cfb81547..e84ae835c0 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -296,7 +296,7 @@ internal static void InternalInit ( Current = Top; // Ensure Top's layout is up to date. - Current.SetRelativeLayout (Driver.Bounds); + Current.SetRelativeLayout (Driver.Viewport); SupportedCultures = GetSupportedCultures (); _mainThreadId = Thread.CurrentThread.ManagedThreadId; @@ -487,7 +487,7 @@ public static RunState Begin (Toplevel Toplevel) } //if (Toplevel.LayoutStyle == LayoutStyle.Computed) { - Toplevel.SetRelativeLayout (Driver.Bounds); + Toplevel.SetRelativeLayout (Driver.Viewport); //} @@ -1408,7 +1408,7 @@ internal static void OnMouseEvent (MouseEventEventArgs a) if (MouseGrabView is { }) { // If the mouse is grabbed, send the event to the view that grabbed it. - // The coordinates are relative to the Bounds of the view that grabbed the mouse. + // The coordinates are relative to the Viewport of the view that grabbed the mouse. Point frameLoc = MouseGrabView.ScreenToFrame (a.MouseEvent.X, a.MouseEvent.Y); var viewRelativeMouseEvent = new MouseEvent diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs index 2a80f34738..42db871876 100644 --- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs @@ -19,7 +19,7 @@ public abstract class ConsoleDriver internal bool [] _dirtyLines; /// Gets the dimensions of the terminal. - public Rectangle Bounds => new (0, 0, Cols, Rows); + public Rectangle Viewport => new (0, 0, Cols, Rows); /// /// Gets or sets the clip rectangle that and are subject diff --git a/Terminal.Gui/Drawing/LineCanvas.cs b/Terminal.Gui/Drawing/LineCanvas.cs index 6fe9858523..fb9167ec51 100644 --- a/Terminal.Gui/Drawing/LineCanvas.cs +++ b/Terminal.Gui/Drawing/LineCanvas.cs @@ -67,7 +67,7 @@ public LineCanvas () /// Gets the rectangle that describes the bounds of the canvas. Location is the coordinates of the line that is /// furthest left/top and Size is defined by the line that extends the furthest right/bottom. /// - public Rectangle Bounds + public Rectangle Viewport { get { @@ -78,11 +78,11 @@ public Rectangle Bounds return _cachedBounds; } - Rectangle bounds = _lines [0].Bounds; + Rectangle bounds = _lines [0].Viewport; for (var i = 1; i < _lines.Count; i++) { - bounds = Rectangle.Union (bounds, _lines [i].Bounds); + bounds = Rectangle.Union (bounds, _lines [i].Viewport); } if (bounds is {Width: 0} or {Height: 0}) @@ -170,9 +170,9 @@ public Dictionary GetCellMap () Dictionary map = new (); // walk through each pixel of the bitmap - for (int y = Bounds.Y; y < Bounds.Y + Bounds.Height; y++) + for (int y = Viewport.Y; y < Viewport.Y + Viewport.Height; y++) { - for (int x = Bounds.X; x < Bounds.X + Bounds.Width; x++) + for (int x = Viewport.X; x < Viewport.X + Viewport.Width; x++) { IntersectionDefinition? [] intersects = _lines .Select (l => l.Intersects (x, y)) @@ -232,7 +232,7 @@ public Dictionary GetMap (Rectangle inArea) /// intersection symbols. /// /// A map of all the points within the canvas. - public Dictionary GetMap () { return GetMap (Bounds); } + public Dictionary GetMap () { return GetMap (Viewport); } /// Merges one line canvas into this one. /// @@ -260,13 +260,13 @@ public StraightLine RemoveLastLine () /// /// Returns the contents of the line canvas rendered to a string. The string will include all columns and rows, - /// even if has negative coordinates. For example, if the canvas contains a single line that + /// even if has negative coordinates. For example, if the canvas contains a single line that /// starts at (-1,-1) with a length of 2, the rendered string will have a length of 2. /// /// The canvas rendered to a string. public override string ToString () { - if (Bounds.IsEmpty) + if (Viewport.IsEmpty) { return string.Empty; } @@ -275,13 +275,13 @@ public override string ToString () Dictionary runeMap = GetMap (); // Create the rune canvas - Rune [,] canvas = new Rune [Bounds.Height, Bounds.Width]; + Rune [,] canvas = new Rune [Viewport.Height, Viewport.Width]; // Copy the rune map to the canvas, adjusting for any negative coordinates foreach (KeyValuePair kvp in runeMap) { - int x = kvp.Key.X - Bounds.X; - int y = kvp.Key.Y - Bounds.Y; + int x = kvp.Key.X - Viewport.X; + int y = kvp.Key.Y - Viewport.Y; canvas [y, x] = kvp.Value; } diff --git a/Terminal.Gui/Drawing/StraightLine.cs b/Terminal.Gui/Drawing/StraightLine.cs index 1dd7b803c4..9a2785f0f4 100644 --- a/Terminal.Gui/Drawing/StraightLine.cs +++ b/Terminal.Gui/Drawing/StraightLine.cs @@ -45,8 +45,8 @@ public StraightLine ( /// Gets the rectangle that describes the bounds of the canvas. Location is the coordinates of the line that is /// furthest left/top and Size is defined by the line that extends the furthest right/bottom. /// - // PERF: Probably better to store the rectangle rather than make a new one on every single access to Bounds. - internal Rectangle Bounds + // PERF: Probably better to store the rectangle rather than make a new one on every single access to Viewport. + internal Rectangle Viewport { get { diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index 74348cfeeb..785f727821 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -112,7 +112,7 @@ internal override void LayoutAdornments () public override Rectangle Viewport { get => Frame with { Location = Point.Empty }; - set => throw new InvalidOperationException ("It makes no sense to set Bounds of a Thickness."); + set => throw new InvalidOperationException ("It makes no sense to set Viewport of a Thickness."); } /// diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 18ab7c5631..057dcf56ca 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -284,7 +284,7 @@ public Dim Width #endregion Frame - #region Bounds + #region Viewport /// /// The bounds represent the View-relative rectangle used for this view; the area inside the view where @@ -293,16 +293,16 @@ public Dim Width /// The rectangle describing the location and size of the area where the views' subviews and content are drawn. /// /// - /// If is the value of Bounds is indeterminate until + /// If is the value of Viewport is indeterminate until /// the view has been initialized ( is true) and has been /// called. /// /// - /// Updates to the Bounds updates , and has the same effect as updating the + /// Updates to the Viewport updates , and has the same effect as updating the /// . /// /// - /// Altering the Bounds will eventually (when the view is next laid out) cause the + /// Altering the Viewport will eventually (when the view is next laid out) cause the /// and methods to be called. /// /// @@ -319,7 +319,7 @@ public virtual Rectangle Viewport if (LayoutStyle == LayoutStyle.Computed && !IsInitialized) { Debug.WriteLine ( - $"WARNING: Bounds is being accessed before the View has been initialized. This is likely a bug in {this}" + $"WARNING: Viewport is being accessed before the View has been initialized. This is likely a bug in {this}" ); } #endif // DEBUG @@ -341,13 +341,13 @@ public virtual Rectangle Viewport } set { - // TODO: Should we enforce Bounds.X/Y == 0? The code currently ignores value.X/Y which is + // TODO: Should we enforce Viewport.X/Y == 0? The code currently ignores value.X/Y which is // TODO: correct behavior, but is silent. Perhaps an exception? #if DEBUG if (value.Location != Point.Empty) { Debug.WriteLine ( - $"WARNING: Bounds.Location must always be 0,0. Location ({value.Location}) is ignored. {this}" + $"WARNING: Viewport.Location must always be 0,0. Location ({value.Location}) is ignored. {this}" ); } #endif // DEBUG @@ -365,7 +365,7 @@ public virtual Rectangle Viewport /// Converts a -relative rectangle to a screen-relative rectangle. public Rectangle BoundsToScreen (in Rectangle bounds) { - // Translate bounds to Frame (our SuperView's Bounds-relative coordinates) + // 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); @@ -387,12 +387,12 @@ public Point ScreenToBounds (int x, int y) } /// - /// Helper to get the X and Y offset of the Bounds from the Frame. This is the sum of the Left and Top properties + /// 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; } - #endregion Bounds + #endregion Viewport #region AutoSize @@ -573,7 +573,7 @@ internal bool TrySetWidth (int desiredWidth, out int resultWidth) /// Resizes the View to fit the specified size. Factors in the HotKey. /// ResizeBoundsToFit can only be called when AutoSize is true (or being set to true). /// - /// whether the Bounds was changed or not + /// whether the Viewport was changed or not private bool ResizeBoundsToFit (Size size) { //if (AutoSize == false) { @@ -728,7 +728,7 @@ public virtual bool Contains (int x, int y) #nullable restore /// - /// Gets a new location of the that is within the Bounds of the 's + /// Gets a new location of the that is within the Viewport of the 's /// (e.g. for dragging a Window). The `out` parameters are the new X and Y coordinates. /// /// @@ -765,7 +765,7 @@ out StatusBar statusBar } else { - // Use the SuperView's Bounds, not Frame + // Use the SuperView's Viewport, not Frame maxDimension = viewToMove.SuperView.Viewport.Width; superView = viewToMove.SuperView; } @@ -972,11 +972,11 @@ internal void OnResizeNeeded () { // TODO: Identify a real-world use-case where this API should be virtual. // TODO: Until then leave it `internal` and non-virtual - // First try SuperView.Bounds, then Application.Top, then Driver.Bounds. + // First try SuperView.Viewport, then Application.Top, then Driver.Viewport. // Finally, if none of those are valid, use int.MaxValue (for Unit tests). Rectangle relativeBounds = SuperView is { IsInitialized: true } ? SuperView.Viewport : Application.Top is { } && Application.Top.IsInitialized ? Application.Top.Viewport : - Application.Driver?.Bounds ?? new Rectangle (0, 0, int.MaxValue, int.MaxValue); + Application.Driver?.Viewport ?? new Rectangle (0, 0, int.MaxValue, int.MaxValue); SetRelativeLayout (relativeBounds); // TODO: Determine what, if any of the below is actually needed here. @@ -1018,12 +1018,12 @@ internal void SetNeedsLayout () /// /// Applies the view's position (, ) and dimension (, and - /// ) to , given a rectangle describing the SuperView's Bounds (nominally the - /// same as this.SuperView.Bounds). + /// ) to , given a rectangle describing the SuperView's Viewport (nominally the + /// same as this.SuperView.Viewport). /// /// - /// The rectangle describing the SuperView's Bounds (nominally the same as - /// this.SuperView.Bounds). + /// The rectangle describing the SuperView's Viewport (nominally the same as + /// this.SuperView.Viewport). /// internal void SetRelativeLayout (Rectangle superviewBounds) { @@ -1047,7 +1047,7 @@ internal void SetRelativeLayout (Rectangle superviewBounds) // TODO: View.AutoSize stuff is removed. // Returns the new dimension (width or height) and location (x or y) for the View given - // the superview's Bounds + // the superview's Viewport // the current Pos (View.X or View.Y) // the current Dim (View.Width or View.Height) // This method is called recursively if pos is Pos.PosCombine diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs index 84b30e3bdf..a66fb19fc1 100644 --- a/Terminal.Gui/View/View.cs +++ b/Terminal.Gui/View/View.cs @@ -234,7 +234,7 @@ public virtual void EndInit () // TODO: Move these into ViewText.cs as EndInit_Text() to consolodate. // TODO: Verify UpdateTextDirection really needs to be called here. - // These calls were moved from BeginInit as they access Bounds which is indeterminate until EndInit is called. + // These calls were moved from BeginInit as they access Viewport which is indeterminate until EndInit is called. UpdateTextDirection (TextDirection); UpdateTextFormatterText (); OnResizeNeeded (); diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 0107ca1ad9..284db73c65 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -86,7 +86,7 @@ public void AddRune (int col, int row, Rune ch) /// Clears the specified -relative rectangle with the normal background. /// - /// The Bounds-relative rectangle to clear. + /// The Viewport-relative rectangle to clear. public void Clear (Rectangle contentArea) { if (Driver is null) @@ -141,7 +141,7 @@ public Rectangle ClipToBounds () /// /// /// Overrides of must ensure they do not set Driver.Clip to a clip - /// region larger than the property, as this will cause the driver to clip the entire region. + /// region larger than the property, as this will cause the driver to clip the entire region. /// /// public void Draw () @@ -443,7 +443,7 @@ public virtual bool OnRenderLineCanvas () } // If we have a SuperView, it'll render our frames. - if (!SuperViewRendersLineCanvas && LineCanvas.Bounds != Rectangle.Empty) + if (!SuperViewRendersLineCanvas && LineCanvas.Viewport != Rectangle.Empty) { foreach (KeyValuePair p in LineCanvas.GetCellMap ()) { @@ -501,7 +501,7 @@ public void SetNeedsDisplay () /// If the view has not been initialized ( is ), the area to be /// redrawn will be the . /// - /// The Bounds-relative region that needs to be redrawn. + /// The Viewport-relative region that needs to be redrawn. public virtual void SetNeedsDisplay (Rectangle region) { if (!IsInitialized) diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 911f72938a..7292afef5e 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -304,12 +304,12 @@ private bool SetFrameToFitText () throw new InvalidOperationException ("SetFrameToFitText can only be called when AutoSize is true"); } - // BUGBUG: This API is broken - should not assume Frame.Height == Bounds.Height + // BUGBUG: This API is broken - should not assume Frame.Height == Viewport.Height // // Gets the minimum dimensions required to fit the View's , factoring in . // // The minimum dimensions required. - // if the dimensions fit within the View's , otherwise. + // if the dimensions fit within the View's , otherwise. // // Always returns if is or // if (Horizontal) or (Vertical) are not not set or zero. @@ -336,7 +336,7 @@ bool GetMinimumSizeOfText (out Size sizeRequired) case true: int colWidth = TextFormatter.GetWidestLineLength (new List { TextFormatter.Text }, 0, 1); - // TODO: v2 - This uses frame.Width; it should only use Bounds + // TODO: v2 - This uses frame.Width; it should only use Viewport if (_frame.Width < colWidth && (Width is null || (Viewport.Width >= 0 && Width is Dim.DimAbsolute && Width.Anchor (0) >= 0 && Width.Anchor (0) < colWidth))) { diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index 118e4437d9..88686ca270 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -778,7 +778,7 @@ private int CalculateOkButtonPosX () - _btnCancel.Viewport.Width - 1 - // TODO: Fiddle factor, seems the Bounds are wrong for someone + // TODO: Fiddle factor, seems the Viewport are wrong for someone - 2; } diff --git a/Terminal.Gui/Views/GraphView/Annotations.cs b/Terminal.Gui/Views/GraphView/Annotations.cs index 25d2d02035..30247d4a69 100644 --- a/Terminal.Gui/Views/GraphView/Annotations.cs +++ b/Terminal.Gui/Views/GraphView/Annotations.cs @@ -62,7 +62,7 @@ public void Render (GraphView graph) /// /// Draws the at the given coordinates with truncation to avoid spilling over - /// of the + /// of the /// /// /// Screen x position to start drawing string diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs index 5f994a4ced..c66a040ca2 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -264,7 +264,7 @@ public void ApplyEdits (Stream stream = null) /// protected internal override bool OnMouseEvent (MouseEvent me) { - // BUGBUG: Test this with a border! Assumes Frame == Bounds! + // BUGBUG: Test this with a border! Assumes Frame == Viewport! if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked) @@ -358,7 +358,7 @@ public override void OnDrawContent (Rectangle contentArea) Driver.SetAttribute (current); Move (0, 0); - // BUGBUG: Bounds!!!! + // BUGBUG: Viewport!!!! Rectangle frame = Frame; int nblocks = bytesPerLine / bsize; @@ -619,7 +619,7 @@ private void HexView_LayoutComplete (object sender, LayoutEventArgs e) private bool MoveDown (int bytes) { - // BUGBUG: Bounds! + // BUGBUG: Viewport! RedisplayLine (position); if (position + bytes < source.Length) @@ -657,7 +657,7 @@ private bool MoveEnd () { position = source.Length; - // BUGBUG: Bounds! + // BUGBUG: Viewport! if (position >= DisplayStart + bytesPerLine * Frame.Height) { SetDisplayStart (position); @@ -744,7 +744,7 @@ private bool MoveRight () position++; } - // BUGBUG: Bounds! + // BUGBUG: Viewport! if (position >= DisplayStart + bytesPerLine * Frame.Height) { SetDisplayStart (DisplayStart + bytesPerLine); @@ -793,7 +793,7 @@ private void RedisplayLine (long pos) var delta = (int)(pos - DisplayStart); int line = delta / bytesPerLine; - // BUGBUG: Bounds! + // BUGBUG: Viewport! SetNeedsDisplay (new (0, line, Frame.Width, 1)); } diff --git a/Terminal.Gui/Views/Menu/ContextMenu.cs b/Terminal.Gui/Views/Menu/ContextMenu.cs index f9ee4625f2..4fa1331646 100644 --- a/Terminal.Gui/Views/Menu/ContextMenu.cs +++ b/Terminal.Gui/Views/Menu/ContextMenu.cs @@ -142,7 +142,7 @@ public void Show () _container = Application.Current; _container.Closing += Container_Closing; - Rectangle frame = Application.Driver.Bounds; + Rectangle frame = Application.Driver.Viewport; Point position = Position; if (Host is { }) diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index ca18c4426a..1abe33e82a 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -825,7 +825,7 @@ internal Point GetScreenOffset () return Point.Empty; } - Rectangle superViewFrame = SuperView is null ? Driver.Bounds : SuperView.Frame; + Rectangle superViewFrame = SuperView is null ? Driver.Viewport : SuperView.Frame; View sv = SuperView is null ? Application.Current : SuperView; Point boundsOffset = sv.GetBoundsOffset (); @@ -842,7 +842,7 @@ internal Point GetScreenOffset () /// The location offset. internal Point GetScreenOffsetFromCurrent () { - Rectangle screen = Driver.Bounds; + Rectangle screen = Driver.Viewport; Rectangle currentFrame = Application.Current.Frame; Point boundsOffset = Application.Top.GetBoundsOffset (); diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 8609872999..65bbb616ae 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -291,7 +291,7 @@ private void ProgressBar_LayoutStarted (object sender, EventArgs e) private void SetInitialProperties () { - Height = 1; // This will be updated when Bounds is updated in ProgressBar_LayoutStarted + Height = 1; // This will be updated when Viewport is updated in ProgressBar_LayoutStarted CanFocus = false; _fraction = 0; LayoutStarted += ProgressBar_LayoutStarted; diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index 08a4815549..b0ebaa30e1 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -374,7 +374,7 @@ public bool AllowEmpty } /// - /// If the slider will be sized to fit the available space (the Bounds of the the + /// If the slider will be sized to fit the available space (the Viewport of the the /// SuperView). /// /// @@ -663,10 +663,10 @@ internal void CalcSpacingConfig () if (AutoSize) { - // Max size is SuperView's Bounds. Min Size is size that will fit. + // Max size is SuperView's Viewport. Min Size is size that will fit. if (SuperView is { }) { - // Calculate the size of the slider based on the size of the SuperView's Bounds. + // Calculate the size of the slider based on the size of the SuperView's Viewport. if (_config._sliderOrientation == Orientation.Horizontal) { size = int.Min (SuperView.Viewport.Width, CalcBestLength ()); @@ -686,7 +686,7 @@ internal void CalcSpacingConfig () } else { - // Fit Slider to the Bounds + // Fit Slider to the Viewport if (_config._sliderOrientation == Orientation.Horizontal) { size = Viewport.Width; diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index 1d9d0fd2c5..e3e0f56f1c 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -1746,7 +1746,7 @@ private void MoveWordRightExtend () } } - // BUGBUG: This assumes Frame == Bounds. It's also not clear what the intention is. For now, changed to always return 0. + // BUGBUG: This assumes Frame == Viewport. It's also not clear what the intention is. For now, changed to always return 0. private int OffSetBackground () { var offB = 0; diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index 60f264984f..2201e43c51 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -297,7 +297,7 @@ public override void OnDrawContent (Rectangle contentArea) // This is causing the menus drawn incorrectly if UseSubMenusSingleFrame is true //if (this.MenuBar is { } && this.MenuBar.IsMenuOpen && this.MenuBar.openMenu is { }) { // // TODO: Hack until we can get compositing working right. - // this.MenuBar.openMenu.Redraw (this.MenuBar.openMenu.Bounds); + // this.MenuBar.openMenu.Redraw (this.MenuBar.openMenu.Viewport); //} } } diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index 90797c851e..afe6aac3aa 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -48,7 +48,7 @@ static void DoMessage (Button button, string txt) View prev = colorButtonsLabel; - //With this method there is no need to call Application.TopReady += () => Application.TopRedraw (Top.Bounds); + //With this method there is no need to call Application.TopReady += () => Application.TopRedraw (Top.Viewport); Pos x = Pos.Right (colorButtonsLabel) + 2; foreach (KeyValuePair colorScheme in Colors.ColorSchemes) diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index fa90d8539f..424de7882a 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -529,21 +529,21 @@ public override void OnDrawContent (Rectangle contentArea) //if (ShowHorizontalScrollIndicator && ContentSize.Height < (int)(MaxCodePoint / 16 + 2)) { // //ContentSize = new (CharMap.RowWidth, (int)(MaxCodePoint / 16 + 2)); // //ContentSize = new (CharMap.RowWidth, (int)(MaxCodePoint / 16) * _rowHeight + 2); - // var width = (Bounds.Width / COLUMN_WIDTH * COLUMN_WIDTH) - (ShowVerticalScrollIndicator ? RowLabelWidth + 1 : RowLabelWidth); + // var width = (Viewport.Width / COLUMN_WIDTH * COLUMN_WIDTH) - (ShowVerticalScrollIndicator ? RowLabelWidth + 1 : RowLabelWidth); // if (Cursor.X + ContentOffset.X >= width) { // // Snap to the selected glyph. // ContentOffset = new ( // Math.Min (Cursor.X, Cursor.X - width + COLUMN_WIDTH), - // ContentOffset.Y == -ContentSize.Height + Bounds.Height ? ContentOffset.Y - 1 : ContentOffset.Y); + // ContentOffset.Y == -ContentSize.Height + Viewport.Height ? ContentOffset.Y - 1 : ContentOffset.Y); // } else { // ContentOffset = new ( // ContentOffset.X - Cursor.X, - // ContentOffset.Y == -ContentSize.Height + Bounds.Height ? ContentOffset.Y - 1 : ContentOffset.Y); + // ContentOffset.Y == -ContentSize.Height + Viewport.Height ? ContentOffset.Y - 1 : ContentOffset.Y); // } //} else if (!ShowHorizontalScrollIndicator && ContentSize.Height > (int)(MaxCodePoint / 16 + 1)) { // //ContentSize = new (CharMap.RowWidth, (int)(MaxCodePoint / 16 + 1)); // // Snap 1st column into view if it's been scrolled horizontally - // ContentOffset = new (0, ContentOffset.Y < -ContentSize.Height + Bounds.Height ? ContentOffset.Y - 1 : ContentOffset.Y); + // ContentOffset = new (0, ContentOffset.Y < -ContentSize.Height + Viewport.Height ? ContentOffset.Y - 1 : ContentOffset.Y); //} base.OnDrawContent (contentArea); } diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index 159dd75879..8fe1a55039 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -217,17 +217,17 @@ public override void Setup () containerLabel.Text = $"Container.Frame: { Application.Top.Frame - } .Bounds: { + } .Viewport: { Application.Top.Viewport }\nView.Frame: { view.Frame - } .Bounds: { + } .Viewport: { view.Viewport } .BoundsOffset: { view.GetBoundsOffset () }\n .Padding.Frame: { view.Padding.Frame - } .Padding.Bounds: { + } .Padding.Viewport: { view.Padding.Viewport }"; }; diff --git a/UnitTests/Application/MouseTests.cs b/UnitTests/Application/MouseTests.cs index 8c0791070f..0d64503b6b 100644 --- a/UnitTests/Application/MouseTests.cs +++ b/UnitTests/Application/MouseTests.cs @@ -61,7 +61,7 @@ void OnApplicationOnMouseEvent (object s, MouseEventEventArgs e) /// /// Tests that the mouse coordinates passed to the focused view are correct when the mouse is clicked. No adornments; - /// Frame == Bounds + /// Frame == Viewport /// [Theory] [AutoInitShutdown] @@ -134,7 +134,7 @@ bool expectedClicked /// /// Tests that the mouse coordinates passed to the focused view are correct when the mouse is clicked. With - /// Frames; Frame != Bounds + /// Frames; Frame != Viewport /// [AutoInitShutdown] [Theory] @@ -206,7 +206,7 @@ bool expectedClicked var view = new View { X = pos.X, Y = pos.Y, Width = size.Width, Height = size.Height }; - // Give the view a border. With PR #2920, mouse clicks are only passed if they are inside the view's Bounds. + // Give the view a border. With PR #2920, mouse clicks are only passed if they are inside the view's Viewport. view.BorderStyle = LineStyle.Single; view.CanFocus = true; diff --git a/UnitTests/Drawing/LineCanvasTests.cs b/UnitTests/Drawing/LineCanvasTests.cs index 35968090b3..c386fdcc8d 100644 --- a/UnitTests/Drawing/LineCanvasTests.cs +++ b/UnitTests/Drawing/LineCanvasTests.cs @@ -380,7 +380,7 @@ int expectedHeight canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single); canvas.AddLine (new Point (x, y), length, Orientation.Vertical, LineStyle.Single); - Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Bounds); + Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Viewport); } [InlineData ( @@ -461,7 +461,7 @@ int expectedHeight var canvas = new LineCanvas (); canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single); - Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Bounds); + Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Viewport); } [Fact] @@ -483,27 +483,27 @@ public void Bounds_Specific () // Add a short horiz line for ╔╡ lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 2, 1), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 2, 1), lc.Viewport); //LHS line down lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 2, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport); //Vertical line before Title, results in a ╡ lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single); - Assert.Equal (new Rectangle (x, y, 2, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport); //Vertical line after Title, results in a ╞ lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single); - Assert.Equal (new Rectangle (x, y, 3, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 3, 2), lc.Viewport); // remainder of top line lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 4, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport); //RHS line down lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 4, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport); TestHelpers.AssertEqual ( output, @@ -533,27 +533,27 @@ public void Bounds_Specific_With_Ustring () // Add a short horiz line for ╔╡ lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 2, 1), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 2, 1), lc.Viewport); //LHS line down lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 2, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport); //Vertical line before Title, results in a ╡ lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single); - Assert.Equal (new Rectangle (x, y, 2, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport); //Vertical line after Title, results in a ╞ lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single); - Assert.Equal (new Rectangle (x, y, 3, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 3, 2), lc.Viewport); // remainder of top line lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 4, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport); //RHS line down lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double); - Assert.Equal (new Rectangle (x, y, 4, 2), lc.Bounds); + Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport); TestHelpers.AssertEqual ( output, @@ -570,13 +570,13 @@ public void Canvas_Updates_On_Changes () { var lc = new LineCanvas (); - Assert.Equal (Rectangle.Empty, lc.Bounds); + Assert.Equal (Rectangle.Empty, lc.Viewport); lc.AddLine (Point.Empty, 2, Orientation.Horizontal, LineStyle.Double); - Assert.NotEqual (Rectangle.Empty, lc.Bounds); + Assert.NotEqual (Rectangle.Empty, lc.Viewport); lc.Clear (); - Assert.Equal (Rectangle.Empty, lc.Bounds); + Assert.Equal (Rectangle.Empty, lc.Viewport); } [InlineData (0, 0, Orientation.Horizontal, "─")] @@ -873,7 +873,7 @@ public void Top_With_1Down () //// Left Up //canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, LineStyle.Single); - Assert.Equal (new Rectangle (0, 0, 2, 2), canvas.Bounds); + Assert.Equal (new Rectangle (0, 0, 2, 2), canvas.Viewport); Dictionary map = canvas.GetMap (); Assert.Equal (2, map.Count); diff --git a/UnitTests/Drawing/StraightLineTests.cs b/UnitTests/Drawing/StraightLineTests.cs index 1745c6286f..bb68708214 100644 --- a/UnitTests/Drawing/StraightLineTests.cs +++ b/UnitTests/Drawing/StraightLineTests.cs @@ -309,7 +309,7 @@ public class StraightLineTests )] [Theory] [SetupFakeDriver] - public void Bounds ( + public void Viewport ( Orientation orientation, int x, int y, @@ -322,6 +322,6 @@ int expectedHeight { var sl = new StraightLine (new Point (x, y), length, orientation, LineStyle.Single); - Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), sl.Bounds); + Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), sl.Viewport); } } diff --git a/UnitTests/View/Adornment/ToScreenTests.cs b/UnitTests/View/Adornment/ToScreenTests.cs index ddc5aa300c..518b38f763 100644 --- a/UnitTests/View/Adornment/ToScreenTests.cs +++ b/UnitTests/View/Adornment/ToScreenTests.cs @@ -286,7 +286,7 @@ public void BoundsToScreen_NoSuperView_WithAdornments (int frameX, int boundsX, view.Margin.Thickness = new (1); view.Border.Thickness = new (1); view.Padding.Thickness = new (1); - // Total thickness is 3 (view.Bounds will be Frame.Width - 6) + // Total thickness is 3 (view.Viewport will be Frame.Width - 6) view.Frame = frame; Assert.Equal(4, view.Viewport.Width); diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index 9b616ad7be..ad8c9ac733 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -232,7 +232,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds () var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single }; view.BeginInit (); view.EndInit (); - view.SetRelativeLayout (Application.Driver.Bounds); + view.SetRelativeLayout (Application.Driver.Viewport); Assert.Equal (new (0,0,2,2), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); @@ -257,7 +257,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Bottom () view.Border.Thickness = new Thickness (1, 1, 1, 0); view.BeginInit (); view.EndInit (); - view.SetRelativeLayout (Application.Driver.Bounds); + view.SetRelativeLayout (Application.Driver.Viewport); Assert.Equal (new (0,0,2,1), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); @@ -275,7 +275,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Left () view.Border.Thickness = new Thickness (0, 1, 1, 1); view.BeginInit (); view.EndInit (); - view.SetRelativeLayout (Application.Driver.Bounds); + view.SetRelativeLayout (Application.Driver.Viewport); Assert.Equal (new (0,0,1,2), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); @@ -300,7 +300,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Right () view.Border.Thickness = new Thickness (1, 1, 0, 1); view.BeginInit (); view.EndInit (); - view.SetRelativeLayout (Application.Driver.Bounds); + view.SetRelativeLayout (Application.Driver.Viewport); Assert.Equal (new (0,0,1,2), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); @@ -326,7 +326,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Top () view.BeginInit (); view.EndInit (); - view.SetRelativeLayout (Application.Driver.Bounds); + view.SetRelativeLayout (Application.Driver.Viewport); Assert.Equal (new (0,0,2,1), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); diff --git a/UnitTests/View/Layout/AbsoluteLayoutTests.cs b/UnitTests/View/Layout/AbsoluteLayoutTests.cs index 1936704539..ef3cf21b99 100644 --- a/UnitTests/View/Layout/AbsoluteLayoutTests.cs +++ b/UnitTests/View/Layout/AbsoluteLayoutTests.cs @@ -32,7 +32,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (30), v.Width); @@ -47,7 +47,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (30), v.Width); @@ -63,7 +63,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (10), v.X); Assert.Equal (Pos.At (20), v.Y); Assert.Equal (Dim.Sized (30), v.Width); @@ -78,7 +78,7 @@ public void AbsoluteLayout_Change_Frame () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (10), v.X); Assert.Equal (Pos.At (20), v.Y); Assert.Equal (Dim.Sized (30), v.Width); @@ -102,7 +102,7 @@ public void AbsoluteLayout_Change_Height_or_Width_Absolute () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal ($"Absolute({newFrame.Height})", v.Height.ToString ()); @@ -137,7 +137,7 @@ public void AbsoluteLayout_Change_X_or_Y_Absolute () Assert.Equal ( new Rectangle (0, 0, newFrame.Width, newFrame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ()); Assert.Equal ($"Absolute({newFrame.Y})", v.Y.ToString ()); Assert.Equal (Dim.Sized (3), v.Width); @@ -251,7 +251,7 @@ public void AbsoluteLayout_Constructor () Assert.Equal ( new Rectangle (0, 0, frame.Width, frame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (0), v.X); Assert.Equal (Pos.At (0), v.Y); Assert.Equal (Dim.Sized (0), v.Width); @@ -266,7 +266,7 @@ public void AbsoluteLayout_Constructor () Assert.Equal ( new Rectangle (0, 0, frame.Width, frame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (3), v.Width); @@ -280,7 +280,7 @@ public void AbsoluteLayout_Constructor () Assert.Equal ( new Rectangle (0, 0, frame.Width, frame.Height), v.Viewport - ); // With Absolute Bounds *is* deterministic before Layout + ); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (3), v.Width); @@ -294,7 +294,7 @@ public void AbsoluteLayout_Constructor () // That is correct it should be 0,0 because AutoSize is false // and the size wasn't set on the initializer Assert.Equal (new Rectangle (frame.X, frame.Y, 0, 0), v.Frame); - Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Bounds *is* deterministic before Layout + Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (0), v.Width); @@ -304,7 +304,7 @@ public void AbsoluteLayout_Constructor () v = new View (); Assert.True (v.LayoutStyle == LayoutStyle.Absolute); Assert.Equal (new Rectangle (0, 0, 0, 0), v.Frame); - Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Bounds *is* deterministic before Layout + Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (0), v.X); Assert.Equal (Pos.At (0), v.Y); Assert.Equal (Dim.Sized (0), v.Width); @@ -314,7 +314,7 @@ public void AbsoluteLayout_Constructor () v = new View { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height }; Assert.True (v.LayoutStyle == LayoutStyle.Absolute); Assert.Equal (new Rectangle (frame.X, frame.Y, 3, 4), v.Frame); - Assert.Equal (new Rectangle (0, 0, 3, 4), v.Viewport); // With Absolute Bounds *is* deterministic before Layout + Assert.Equal (new Rectangle (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout Assert.Equal (Pos.At (1), v.X); Assert.Equal (Pos.At (2), v.Y); Assert.Equal (Dim.Sized (3), v.Width); @@ -348,7 +348,7 @@ public void AbsoluteLayout_LayoutSubviews () [Fact] public void AbsoluteLayout_Setting_Bounds_Location_NotEmpty () { - // TODO: Should we enforce Bounds.X/Y == 0? The code currently ignores value.X/Y which is + // TODO: Should we enforce Viewport.X/Y == 0? The code currently ignores value.X/Y which is // TODO: correct behavior, but is silent. Perhaps an exception? var frame = new Rectangle (1, 2, 3, 4); var newBounds = new Rectangle (10, 20, 30, 40); @@ -389,7 +389,7 @@ public void AbsoluteLayout_Setting_Bounds_Sets_Frame () v.BorderStyle = LineStyle.Single; - // Bounds should shrink + // Viewport should shrink Assert.Equal (new Rectangle (0, 0, 1, 2), v.Viewport); // Frame should not change diff --git a/UnitTests/View/Layout/BoundsTests.cs b/UnitTests/View/Layout/BoundsTests.cs index 69bb1d87b1..7af892b6cc 100644 --- a/UnitTests/View/Layout/BoundsTests.cs +++ b/UnitTests/View/Layout/BoundsTests.cs @@ -4,7 +4,7 @@ namespace Terminal.Gui.ViewTests; /// /// Test the . -/// DOES NOT TEST Adornment.Bounds methods. Those are in ./Adornment/BoundsTests.cs +/// DOES NOT TEST Adornment.Viewport methods. Those are in ./Adornment/BoundsTests.cs /// /// public class BoundsTests (ITestOutputHelper output) diff --git a/UnitTests/View/Layout/DimTests.cs b/UnitTests/View/Layout/DimTests.cs index c700c6dbec..fc6801a824 100644 --- a/UnitTests/View/Layout/DimTests.cs +++ b/UnitTests/View/Layout/DimTests.cs @@ -669,7 +669,7 @@ public void Only_DimAbsolute_And_DimFactor_As_A_Different_Procedure_For_Assignin #if DEBUG Assert.Equal ($"Combine(View(Width,Button(v1){v1.Frame})-View(Width,Button(v3){v3.Viewport}))", v5.Width.ToString ()); #else - Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Bounds}))", v5.Height.ToString ( )); + Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Viewport}))", v5.Height.ToString ( )); #endif Assert.Equal (38, v5.Frame.Width); // 47-9=38 Assert.Equal (80, v5.Frame.Height); // 89-9=80 diff --git a/UnitTests/View/Layout/PosTests.cs b/UnitTests/View/Layout/PosTests.cs index 5fb9cf7823..b48f4210e9 100644 --- a/UnitTests/View/Layout/PosTests.cs +++ b/UnitTests/View/Layout/PosTests.cs @@ -141,12 +141,12 @@ public void AnchorEnd_View_And_Button () frame.Draw (); Assert.Equal (6, btn.Viewport.Width); - Assert.Equal (10, btn.Frame.X); // frame.Bounds.Width (16) - btn.Frame.Width (6) = 10 + Assert.Equal (10, btn.Frame.X); // frame.Viewport.Width (16) - btn.Frame.Width (6) = 10 Assert.Equal (0, btn.Frame.Y); Assert.Equal (6, btn.Frame.Width); Assert.Equal (1, btn.Frame.Height); - Assert.Equal (9, view.Viewport.Width); // frame.Bounds.Width (16) - Dim.Fill (1) - Dim.Function (6) = 9 + Assert.Equal (9, view.Viewport.Width); // frame.Viewport.Width (16) - Dim.Fill (1) - Dim.Function (6) = 9 Assert.Equal (0, view.Frame.X); Assert.Equal (0, view.Frame.Y); Assert.Equal (9, view.Frame.Width); diff --git a/UnitTests/View/SubviewTests.cs b/UnitTests/View/SubviewTests.cs index 0d7bff9fa7..bde692a1fc 100644 --- a/UnitTests/View/SubviewTests.cs +++ b/UnitTests/View/SubviewTests.cs @@ -82,12 +82,12 @@ public void Initialized_Event_Comparing_With_Added_Event () { Application.Init (new FakeDriver ()); - var top = new Toplevel { Id = "0" }; // Frame: 0, 0, 80, 25; Bounds: 0, 0, 80, 25 + var top = new Toplevel { Id = "0" }; // Frame: 0, 0, 80, 25; Viewport: 0, 0, 80, 25 var winAddedToTop = new Window { Id = "t", Width = Dim.Fill (), Height = Dim.Fill () - }; // Frame: 0, 0, 80, 25; Bounds: 0, 0, 78, 23 + }; // Frame: 0, 0, 80, 25; Viewport: 0, 0, 78, 23 var v1AddedToWin = new View { @@ -159,37 +159,37 @@ public void Initialized_Event_Comparing_With_Added_Event () { v1c++; - // Top.Frame: 0, 0, 80, 25; Top.Bounds: 0, 0, 80, 25 + // Top.Frame: 0, 0, 80, 25; Top.Viewport: 0, 0, 80, 25 // BUGBUG: This is wrong, it should be 78, 23. This test has always been broken. - // in no way should the v1AddedToWin.Frame be the same as the Top.Frame/Bounds + // in no way should the v1AddedToWin.Frame be the same as the Top.Frame/Viewport // as it is a subview of winAddedToTop, which has a border! - //Assert.Equal (top.Bounds.Width, v1AddedToWin.Frame.Width); - //Assert.Equal (top.Bounds.Height, v1AddedToWin.Frame.Height); + //Assert.Equal (top.Viewport.Width, v1AddedToWin.Frame.Width); + //Assert.Equal (top.Viewport.Height, v1AddedToWin.Frame.Height); }; v2AddedToWin.Initialized += (s, e) => { v2c++; - // Top.Frame: 0, 0, 80, 25; Top.Bounds: 0, 0, 80, 25 + // Top.Frame: 0, 0, 80, 25; Top.Viewport: 0, 0, 80, 25 // BUGBUG: This is wrong, it should be 78, 23. This test has always been broken. - // in no way should the v2AddedToWin.Frame be the same as the Top.Frame/Bounds + // in no way should the v2AddedToWin.Frame be the same as the Top.Frame/Viewport // as it is a subview of winAddedToTop, which has a border! - //Assert.Equal (top.Bounds.Width, v2AddedToWin.Frame.Width); - //Assert.Equal (top.Bounds.Height, v2AddedToWin.Frame.Height); + //Assert.Equal (top.Viewport.Width, v2AddedToWin.Frame.Width); + //Assert.Equal (top.Viewport.Height, v2AddedToWin.Frame.Height); }; svAddedTov1.Initialized += (s, e) => { sv1c++; - // Top.Frame: 0, 0, 80, 25; Top.Bounds: 0, 0, 80, 25 + // Top.Frame: 0, 0, 80, 25; Top.Viewport: 0, 0, 80, 25 // BUGBUG: This is wrong, it should be 78, 23. This test has always been broken. - // in no way should the svAddedTov1.Frame be the same as the Top.Frame/Bounds + // in no way should the svAddedTov1.Frame be the same as the Top.Frame/Viewport // because sv1AddedTov1 is a subview of v1AddedToWin, which is a subview of // winAddedToTop, which has a border! - //Assert.Equal (top.Bounds.Width, svAddedTov1.Frame.Width); - //Assert.Equal (top.Bounds.Height, svAddedTov1.Frame.Height); + //Assert.Equal (top.Viewport.Width, svAddedTov1.Frame.Width); + //Assert.Equal (top.Viewport.Height, svAddedTov1.Frame.Height); Assert.False (svAddedTov1.CanFocus); Assert.Throws (() => svAddedTov1.CanFocus = true); Assert.False (svAddedTov1.CanFocus); @@ -266,16 +266,16 @@ public void Initialized_Event_Will_Be_Invoked_When_Added_Dynamically () { v1c++; - //Assert.Equal (t.Bounds.Width, v1.Frame.Width); - //Assert.Equal (t.Bounds.Height, v1.Frame.Height); + //Assert.Equal (t.Viewport.Width, v1.Frame.Width); + //Assert.Equal (t.Viewport.Height, v1.Frame.Height); }; v2.Initialized += (s, e) => { v2c++; - //Assert.Equal (t.Bounds.Width, v2.Frame.Width); - //Assert.Equal (t.Bounds.Height, v2.Frame.Height); + //Assert.Equal (t.Viewport.Width, v2.Frame.Width); + //Assert.Equal (t.Viewport.Height, v2.Frame.Height); }; w.Add (v1, v2); t.Add (w); diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index c133622619..dbd813478f 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -1123,7 +1123,7 @@ public override void OnDrawContent (Rectangle contentArea) { var idx = 0; - // BUGBUG: v2 - this should use Bounds, not Frame + // BUGBUG: v2 - this should use Viewport, not Frame for (var r = 0; r < Frame.Height; r++) { for (var c = 0; c < Frame.Width; c++) diff --git a/UnitTests/Views/ScrollBarViewTests.cs b/UnitTests/Views/ScrollBarViewTests.cs index 4422a133bd..4b1e30ef3b 100644 --- a/UnitTests/Views/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -421,7 +421,7 @@ public void { newScrollBarView.Position = 100; - //Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.LeftItem + (listView.LeftItem - listView.Bounds.Width)); + //Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.LeftItem + (listView.LeftItem - listView.Viewport.Width)); Assert.Equal (newScrollBarView.Position, listView.LeftItem); //Assert.Equal (92, newScrollBarView.Position); diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index f71cb99783..d597495b2c 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -7657,7 +7657,7 @@ This is the second line. ); ((FakeDriver)Application.Driver).SetBufferSize (6, 25); - tv.SetRelativeLayout (Application.Driver.Bounds); + tv.SetRelativeLayout (Application.Driver.Viewport); tv.Draw (); Assert.Equal (new Point (4, 2), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); From 0900333e1268dfcf6184577f72c233ef9f1675b9 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 08:12:50 -0800 Subject: [PATCH 3/8] 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 e84ae835c0..1b016166f9 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -1422,7 +1422,7 @@ internal static void OnMouseEvent (MouseEventEventArgs a) 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 @@ internal static void OnMouseEvent (MouseEventEventArgs a) 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 fb9167ec51..108559b71b 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 Rectangle Viewport { 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 Rectangle Viewport }; } - _cachedBounds = bounds; + _cachedViewport = bounds; } - return _cachedBounds; + return _cachedViewport; } } @@ -134,7 +134,7 @@ public void AddLine ( Attribute? attribute = default ) { - _cachedBounds = Rectangle.Empty; + _cachedViewport = Rectangle.Empty; _lines.Add (new StraightLine (start, length, orientation, style, attribute)); } @@ -142,14 +142,14 @@ public void AddLine ( /// 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 void Clear () /// 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 86fc2ca85c..cde82ce67e 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -73,8 +73,8 @@ public TextDirection Direction } /// - /// 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 bool WordWrap /// 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 void Draw ( } 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 void Draw ( 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 void Draw ( 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 void Draw ( 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 void Draw ( 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 void Draw ( { 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 void Draw ( 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 void Draw ( 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 785f727821..56900f3ec7 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -146,7 +146,7 @@ public override void OnDrawContent (Rectangle contentArea) return; } - Rectangle screenBounds = BoundsToScreen (contentArea); + Rectangle screenBounds = ViewportToScreen (contentArea); Attribute normalAttr = GetNormalColor (); Driver.SetAttribute (normalAttr); @@ -297,7 +297,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) _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 23174acb3f..54692d594f 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -194,7 +194,7 @@ public override void OnDrawContent (Rectangle contentArea) } //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 057dcf56ca..838127c452 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -101,10 +101,10 @@ public virtual Rectangle FrameToScreen () 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 virtual Rectangle FrameToScreen () /// 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 Dim Width #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 Dim Width /// 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 virtual Rectangle Viewport } /// 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 Point ScreenToBounds (int x, int y) /// 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 virtual bool Contains (int x, int y) 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 virtual void LayoutSubviews () 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 284db73c65..911a745db3 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -98,7 +98,7 @@ public void Clear (Rectangle contentArea) // 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 void Clear (Rectangle contentArea) /// . /// /// - public Rectangle ClipToBounds () + public Rectangle ClipToViewport () { if (Driver is null) { @@ -121,7 +121,7 @@ public Rectangle ClipToBounds () } 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 void Draw () OnDrawAdornments (); - Rectangle prevClip = ClipToBounds (); + Rectangle prevClip = ClipToViewport (); if (ColorScheme is { }) { @@ -326,7 +326,7 @@ public void Move (int col, int row) 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 virtual bool OnDrawAdornments () } /// 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 virtual void OnDrawContent (Rectangle contentArea) // This should NOT clear TextFormatter?.Draw ( - BoundsToScreen (contentArea), + ViewportToScreen (viewport), HasFocus ? GetFocusColor () : GetNormalColor (), HasFocus ? ColorScheme.HotFocus : GetHotNormalColor (), Rectangle.Empty @@ -418,7 +418,7 @@ public virtual void OnDrawContent (Rectangle contentArea) /// 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 virtual void OnDrawContent (Rectangle contentArea) /// 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 @@ protected virtual void ClearNeedsDisplay () _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 a08e1a361a..188c8dab13 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -494,7 +494,7 @@ private void HideList () _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 9fe92ae7a7..ffc6224d43 100644 --- a/Terminal.Gui/Views/Line.cs +++ b/Terminal.Gui/Views/Line.cs @@ -26,7 +26,7 @@ public override void OnDrawContent (Rectangle contentArea) 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 4fa1331646..6ee004f1b5 100644 --- a/Terminal.Gui/Views/Menu/ContextMenu.cs +++ b/Terminal.Gui/Views/Menu/ContextMenu.cs @@ -147,7 +147,7 @@ public void Show () 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 void Show () } 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 65a3081d58..9eb7434091 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -724,7 +724,7 @@ private void Application_RootMouseEvent (object sender, MouseEventEventArgs a) 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 @@ public override void OnDrawContent (Rectangle contentArea) continue; } - if (BoundsToScreen (Viewport).Y + i >= Driver.Rows) + if (ViewportToScreen (Viewport).Y + i >= Driver.Rows) { break; } @@ -808,7 +808,7 @@ public override void OnDrawContent (Rectangle contentArea) continue; } - if (BoundsToScreen (Viewport).X + p >= Driver.Cols) + if (ViewportToScreen (Viewport).X + p >= Driver.Cols) { break; } @@ -873,7 +873,7 @@ public override void OnDrawContent (Rectangle contentArea) 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 @@ public override void OnDrawContent (Rectangle contentArea) // 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 @@ public override void OnDrawContent (Rectangle contentArea) ? 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 1abe33e82a..6266ec41f8 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -827,11 +827,11 @@ internal Point GetScreenOffset () 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 @@ internal Point GetScreenOffsetFromCurrent () { 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 @@ private void ProcessMenu (int i, MenuBarItem mi) 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 @@ protected internal override bool OnMouseEvent (MouseEvent me) { 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 65bbb616ae..4d25b9f8a6 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -190,10 +190,10 @@ public override void OnDrawContent (Rectangle contentArea) } 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 ddeede202a..89bb19a79b 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -339,7 +339,7 @@ public override void OnDrawContent (Rectangle contentArea) { 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 7ff5eca7d6..8e811fa759 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -317,7 +317,7 @@ public override void OnDrawContent (Rectangle contentArea) if (Tabs.Any ()) { - Rectangle savedClip = ClipToBounds (); + Rectangle savedClip = ClipToViewport (); _tabsBar.OnDrawContent (contentArea); _contentView.SetNeedsDisplay (); _contentView.Draw (); @@ -683,7 +683,7 @@ public override void OnDrawContentComplete (Rectangle contentArea) 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 override void OnDrawContentComplete (Rectangle contentArea) 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 @@ private void RenderTabLine () } 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 e3e0f56f1c..5697da185b 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -1196,8 +1196,8 @@ public override void PositionCursor () 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 5938820520..1344b2d4b1 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -217,7 +217,7 @@ public override void OnDrawContent (Rectangle contentArea) { 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 TileTitleToRender (TileView parent, Tile tile, int depth) /// 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 424de7882a..2d6d814fc3 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -564,7 +564,7 @@ public override void OnDrawContentComplete (Rectangle contentArea) ) ); - Rectangle oldClip = ClipToBounds (); + Rectangle oldClip = ClipToViewport (); if (ShowHorizontalScrollIndicator) { diff --git a/UICatalog/Scenarios/Notepad.cs b/UICatalog/Scenarios/Notepad.cs index 85aa23f304..d1928b0b47 100644 --- a/UICatalog/Scenarios/Notepad.cs +++ b/UICatalog/Scenarios/Notepad.cs @@ -350,7 +350,7 @@ private void TabView_TabClicked (object sender, TabMouseEventArgs e) ); } - 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 8fe1a55039..4fb5934719 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -223,8 +223,8 @@ public override void Setup () 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 8d8752742d..199636d712 100644 --- a/UnitTests/View/Adornment/AdornmentTests.cs +++ b/UnitTests/View/Adornment/AdornmentTests.cs @@ -105,7 +105,7 @@ public void BoundsToScreen_Uses_Parent_Not_SuperView () 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 518b38f763..4a550f7c71 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 void BoundsToScreen_NoSuperView_WithoutAdornments (int frameX, int bounds 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 void BoundsToScreen_NoSuperView_WithAdornments (int frameX, int boundsX, 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 void BoundsToScreen_SuperView_WithoutAdornments (int frameX, int boundsX, 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 void BoundsToScreen_SuperView_WithAdornments (int frameX, int boundsX, in 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 void BoundsToScreen_NestedSuperView_WithoutAdornments (int frameX, int bo 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 void BoundsToScreen_NestedSuperView_WithAdornments (int frameX, int bound 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 6295417a47..b7a54aa330 100644 --- a/UnitTests/View/Layout/ScreenToTests.cs +++ b/UnitTests/View/Layout/ScreenToTests.cs @@ -32,7 +32,7 @@ public void ScreenToBounds_NoSuper_HasAdornments (int viewX, int viewY, int x, i 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 void ScreenToBounds_NoSuper_NoAdornments (int viewX, int viewY, int x, in { 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 void ScreenToBounds_SuperHasNoAdornments (int viewX, int viewY, int x, in 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 a317157763..057dcf585d 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 void BoundsToScreen_NoSuperView_WithoutAdornments (int frameX, int bounds 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 void BoundsToScreen_NoSuperView_WithAdornments (int frameX, int boundsX, 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 void BoundsToScreen_SuperView_WithoutAdornments (int frameX, int boundsX, 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 void BoundsToScreen_SuperView_WithAdornments (int frameX, int boundsX, in 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 void BoundsToScreen_NestedSuperView_WithoutAdornments (int frameX, int bo 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 void BoundsToScreen_NestedSuperView_WithAdornments (int frameX, int bound 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 7df35b0e3f..efbc41a49a 100644 --- a/UnitTests/View/NavigationTests.cs +++ b/UnitTests/View/NavigationTests.cs @@ -841,19 +841,19 @@ public void ScreenToView_ViewToScreen_FindDeepestView_Full_Top () // 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 void ScreenToView_ViewToScreen_FindDeepestView_Full_Top () 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 void ScreenToView_ViewToScreen_FindDeepestView_Full_Top () //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 void ScreenToView_ViewToScreen_FindDeepestView_Full_Top () //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 void ScreenToView_ViewToScreen_FindDeepestView_Full_Top () // 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 void ScreenToView_ViewToScreen_FindDeepestView_Smaller_Top () // 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 e13d2dcc71..f4e4cb9ee8 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1805,7 +1805,7 @@ public void Draw_A_Top_Subview_On_A_Window () btnPopup.Accept += (s, e) => { - Rectangle viewToScreen = btnPopup.BoundsToScreen (top.Frame); + Rectangle viewToScreen = btnPopup.ViewportToScreen (top.Frame); var viewAddedToTop = new View { From b187a8e70f543f31b593ea19e81c55a6b4a77d6b Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 09:55:27 -0800 Subject: [PATCH 4/8] Reamed Bounds -> Viewport - MOAR rename --- Terminal.Gui/Application.cs | 2 +- Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs | 4 +- Terminal.Gui/Drawing/LineCanvas.cs | 14 +++---- .../Autocomplete/PopupAutocomplete.PopUp.cs | 2 +- Terminal.Gui/Text/TextFormatter.cs | 14 +++---- Terminal.Gui/View/Adornment/Adornment.cs | 10 ++--- Terminal.Gui/View/Adornment/Border.cs | 20 ++++----- Terminal.Gui/View/Layout/ViewLayout.cs | 4 +- Terminal.Gui/View/ViewDrawing.cs | 6 +-- Terminal.Gui/Views/ColorPicker.cs | 4 +- Terminal.Gui/Views/ComboBox.cs | 6 +-- Terminal.Gui/Views/FileDialog.cs | 4 +- Terminal.Gui/Views/GraphView/GraphView.cs | 2 +- Terminal.Gui/Views/HexView.cs | 2 +- Terminal.Gui/Views/Line.cs | 4 +- Terminal.Gui/Views/LineView.cs | 4 +- Terminal.Gui/Views/ListView.cs | 4 +- Terminal.Gui/Views/Menu/Menu.cs | 2 +- Terminal.Gui/Views/Menu/MenuBar.cs | 2 +- Terminal.Gui/Views/ProgressBar.cs | 2 +- Terminal.Gui/Views/RadioGroup.cs | 4 +- Terminal.Gui/Views/ScrollBarView.cs | 2 +- Terminal.Gui/Views/ScrollView.cs | 4 +- Terminal.Gui/Views/Slider.cs | 6 +-- Terminal.Gui/Views/StatusBar.cs | 2 +- Terminal.Gui/Views/TabView.cs | 12 +++--- Terminal.Gui/Views/TableView/TableView.cs | 4 +- Terminal.Gui/Views/TextField.cs | 2 +- Terminal.Gui/Views/TextValidateField.cs | 2 +- Terminal.Gui/Views/TextView.cs | 6 +-- Terminal.Gui/Views/TileView.cs | 42 +++++++++---------- Terminal.Gui/Views/Toplevel.cs | 4 +- Terminal.Gui/Views/TreeView/TreeView.cs | 2 +- UICatalog/Scenarios/Animation.cs | 4 +- UICatalog/Scenarios/CharacterMap.cs | 12 +++--- UICatalog/Scenarios/LineDrawing.cs | 4 +- UICatalog/Scenarios/Snake.cs | 6 +-- UnitTests/View/ViewTests.cs | 2 +- 38 files changed, 116 insertions(+), 116 deletions(-) diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index 1b016166f9..e15055d1c2 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -1365,7 +1365,7 @@ private static void OnUnGrabbedMouse (View view) /// /// /// Use this event to receive mouse events in screen coordinates. Use to - /// receive mouse events relative to a 's bounds. + /// receive mouse events relative to a . /// /// The will contain the that contains the mouse coordinates. /// diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs index 42db871876..80b6288f4d 100644 --- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs @@ -25,7 +25,7 @@ public abstract class ConsoleDriver /// Gets or sets the clip rectangle that and are subject /// to. /// - /// The rectangle describing the bounds of . + /// The rectangle describing the of region. public Rectangle Clip { get; set; } /// Get the operating system clipboard. @@ -372,7 +372,7 @@ public void FillRect (Rectangle rect, Rune rune = default) /// The column. /// The row. /// - /// if the coordinate is outside of the screen bounds or outside of . + /// if the coordinate is outside the screen bounds or outside of . /// otherwise. /// public bool IsValidLocation (int col, int row) { return col >= 0 && row >= 0 && col < Cols && row < Rows && Clip.Contains (col, row); } diff --git a/Terminal.Gui/Drawing/LineCanvas.cs b/Terminal.Gui/Drawing/LineCanvas.cs index 108559b71b..0e9fac7613 100644 --- a/Terminal.Gui/Drawing/LineCanvas.cs +++ b/Terminal.Gui/Drawing/LineCanvas.cs @@ -78,23 +78,23 @@ public Rectangle Viewport return _cachedViewport; } - Rectangle bounds = _lines [0].Viewport; + Rectangle viewport = _lines [0].Viewport; for (var i = 1; i < _lines.Count; i++) { - bounds = Rectangle.Union (bounds, _lines [i].Viewport); + viewport = Rectangle.Union (viewport, _lines [i].Viewport); } - if (bounds is {Width: 0} or {Height: 0}) + if (viewport is {Width: 0} or {Height: 0}) { - bounds = bounds with + viewport = viewport with { - Width = Math.Clamp (bounds.Width, 1, short.MaxValue), - Height = Math.Clamp (bounds.Height, 1, short.MaxValue) + Width = Math.Clamp (viewport.Width, 1, short.MaxValue), + Height = Math.Clamp (viewport.Height, 1, short.MaxValue) }; } - _cachedViewport = bounds; + _cachedViewport = viewport; } return _cachedViewport; diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs index 55a6140759..86fc949ecf 100644 --- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs +++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs @@ -16,7 +16,7 @@ public Popup (PopupAutocomplete autoComplete) protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { return _autoComplete.OnMouseEvent (mouseEvent); } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (!_autoComplete.LastPopupPos.HasValue) { diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs index cde82ce67e..5e970d86f0 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -240,12 +240,12 @@ public void Draw ( } bool isVertical = IsVerticalDirection (Direction); - Rectangle maxBounds = viewport; + Rectangle maxViewport = viewport; if (driver is { }) { // INTENT: What, exactly, is the intent of this? - maxBounds = maximum == default (Rectangle) + maxViewport = maximum == default (Rectangle) ? viewport : new ( Math.Max (maximum.X, viewport.X), @@ -264,7 +264,7 @@ public void Draw ( ); } - if (maxBounds.Width == 0 || maxBounds.Height == 0) + if (maxViewport.Width == 0 || maxViewport.Height == 0) { return; } @@ -278,8 +278,8 @@ public void Draw ( continue; } - if ((isVertical && line >= maxBounds.Left + maxBounds.Width) - || (!isVertical && line >= maxBounds.Top + maxBounds.Height + lineOffset)) + if ((isVertical && line >= maxViewport.Left + maxViewport.Width) + || (!isVertical && line >= maxViewport.Top + maxViewport.Height + lineOffset)) { break; } @@ -422,8 +422,8 @@ public void Draw ( break; } - if ((!isVertical && current - start > maxBounds.Left + maxBounds.Width - viewport.X + colOffset) - || (isVertical && idx > maxBounds.Top + maxBounds.Height - viewport.Y)) + if ((!isVertical && current - start > maxViewport.Left + maxViewport.Width - viewport.X + colOffset) + || (isVertical && idx > maxViewport.Top + maxViewport.Height - viewport.Y)) { break; } diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index 56900f3ec7..210f625a95 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -139,19 +139,19 @@ public override Rectangle FrameToScreen () public override bool OnDrawAdornments () { return false; } /// Redraws the Adornments that comprise the . - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (Thickness == Thickness.Empty) { return; } - Rectangle screenBounds = ViewportToScreen (contentArea); + Rectangle screen = ViewportToScreen (viewport); Attribute normalAttr = GetNormalColor (); Driver.SetAttribute (normalAttr); // This just draws/clears the thickness, not the insides. - Thickness.Draw (screenBounds, ToString ()); + Thickness.Draw (screen, ToString ()); if (!string.IsNullOrEmpty (TextFormatter.Text)) { @@ -162,11 +162,11 @@ public override void OnDrawContent (Rectangle contentArea) } } - TextFormatter?.Draw (screenBounds, normalAttr, normalAttr, Rectangle.Empty); + TextFormatter?.Draw (screen, normalAttr, normalAttr, Rectangle.Empty); if (Subviews.Count > 0) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); } ClearLayoutNeeded (); diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index 54692d594f..fc63e9031b 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -136,14 +136,14 @@ public override ColorScheme ColorScheme } } - Rectangle GetBorderBounds (Rectangle screenBounds) + Rectangle GetBorderRectangle (Rectangle screenRect) { return new ( - screenBounds.X + Math.Max (0, Thickness.Left - 1), - screenBounds.Y + Math.Max (0, Thickness.Top - 1), + screenRect.X + Math.Max (0, Thickness.Left - 1), + screenRect.Y + Math.Max (0, Thickness.Top - 1), Math.Max ( 0, - screenBounds.Width + screenRect.Width - Math.Max ( 0, Math.Max (0, Thickness.Left - 1) @@ -152,7 +152,7 @@ Rectangle GetBorderBounds (Rectangle screenBounds) ), Math.Max ( 0, - screenBounds.Height + screenRect.Height - Math.Max ( 0, Math.Max (0, Thickness.Top - 1) @@ -184,9 +184,9 @@ public LineStyle LineStyle } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); if (Thickness == Thickness.Empty) { @@ -194,7 +194,7 @@ public override void OnDrawContent (Rectangle contentArea) } //Driver.SetAttribute (Colors.ColorSchemes ["Error"].Normal); - Rectangle screenBounds = ViewportToScreen (contentArea); + Rectangle screenBounds = ViewportToScreen (viewport); //OnDrawSubviews (bounds); @@ -205,7 +205,7 @@ public override void OnDrawContent (Rectangle contentArea) // ...thickness extends outward (border/title is always as far in as possible) // PERF: How about a call to Rectangle.Offset? - var borderBounds = GetBorderBounds (screenBounds); + var borderBounds = GetBorderRectangle (screenBounds); int topTitleLineY = borderBounds.Y; int titleY = borderBounds.Y; var titleBarsLength = 0; // the little vertical thingies @@ -466,6 +466,6 @@ public override void OnDrawContent (Rectangle contentArea) } } - //base.OnDrawContent (contentArea); + //base.OnDrawContent (viewport); } } diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 838127c452..b48c4a5aec 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -1410,10 +1410,10 @@ internal static List TopologicalSort ( return result; } // TopologicalSort - private void LayoutSubview (View v, Rectangle contentArea) + private void LayoutSubview (View v, Rectangle viewport) { //if (v.LayoutStyle == LayoutStyle.Computed) { - v.SetRelativeLayout (contentArea); + v.SetRelativeLayout (viewport); //} diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 911a745db3..3709750791 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -87,7 +87,7 @@ public void AddRune (int col, int row, Rune ch) /// Clears the specified -relative rectangle with the normal background. /// /// The Viewport-relative rectangle to clear. - public void Clear (Rectangle contentArea) + public void Clear (Rectangle viewport) { if (Driver is null) { @@ -97,8 +97,8 @@ public void Clear (Rectangle contentArea) Attribute prev = Driver.SetAttribute (GetNormalColor ()); // Clamp the region to the bounds of the view - contentArea = Rectangle.Intersect (contentArea, Viewport); - Driver.FillRect (ViewportToScreen (contentArea)); + viewport = Rectangle.Intersect (viewport, Viewport); + Driver.FillRect (ViewportToScreen (viewport)); Driver.SetAttribute (prev); } diff --git a/Terminal.Gui/Views/ColorPicker.cs b/Terminal.Gui/Views/ColorPicker.cs index 249c44cff6..09ffcc3d3c 100644 --- a/Terminal.Gui/Views/ColorPicker.cs +++ b/Terminal.Gui/Views/ColorPicker.cs @@ -157,9 +157,9 @@ public virtual bool MoveUp () } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); Driver.SetAttribute (HasFocus ? ColorScheme.Focus : GetNormalColor ()); var colorIndex = 0; diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index 188c8dab13..8f3c954a87 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -284,9 +284,9 @@ protected internal override bool OnMouseEvent (MouseEvent me) public virtual void OnCollapsed () { Collapsed?.Invoke (this, EventArgs.Empty); } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); if (!_autoHide) { @@ -839,7 +839,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) return res; } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Attribute current = ColorScheme.Focus; Driver.SetAttribute (current); diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index 88686ca270..f14ef2ada3 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -407,9 +407,9 @@ public bool IsCompatibleWithAllowedExtensions (IFileInfo file) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); if (!string.IsNullOrWhiteSpace (_feedback)) { diff --git a/Terminal.Gui/Views/GraphView/GraphView.cs b/Terminal.Gui/Views/GraphView/GraphView.cs index 2c9cbc7691..6f4f05bf16 100644 --- a/Terminal.Gui/Views/GraphView/GraphView.cs +++ b/Terminal.Gui/Views/GraphView/GraphView.cs @@ -197,7 +197,7 @@ public Point GraphSpaceToScreen (PointF location) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (CellSize.X == 0 || CellSize.Y == 0) { diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs index c66a040ca2..2d166db3c2 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -351,7 +351,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Attribute currentAttribute; Attribute current = ColorScheme.Focus; diff --git a/Terminal.Gui/Views/Line.cs b/Terminal.Gui/Views/Line.cs index ffc6224d43..8ef2940615 100644 --- a/Terminal.Gui/Views/Line.cs +++ b/Terminal.Gui/Views/Line.cs @@ -17,7 +17,7 @@ public Line () public Orientation Orientation { get; set; } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { LineCanvas lc = LineCanvas; @@ -26,7 +26,7 @@ public override void OnDrawContent (Rectangle contentArea) lc = adornment.Parent.LineCanvas; } lc.AddLine ( - ViewportToScreen (contentArea).Location, + ViewportToScreen (viewport).Location, Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height, Orientation, BorderStyle diff --git a/Terminal.Gui/Views/LineView.cs b/Terminal.Gui/Views/LineView.cs index 23df0387d8..a362cca10d 100644 --- a/Terminal.Gui/Views/LineView.cs +++ b/Terminal.Gui/Views/LineView.cs @@ -54,9 +54,9 @@ public LineView (Orientation orientation) public Rune? StartingAnchor { get; set; } /// Draws the line including any starting/ending anchors - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); Move (0, 0); Driver.SetAttribute (GetNormalColor ()); diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 321e97fc5d..797aa71678 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -616,9 +616,9 @@ public virtual bool MoveUp () } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); Attribute current = ColorScheme.Focus; Driver.SetAttribute (current); diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 9eb7434091..a7d9f91df7 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -755,7 +755,7 @@ internal Attribute DetermineColorSchemeFor (MenuItem item, int index) return !item.IsEnabled () ? ColorScheme.Disabled : GetNormalColor (); } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (_barItems.Children is null) { diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index 6266ec41f8..46573a457e 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -469,7 +469,7 @@ internal Menu openCurrentMenu public event EventHandler MenuOpening; /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Move (0, 0); Driver.SetAttribute (GetNormalColor ()); diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 4d25b9f8a6..cfddca1e00 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -143,7 +143,7 @@ public override string Text } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Driver.SetAttribute (GetHotNormalColor ()); diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs index 82de31e386..b8fe9b8cd1 100644 --- a/Terminal.Gui/Views/RadioGroup.cs +++ b/Terminal.Gui/Views/RadioGroup.cs @@ -201,9 +201,9 @@ protected internal override bool OnMouseEvent (MouseEvent me) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); Driver.SetAttribute (GetNormalColor ()); diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs index e42524fd14..cdea47b1f0 100644 --- a/Terminal.Gui/Views/ScrollBarView.cs +++ b/Terminal.Gui/Views/ScrollBarView.cs @@ -449,7 +449,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) public virtual void OnChangedPosition () { ChangedPosition?.Invoke (this, EventArgs.Empty); } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (ColorScheme is null || ((!_showScrollIndicator || Size == 0) && AutoHideScrollBars && Visible)) { diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs index 89bb19a79b..b13bc1a05c 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -335,14 +335,14 @@ public override void Add (View view) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { SetViewsNeedsDisplay (); Rectangle savedClip = ClipToViewport (); // TODO: It's bad practice for views to always clear a view. It negates clipping. - Clear (contentArea); + Clear (viewport); if (!string.IsNullOrEmpty (_contentView.Text) || _contentView.Subviews.Count > 0) { diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index b0ebaa30e1..e869578b87 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -996,7 +996,7 @@ public override void PositionCursor () } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { // TODO: make this more surgical to reduce repaint @@ -1009,9 +1009,9 @@ public override void OnDrawContent (Rectangle contentArea) #if (DEBUG) Driver?.SetAttribute (new Attribute (Color.White, Color.Red)); - for (var y = 0; y < contentArea.Height; y++) + for (var y = 0; y < viewport.Height; y++) { - for (var x = 0; x < contentArea.Width; x++) + for (var x = 0; x < viewport.Width; x++) { // MoveAndAdd (x, y, '·'); } diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index 0dfe31cf11..6dc96f663d 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -172,7 +172,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Move (0, 0); Driver.SetAttribute (GetNormalColor ()); diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 8e811fa759..92a21b133f 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -311,14 +311,14 @@ public void EnsureSelectedTabIsVisible () public int EnsureValidScrollOffsets (int value) { return Math.Max (Math.Min (value, Tabs.Count - 1), 0); } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Driver.SetAttribute (GetNormalColor ()); if (Tabs.Any ()) { Rectangle savedClip = ClipToViewport (); - _tabsBar.OnDrawContent (contentArea); + _tabsBar.OnDrawContent (viewport); _contentView.SetNeedsDisplay (); _contentView.Draw (); Driver.Clip = savedClip; @@ -326,7 +326,7 @@ public override void OnDrawContent (Rectangle contentArea) } /// - public override void OnDrawContentComplete (Rectangle contentArea) { _tabsBar.OnDrawContentComplete (contentArea); } + public override void OnDrawContentComplete (Rectangle viewport) { _tabsBar.OnDrawContentComplete (viewport); } /// /// Removes the given from . Caller is responsible for disposing the @@ -657,12 +657,12 @@ protected internal override bool OnMouseEvent (MouseEvent me) return false; } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { _host._tabLocations = _host.CalculateViewport (Viewport).ToArray (); // clear any old text - Clear (contentArea); + Clear (viewport); RenderTabLine (); @@ -670,7 +670,7 @@ public override void OnDrawContent (Rectangle contentArea) Driver.SetAttribute (GetNormalColor ()); } - public override void OnDrawContentComplete (Rectangle contentArea) + public override void OnDrawContentComplete (Rectangle viewport) { if (_host._tabLocations is null) { diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index d444af67ae..8084abfc88 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -896,9 +896,9 @@ protected internal override bool OnMouseEvent (MouseEvent me) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); Move (0, 0); diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index 5697da185b..5ee281596e 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -973,7 +973,7 @@ public void MoveEnd () } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { _isDrawing = true; diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index ad12ea2581..a62fa4a549 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -555,7 +555,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (_provider is null) { diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 038e1ced38..a20b4cbbc4 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -3586,7 +3586,7 @@ public virtual void OnContentsChanged () } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { _isDrawing = true; @@ -3649,7 +3649,7 @@ public override void OnDrawContent (Rectangle contentArea) AddRune (col, row, rune); } - if (!TextModel.SetCol (ref col, contentArea.Right, cols)) + if (!TextModel.SetCol (ref col, viewport.Right, cols)) { break; } @@ -3672,7 +3672,7 @@ public override void OnDrawContent (Rectangle contentArea) if (row < bottom) { SetNormalColor (); - ClearRegion (contentArea.Left, row, right, bottom); + ClearRegion (viewport.Left, row, right, bottom); } PositionCursor (); diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 1344b2d4b1..330f22e556 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -156,19 +156,19 @@ public override void LayoutSubviews () return; } - Rectangle contentArea = Viewport; + Rectangle viewport = Viewport; if (HasBorder ()) { - contentArea = new ( - contentArea.X + 1, - contentArea.Y + 1, - Math.Max (0, contentArea.Width - 2), - Math.Max (0, contentArea.Height - 2) - ); + viewport = new ( + viewport.X + 1, + viewport.Y + 1, + Math.Max (0, viewport.Width - 2), + Math.Max (0, viewport.Height - 2) + ); } - Setup (contentArea); + Setup (viewport); base.LayoutSubviews (); } @@ -179,12 +179,12 @@ public override void LayoutSubviews () public override bool OnDrawAdornments () { return false; } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { Driver.SetAttribute (ColorScheme.Normal); - Clear (contentArea); + Clear (viewport); - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); var lc = new LineCanvas (); @@ -758,9 +758,9 @@ private bool RecursiveContains (IEnumerable haystack, View needle) return false; } - private void Setup (Rectangle contentArea) + private void Setup (Rectangle viewport) { - if (contentArea.IsEmpty || contentArea.Height <= 0 || contentArea.Width <= 0) + if (viewport.IsEmpty || viewport.Height <= 0 || viewport.Width <= 0) { return; } @@ -803,16 +803,16 @@ private void Setup (Rectangle contentArea) if (Orientation == Orientation.Vertical) { - tile.ContentView.X = i == 0 ? contentArea.X : Pos.Right (visibleSplitterLines [i - 1]); - tile.ContentView.Y = contentArea.Y; - tile.ContentView.Height = contentArea.Height; + tile.ContentView.X = i == 0 ? viewport.X : Pos.Right (visibleSplitterLines [i - 1]); + tile.ContentView.Y = viewport.Y; + tile.ContentView.Height = viewport.Height; tile.ContentView.Width = GetTileWidthOrHeight (i, Viewport.Width, visibleTiles, visibleSplitterLines); } else { - tile.ContentView.X = contentArea.X; - tile.ContentView.Y = i == 0 ? contentArea.Y : Pos.Bottom (visibleSplitterLines [i - 1]); - tile.ContentView.Width = contentArea.Width; + tile.ContentView.X = viewport.X; + tile.ContentView.Y = i == 0 ? viewport.Y : Pos.Bottom (visibleSplitterLines [i - 1]); + tile.ContentView.Width = viewport.Width; tile.ContentView.Height = GetTileWidthOrHeight (i, Viewport.Height, visibleTiles, visibleSplitterLines); } } @@ -969,9 +969,9 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) return false; } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); DrawSplitterSymbol (); } diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index 2201e43c51..b6218ec658 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -249,7 +249,7 @@ public virtual void OnAlternateForwardKeyChanged (KeyChangedEventArgs e) } /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (!Visible) { @@ -292,7 +292,7 @@ public override void OnDrawContent (Rectangle contentArea) } } - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); // This is causing the menus drawn incorrectly if UseSubMenusSingleFrame is true //if (this.MenuBar is { } && this.MenuBar.IsMenuOpen && this.MenuBar.openMenu is { }) { diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs index ef15270021..2eb67267c1 100644 --- a/Terminal.Gui/Views/TreeView/TreeView.cs +++ b/Terminal.Gui/Views/TreeView/TreeView.cs @@ -1143,7 +1143,7 @@ protected internal override bool OnMouseEvent (MouseEvent me) public event EventHandler> ObjectActivated; /// - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { if (roots is null) { diff --git a/UICatalog/Scenarios/Animation.cs b/UICatalog/Scenarios/Animation.cs index db91439d77..85562c64ff 100644 --- a/UICatalog/Scenarios/Animation.cs +++ b/UICatalog/Scenarios/Animation.cs @@ -163,9 +163,9 @@ private class ImageView : View private Rectangle oldSize = Rectangle.Empty; public void NextFrame () { currentFrame = (currentFrame + 1) % frameCount; } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); if (oldSize != Viewport) { diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 2d6d814fc3..797e713ba2 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -524,7 +524,7 @@ public int StartCodePoint private static int RowWidth => RowLabelWidth + COLUMN_WIDTH * 16; public event EventHandler Hover; - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { //if (ShowHorizontalScrollIndicator && ContentSize.Height < (int)(MaxCodePoint / 16 + 2)) { // //ContentSize = new (CharMap.RowWidth, (int)(MaxCodePoint / 16 + 2)); @@ -545,18 +545,18 @@ public override void OnDrawContent (Rectangle contentArea) // // Snap 1st column into view if it's been scrolled horizontally // ContentOffset = new (0, ContentOffset.Y < -ContentSize.Height + Viewport.Height ? ContentOffset.Y - 1 : ContentOffset.Y); //} - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); } //public void CharMap_DrawContent (object s, DrawEventArgs a) - public override void OnDrawContentComplete (Rectangle contentArea) + public override void OnDrawContentComplete (Rectangle viewport) { - if (contentArea.Height == 0 || contentArea.Width == 0) + if (viewport.Height == 0 || viewport.Width == 0) { return; } - Rectangle viewport = new ( + Rectangle viewportOffset = new ( ContentOffset, new ( Math.Max (Viewport.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0), @@ -606,7 +606,7 @@ public override void OnDrawContentComplete (Rectangle contentArea) } } - int firstColumnX = viewport.X + RowLabelWidth; + int firstColumnX = viewportOffset.X + RowLabelWidth; for (var y = 1; y < Viewport.Height; y++) { diff --git a/UICatalog/Scenarios/LineDrawing.cs b/UICatalog/Scenarios/LineDrawing.cs index d67e81384d..5317a90f74 100644 --- a/UICatalog/Scenarios/LineDrawing.cs +++ b/UICatalog/Scenarios/LineDrawing.cs @@ -36,9 +36,9 @@ private class DrawingArea : View public DrawingArea () { AddLayer (); } public LineStyle LineStyle { get; set; } - public override void OnDrawContentComplete (Rectangle contentArea) + public override void OnDrawContentComplete (Rectangle viewport) { - base.OnDrawContentComplete (contentArea); + base.OnDrawContentComplete (viewport); foreach (LineCanvas canvas in _layers) { diff --git a/UICatalog/Scenarios/Snake.cs b/UICatalog/Scenarios/Snake.cs index 2938addcf3..d6897dd39f 100644 --- a/UICatalog/Scenarios/Snake.cs +++ b/UICatalog/Scenarios/Snake.cs @@ -309,12 +309,12 @@ public SnakeView (SnakeState state) public SnakeState State { get; } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { - base.OnDrawContent (contentArea); + base.OnDrawContent (viewport); Driver.SetAttribute (white); - Clear (contentArea); + Clear (viewport); var canvas = new LineCanvas (); diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index dbd813478f..9a1cfd4595 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -1119,7 +1119,7 @@ public class DerivedView : View public bool IsKeyUp { get; set; } public override string Text { get; set; } - public override void OnDrawContent (Rectangle contentArea) + public override void OnDrawContent (Rectangle viewport) { var idx = 0; From ebc47de514a989428b0d4343c7dfe7df9f39c5c8 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 10:24:31 -0800 Subject: [PATCH 5/8] Reamed Bounds -> Viewport test rename --- UnitTests/Drawing/LineCanvasTests.cs | 8 ++++---- UnitTests/View/Adornment/AdornmentTests.cs | 10 +++++----- UnitTests/View/DrawTests.cs | 16 ++++++++-------- UnitTests/View/Layout/AbsoluteLayoutTests.cs | 4 ++-- UnitTests/View/Layout/ScreenToTests.cs | 8 ++++---- .../{BoundsTests.cs => ViewportTests.cs} | 10 +++++----- UnitTests/View/ViewTests.cs | 18 +++++++++--------- UnitTests/Views/GraphViewTests.cs | 4 ++-- UnitTests/Views/TextFieldTests.cs | 2 +- UnitTests/Views/ToplevelTests.cs | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) rename UnitTests/View/Layout/{BoundsTests.cs => ViewportTests.cs} (90%) diff --git a/UnitTests/Drawing/LineCanvasTests.cs b/UnitTests/Drawing/LineCanvasTests.cs index c386fdcc8d..2fda833842 100644 --- a/UnitTests/Drawing/LineCanvasTests.cs +++ b/UnitTests/Drawing/LineCanvasTests.cs @@ -366,7 +366,7 @@ string expected )] [Theory] [SetupFakeDriver] - public void Bounds_H_And_V_Lines_Both_Positive ( + public void Viewport_H_And_V_Lines_Both_Positive ( int x, int y, int length, @@ -448,7 +448,7 @@ int expectedHeight )] [Theory] [SetupFakeDriver] - public void Bounds_H_Line ( + public void Viewport_H_Line ( int x, int y, int length, @@ -466,7 +466,7 @@ int expectedHeight [Fact] [SetupFakeDriver] - public void Bounds_Specific () + public void Viewport_Specific () { // Draw at 1,1 within client area of View (i.e. leave a top and left margin of 1) // This proves we aren't drawing excess above @@ -516,7 +516,7 @@ public void Bounds_Specific () [Fact] [SetupFakeDriver] - public void Bounds_Specific_With_Ustring () + public void Viewport_Specific_With_Ustring () { // Draw at 1,1 within client area of View (i.e. leave a top and left margin of 1) // This proves we aren't drawing excess above diff --git a/UnitTests/View/Adornment/AdornmentTests.cs b/UnitTests/View/Adornment/AdornmentTests.cs index 199636d712..7010a2bc48 100644 --- a/UnitTests/View/Adornment/AdornmentTests.cs +++ b/UnitTests/View/Adornment/AdornmentTests.cs @@ -7,7 +7,7 @@ public class AdornmentTests (ITestOutputHelper output) private readonly ITestOutputHelper _output = output; [Fact] - public void Bounds_Location_Always_Empty_Size_Correct () + public void Viewport_Location_Always_Empty_Size_Correct () { var view = new View { @@ -42,7 +42,7 @@ public void Bounds_Location_Always_Empty_Size_Correct () Assert.Equal (new (0, 0, view.Padding.Frame.Width , view.Padding.Frame.Height), view.Padding.Viewport); } - // Test that Adornment.Bounds_get override returns Frame.Size minus Thickness + // Test that Adornment.Viewport_get override returns Frame.Size minus Thickness [Theory] [InlineData (0, 0, 0, 0, 0)] [InlineData (0, 0, 0, 1, 1)] @@ -79,7 +79,7 @@ public void Bounds_Location_Always_Empty_Size_Correct () [InlineData (1, 1, 1, 4, 4)] [InlineData (1, 1, 1, 4, 0)] [InlineData (1, 1, 1, 0, 4)] - public void Bounds_Width_Is_Frame_Width (int thickness, int x, int y, int w, int h) + public void Viewport_Width_Is_Frame_Width (int thickness, int x, int y, int w, int h) { var adornment = new Adornment (null); adornment.Thickness = new Thickness (thickness); @@ -90,7 +90,7 @@ public void Bounds_Width_Is_Frame_Width (int thickness, int x, int y, int w, int Assert.Equal (expectedBounds, adornment.Viewport); } - // Test that Adornment.Bounds_get override uses Parent not SuperView + // Test that Adornment.Viewport_get override uses Parent not SuperView [Fact] public void BoundsToScreen_Uses_Parent_Not_SuperView () { @@ -281,7 +281,7 @@ public void GetAdornmentsThickness () } [Fact] - public void Setting_Bounds_Throws () + public void Setting_Viewport_Throws () { var adornment = new Adornment (null); Assert.Throws (() => adornment.Viewport = new Rectangle (1, 2, 3, 4)); diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index ad8c9ac733..38cffae9ac 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -15,7 +15,7 @@ public class DrawTests [InlineData (0, 0, 2, 2)] [InlineData (-1, -1, 2, 2)] [SetupFakeDriver] - public void Clear_Bounds_Clears_Only_Bounds (int x, int y, int width, int height) + public void Clear_Viewport_Clears_Only_Bounds (int x, int y, int width, int height) { var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () }; @@ -251,7 +251,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds () [Fact] [SetupFakeDriver] - public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Bottom () + public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Bottom () { var view = new View { Width = 2, Height = 1, BorderStyle = LineStyle.Single }; view.Border.Thickness = new Thickness (1, 1, 1, 0); @@ -269,7 +269,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Bottom () [Fact] [SetupFakeDriver] - public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Left () + public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Left () { var view = new View { Width = 1, Height = 2, BorderStyle = LineStyle.Single }; view.Border.Thickness = new Thickness (0, 1, 1, 1); @@ -294,7 +294,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Left () [Fact] [SetupFakeDriver] - public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Right () + public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Right () { var view = new View { Width = 1, Height = 2, BorderStyle = LineStyle.Single }; view.Border.Thickness = new Thickness (1, 1, 0, 1); @@ -319,7 +319,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Right () [Fact] [SetupFakeDriver] - public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Top () + public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Top () { var view = new View { Width = 2, Height = 1, BorderStyle = LineStyle.Single }; view.Border.Thickness = new Thickness (1, 0, 1, 1); @@ -345,7 +345,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds_Without_Top () [Fact] [AutoInitShutdown] - public void Draw_Negative_Bounds_Horizontal_With_New_Lines () + public void Draw_Negative_Viewport_Horizontal_With_New_Lines () { var subView = new View { @@ -492,7 +492,7 @@ public void Draw_Negative_Bounds_Horizontal_With_New_Lines () [Fact] [AutoInitShutdown] - public void Draw_Negative_Bounds_Horizontal_Without_New_Lines () + public void Draw_Negative_Viewport_Horizontal_Without_New_Lines () { // BUGBUG: This previously assumed the default height of a View was 1. var subView = new View @@ -571,7 +571,7 @@ public void Draw_Negative_Bounds_Horizontal_Without_New_Lines () [Fact] [AutoInitShutdown] - public void Draw_Negative_Bounds_Vertical () + public void Draw_Negative_Viewport_Vertical () { var subView = new View { diff --git a/UnitTests/View/Layout/AbsoluteLayoutTests.cs b/UnitTests/View/Layout/AbsoluteLayoutTests.cs index ef3cf21b99..9ef8647579 100644 --- a/UnitTests/View/Layout/AbsoluteLayoutTests.cs +++ b/UnitTests/View/Layout/AbsoluteLayoutTests.cs @@ -346,7 +346,7 @@ public void AbsoluteLayout_LayoutSubviews () } [Fact] - public void AbsoluteLayout_Setting_Bounds_Location_NotEmpty () + public void AbsoluteLayout_Setting_Viewport_Location_NotEmpty () { // TODO: Should we enforce Viewport.X/Y == 0? The code currently ignores value.X/Y which is // TODO: correct behavior, but is silent. Perhaps an exception? @@ -359,7 +359,7 @@ public void AbsoluteLayout_Setting_Bounds_Location_NotEmpty () } [Fact] - public void AbsoluteLayout_Setting_Bounds_Sets_Frame () + public void AbsoluteLayout_Setting_Viewport_Sets_Frame () { var frame = new Rectangle (1, 2, 3, 4); var newBounds = new Rectangle (0, 0, 30, 40); diff --git a/UnitTests/View/Layout/ScreenToTests.cs b/UnitTests/View/Layout/ScreenToTests.cs index b7a54aa330..df45c9006d 100644 --- a/UnitTests/View/Layout/ScreenToTests.cs +++ b/UnitTests/View/Layout/ScreenToTests.cs @@ -21,7 +21,7 @@ public class ScreenToTests [InlineData (1, 1, 1, 1, -1, -1)] [InlineData (1, 1, 9, 9, 7, 7)] [InlineData (1, 1, 11, 11, 9, 9)] - public void ScreenToBounds_NoSuper_HasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) + public void ScreenToViewport_NoSuper_HasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) { var view = new View { @@ -50,7 +50,7 @@ public void ScreenToBounds_NoSuper_HasAdornments (int viewX, int viewY, int x, i [InlineData (1, 1, 1, 1, 0, 0)] [InlineData (1, 1, 9, 9, 8, 8)] [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds - public void ScreenToBounds_NoSuper_NoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) + public void ScreenToViewport_NoSuper_NoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) { var view = new View { X = viewX, Y = viewY, Width = 10, Height = 10 }; @@ -69,7 +69,7 @@ public void ScreenToBounds_NoSuper_NoAdornments (int viewX, int viewY, int x, in [InlineData (1, 1, 1, 1, -1, -1)] [InlineData (1, 1, 9, 9, 7, 7)] [InlineData (1, 1, 11, 11, 9, 9)] // it's ok for the view to return coordinates outside of its bounds - public void ScreenToBounds_SuperHasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) + public void ScreenToViewport_SuperHasAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) { var super = new View { @@ -97,7 +97,7 @@ public void ScreenToBounds_SuperHasAdornments (int viewX, int viewY, int x, int [InlineData (1, 1, 1, 1, 0, 0)] [InlineData (1, 1, 9, 9, 8, 8)] [InlineData (1, 1, 11, 11, 10, 10)] // it's ok for the view to return coordinates outside of its bounds - public void ScreenToBounds_SuperHasNoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) + public void ScreenToViewport_SuperHasNoAdornments (int viewX, int viewY, int x, int y, int expectedX, int expectedY) { var super = new View { X = 0, Y = 0, Width = 10, Height = 10 }; var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 }; diff --git a/UnitTests/View/Layout/BoundsTests.cs b/UnitTests/View/Layout/ViewportTests.cs similarity index 90% rename from UnitTests/View/Layout/BoundsTests.cs rename to UnitTests/View/Layout/ViewportTests.cs index 7af892b6cc..b95b1ffb6d 100644 --- a/UnitTests/View/Layout/BoundsTests.cs +++ b/UnitTests/View/Layout/ViewportTests.cs @@ -4,10 +4,10 @@ namespace Terminal.Gui.ViewTests; /// /// Test the . -/// DOES NOT TEST Adornment.Viewport methods. Those are in ./Adornment/BoundsTests.cs +/// DOES NOT TEST Adornment.Viewport methods. Those are in ./Adornment/ViewportTests.cs /// /// -public class BoundsTests (ITestOutputHelper output) +public class ViewportTests (ITestOutputHelper output) { private readonly ITestOutputHelper _output = output; @@ -16,7 +16,7 @@ public class BoundsTests (ITestOutputHelper output) [InlineData (1, 10)] [InlineData (-1, 10)] [InlineData (11, 10)] - public void Get_Bounds_NoSuperView_WithoutAdornments (int x, int expectedW) + public void Get_Viewport_NoSuperView_WithoutAdornments (int x, int expectedW) { // We test with only X because Y is equivalent. Height/Width are irrelevant. // Arrange @@ -47,7 +47,7 @@ public void Get_Bounds_NoSuperView_WithoutAdornments (int x, int expectedW) [InlineData (10, 1, 0)] [InlineData (11, 1, 0)] - public void Get_Bounds_NestedSuperView_WithAdornments (int frameX, int borderThickness, int expectedW) + public void Get_Viewport_NestedSuperView_WithAdornments (int frameX, int borderThickness, int expectedW) { // We test with only X because Y is equivalent. Height/Width are irrelevant. // Arrange @@ -105,7 +105,7 @@ public void Get_Bounds_NestedSuperView_WithAdornments (int frameX, int borderThi [InlineData (-1, 1, 5)] [InlineData (10, 1, 0)] [InlineData (11, 1, 0)] - public void Get_Bounds_NestedSuperView_WithAdornments_WithBorder (int frameX, int borderThickness, int expectedW) + public void Get_Viewport_NestedSuperView_WithAdornments_WithBorder (int frameX, int borderThickness, int expectedW) { // We test with only X because Y is equivalent. Height/Width are irrelevant. // Arrange diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index 9a1cfd4595..0f594a82ba 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -11,7 +11,7 @@ public class ViewTests [Fact] [AutoInitShutdown] - public void Clear_Bounds_Can_Use_Driver_AddRune_Or_AddStr_Methods () + public void Clear_Viewport_Can_Use_Driver_AddRune_Or_AddStr_Methods () { var view = new FrameView { Width = Dim.Fill (), Height = Dim.Fill () }; @@ -220,7 +220,7 @@ Colors.ColorSchemes ["Base"].Focus [Fact] [AutoInitShutdown] - public void Correct_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Frame () + public void Correct_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Frame () { var label = new Label { Text = "At 0,0" }; @@ -265,7 +265,7 @@ A text with some long width [Fact] [AutoInitShutdown] - public void Correct_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Pos_Dim () + public void Correct_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Pos_Dim () { var label = new Label { Text = "At 0,0" }; @@ -314,7 +314,7 @@ A text with some long width [Fact] [AutoInitShutdown] - public void Correct_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Frame () + public void Correct_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Frame () { var label = new Label { Text = "At 0,0" }; @@ -359,7 +359,7 @@ A text with some long width [Fact] [AutoInitShutdown] - public void Correct_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Pos_Dim () + public void Correct_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Pos_Dim () { var label = new Label { Text = "At 0,0" }; @@ -527,7 +527,7 @@ public void GetNormalColor_ColorScheme () [Fact] [AutoInitShutdown] - public void Incorrect_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Frame () + public void Incorrect_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Frame () { var label = new Label { Text = "At 0,0" }; @@ -572,7 +572,7 @@ A text with some long width [Fact] [AutoInitShutdown] - public void Incorrect_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Pos_Dim () + public void Incorrect_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Down_Right_Using_Pos_Dim () { var label = new Label { Text = "At 0,0" }; @@ -621,7 +621,7 @@ A text with some long width [Fact] [AutoInitShutdown] - public void Incorrect_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Frame () + public void Incorrect_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Frame () { var label = new Label { Text = "At 0,0" }; @@ -668,7 +668,7 @@ A text with some long width [Fact] [AutoInitShutdown] - public void Incorrect_Redraw_Bounds_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Pos_Dim () + public void Incorrect_Redraw_Viewport_NeedDisplay_On_Shrink_And_Move_Up_Left_Using_Pos_Dim () { var label = new Label { Text = "At 0,0" }; diff --git a/UnitTests/Views/GraphViewTests.cs b/UnitTests/Views/GraphViewTests.cs index bd27070e97..a40238eb88 100644 --- a/UnitTests/Views/GraphViewTests.cs +++ b/UnitTests/Views/GraphViewTests.cs @@ -441,7 +441,7 @@ public void GraphSpaceToScreen_CustomCellSize_WithScrollOffset () public class SeriesTests { [Fact] - public void Series_GetsPassedCorrectBounds_AllAtOnce () + public void Series_GetsPassedCorrectViewport_AllAtOnce () { GraphViewTests.InitFakeDriver (); @@ -493,7 +493,7 @@ public void Series_GetsPassedCorrectBounds_AllAtOnce () /// results in multiple units of graph space being condensed into each cell of console /// [Fact] - public void Series_GetsPassedCorrectBounds_AllAtOnce_LargeCellSize () + public void Series_GetsPassedCorrectViewport_AllAtOnce_LargeCellSize () { GraphViewTests.InitFakeDriver (); diff --git a/UnitTests/Views/TextFieldTests.cs b/UnitTests/Views/TextFieldTests.cs index 413973ac00..997597159a 100644 --- a/UnitTests/Views/TextFieldTests.cs +++ b/UnitTests/Views/TextFieldTests.cs @@ -177,7 +177,7 @@ public void CaptionedTextField_DoesNotOverspillBounds (string caption, string ex [Fact] [AutoInitShutdown] - public void CaptionedTextField_DoesNotOverspillBounds_Unicode () + public void CaptionedTextField_DoesNotOverspillViewport_Unicode () { string caption = "Mise" + char.ConvertFromUtf32 (int.Parse ("0301", NumberStyles.HexNumber)) + "rables"; diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index f4e4cb9ee8..1ce9a32102 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1513,7 +1513,7 @@ public void Toplevel_Inside_ScrollView_MouseGrabView () [Fact] [AutoInitShutdown] - public void Window_Bounds_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom () + public void Window_Viewport_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom () { Toplevel top = Application.Top; var window = new Window { Width = 20, Height = 3 }; From ab021bf0b0f85c20db54f53473215b7ff94c7f04 Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 17 Mar 2024 08:57:01 -0800 Subject: [PATCH 6/8] Updated API docs --- Terminal.Gui/View/Layout/ViewLayout.cs | 20 +++--- Terminal.Gui/View/ViewDrawing.cs | 88 ++++++++++++++++++-------- UICatalog/Scenarios/CharacterMap.cs | 2 +- 3 files changed, 73 insertions(+), 37 deletions(-) diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index b48c4a5aec..ca1b1220aa 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -287,12 +287,12 @@ public Dim Width #region Viewport /// - /// 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 . + /// Gets or sets the rectangle describing the portion of the View's content that is visible to the user. + /// The viewport Location is relative to the top-left corner of the inner rectangle of the s. + /// If the viewport Size is the sames as the the Location will be 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 visible. + /// The rectangle describing the location and size of the viewport into the View's virtual content, described by . /// /// /// If is the value of Viewport is indeterminate until @@ -300,11 +300,11 @@ public Dim Width /// called. /// /// - /// Updates to the Viewport size updates , and has the same effect as updating the + /// Updates to the Viewport Size updates , and has the same impact as updating the /// . /// /// - /// Altering the Viewport size 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. /// /// @@ -360,14 +360,14 @@ public virtual Rectangle Viewport } /// Converts a -relative rectangle to a screen-relative rectangle. - public Rectangle ViewportToScreen (in Rectangle bounds) + public Rectangle ViewportToScreen (in Rectangle viewport) { // Translate bounds to Frame (our SuperView's Viewport-relative coordinates) Rectangle screen = FrameToScreen (); Point viewportOffset = GetViewportOffset (); - screen.Offset (viewportOffset.X + bounds.X, viewportOffset.Y + bounds.Y); + screen.Offset (viewportOffset.X + viewport.X, viewportOffset.Y + viewport.Y); - return new (screen.Location, bounds.Size); + return new (screen.Location, viewport.Size); } /// Converts a screen-relative coordinate to a Viewport-relative coordinate. diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 3709750791..7eb4e7f600 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -54,15 +54,18 @@ public bool NeedsDisplay /// /// Gets or sets whether this View will use it's SuperView's for rendering any border - /// lines. If the rendering of any borders drawn by this Frame will be done by it's parent's + /// lines. If the rendering of any borders drawn by this Frame will be done by its parent's /// SuperView. If (the default) this View's method will be /// called to render the borders. /// public virtual bool SuperViewRendersLineCanvas { get; set; } = false; - /// Displays the specified character in the specified column and row of the View. - /// Column (view-relative). - /// Row (view-relative). + /// Draws the specified character in the specified viewport-relative column and row of the View. + /// + /// The top-left corner of the visible content area is ViewPort.Location. + /// + /// Column (viewport-relative). + /// Row (viewport-relative). /// Ch. public void AddRune (int col, int row, Rune ch) { @@ -71,6 +74,7 @@ public void AddRune (int col, int row, Rune ch) return; } + // BUGBUG: This should be Viewport.Size if (row > _frame.Height - 1 || col > _frame.Width - 1) { return; @@ -86,7 +90,7 @@ public void AddRune (int col, int row, Rune ch) /// Clears the specified -relative rectangle with the normal background. /// - /// The Viewport-relative rectangle to clear. + /// The Viewport-relative rectangle to clear. public void Clear (Rectangle viewport) { if (Driver is null) @@ -141,7 +145,8 @@ public Rectangle ClipToViewport () /// /// /// Overrides of must ensure they do not set Driver.Clip to a clip - /// region larger than the property, as this will cause the driver to clip the entire region. + /// region larger than the property, as this will cause the driver to clip the entire + /// region. /// /// public void Draw () @@ -263,8 +268,8 @@ public void DrawHotString (string text, bool focused, ColorScheme scheme) /// Determines the current based on the value. /// - /// if is or - /// if is . If it's + /// if is or + /// if is . If it's /// overridden can return other values. /// public virtual Attribute GetFocusColor () @@ -315,10 +320,12 @@ public virtual Attribute GetNormalColor () return Enabled ? cs.Normal : cs.Disabled; } - /// This moves the cursor to the specified column and row in the view. - /// The move. - /// The column to move to, in view-relative coordinates. - /// the row to move to, in view-relative coordinates. + /// This moves the cursor to the specified view-relative column and row in the view. + /// + /// The top-left corner of the visible content area is ViewPort.Location. + /// + /// Column (viewport-relative). + /// Row (viewport-relative). public void Move (int col, int row) { if (Driver is null || Driver?.Rows == 0) @@ -327,6 +334,8 @@ public void Move (int col, int row) } Rectangle screen = ViewportToScreen (new (col, row, 0, 0)); + + // TODO: Clamp this to stay within the View's Viewport Driver?.Move (screen.X, screen.Y); } @@ -353,12 +362,36 @@ public virtual bool OnDrawAdornments () return true; } - /// Enables overrides to draw infinitely scrolled content and/or a background behind added controls. + /// + /// Draws the view's content, including Subviews. + /// + /// + /// + /// The parameter is provided as a convenience; it has the same values as the + /// property. + /// + /// + /// The Location and Size indicate what part of the View's virtual content area, defined + /// by , is visible and should be drawn. The coordinates taken by and + /// are relative to , thus if ViewPort.Location.Y is 5 + /// the 5th row of the content should be drawn using MoveTo (x, 5). + /// + /// + /// If is larger than ViewPort.Size drawing code should use + /// to constrain drawing for better performance. + /// + /// + /// The may define smaller area than ; complex drawing code can be more + /// efficient by using to constrain drawing for better performance. + /// + /// + /// Overrides should loop through the subviews and call . + /// + /// /// - /// The view-relative rectangle describing the currently visible viewport into the - /// + /// The rectangle describing the currently visible viewport into the ; has the same value as + /// . /// - /// This method will be called before any subviews added with have been drawn. public virtual void OnDrawContent (Rectangle viewport) { if (NeedsDisplay) @@ -386,6 +419,7 @@ public virtual void OnDrawContent (Rectangle viewport) SetSubViewNeedsDisplay (); } + // TODO: Move drawing of subviews to a separate OnDrawSubviews virtual method // Draw subviews // TODO: Implement OnDrawSubviews (cancelable); if (_subviews is { } && SubViewNeedsDisplay) @@ -415,17 +449,12 @@ public virtual void OnDrawContent (Rectangle viewport) } /// - /// Enables overrides after completed drawing infinitely scrolled content and/or a background behind removed - /// controls. + /// Called after to enable overrides. /// /// - /// The view-relative rectangle describing the currently visible viewport into the + /// The viewport-relative rectangle describing the currently visible viewport into the /// /// - /// - /// This method will be called after any subviews removed with have been completed - /// drawing. - /// public virtual void OnDrawContentComplete (Rectangle viewport) { DrawContentComplete?.Invoke (this, new (viewport)); } // TODO: Make this cancelable @@ -498,15 +527,22 @@ public void SetNeedsDisplay () /// Expands the area of this view needing to be redrawn to include . /// - /// If the view has not been initialized ( is ), the area to be - /// redrawn will be the . + /// + /// The location of are relative to the View's content, bound by Size.Empty and + /// . + /// + /// + /// If the view has not been initialized ( is ), the area to be + /// redrawn will be the . + /// /// - /// The Viewport-relative region that needs to be redrawn. + /// The content-relative region that needs to be redrawn. public virtual void SetNeedsDisplay (Rectangle region) { if (!IsInitialized) { _needsDisplayRect = region; + return; } diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 797e713ba2..286246073c 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -608,7 +608,7 @@ public override void OnDrawContentComplete (Rectangle viewport) int firstColumnX = viewportOffset.X + RowLabelWidth; - for (var y = 1; y < Viewport.Height; y++) + for (var y = 1; y < Viewport.Height - (ShowHorizontalScrollIndicator ? 1 : 0); y++) { // What row is this? int row = (y - ContentOffset.Y - 1) / _rowHeight; From 7767bd13fa6fe9883743455ff6c2382da28a5315 Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 17 Mar 2024 10:43:39 -0700 Subject: [PATCH 7/8] Made View.Move and View.AddRune constrain; added unit tests --- Terminal.Gui/View/ViewDrawing.cs | 33 +++-- UnitTests/View/DrawTests.cs | 206 +++++++++++++++++++++++-------- 2 files changed, 175 insertions(+), 64 deletions(-) diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 7eb4e7f600..033731307f 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -61,27 +61,25 @@ public bool NeedsDisplay public virtual bool SuperViewRendersLineCanvas { get; set; } = false; /// Draws the specified character in the specified viewport-relative column and row of the View. + /// + /// If the provided coordinates are outside the visible content area, this method does nothing. + /// /// /// The top-left corner of the visible content area is ViewPort.Location. /// /// Column (viewport-relative). /// Row (viewport-relative). - /// Ch. - public void AddRune (int col, int row, Rune ch) + /// The Rune. + public void AddRune (int col, int row, Rune rune) { - if (row < 0 || col < 0) - { - return; - } - - // BUGBUG: This should be Viewport.Size - if (row > _frame.Height - 1 || col > _frame.Width - 1) + if (row < 0 || col < 0 || row >= Viewport.Height || col >= Viewport.Width) { + // TODO: Change return type to bool so callers can determine success? return; } Move (col, row); - Driver.AddRune (ch); + Driver.AddRune (rune); } /// Clears with the normal background. @@ -320,9 +318,14 @@ public virtual Attribute GetNormalColor () return Enabled ? cs.Normal : cs.Disabled; } - /// This moves the cursor to the specified view-relative column and row in the view. + /// Moves the drawing cursor to the specified view-relative column and row in the view. /// + /// + /// If the provided coordinates are outside the visible content area, this method does nothing. + /// + /// /// The top-left corner of the visible content area is ViewPort.Location. + /// /// /// Column (viewport-relative). /// Row (viewport-relative). @@ -333,9 +336,13 @@ public void Move (int col, int row) return; } - Rectangle screen = ViewportToScreen (new (col, row, 0, 0)); + if (col < 0 || row < 0 || col >= Viewport.Size.Width || row >= Viewport.Size.Height) + { + // TODO: Change return type to bool so callers can determine success? + return; + } - // TODO: Clamp this to stay within the View's Viewport + Rectangle screen = ViewportToScreen (new (col, row, 0, 0)); Driver?.Move (screen.X, screen.Y); } diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index 38cffae9ac..0dde48c882 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -4,18 +4,70 @@ namespace Terminal.Gui.ViewTests; -[Trait("Category","Output")] -public class DrawTests +[Trait ("Category", "Output")] +public class DrawTests (ITestOutputHelper output) { - private readonly ITestOutputHelper _output; - public DrawTests (ITestOutputHelper output) { _output = output; } + [Fact] + [SetupFakeDriver] + public void Move_Is_Constrained_To_Viewport () + { + var view = new View + { + X = 1, + Y = 1, + Width = 3, Height = 3 + }; + view.Margin.Thickness = new Thickness (1); + + // Only valid location w/in Viewport is 0, 0 (view) - 2, 2 (screen) + + view.Move (0, 0); + Assert.Equal(new Point(2, 2), new Point (Application.Driver.Col, Application.Driver.Row)); + + view.Move (-1, -1); + Assert.Equal (new Point (2, 2), new Point (Application.Driver.Col, Application.Driver.Row)); + + view.Move (1, 1); + Assert.Equal (new Point (2, 2), new Point (Application.Driver.Col, Application.Driver.Row)); + } + + [Fact] + [SetupFakeDriver] + public void AddRune_Is_Constrained_To_Viewport () + { + var view = new View + { + X = 1, + Y = 1, + Width = 3, Height = 3 + }; + view.Margin.Thickness = new Thickness (1); + View.Diagnostics = ViewDiagnosticFlags.Padding; + view.BeginInit(); + view.EndInit(); + view.Draw(); + + // Only valid location w/in Viewport is 0, 0 (view) - 2, 2 (screen) + Assert.Equal ((Rune)' ', Application.Driver.Contents [2, 2].Rune); + + view.AddRune(0, 0, Rune.ReplacementChar); + Assert.Equal (Rune.ReplacementChar, Application.Driver.Contents [2, 2].Rune); + + view.AddRune (-1, -1, Rune.ReplacementChar); + Assert.Equal ((Rune)'M', Application.Driver.Contents [1, 1].Rune); + + view.AddRune (1, 1, Rune.ReplacementChar); + Assert.Equal ((Rune)'M', Application.Driver.Contents [3, 3].Rune); + + View.Diagnostics = ViewDiagnosticFlags.Off; + } [Theory] [InlineData (0, 0, 1, 1)] [InlineData (0, 0, 2, 2)] [InlineData (-1, -1, 2, 2)] [SetupFakeDriver] - public void Clear_Viewport_Clears_Only_Bounds (int x, int y, int width, int height) + public void Clear_Clears_Only_Viewport (int x, int y, int width, int height) { var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () }; @@ -32,28 +84,80 @@ public void Clear_Viewport_Clears_Only_Bounds (int x, int y, int width, int heig superView.LayoutSubviews (); superView.Draw (); + TestHelpers.AssertDriverContentsWithFrameAre ( + @" + ┌─┐ + │X│ + └─┘", + output); + Rectangle toClear = new (x, y, width, height); + view.Clear (toClear); + TestHelpers.AssertDriverContentsWithFrameAre ( + @" + ┌─┐ + │ │ + └─┘", + output); + // Now try to clear beyond Viewport (invalid) + superView.SetNeedsDisplay (); + superView.Draw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" ┌─┐ │X│ └─┘", - _output); + output); + toClear = new (-width, -height, width, height); + view.Clear (toClear); + TestHelpers.AssertDriverContentsWithFrameAre ( + @" + ┌─┐ + │X│ + └─┘", + output); - Rectangle boundsToClear = new (x, y, width, height); - view.Clear (boundsToClear); + // Now try to clear beyond Viewport (valid) + superView.SetNeedsDisplay (); + superView.Draw (); + TestHelpers.AssertDriverContentsWithFrameAre ( + @" + ┌─┐ + │X│ + └─┘", + output); + toClear = new (-1, -1, width + 1, height + 1); + view.Clear (toClear); TestHelpers.AssertDriverContentsWithFrameAre ( @" ┌─┐ │ │ └─┘", - _output); + output); + // Now clear too much size + superView.SetNeedsDisplay (); + superView.Draw (); + TestHelpers.AssertDriverContentsWithFrameAre ( + @" + ┌─┐ + │X│ + └─┘", + output); + toClear = new (0, 0, width * 2, height * 2); + view.Clear (toClear); + TestHelpers.AssertDriverContentsWithFrameAre ( + @" + ┌─┐ + │ │ + └─┘", + output); } + [Fact] [AutoInitShutdown] - [Trait("Category","Unicode")] + [Trait ("Category", "Unicode")] public void CJK_Compatibility_Ideographs_ConsoleWidth_ColumnWidth_Equal_Two () { const string us = "\U0000f900"; @@ -83,9 +187,9 @@ public void CJK_Compatibility_Ideographs_ConsoleWidth_ColumnWidth_Equal_Two () │豈 │ └────────┘ """; - TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, output); - TestHelpers.AssertDriverContentsAre (expectedOutput, _output); + TestHelpers.AssertDriverContentsAre (expectedOutput, output); Attribute [] expectedColors = { @@ -115,7 +219,7 @@ Colors.ColorSchemes ["Base"].HotNormal // TODO: Refactor this test to not depend on TextView etc... Make it as primitive as possible [Fact] [AutoInitShutdown] - [Trait("Category","Unicode")] + [Trait ("Category", "Unicode")] public void Clipping_AddRune_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space () { var tv = new TextView @@ -161,13 +265,13 @@ public void Clipping_AddRune_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_Wi └────────────────────────────┘ """; - Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, _output); + Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, output); Assert.Equal (new Rectangle (0, 0, 30, 10), pos); } [Fact] [AutoInitShutdown] - [Trait("Category","Output")] + [Trait ("Category", "Output")] public void Colors_On_TextAlignment_Right_And_Bottom () { var viewRight = new View @@ -206,7 +310,7 @@ public void Colors_On_TextAlignment_Right_And_Bottom () s t """, - _output + output ); TestHelpers.AssertDriverAttributesAre ( @@ -227,14 +331,14 @@ Colors.ColorSchemes ["Base"].Normal [Fact] [SetupFakeDriver] - public void Draw_Minimum_Full_Border_With_Empty_Bounds () + public void Draw_Minimum_Full_Border_With_Empty_Viewport () { var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single }; view.BeginInit (); view.EndInit (); view.SetRelativeLayout (Application.Driver.Viewport); - Assert.Equal (new (0,0,2,2), view.Frame); + Assert.Equal (new (0, 0, 2, 2), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -245,7 +349,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Bounds () ┌┐ └┘ """, - _output + output ); } @@ -259,12 +363,12 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Bottom () view.EndInit (); view.SetRelativeLayout (Application.Driver.Viewport); - Assert.Equal (new (0,0,2,1), view.Frame); + Assert.Equal (new (0, 0, 2, 1), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); - TestHelpers.AssertDriverContentsWithFrameAre (string.Empty, _output); + TestHelpers.AssertDriverContentsWithFrameAre (string.Empty, output); } [Fact] @@ -277,7 +381,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Left () view.EndInit (); view.SetRelativeLayout (Application.Driver.Viewport); - Assert.Equal (new (0,0,1,2), view.Frame); + Assert.Equal (new (0, 0, 1, 2), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -288,7 +392,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Left () │ │ """, - _output + output ); } @@ -302,7 +406,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Right () view.EndInit (); view.SetRelativeLayout (Application.Driver.Viewport); - Assert.Equal (new (0,0,1,2), view.Frame); + Assert.Equal (new (0, 0, 1, 2), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -313,7 +417,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Right () │ │ """, - _output + output ); } @@ -328,7 +432,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Top () view.EndInit (); view.SetRelativeLayout (Application.Driver.Viewport); - Assert.Equal (new (0,0,2,1), view.Frame); + Assert.Equal (new (0, 0, 2, 1), view.Frame); Assert.Equal (Rectangle.Empty, view.Viewport); view.Draw (); @@ -339,7 +443,7 @@ public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Top () ┌┐ """, - _output + output ); } @@ -416,7 +520,7 @@ public void Draw_Negative_Viewport_Horizontal_With_New_Lines () 3V 4i """, - _output + output ); content.X = -1; @@ -431,12 +535,12 @@ public void Draw_Negative_Viewport_Horizontal_With_New_Lines () V i """, - _output + output ); content.X = -2; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre (@"", _output); + TestHelpers.AssertDriverContentsWithFrameAre (@"", output); content.X = 0; content.Y = -1; @@ -451,7 +555,7 @@ public void Draw_Negative_Viewport_Horizontal_With_New_Lines () 4i 5e """, - _output + output ); content.Y = -6; @@ -466,7 +570,7 @@ public void Draw_Negative_Viewport_Horizontal_With_New_Lines () 9 0 """, - _output + output ); content.Y = -19; @@ -477,17 +581,17 @@ public void Draw_Negative_Viewport_Horizontal_With_New_Lines () 9 """, - _output + output ); content.Y = -20; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre ("", _output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); content.X = -2; content.Y = 0; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre ("", _output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); } [Fact] @@ -533,7 +637,7 @@ public void Draw_Negative_Viewport_Horizontal_Without_New_Lines () 01234 subVi """, - _output + output ); content.X = -1; @@ -545,7 +649,7 @@ public void Draw_Negative_Viewport_Horizontal_Without_New_Lines () 12345 ubVie """, - _output + output ); content.Y = -1; @@ -556,17 +660,17 @@ public void Draw_Negative_Viewport_Horizontal_Without_New_Lines () ubVie """, - _output + output ); content.Y = -2; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre ("", _output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); content.X = -20; content.Y = 0; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre ("", _output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); } [Fact] @@ -618,7 +722,7 @@ public void Draw_Negative_Viewport_Vertical () 3V 4i """, - _output + output ); content.X = -1; @@ -633,12 +737,12 @@ public void Draw_Negative_Viewport_Vertical () V i """, - _output + output ); content.X = -2; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre (@"", _output); + TestHelpers.AssertDriverContentsWithFrameAre (@"", output); content.X = 0; content.Y = -1; @@ -653,7 +757,7 @@ public void Draw_Negative_Viewport_Vertical () 4i 5e """, - _output + output ); content.Y = -6; @@ -668,7 +772,7 @@ public void Draw_Negative_Viewport_Vertical () 9 0 """, - _output + output ); content.Y = -19; @@ -679,17 +783,17 @@ public void Draw_Negative_Viewport_Vertical () 9 """, - _output + output ); content.Y = -20; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre ("", _output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); content.X = -2; content.Y = 0; Application.Refresh (); - TestHelpers.AssertDriverContentsWithFrameAre ("", _output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); } [Theory] @@ -701,7 +805,7 @@ public void DrawHotString_NonBmp (string expected) var view = new View { Width = 10, Height = 1 }; view.DrawHotString (expected, Attribute.Default, Attribute.Default); - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } // TODO: The tests below that use Label should use View instead. @@ -736,9 +840,9 @@ public void Non_Bmp_ConsoleWidth_ColumnWidth_Equal_Two () │𝔹 │ └────────┘ """; - TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); - TestHelpers.AssertDriverContentsAre (expected, _output); + TestHelpers.AssertDriverContentsAre (expected, output); Attribute [] expectedColors = { From 0cde0e17ea75f376122ca82290b792271ab0c85a Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 17 Mar 2024 11:16:00 -0700 Subject: [PATCH 8/8] Fixed menu code that was using View.Move inproperly --- Terminal.Gui/Views/Menu/Menu.cs | 6 ++++-- Terminal.Gui/Views/Menu/MenuBar.cs | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index a7d9f91df7..c2ee48ade4 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -790,7 +790,8 @@ public override void OnDrawContent (Rectangle viewport) if (item is null && BorderStyle != LineStyle.None) { - Move (-1, i); + var s = ViewportToScreen (new (-1, i, 0, 0)); + Driver.Move (s.X, s.Y); Driver.AddRune (Glyphs.LeftTee); } else if (Frame.X < Driver.Cols) @@ -837,7 +838,8 @@ public override void OnDrawContent (Rectangle viewport) { if (BorderStyle != LineStyle.None && SuperView?.Frame.Right - Frame.X > Frame.Width) { - Move (Frame.Width - 2, i); + var s = ViewportToScreen (new (Frame.Width - 2, i, 0, 0)); + Driver.Move (s.X, s.Y); Driver.AddRune (Glyphs.RightTee); } diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index 46573a457e..7e141d92f0 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -471,13 +471,9 @@ internal Menu openCurrentMenu /// public override void OnDrawContent (Rectangle viewport) { - Move (0, 0); Driver.SetAttribute (GetNormalColor ()); - for (var i = 0; i < Frame.Width; i++) - { - Driver.AddRune ((Rune)' '); - } + Clear (); Move (1, 0); var pos = 0;