From f6ff36968e70f59c206b73f5e7c562e955ffa50e Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 14 Mar 2024 07:30:27 -0800 Subject: [PATCH] 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 b2d2cbe36..94cfb8154 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -1420,7 +1420,7 @@ public static partial class Application 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 @@ public static partial class Application 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 f8225c9bf..0661fe09a 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 ba5fbed5a..76d74f512 100644 --- a/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs @@ -117,7 +117,7 @@ public class AppendAutocomplete : AutocompleteBase 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 84ea48365..e76aa8a2d 100644 --- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs @@ -271,13 +271,13 @@ public abstract partial class PopupAutocomplete : AutocompleteBase 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 abstract partial class PopupAutocomplete : AutocompleteBase 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 abstract partial class PopupAutocomplete : AutocompleteBase 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 6168c53f0..86fc2ca85 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -30,7 +30,7 @@ public class TextFormatter /// 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 5fe40cab9..74348cfee 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 @@ public class Adornment : View /// 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 @@ public class Adornment : View /// 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 3c2a645c1..206f87bf4 100644 --- a/Terminal.Gui/View/Adornment/Padding.cs +++ b/Terminal.Gui/View/Adornment/Padding.cs @@ -42,7 +42,7 @@ public class Padding : Adornment /// 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 af1e417a9..18ab7c563 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 partial class View /// /// 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 partial class View /// 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 partial class View } } - /// 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 partial class View } /// 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 partial class View /// /// 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 @@ public partial class View 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 @@ public partial class View 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 partial class View LayoutAdornments (); - Rectangle oldBounds = Bounds; + Rectangle oldBounds = Viewport; OnLayoutStarted (new () { OldBounds = oldBounds }); SetTextFormatterSize (); @@ -925,7 +925,7 @@ public partial class View 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 @@ public partial class View // 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 c78d327f5..84b30e3bd 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 5cf036439..53a0f3ffc 100644 --- a/Terminal.Gui/View/ViewAdornments.cs +++ b/Terminal.Gui/View/ViewAdornments.cs @@ -39,7 +39,7 @@ public partial class View /// /// 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 @@ public partial class View 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 partial class View } /// - /// 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 7bc9f5b2d..0107ca1ad 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -80,11 +80,11 @@ public partial class View 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 partial class View 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 partial class View } 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 partial class View /// /// /// - /// Always use (view-relative) when calling , NOT + /// Always use (view-relative) when calling , NOT /// (superview-relative). /// /// @@ -162,12 +162,12 @@ public partial class View } // 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 partial class View 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 partial class View // 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 partial class View 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 partial class View { if (IsInitialized) { - SetNeedsDisplay (Bounds); + SetNeedsDisplay (Viewport); } } @@ -525,9 +525,9 @@ public partial class View _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 90422ecec..6ef2c783c 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 @@ public partial class View // 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 @@ public partial class View } // 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 598e2c76b..911f72938 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -30,10 +30,10 @@ public partial class View /// 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 partial class View /// 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 partial class View /// . /// /// - /// 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 partial class View /// 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 partial class View } /// - /// 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 partial class View 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 @@ public partial class View } /// - /// Internal API. Sets .Size to the current size, adjusted for + /// Internal API. Sets .Size to the current size, adjusted for /// . /// /// @@ -244,14 +244,14 @@ public partial class View 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 @@ public partial class View return false; } - sizeRequired = Bounds.Size; + sizeRequired = Viewport.Size; if (AutoSize || string.IsNullOrEmpty (TextFormatter.Text)) { @@ -338,9 +338,9 @@ public partial class View // 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 @@ public partial class View 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 @@ public partial class View } 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 e1f8179a5..249c44cff 100644 --- a/Terminal.Gui/Views/ColorPicker.cs +++ b/Terminal.Gui/Views/ColorPicker.cs @@ -98,7 +98,7 @@ public class ColorPicker : View 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 class ColorPicker : View 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 9d151f465..a08e1a361 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -245,8 +245,8 @@ public class ComboBox : View /// 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 class ComboBox : View } Driver.SetAttribute (ColorScheme.Focus); - Move (Bounds.Right - 1, 0); + Move (Viewport.Right - 1, 0); Driver.AddRune (Glyphs.DownArrow); } @@ -401,15 +401,15 @@ public class ComboBox : View /// 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 @@ public class ComboBox : View } 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 @@ public class ComboBox : View 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 @@ public class ComboBox : View 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 7b821bf13..c6d04a253 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -165,7 +165,7 @@ public class Dialog : Window { 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 @@ public class Dialog : Window } else { - button.X = Bounds.Width - shiftLeft; + button.X = Viewport.Width - shiftLeft; } button.Y = Pos.AnchorEnd (1); @@ -190,7 +190,7 @@ public class Dialog : Window // 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 @@ public class Dialog : Window 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 f36099d29..118e4437d 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -414,16 +414,16 @@ public class FileDialog : Dialog 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 @@ public class FileDialog : Dialog 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 1a77a4949..25d2d0203 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 class TextAnnotation : IAnnotation 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 @@ public class TextAnnotation : IAnnotation graph.Move (x, y); - int availableWidth = graph.Bounds.Width - x; + int availableWidth = graph.Viewport.Width - x; if (availableWidth <= 0) { @@ -127,7 +127,7 @@ public class LegendAnnotation : View, IAnnotation /// 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 class LegendAnnotation : View, IAnnotation // 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 class LegendAnnotation : View, IAnnotation /// 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 8d0389b37..32addb648 100644 --- a/Terminal.Gui/Views/GraphView/Axis.cs +++ b/Terminal.Gui/Views/GraphView/Axis.cs @@ -113,7 +113,7 @@ public class HorizontalAxis : Axis 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 class HorizontalAxis : Axis 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 class HorizontalAxis : Axis return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; IEnumerable labels = GetLabels (graph, bounds); @@ -155,12 +155,12 @@ public class HorizontalAxis : Axis 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 class HorizontalAxis : Axis return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; graph.Move (0, 0); @@ -212,7 +212,7 @@ public class HorizontalAxis : Axis // 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 class VerticalAxis : Axis return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; IEnumerable labels = GetLabels (graph, bounds); foreach (AxisIncrementToRender label in labels) @@ -331,13 +331,13 @@ public class VerticalAxis : Axis 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 class VerticalAxis : Axis return; } - Rectangle bounds = graph.Bounds; + Rectangle bounds = graph.Viewport; int x = GetAxisXPosition (graph); @@ -385,7 +385,7 @@ public class VerticalAxis : Axis // 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 @@ public class VerticalAxis : Axis 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 30b902286..2c9cbc769 100644 --- a/Terminal.Gui/Views/GraphView/GraphView.cs +++ b/Terminal.Gui/Views/GraphView/GraphView.cs @@ -192,7 +192,7 @@ public class GraphView : View (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 class GraphView : View 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 class GraphView : View } // 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 class GraphView : 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 class GraphView : View { 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 673419b16..c117bd0a2 100644 --- a/Terminal.Gui/Views/GraphView/Series.cs +++ b/Terminal.Gui/Views/GraphView/Series.cs @@ -192,7 +192,7 @@ public class BarSeries : ISeries 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 a9a7f0aad..5f994a4ce 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -373,7 +373,7 @@ public class HexView : View { Rectangle lineRect = new (0, line, frame.Width, 1); - if (!Bounds.Contains (lineRect)) + if (!Viewport.Contains (lineRect)) { continue; } @@ -611,9 +611,9 @@ public class HexView : View // 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 2f4341113..23df0387d 100644 --- a/Terminal.Gui/Views/LineView.cs +++ b/Terminal.Gui/Views/LineView.cs @@ -63,7 +63,7 @@ public class LineView : View 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 132be3213..321e97fc5 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -318,9 +318,9 @@ public class ListView : View { _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 @@ public class ListView : View 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 class ListView : View //can move by down by one. _selected++; - if (_selected >= _top + Bounds.Height) + if (_selected >= _top + Viewport.Height) { _top++; } @@ -466,9 +466,9 @@ public class ListView : View 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 class ListView : View { _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 class ListView : View /// public virtual bool MovePageDown () { - int n = _selected + Bounds.Height; + int n = _selected + Viewport.Height; if (n >= _source.Count) { @@ -528,7 +528,7 @@ public class ListView : View { _selected = n; - if (_source.Count >= Bounds.Height) + if (_source.Count >= Viewport.Height) { _top = Math.Max (_selected, 0); } @@ -548,7 +548,7 @@ public class ListView : View /// public virtual bool MovePageUp () { - int n = _selected - Bounds.Height; + int n = _selected - Viewport.Height; if (n < 0) { @@ -598,9 +598,9 @@ public class ListView : View { _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 class ListView : View 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 class ListView : View } 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 0cc365595..65a3081d5 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -769,14 +769,14 @@ internal sealed class Menu : View 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 @@ internal sealed class Menu : View 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 @@ internal sealed class Menu : View continue; } - if (BoundsToScreen (Bounds).X + p >= Driver.Cols) + if (BoundsToScreen (Viewport).X + p >= Driver.Cols) { break; } @@ -894,7 +894,7 @@ internal sealed class Menu : View 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 @@ internal sealed class Menu : View { if (Visible) { - OnDrawContent (Bounds); + OnDrawContent (Viewport); } } diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 16395760a..27aa3a054 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -394,7 +394,7 @@ public static class MessageBox } // 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 189533ee6..860987299 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -151,7 +151,7 @@ public class ProgressBar : View 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 class ProgressBar : View } 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 class ProgressBar : View } 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 class ProgressBar : View _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 92fcbd505..e42524fd1 100644 --- a/Terminal.Gui/Views/ScrollBarView.cs +++ b/Terminal.Gui/Views/ScrollBarView.cs @@ -152,14 +152,14 @@ public class ScrollBarView : View _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 @@ public class ScrollBarView : View } 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 class ScrollBarView : View 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 class ScrollBarView : View 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 class ScrollBarView : View Move (col, 0); - if (Bounds.Height == 1) + if (Viewport.Height == 1) { Driver.AddRune (Glyphs.Diamond); } @@ -495,15 +495,15 @@ public class ScrollBarView : View 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 class ScrollBarView : View 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 class ScrollBarView : View if (!hasLeftTee) { - Move (Bounds.Width - 2, row); + Move (Viewport.Width - 2, row); Driver.AddRune (Glyphs.LeftTee); } @@ -685,7 +685,7 @@ public class ScrollBarView : 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 @@ public class ScrollBarView : View 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 @@ public class ScrollBarView : View 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 35b213f56..ddeede202 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -83,10 +83,10 @@ public class ScrollView : View 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 class ScrollView : View _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 @@ public class ScrollView : View 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 @@ public class ScrollView : View 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 @@ public class ScrollView : View v = true; } - if (Bounds.Width == 0 || Bounds.Width > _contentSize.Width) + if (Viewport.Width == 0 || Viewport.Width > _contentSize.Width) { if (ShowHorizontalScrollIndicator) { @@ -644,7 +644,7 @@ public class ScrollView : View 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 @@ public class ScrollView : View if (v) { - _vertical.SetRelativeLayout (Bounds); + _vertical.SetRelativeLayout (Viewport); _vertical.Draw (); } if (h) { - _horizontal.SetRelativeLayout (Bounds); + _horizontal.SetRelativeLayout (Viewport); _horizontal.Draw (); } @@ -710,7 +710,7 @@ public class ScrollView : View 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 750003724..08a481554 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -669,11 +669,11 @@ public class Slider : View // 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 @@ public class Slider : View // 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 class Slider : View 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 class Slider : View } 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 class Slider : View 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 @@ public class Slider : View private void DrawSlider () { // TODO: be more surgical on clear - Clear (Bounds); + Clear (Viewport); // Attributes @@ -1241,7 +1241,7 @@ public class Slider : View } } - 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 88689e2c5..7ff5eca7d 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -297,7 +297,7 @@ public class TabView : View } // 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 @@ public class TabView : View 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 class TabView : View 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 class TabView : View 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 @@ public class TabView : View 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 @@ public class TabView : View } tab.TextFormatter.Draw ( - tab.BoundsToScreen (tab.Bounds), + tab.BoundsToScreen (tab.Viewport), prevAttr, ColorScheme.HotNormal ); @@ -1360,7 +1360,7 @@ public class TabView : View // 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 869515501..1286e2660 100644 --- a/Terminal.Gui/Views/TableView/ListTableSource.cs +++ b/Terminal.Gui/Views/TableView/ListTableSource.cs @@ -109,12 +109,12 @@ public class ListTableSource : ITableSource 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 @@ public class ListTableSource : ITableSource 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 @@ public class ListTableSource : ITableSource 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 352547168..d444af67a 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -483,7 +483,7 @@ public class TableView : View return null; } - IEnumerable viewPort = CalculateViewport (Bounds); + IEnumerable viewPort = CalculateViewport (Viewport); int headerHeight = GetHeaderHeightIfAny (); @@ -502,7 +502,7 @@ public class TableView : View } // 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 class TableView : View 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 class TableView : View 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 class TableView : View } //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 class TableView : View 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 class TableView : View */ if (Style.ShowHorizontalHeaderOverline) { - RenderHeaderOverline (line, Bounds.Width, columnsToRender); + RenderHeaderOverline (line, Viewport.Width, columnsToRender); line++; } @@ -937,7 +937,7 @@ public class TableView : View if (Style.ShowHorizontalHeaderUnderline) { - RenderHeaderUnderline (line, Bounds.Width, columnsToRender); + RenderHeaderUnderline (line, Viewport.Width, columnsToRender); line++; } } @@ -945,9 +945,9 @@ public class TableView : View 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 class TableView : View { if (rowToRender == Table.Rows && Style.ShowHorizontalBottomline) { - RenderBottomLine (line, Bounds.Width, columnsToRender); + RenderBottomLine (line, Viewport.Width, columnsToRender); } continue; @@ -1001,7 +1001,7 @@ public class TableView : View /// 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 class TableView : View /// 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 class TableView : View return null; } - IEnumerable viewPort = CalculateViewport (Bounds); + IEnumerable viewPort = CalculateViewport (Viewport); int headerHeight = GetHeaderHeightIfAny (); @@ -1658,7 +1658,7 @@ public class TableView : View // 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 @@ public class TableView : View //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 @@ public class TableView : View } 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 @@ public class TableView : View //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 e97a27ec5..1d9d0fd2c 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -1196,8 +1196,8 @@ public class TextField : View int pos = _cursorPosition - ScrollOffset + Math.Min (Frame.X, 0); int offB = OffSetBackground (); - Rectangle containerFrame = SuperView?.BoundsToScreen (SuperView.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 @@ public class TextField : View 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 @@ public class TextField : View { _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 a86cd910f..ad12ea258 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -537,7 +537,7 @@ namespace Terminal.Gui { 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 @@ namespace Terminal.Gui 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 @@ namespace Terminal.Gui /// 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 @@ namespace Terminal.Gui 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 8ef1c5b4a..593882052 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -156,7 +156,7 @@ public class TileView : View return; } - Rectangle contentArea = Bounds; + Rectangle contentArea = Viewport; if (HasBorder ()) { @@ -195,19 +195,19 @@ public class TileView : View { 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 class TileView : View 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 class TileView : View ); } - 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 @@ public class TileView : View 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 @@ public class TileView : View { 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 class TileView : View { 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 @@ public class TileView : View { 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 @@ public class TileView : View { 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 class TileView : View { 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 @@ public class TileView : View { 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 @@ public class TileView : View { 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 ed0a11501..60f264984 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -268,12 +268,12 @@ public partial class Toplevel : View { 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 partial class Toplevel : View // 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 941948737..ef1527002 100644 --- a/Terminal.Gui/Views/TreeView/TreeView.cs +++ b/Terminal.Gui/Views/TreeView/TreeView.cs @@ -742,10 +742,10 @@ public class TreeView : View, ITreeView where T : class //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 class TreeView : View, ITreeView where T : class } // 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 class TreeView : View, ITreeView where T : class /// 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 class TreeView : View, ITreeView where T : class 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 @@ public class TreeView : View, ITreeView where T : class /// 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 class TreeView : View, ITreeView where T : class 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 class TreeView : View, ITreeView where T : class 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 class TreeView : View, ITreeView where T : class 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 c597b18d9..6fbdaf4ac 100644 --- a/UICatalog/Scenarios/ASCIICustomButton.cs +++ b/UICatalog/Scenarios/ASCIICustomButton.cs @@ -79,14 +79,14 @@ public class ASCIICustomButtonTest : Scenario 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 b5c875519..db91439d7 100644 --- a/UICatalog/Scenarios/Animation.cs +++ b/UICatalog/Scenarios/Animation.cs @@ -167,12 +167,12 @@ public class Animation : Scenario { 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 class Animation : Scenario 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 9445c226f..eebc86d4f 100644 --- a/UICatalog/Scenarios/BackgroundWorkerCollection.cs +++ b/UICatalog/Scenarios/BackgroundWorkerCollection.cs @@ -285,7 +285,7 @@ public class BackgroundWorkerCollection : Scenario 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 4921ccd71..fa90d8539 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -373,7 +373,7 @@ internal class CharMap : ScrollView 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 @@ internal class CharMap : ScrollView 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 @@ internal class CharMap : ScrollView 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 @@ internal class CharMap : ScrollView ); } - 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 @@ internal class CharMap : ScrollView 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 @@ internal class CharMap : ScrollView 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 @@ internal class CharMap : ScrollView { 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 f15fc7726..ead701305 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -56,12 +56,12 @@ public class ComputedLayout : Scenario 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 01cbb7c87..94561b014 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -758,8 +758,8 @@ public class Editor : Scenario _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 8ca960a23..caef010a1 100644 --- a/UICatalog/Scenarios/GraphViewExample.cs +++ b/UICatalog/Scenarios/GraphViewExample.cs @@ -254,7 +254,7 @@ public class GraphViewExample : Scenario _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 @@ public class GraphViewExample : Scenario _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 44b2875b1..0d3f93fe9 100644 --- a/UICatalog/Scenarios/ProgressBarStyles.cs +++ b/UICatalog/Scenarios/ProgressBarStyles.cs @@ -70,7 +70,7 @@ public class ProgressBarStyles : Scenario 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 dd0772803..8bdda1cb3 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -67,17 +67,17 @@ public class Scrolling : Scenario 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 5c08962f2..2938addcf 100644 --- a/UICatalog/Scenarios/Snake.cs +++ b/UICatalog/Scenarios/Snake.cs @@ -341,7 +341,7 @@ public class Snake : Scenario ); } - 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 f1303e0bf..159dd7587 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -218,17 +218,17 @@ public class ViewExperiments : Scenario $"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 37ffced39..bdcfc6fea 100644 --- a/UICatalog/Scenarios/VkeyPacketSimulator.cs +++ b/UICatalog/Scenarios/VkeyPacketSimulator.cs @@ -265,20 +265,20 @@ public class VkeyPacketSimulator : Scenario 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 c2fb7c39e..35968090b 100644 --- a/UnitTests/Drawing/LineCanvasTests.cs +++ b/UnitTests/Drawing/LineCanvasTests.cs @@ -293,7 +293,7 @@ public class LineCanvasTests 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 @@ public class LineCanvasTests 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 class LineCanvasTests /// 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 @@ public class LineCanvasTests 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 6a2b7803f..0e23dc4bc 100644 --- a/UnitTests/UICatalog/ScenarioTests.cs +++ b/UnitTests/UICatalog/ScenarioTests.cs @@ -254,7 +254,7 @@ public class ScenarioTests _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 1d6e5b6e0..8d8752742 100644 --- a/UnitTests/View/Adornment/AdornmentTests.cs +++ b/UnitTests/View/Adornment/AdornmentTests.cs @@ -21,25 +21,25 @@ public class AdornmentTests (ITestOutputHelper output) 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 class AdornmentTests (ITestOutputHelper output) 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 class AdornmentTests (ITestOutputHelper output) 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 class AdornmentTests (ITestOutputHelper output) 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 class AdornmentTests (ITestOutputHelper output) 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 class AdornmentTests (ITestOutputHelper output) 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 class AdornmentTests (ITestOutputHelper output) 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 bc4508648..ddc5aa300 100644 --- a/UnitTests/View/Adornment/ToScreenTests.cs +++ b/UnitTests/View/Adornment/ToScreenTests.cs @@ -289,7 +289,7 @@ public class AdornmentToScreenTests (ITestOutputHelper output) // 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 e29d5f662..9b616ad7b 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -235,7 +235,7 @@ public class DrawTests 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 class DrawTests 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 class DrawTests 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 class DrawTests 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 class DrawTests 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 2f4b27fea..193670453 100644 --- a/UnitTests/View/Layout/AbsoluteLayoutTests.cs +++ b/UnitTests/View/Layout/AbsoluteLayoutTests.cs @@ -31,7 +31,7 @@ public class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests // 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests 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 class AbsoluteLayoutTests // 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 2a4c3e5c6..69bb1d87b 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 class BoundsTests (ITestOutputHelper output) view.EndInit(); // Act - var bounds = view.Bounds; + var bounds = view.Viewport; // Assert Assert.Equal(expectedW, bounds.Width); @@ -85,7 +85,7 @@ public class BoundsTests (ITestOutputHelper output) superSuperView.LayoutSubviews (); // Act - var bounds = view.Bounds; + var bounds = view.Viewport; // Assert Assert.Equal (expectedW, bounds.Width); @@ -144,7 +144,7 @@ public class BoundsTests (ITestOutputHelper output) 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 367a2c65d..c700c6dbe 100644 --- a/UnitTests/View/Layout/DimTests.cs +++ b/UnitTests/View/Layout/DimTests.cs @@ -39,7 +39,7 @@ public class DimTests 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 class DimTests 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 class DimTests 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 644e4580e..5fb9cf782 100644 --- a/UnitTests/View/Layout/PosTests.cs +++ b/UnitTests/View/Layout/PosTests.cs @@ -116,11 +116,11 @@ public class PosTests 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 class PosTests 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 cfd028820..24e23dbed 100644 --- a/UnitTests/View/Layout/SetRelativeLayoutTests.cs +++ b/UnitTests/View/Layout/SetRelativeLayoutTests.cs @@ -54,10 +54,10 @@ public class SetRelativeLayoutTests 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 class SetRelativeLayoutTests 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 d4f730c95..0d7bff9fa 100644 --- a/UnitTests/View/SubviewTests.cs +++ b/UnitTests/View/SubviewTests.cs @@ -151,8 +151,8 @@ public class SubviewTests 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 class SubviewTests 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 2c3109522..85a0d5f86 100644 --- a/UnitTests/View/Text/AutoSizeFalseTests.cs +++ b/UnitTests/View/Text/AutoSizeFalseTests.cs @@ -145,7 +145,7 @@ public class AutoSizeFalseTests 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 class AutoSizeFalseTests 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 class AutoSizeFalseTests 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 00ec2208a..14b61b25a 100644 --- a/UnitTests/View/Text/AutoSizeTrueTests.cs +++ b/UnitTests/View/Text/AutoSizeTrueTests.cs @@ -587,7 +587,7 @@ public class AutoSizeTrueTests 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 class AutoSizeTrueTests 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 class AutoSizeTrueTests 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 class AutoSizeTrueTests // 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 class AutoSizeTrueTests // #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 class AutoSizeTrueTests // 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 class AutoSizeTrueTests 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 133c1f19e..c13362261 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -18,13 +18,13 @@ public class ViewTests 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 class ViewTests 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 class ViewTests 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 class ViewTests 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 ); 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 @@ At 0,0 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 72d9e9cd3..b91246901 100644 --- a/UnitTests/Views/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -432,14 +432,14 @@ public class ButtonTests 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 class ButtonTests 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 class ButtonTests "; 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 class ButtonTests 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 class ButtonTests 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 1a38b80d4..6e6724e2e 100644 --- a/UnitTests/Views/ComboBoxTests.cs +++ b/UnitTests/Views/ComboBoxTests.cs @@ -144,7 +144,7 @@ public class ComboBoxTests 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 class ComboBoxTests 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 class ComboBoxTests 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 class ComboBoxTests 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 @@ public class ComboBoxTests 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 @@ public class ComboBoxTests 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 class ComboBoxTests 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 @@ public class ComboBoxTests 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 @@ public class ComboBoxTests 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 @@ public class ComboBoxTests 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 class ComboBoxTests 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 @@ Three ", 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 @@ Three ", 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 @@ Three ", 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 @@ Three ", 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 @@ Three ", 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 @@ Three ", 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 7362e7cf1..bd27070e9 100644 --- a/UnitTests/Views/GraphViewTests.cs +++ b/UnitTests/Views/GraphViewTests.cs @@ -61,7 +61,7 @@ public class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests // 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class GraphViewTests 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 class SeriesTests 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 class SeriesTests 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 class MultiBarSeriesTests // 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 @@ public class BarSeriesTests // 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 @@ public class AxisTests 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 class PathAnnotationTests 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 @@ public class PathAnnotationTests 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 94d9f6068..ab99e9ddf 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -458,7 +458,7 @@ e 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 @@ e 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 @@ e 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 @@ e 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 @@ e 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 eafe135df..4422a133b 100644 --- a/UnitTests/Views/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -23,13 +23,13 @@ public class ScrollBarViewTests 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 class ScrollBarViewTests $"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 class ScrollBarViewTests $"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 class ScrollBarViewTests $"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 class ScrollBarViewTests $"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 class ScrollBarViewTests $"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 @@ This is a tes 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 @@ This is a test 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 @@ This is a test 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 @@ This is a test 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 @@ This is a test 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 fcaab5760..b94f5c774 100644 --- a/UnitTests/Views/ScrollViewTests.cs +++ b/UnitTests/Views/ScrollViewTests.cs @@ -34,7 +34,7 @@ public class ScrollViewTests 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 class ScrollViewTests ); 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 class ScrollViewTests { 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 1deb7a0be..e4a325967 100644 --- a/UnitTests/Views/StatusBarTests.cs +++ b/UnitTests/Views/StatusBarTests.cs @@ -99,7 +99,7 @@ public class StatusBarTests ); Application.Top.Add (sb); - sb.OnDrawContent (sb.Bounds); + sb.OnDrawContent (sb.Viewport); var expected = @$" ^O Open { @@ -121,7 +121,7 @@ public class StatusBarTests } ); 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 b90f42b11..649e347a1 100644 --- a/UnitTests/Views/TableViewTests.cs +++ b/UnitTests/Views/TableViewTests.cs @@ -125,7 +125,7 @@ public class TableViewTests // 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 class TableViewTests // 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 class TableViewTests 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 class TableViewTests { 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 class TableViewTests { 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 class TableViewTests { 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 class TableViewTests { 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests // 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 class TableViewTests "; 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 class TableViewTests { 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 class TableViewTests { 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests 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 class TableViewTests { 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 class TableViewTests { 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 class TableViewTests 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 class TableViewTests // should select that row Assert.Equal (2, tv.SelectedRow); - tv.OnDrawContent (tv.Bounds); + tv.OnDrawContent (tv.Viewport); var expected = @" @@ -2310,7 +2310,7 @@ public class TableViewTests 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 @@ A B C 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 @@ A B C // should select that row Assert.Equal (2, tv.SelectedRow); - tv.OnDrawContent (tv.Bounds); + tv.OnDrawContent (tv.Viewport); var expected = @" @@ -2425,7 +2425,7 @@ A B C //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 @@ A B C 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 @@ A B C { 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 @@ A B C 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 @@ A B C 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 981c83a27..ea65f7eea 100644 --- a/UnitTests/Views/TextValidateFieldTests.cs +++ b/UnitTests/Views/TextValidateFieldTests.cs @@ -71,7 +71,7 @@ public class TextValidateField_NET_Provider_Tests // 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 fdbe0e789..f71cb9978 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -63,7 +63,7 @@ public class TextViewTests 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 @@ This is the second line. 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 @@ This is the second line. 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 @@ This is the second line. 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 @@ This is the second line. 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 @@ This is the second line. 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 9eaee637f..e13d2dcc7 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1360,7 +1360,7 @@ public class ToplevelTests 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 68d006f35..f572e529a 100644 --- a/UnitTests/Views/TreeTableSourceTests.cs +++ b/UnitTests/Views/TreeTableSourceTests.cs @@ -227,7 +227,7 @@ public class TreeTableSourceTests : IDisposable 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 5b180870b..843612898 100644 --- a/UnitTests/Views/TreeViewTests.cs +++ b/UnitTests/Views/TreeViewTests.cs @@ -30,7 +30,7 @@ public class TreeViewTests 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 class TreeViewTests 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 class TreeViewTests 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 83e4b0822..a6e6765ae 100644 --- a/UnitTests/Views/WindowTests.cs +++ b/UnitTests/Views/WindowTests.cs @@ -135,7 +135,7 @@ public class WindowTests 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 class WindowTests #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 class WindowTests #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);