diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index 45072846c..4dd46e833 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -421,6 +421,9 @@ namespace Terminal.Gui { throw new InvalidOperationException ("Only one Overlapped Container is allowed."); } + // Ensure the mouse is ungrabed. + _mouseGrabView = null; + var rs = new RunState (Toplevel); // View implements ISupportInitializeNotification which is derived from ISupportInitialize @@ -494,7 +497,7 @@ namespace Terminal.Gui { OverlappedTop?.OnChildLoaded (Toplevel); Toplevel.OnLoaded (); Toplevel.SetNeedsDisplay (); - Toplevel.Redraw (Toplevel.Bounds); + Toplevel.Draw (); Toplevel.PositionCursor (); Driver.Refresh (); } @@ -631,7 +634,7 @@ namespace Terminal.Gui { if (v.Visible) { v.SetNeedsDisplay (); v.SetSubViewNeedsDisplay (); - v.Redraw (v.Bounds); + v.Draw (); } last = v; } @@ -766,11 +769,12 @@ namespace Terminal.Gui { if (state.Toplevel != Top && (!Top._needsDisplay.IsEmpty || Top._subViewNeedsDisplay || Top.LayoutNeeded)) { state.Toplevel.SetNeedsDisplay (state.Toplevel.Bounds); - Top.Redraw (Top.Bounds); + Top.Draw (); foreach (var top in _toplevels.Reverse ()) { if (top != Top && top != state.Toplevel) { top.SetNeedsDisplay (); - top.Redraw (top.Bounds); + top.SetSubViewNeedsDisplay (); + top.Draw (); } } } @@ -785,7 +789,7 @@ namespace Terminal.Gui { if (!state.Toplevel._needsDisplay.IsEmpty || state.Toplevel._subViewNeedsDisplay || state.Toplevel.LayoutNeeded || OverlappedChildNeedsDisplay ()) { - state.Toplevel.Redraw (state.Toplevel.Bounds); + state.Toplevel.Draw (); //if (state.Toplevel.SuperView != null) { // state.Toplevel.SuperView?.OnRenderLineCanvas (); //} else { @@ -798,7 +802,7 @@ namespace Terminal.Gui { } if (state.Toplevel != Top && !state.Toplevel.Modal && (!Top._needsDisplay.IsEmpty || Top._subViewNeedsDisplay || Top.LayoutNeeded)) { - Top.Redraw (Top.Bounds); + Top.Draw (); } } diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs index e97f9611f..f24cf6e55 100644 --- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs @@ -34,7 +34,7 @@ namespace Terminal.Gui { } } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (autocomplete.LastPopupPos == null) { return; @@ -43,6 +43,7 @@ namespace Terminal.Gui { autocomplete.RenderOverlay ((Point)autocomplete.LastPopupPos); } + public override bool MouseEvent (MouseEvent mouseEvent) { return autocomplete.MouseEvent (mouseEvent); diff --git a/Terminal.Gui/Types/Rect.cs b/Terminal.Gui/Types/Rect.cs index 9a1e62fc9..396dd6026 100644 --- a/Terminal.Gui/Types/Rect.cs +++ b/Terminal.Gui/Types/Rect.cs @@ -9,15 +9,12 @@ // using System; -using System.Drawing; -namespace Terminal.Gui -{ +namespace Terminal.Gui { /// /// Stores a set of four integers that represent the location and size of a rectangle /// - public struct Rect - { + public struct Rect { int width; int height; @@ -199,7 +196,7 @@ namespace Terminal.Gui public static bool operator == (Rect left, Rect right) { - return ((left.Location == right.Location) && + return ((left.Location == right.Location) && (left.Size == right.Size)); } @@ -215,7 +212,7 @@ namespace Terminal.Gui public static bool operator != (Rect left, Rect right) { - return ((left.Location != right.Location) || + return ((left.Location != right.Location) || (left.Size != right.Size)); } @@ -379,7 +376,7 @@ namespace Terminal.Gui public bool Contains (int x, int y) { - return ((x >= Left) && (x < Right) && + return ((x >= Left) && (x < Right) && (y >= Top) && (y < Bottom)); } @@ -423,7 +420,7 @@ namespace Terminal.Gui if (!(obj is Rect)) return false; - return (this == (Rect) obj); + return (this == (Rect)obj); } /// diff --git a/Terminal.Gui/View/Frame.cs b/Terminal.Gui/View/Frame.cs index 9f9313e7d..beed23d88 100644 --- a/Terminal.Gui/View/Frame.cs +++ b/Terminal.Gui/View/Frame.cs @@ -74,6 +74,12 @@ namespace Terminal.Gui { /// public override bool OnDrawFrames () => false; + /// + /// Does nothing for Frame + /// + /// + public override bool OnRenderLineCanvas () => false; + /// /// Frames only render to their Parent or Parent's SuperView's LineCanvas, /// so this always throws an . @@ -118,8 +124,7 @@ namespace Terminal.Gui { /// /// Redraws the Frames that comprise the . /// - /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (Thickness == Thickness.Empty) return; diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index a83da114e..5dc5236b3 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -295,7 +295,9 @@ namespace Terminal.Gui { // TODO: Make this cancelable /// - /// + /// Prepares . If is true, only the of + /// this view's subviews will be rendered. If is false (the default), this + /// method will cause the be prepared to be rendered. /// /// public virtual bool OnDrawFrames () @@ -315,9 +317,9 @@ namespace Terminal.Gui { // Each of these renders lines to either this View's LineCanvas // Those lines will be finally rendered in OnRenderLineCanvas - Margin?.Redraw (Margin.Frame); - Border?.Redraw (Border.Frame); - Padding?.Redraw (Padding.Frame); + Margin?.OnDrawContent (Bounds); + Border?.OnDrawContent (Bounds); + Padding?.OnDrawContent (Bounds); Driver.Clip = prevClip; @@ -325,23 +327,23 @@ namespace Terminal.Gui { } /// - /// Redraws this view and its subviews; only redraws the views that have been flagged for a re-display. + /// Draws the view. Causes the following virtual methods to be called (along with their related events): + /// , . /// - /// The bounds (view-relative region) to redraw. /// /// - /// Always use (view-relative) when calling , NOT (superview-relative). + /// Always use (view-relative) when calling , NOT (superview-relative). /// /// /// Views should set the color that they want to use on entry, as otherwise this will inherit /// the last color that was set globally on the driver. /// /// - /// Overrides of must ensure they do not set Driver.Clip to a clip region - /// larger than the parameter, as this will cause the driver to clip the entire region. + /// Overrides of must ensure they do not set Driver.Clip to a clip region + /// larger than the property, as this will cause the driver to clip the entire region. /// /// - public virtual void Redraw (Rect bounds) + public void Draw () { if (!CanBeVisible (this)) { return; @@ -356,32 +358,12 @@ namespace Terminal.Gui { Driver.SetAttribute (GetNormalColor ()); } - if (SuperView != null) { - Clear (ViewToScreen (bounds)); - } - // Invoke DrawContentEvent - OnDrawContent (bounds); + var dev = new DrawEventArgs (Bounds); + DrawContent?.Invoke (this, dev); - // Draw subviews - // TODO: Implement OnDrawSubviews (cancelable); - if (_subviews != null) { - foreach (var view in _subviews) { - if (view.Visible) { //!view._needsDisplay.IsEmpty || view._childNeedsDisplay || view.LayoutNeeded) { - if (true) { //view.Frame.IntersectsWith (bounds)) { // && (view.Frame.IntersectsWith (bounds) || bounds.X < 0 || bounds.Y < 0)) { - if (view.LayoutNeeded) { - view.LayoutSubviews (); - } - - // Draw the subview - // Use the view's bounds (view-relative; Location will always be (0,0) - //if (view.Visible && view.Frame.Width > 0 && view.Frame.Height > 0) { - view.Redraw (view.Bounds); - //} - } - view.ClearNeedsDisplay (); - } - } + if (!dev.Cancel) { + OnDrawContent (Bounds); } Driver.Clip = prevClip; @@ -389,15 +371,26 @@ namespace Terminal.Gui { OnRenderLineCanvas (); // Invoke DrawContentCompleteEvent - OnDrawContentComplete (bounds); + OnDrawContentComplete (Bounds); // BUGBUG: v2 - We should be able to use View.SetClip here and not have to resort to knowing Driver details. ClearLayoutNeeded (); ClearNeedsDisplay (); } - internal void OnRenderLineCanvas () + // TODO: Make this cancelable + /// + /// Renders . If is true, only the of + /// this view's subviews will be rendered. If is false (the default), this + /// method will cause the to be rendered. + /// + /// + public virtual bool OnRenderLineCanvas () { + if (!IsInitialized) { + return false; + } + //Driver.SetAttribute (new Attribute(Color.White, Color.Black)); // If we have a SuperView, it'll render our frames. @@ -424,6 +417,8 @@ namespace Terminal.Gui { } LineCanvas.Clear (); } + + return true; } /// @@ -448,20 +443,40 @@ namespace Terminal.Gui { /// public virtual void OnDrawContent (Rect contentArea) { - // TODO: Make DrawContent a cancelable event - // if (!DrawContent?.Invoke(this, new DrawEventArgs (viewport)) { - DrawContent?.Invoke (this, new DrawEventArgs (contentArea)); + if (SuperView != null) { + Clear (ViewToScreen (Bounds)); + } if (!ustring.IsNullOrEmpty (TextFormatter.Text)) { if (TextFormatter != null) { TextFormatter.NeedsFormat = true; } // This should NOT clear - TextFormatter?.Draw (ViewToScreen (contentArea), HasFocus ? GetFocusColor () : GetNormalColor (), + TextFormatter?.Draw (ViewToScreen (Bounds), HasFocus ? GetFocusColor () : GetNormalColor (), HasFocus ? ColorScheme.HotFocus : GetHotNormalColor (), Rect.Empty, false); SetSubViewNeedsDisplay (); } + + // Draw subviews + // TODO: Implement OnDrawSubviews (cancelable); + if (_subviews != null) { + foreach (var view in _subviews) { + if (view.Visible) { //!view._needsDisplay.IsEmpty || view._childNeedsDisplay || view.LayoutNeeded) { + if (true) { //view.Frame.IntersectsWith (bounds)) { // && (view.Frame.IntersectsWith (bounds) || bounds.X < 0 || bounds.Y < 0)) { + if (view.LayoutNeeded) { + view.LayoutSubviews (); + } + + // Draw the subview + // Use the view's bounds (view-relative; Location will always be (0,0) + //if (view.Visible && view.Frame.Width > 0 && view.Frame.Height > 0) { + view.Draw (); + //} + } + } + } + } } /// @@ -480,13 +495,13 @@ namespace Terminal.Gui { /// /// Enables overrides after completed drawing infinitely scrolled content and/or a background behind removed controls. /// - /// The view-relative rectangle describing the currently visible viewport into the + /// The view-relative rectangle describing the currently visible viewport into the /// /// This method will be called after any subviews removed with have been completed drawing. /// - public virtual void OnDrawContentComplete (Rect viewport) + public virtual void OnDrawContentComplete (Rect contentArea) { - DrawContentComplete?.Invoke (this, new DrawEventArgs (viewport)); + DrawContentComplete?.Invoke (this, new DrawEventArgs (contentArea)); } } diff --git a/Terminal.Gui/View/ViewEventArgs.cs b/Terminal.Gui/View/ViewEventArgs.cs index 277ddbc67..576d5e6ac 100644 --- a/Terminal.Gui/View/ViewEventArgs.cs +++ b/Terminal.Gui/View/ViewEventArgs.cs @@ -55,6 +55,11 @@ namespace Terminal.Gui { /// Gets the view-relative rectangle describing the currently visible viewport into the . /// public Rect Rect { get; } + + /// + /// If set to true, the draw operation will be canceled, if applicable. + /// + public bool Cancel { get; set; } } /// diff --git a/Terminal.Gui/View/ViewLayout.cs b/Terminal.Gui/View/ViewLayout.cs index 91c6553c5..f268ea02c 100644 --- a/Terminal.Gui/View/ViewLayout.cs +++ b/Terminal.Gui/View/ViewLayout.cs @@ -198,7 +198,7 @@ namespace Terminal.Gui { /// /// The View-relative rectangle where View content is displayed. SubViews are positioned relative to - /// Bounds.Location (which is always (0, 0)) and clips drawing to + /// Bounds.Location (which is always (0, 0)) and clips drawing to /// Bounds.Size. /// /// The bounds. @@ -473,13 +473,13 @@ namespace Terminal.Gui { if (LayoutNeeded) return; LayoutNeeded = true; - if (SuperView == null) - return; - SuperView.SetNeedsLayout (); foreach (var view in Subviews) { view.SetNeedsLayout (); } TextFormatter.NeedsFormat = true; + if (SuperView == null) + return; + SuperView.SetNeedsLayout (); } /// @@ -498,28 +498,12 @@ namespace Terminal.Gui { /// Y screen-coordinate point. public Point ScreenToView (int x, int y) { + Point boundsOffset = SuperView == null ? Point.Empty : SuperView.GetBoundsOffset (); if (SuperView == null) { - return new Point (x - Frame.X, y - _frame.Y); - } else { - var parent = SuperView.ScreenToView (x, y); - return new Point (parent.X - _frame.X, parent.Y - _frame.Y); - } - } - - /// - /// Converts a point from screen-relative coordinates to bounds-relative coordinates. - /// - /// The mapped point. - /// X screen-coordinate point. - /// Y screen-coordinate point. - public Point ScreenToBounds (int x, int y) - { - if (SuperView == null) { - var boundsOffset = GetBoundsOffset (); return new Point (x - Frame.X + boundsOffset.X, y - Frame.Y + boundsOffset.Y); } else { - var parent = SuperView.ScreenToView (x, y); - return new Point (parent.X - _frame.X, parent.Y - _frame.Y); + var parent = SuperView.ScreenToView (x - boundsOffset.X, y - boundsOffset.Y); + return new Point (parent.X - Frame.X, parent.Y - Frame.Y); } } diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 029cb05a4..6a62ed15d 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -283,7 +283,7 @@ namespace Terminal.Gui { if (!HasFocus) { SetFocus (); SetNeedsDisplay (); - Redraw (Bounds); + Draw (); } OnClicked (); } diff --git a/Terminal.Gui/Views/ColorPicker.cs b/Terminal.Gui/Views/ColorPicker.cs index 03d25f340..1ae910d6c 100644 --- a/Terminal.Gui/Views/ColorPicker.cs +++ b/Terminal.Gui/Views/ColorPicker.cs @@ -158,9 +158,9 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); Driver.SetAttribute (HasFocus ? ColorScheme.Focus : GetNormalColor ()); var colorIndex = 0; diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index 05cd0ac7a..fe14badd6 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -90,7 +90,7 @@ namespace Terminal.Gui { return false; } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { var current = ColorScheme.Focus; Driver.SetAttribute (current); @@ -534,9 +534,9 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); if (!autoHide) { return; diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index 7457fdfbe..7f42ec418 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -593,19 +593,19 @@ namespace Terminal.Gui { = Enumerable.Empty ().ToList ().AsReadOnly (); /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); if (!string.IsNullOrWhiteSpace (feedback)) { var feedbackWidth = feedback.Sum (c => Rune.ColumnWidth (c)); - var feedbackPadLeft = ((bounds.Width - feedbackWidth) / 2) - 1; + var feedbackPadLeft = ((Bounds.Width - feedbackWidth) / 2) - 1; - feedbackPadLeft = Math.Min (bounds.Width, feedbackPadLeft); + feedbackPadLeft = Math.Min (Bounds.Width, feedbackPadLeft); feedbackPadLeft = Math.Max (0, feedbackPadLeft); - var feedbackPadRight = bounds.Width - (feedbackPadLeft + feedbackWidth + 2); - feedbackPadRight = Math.Min (bounds.Width, feedbackPadRight); + var feedbackPadRight = Bounds.Width - (feedbackPadLeft + feedbackWidth + 2); + feedbackPadRight = Math.Min (Bounds.Width, feedbackPadRight); feedbackPadRight = Math.Max (0, feedbackPadRight); Move (0, Bounds.Height / 2); diff --git a/Terminal.Gui/Views/GraphView/Axis.cs b/Terminal.Gui/Views/GraphView/Axis.cs index fbfc2080a..516cbee97 100644 --- a/Terminal.Gui/Views/GraphView/Axis.cs +++ b/Terminal.Gui/Views/GraphView/Axis.cs @@ -215,7 +215,7 @@ namespace Terminal.Gui { var y = GetAxisYPosition (graph); graph.Move (screenPosition, y); - + // draw the tick on the axis driver.AddRune (driver.TopTee); @@ -282,7 +282,7 @@ namespace Terminal.Gui { // Label or no label definetly render it yield return toRender; - + current.X += Increment; } @@ -448,7 +448,7 @@ namespace Terminal.Gui { // draw the axis symbol (and label if it has one) yield return toRender; - + current.Y += Increment; } diff --git a/Terminal.Gui/Views/GraphView/GraphView.cs b/Terminal.Gui/Views/GraphView/GraphView.cs index 78826448a..2af54976e 100644 --- a/Terminal.Gui/Views/GraphView/GraphView.cs +++ b/Terminal.Gui/Views/GraphView/GraphView.cs @@ -79,13 +79,13 @@ namespace Terminal.Gui { AddCommand (Command.ScrollRight, () => { Scroll (CellSize.X, 0); return true; }); AddCommand (Command.ScrollLeft, () => { Scroll (-CellSize.X, 0); return true; }); AddCommand (Command.PageUp, () => { PageUp (); return true; }); - AddCommand (Command.PageDown, () => { PageDown(); return true; }); + AddCommand (Command.PageDown, () => { PageDown (); return true; }); AddKeyBinding (Key.CursorRight, Command.ScrollRight); AddKeyBinding (Key.CursorLeft, Command.ScrollLeft); AddKeyBinding (Key.CursorUp, Command.ScrollUp); AddKeyBinding (Key.CursorDown, Command.ScrollDown); - + // Not bound by default (preserves backwards compatibility) //AddKeyBinding (Key.PageUp, Command.PageUp); //AddKeyBinding (Key.PageDown, Command.PageDown); @@ -108,10 +108,10 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - if(CellSize.X == 0 || CellSize.Y == 0) { - throw new Exception ($"{nameof(CellSize)} cannot be 0"); + if (CellSize.X == 0 || CellSize.Y == 0) { + throw new Exception ($"{nameof (CellSize)} cannot be 0"); } SetDriverColorToGraphColor (); @@ -139,7 +139,7 @@ namespace Terminal.Gui { } // Draw 'before' annotations - foreach (var a in Annotations.ToArray().Where (a => a.BeforeSeries)) { + foreach (var a in Annotations.ToArray ().Where (a => a.BeforeSeries)) { a.Render (this); } @@ -152,7 +152,7 @@ namespace Terminal.Gui { AxisX.DrawAxisLabels (this); // Draw a cross where the two axis cross - var axisIntersection = new Point(AxisY.GetAxisXPosition(this),AxisX.GetAxisYPosition(this)); + var axisIntersection = new Point (AxisY.GetAxisXPosition (this), AxisX.GetAxisYPosition (this)); if (AxisX.Visible && AxisY.Visible) { Move (axisIntersection.X, axisIntersection.Y); @@ -161,8 +161,8 @@ namespace Terminal.Gui { SetDriverColorToGraphColor (); - Rect drawBounds = new Rect((int)MarginLeft,0, graphScreenWidth, graphScreenHeight); - + Rect drawBounds = new Rect ((int)MarginLeft, 0, graphScreenWidth, graphScreenHeight); + RectangleF graphSpace = ScreenToGraphSpace (drawBounds); foreach (var s in Series.ToArray ()) { @@ -179,7 +179,6 @@ namespace Terminal.Gui { foreach (var a in Annotations.ToArray ().Where (a => !a.BeforeSeries)) { a.Render (this); } - } /// @@ -214,7 +213,7 @@ namespace Terminal.Gui { public RectangleF ScreenToGraphSpace (Rect screenArea) { // get position of the bottom left - var pos = ScreenToGraphSpace (screenArea.Left, screenArea.Bottom-1); + var pos = ScreenToGraphSpace (screenArea.Left, screenArea.Bottom - 1); return new RectangleF (pos.X, pos.Y, screenArea.Width * CellSize.X, screenArea.Height * CellSize.Y); } @@ -248,7 +247,7 @@ namespace Terminal.Gui { public override bool ProcessKey (KeyEvent keyEvent) { if (HasFocus && CanFocus) { - var result = InvokeKeybindings (keyEvent); + var result = InvokeKeybindings (keyEvent); if (result != null) return (bool)result; } @@ -259,7 +258,7 @@ namespace Terminal.Gui { /// /// Scrolls the graph up 1 page /// - public void PageUp() + public void PageUp () { Scroll (0, CellSize.Y * Bounds.Height); } @@ -267,9 +266,9 @@ namespace Terminal.Gui { /// /// Scrolls the graph down 1 page /// - public void PageDown() + public void PageDown () { - Scroll(0, -1 * CellSize.Y * Bounds.Height); + Scroll (0, -1 * CellSize.Y * Bounds.Height); } /// /// Scrolls the view by a given number of units in graph space. diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs index 3d9850f62..8fd8286b8 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -198,7 +198,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { Attribute currentAttribute; var current = ColorScheme.Focus; @@ -217,7 +217,7 @@ namespace Terminal.Gui { for (int line = 0; line < frame.Height; line++) { var lineRect = new Rect (0, line, frame.Width, 1); - if (!bounds.Contains (lineRect)) + if (!Bounds.Contains (lineRect)) continue; Move (0, line); diff --git a/Terminal.Gui/Views/Line.cs b/Terminal.Gui/Views/Line.cs index 19f1bf4f6..17886cfac 100644 --- a/Terminal.Gui/Views/Line.cs +++ b/Terminal.Gui/Views/Line.cs @@ -17,13 +17,13 @@ namespace Terminal.Gui { /// /// Constructs a Line object. /// - public Line () + public Line () { } - + /// - public override bool OnDrawFrames() + public override bool OnDrawFrames () { var screenBounds = ViewToScreen (Bounds); LineCanvas lc; @@ -34,17 +34,16 @@ namespace Terminal.Gui { return true; } - //public override void OnDrawContentComplete (Rect viewport) + //public override void OnDrawContentComplete (Rect contentArea) //{ // var screenBounds = ViewToScreen (Frame); //} /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { OnDrawFrames (); - } } } diff --git a/Terminal.Gui/Views/LineView.cs b/Terminal.Gui/Views/LineView.cs index a84c8b4cf..cfe22e529 100644 --- a/Terminal.Gui/Views/LineView.cs +++ b/Terminal.Gui/Views/LineView.cs @@ -1,7 +1,7 @@ using System; namespace Terminal.Gui { - + /// /// A straight line control either horizontal or vertical /// @@ -33,7 +33,7 @@ namespace Terminal.Gui { /// /// Creates a horizontal line /// - public LineView () : this(Orientation.Horizontal) + public LineView () : this (Orientation.Horizontal) { } @@ -66,32 +66,30 @@ namespace Terminal.Gui { /// /// Draws the line including any starting/ending anchors /// - /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); - + base.OnDrawContent (contentArea); + Move (0, 0); Driver.SetAttribute (GetNormalColor ()); var hLineWidth = Math.Max (1, Rune.ColumnWidth (Driver.HLine)); var dEnd = Orientation == Orientation.Horizontal ? - bounds.Width : - bounds.Height; + Bounds.Width : + Bounds.Height; for (int d = 0; d < dEnd; d += hLineWidth) { - - if(Orientation == Orientation.Horizontal) { + + if (Orientation == Orientation.Horizontal) { Move (d, 0); - } - else { - Move (0,d); + } else { + Move (0, d); } Rune rune = LineRune; - if(d == 0) { + if (d == 0) { rune = StartingAnchor ?? LineRune; } else if (d == dEnd - 1) { diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index efb72aa48..5e7fc76c2 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -349,9 +349,9 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); var current = ColorScheme.Focus; Driver.SetAttribute (current); diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs index 9dd5ea556..001423525 100644 --- a/Terminal.Gui/Views/Menu.cs +++ b/Terminal.Gui/Views/Menu.cs @@ -535,7 +535,7 @@ namespace Terminal.Gui { return GetNormalColor (); } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (barItems.Children == null) { return; @@ -651,7 +651,7 @@ namespace Terminal.Gui { private void Current_DrawContentComplete (object sender, DrawEventArgs e) { - Redraw (e.Rect); + OnDrawContent (Bounds); } public override void PositionCursor () @@ -1193,7 +1193,7 @@ namespace Terminal.Gui { // Spaces after the submenu Title, before Help static int parensAroundHelp = 3; /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { Move (0, 0); Driver.SetAttribute (GetNormalColor ()); diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 628c3a6d3..cc386da77 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -275,7 +275,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect region) + public override void OnDrawContent (Rect contentArea) { DrawFrame (); @@ -357,7 +357,7 @@ namespace Terminal.Gui { case ProgressBarFormat.FramedProgressPadded: padding = 2; Border.DrawFrame (Bounds, false); - Border.DrawFrame (new Rect (Bounds.X + padding/2, Bounds.Y + padding/2, Bounds.Width - (padding), Bounds.Height - padding - 1), false); + Border.DrawFrame (new Rect (Bounds.X + padding / 2, Bounds.Y + padding / 2, Bounds.Width - (padding), Bounds.Height - padding - 1), false); break; } } diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs index 05429da14..c92511ece 100644 --- a/Terminal.Gui/Views/RadioGroup.cs +++ b/Terminal.Gui/Views/RadioGroup.cs @@ -190,9 +190,9 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); Driver.SetAttribute (GetNormalColor ()); for (int i = 0; i < radioLabels.Count; i++) { diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs index 365781d17..13b741c17 100644 --- a/Terminal.Gui/Views/ScrollBarView.cs +++ b/Terminal.Gui/Views/ScrollBarView.cs @@ -31,7 +31,7 @@ namespace Terminal.Gui { ScrollBarView otherScrollBarView; View contentBottomRightCorner; - bool showBothScrollIndicator => OtherScrollBarView != null && OtherScrollBarView.showScrollIndicator && showScrollIndicator; + bool showBothScrollIndicator => OtherScrollBarView?.showScrollIndicator == true && showScrollIndicator; /// /// Initializes a new instance of the class using layout. @@ -111,17 +111,29 @@ namespace Terminal.Gui { OtherScrollBarView.ShowScrollIndicator = true; } ShowScrollIndicator = true; - contentBottomRightCorner = new View (" ") { Visible = host.Visible }; - Host.SuperView.Add (contentBottomRightCorner); - // BUGBUG: v2 - Host may be superview and thus this may be bogus - contentBottomRightCorner.X = Pos.Right (host) - 1; - contentBottomRightCorner.Y = Pos.Bottom (host) - 1; - contentBottomRightCorner.Width = 1; - contentBottomRightCorner.Height = 1; - contentBottomRightCorner.MouseClick += ContentBottomRightCorner_MouseClick; + CreateBottomRightCorner (); ClearOnVisibleFalse = false; } + private void CreateBottomRightCorner () + { + if (Host != null && (contentBottomRightCorner == null && OtherScrollBarView == null + || (contentBottomRightCorner == null && OtherScrollBarView != null && OtherScrollBarView.contentBottomRightCorner == null))) { + + contentBottomRightCorner = new View (" ") { + Id = "contentBottomRightCorner", + Visible = Host.Visible, + ClearOnVisibleFalse = false + }; + Host.Add (contentBottomRightCorner); + contentBottomRightCorner.X = Pos.Right (Host) - 1; + contentBottomRightCorner.Y = Pos.Bottom (Host) - 1; + contentBottomRightCorner.Width = 1; + contentBottomRightCorner.Height = 1; + contentBottomRightCorner.MouseClick += ContentBottomRightCorner_MouseClick; + } + } + private void Host_VisibleChanged (object sender, EventArgs e) { if (!Host.Visible) { @@ -155,13 +167,14 @@ namespace Terminal.Gui { void ContentBottomRightCorner_MouseClick (object sender, MouseEventEventArgs me) { if (me.MouseEvent.Flags == MouseFlags.WheeledDown || me.MouseEvent.Flags == MouseFlags.WheeledUp - || me.MouseEvent.Flags == MouseFlags.WheeledRight || me.MouseEvent.Flags == MouseFlags.WheeledLeft) { - me.Handled = true; + || me.MouseEvent.Flags == MouseFlags.WheeledRight || me.MouseEvent.Flags == MouseFlags.WheeledLeft) { + MouseEvent (me.MouseEvent); } else if (me.MouseEvent.Flags == MouseFlags.Button1Clicked) { - me.Handled = true; Host.SetFocus (); } + + me.Handled = true; } void SetInitialProperties (int size, int position, bool isVertical) @@ -171,7 +184,10 @@ namespace Terminal.Gui { this.position = position; this.size = size; WantContinuousButtonPressed = true; - + ClearOnVisibleFalse = false; + + Added += (s, e) => CreateBottomRightCorner (); + Initialized += (s, e) => { SetWidthHeight (); SetRelativeLayout (SuperView?.Frame ?? Host?.Frame ?? Frame); @@ -226,13 +242,11 @@ namespace Terminal.Gui { public int Position { get => position; set { - if (!IsInitialized) { + position = value; + if (IsInitialized) { // We're not initialized so we can't do anything fancy. Just cache value. - position = value; - return; + SetPosition (value); } - - SetPosition (value); } } @@ -410,10 +424,10 @@ namespace Terminal.Gui { } if (showScrollIndicator) { - Redraw (Bounds); + Draw (); } if (otherScrollBarView != null && otherScrollBarView.showScrollIndicator) { - otherScrollBarView.Redraw (otherScrollBarView.Bounds); + otherScrollBarView.Draw (); } } @@ -474,10 +488,10 @@ namespace Terminal.Gui { } if (showBothScrollIndicator) { - Width = vertical ? 1 : Host != SuperView ? Dim.Width (Host) - 1: Dim.Fill () - 1; - Height = vertical ? Host != SuperView ? Dim.Height (Host) - 1: Dim.Fill () - 1 : 1; + Width = vertical ? 1 : Host != SuperView ? Dim.Width (Host) - 1 : Dim.Fill () - 1; + Height = vertical ? Host != SuperView ? Dim.Height (Host) - 1 : Dim.Fill () - 1 : 1; - otherScrollBarView.Width = otherScrollBarView.vertical ? 1 : Host != SuperView ? Dim.Width (Host) - 1: Dim.Fill () - 1; + otherScrollBarView.Width = otherScrollBarView.vertical ? 1 : Host != SuperView ? Dim.Width (Host) - 1 : Dim.Fill () - 1; otherScrollBarView.Height = otherScrollBarView.vertical ? Host != SuperView ? Dim.Height (Host) - 1 : Dim.Fill () - 1 : 1; } else if (showScrollIndicator) { Width = vertical ? 1 : Host != SuperView ? Dim.Width (Host) : Dim.Fill (); @@ -494,7 +508,7 @@ namespace Terminal.Gui { int posRightTee; /// - public override void Redraw (Rect region) + public override void OnDrawContent (Rect contentArea) { if (ColorScheme == null || ((!showScrollIndicator || Size == 0) && AutoHideScrollBars && Visible)) { if ((!showScrollIndicator || Size == 0) && AutoHideScrollBars && Visible) { @@ -510,7 +524,7 @@ namespace Terminal.Gui { Driver.SetAttribute (Host.HasFocus ? ColorScheme.Focus : GetNormalColor ()); if (vertical) { - if (region.Right < Bounds.Width - 1) { + if (Bounds.Right < Bounds.Width - 1) { return; } @@ -582,7 +596,7 @@ namespace Terminal.Gui { Driver.AddRune (Driver.DownArrow); } } else { - if (region.Bottom < Bounds.Height - 1) { + if (Bounds.Bottom < Bounds.Height - 1) { return; } @@ -663,6 +677,7 @@ namespace Terminal.Gui { mouseEvent.Flags != MouseFlags.Button1Released && mouseEvent.Flags != MouseFlags.WheeledDown && mouseEvent.Flags != MouseFlags.WheeledUp && mouseEvent.Flags != MouseFlags.WheeledRight && mouseEvent.Flags != MouseFlags.WheeledLeft && mouseEvent.Flags != MouseFlags.Button1TripleClicked) { + return false; } @@ -682,6 +697,7 @@ namespace Terminal.Gui { if (mouseEvent.Flags != MouseFlags.Button1Released && (Application.MouseGrabView == null || Application.MouseGrabView != this)) { + Application.GrabMouse (this); } else if (mouseEvent.Flags == MouseFlags.Button1Released && Application.MouseGrabView != null && Application.MouseGrabView == this) { lastLocation = -1; @@ -690,6 +706,7 @@ namespace Terminal.Gui { } if (showScrollIndicator && (mouseEvent.Flags == MouseFlags.WheeledDown || mouseEvent.Flags == MouseFlags.WheeledUp || mouseEvent.Flags == MouseFlags.WheeledRight || mouseEvent.Flags == MouseFlags.WheeledLeft)) { + return Host.MouseEvent (mouseEvent); } diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs index c02640a25..a1dcf9fa8 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -262,11 +262,15 @@ namespace Terminal.Gui { /// The view to add to the scrollview. public override void Add (View view) { - if (!IsOverridden (view, "MouseEvent")) { - view.MouseEnter += View_MouseEnter; - view.MouseLeave += View_MouseLeave; + if (view.Id == "contentBottomRightCorner") { + base.Add (view); + } else { + if (!IsOverridden (view, "MouseEvent")) { + view.MouseEnter += View_MouseEnter; + view.MouseLeave += View_MouseLeave; + } + contentView.Add (view); } - contentView.Add (view); SetNeedsLayout (); } @@ -289,25 +293,23 @@ namespace Terminal.Gui { public bool ShowHorizontalScrollIndicator { get => showHorizontalScrollIndicator; set { - if (value == showHorizontalScrollIndicator) { - return; - } - - showHorizontalScrollIndicator = value; - SetNeedsLayout (); - if (value) { - base.Add (horizontal); - horizontal.ShowScrollIndicator = value; - horizontal.AutoHideScrollBars = autoHideScrollBars; - horizontal.OtherScrollBarView = vertical; - horizontal.OtherScrollBarView.ShowScrollIndicator = value; - horizontal.MouseEnter += View_MouseEnter; - horizontal.MouseLeave += View_MouseLeave; - } else { - base.Remove (horizontal); - horizontal.OtherScrollBarView = null; - horizontal.MouseEnter -= View_MouseEnter; - horizontal.MouseLeave -= View_MouseLeave; + if (value != showHorizontalScrollIndicator) { + showHorizontalScrollIndicator = value; + SetNeedsLayout (); + if (value) { + horizontal.OtherScrollBarView = vertical; + base.Add (horizontal); + horizontal.ShowScrollIndicator = value; + horizontal.AutoHideScrollBars = autoHideScrollBars; + horizontal.OtherScrollBarView.ShowScrollIndicator = value; + horizontal.MouseEnter += View_MouseEnter; + horizontal.MouseLeave += View_MouseLeave; + } else { + base.Remove (horizontal); + horizontal.OtherScrollBarView = null; + horizontal.MouseEnter -= View_MouseEnter; + horizontal.MouseLeave -= View_MouseLeave; + } } vertical.Height = Dim.Fill (showHorizontalScrollIndicator ? 1 : 0); } @@ -330,32 +332,30 @@ namespace Terminal.Gui { public bool ShowVerticalScrollIndicator { get => showVerticalScrollIndicator; set { - if (value == showVerticalScrollIndicator) { - return; - } - - showVerticalScrollIndicator = value; - SetNeedsLayout (); - if (value) { - base.Add (vertical); - vertical.ShowScrollIndicator = value; - vertical.AutoHideScrollBars = autoHideScrollBars; - vertical.OtherScrollBarView = horizontal; - vertical.OtherScrollBarView.ShowScrollIndicator = value; - vertical.MouseEnter += View_MouseEnter; - vertical.MouseLeave += View_MouseLeave; - } else { - Remove (vertical); - vertical.OtherScrollBarView = null; - vertical.MouseEnter -= View_MouseEnter; - vertical.MouseLeave -= View_MouseLeave; + if (value != showVerticalScrollIndicator) { + showVerticalScrollIndicator = value; + SetNeedsLayout (); + if (value) { + vertical.OtherScrollBarView = horizontal; + base.Add (vertical); + vertical.ShowScrollIndicator = value; + vertical.AutoHideScrollBars = autoHideScrollBars; + vertical.OtherScrollBarView.ShowScrollIndicator = value; + vertical.MouseEnter += View_MouseEnter; + vertical.MouseLeave += View_MouseLeave; + } else { + Remove (vertical); + vertical.OtherScrollBarView = null; + vertical.MouseEnter -= View_MouseEnter; + vertical.MouseLeave -= View_MouseLeave; + } } horizontal.Width = Dim.Fill (showVerticalScrollIndicator ? 1 : 0); } } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { SetViewsNeedsDisplay (); @@ -363,22 +363,19 @@ namespace Terminal.Gui { Driver.SetAttribute (GetNormalColor ()); Clear (); - contentView.Redraw (contentView.Bounds); - OnDrawContent (new Rect (ContentOffset, - new Size (Math.Max (Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0), - Math.Max (Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0), 0)))); + contentView.Draw (); if (autoHideScrollBars) { ShowHideScrollBars (); } else { if (ShowVerticalScrollIndicator) { //vertical.SetRelativeLayout (Bounds); - vertical.Redraw (vertical.Bounds); + vertical.Draw (); } if (ShowHorizontalScrollIndicator) { //horizontal.SetRelativeLayout (Bounds); - horizontal.Redraw (horizontal.Bounds); + horizontal.Draw (); } } @@ -445,11 +442,11 @@ namespace Terminal.Gui { if (v) { vertical.SetRelativeLayout (Bounds); - vertical.Redraw (vertical.Bounds); + vertical.Draw (); } if (h) { horizontal.SetRelativeLayout (Bounds); - horizontal.Redraw (horizontal.Bounds); + horizontal.Draw (); } } @@ -545,6 +542,7 @@ namespace Terminal.Gui { me.Flags != MouseFlags.WheeledRight && me.Flags != MouseFlags.WheeledLeft && // me.Flags != MouseFlags.Button1Pressed && me.Flags != MouseFlags.Button1Clicked && !me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition)) { + return false; } diff --git a/Terminal.Gui/Views/SpinnerView/SpinnerView.cs b/Terminal.Gui/Views/SpinnerView/SpinnerView.cs index 231b1eb1d..25ae37ec0 100644 --- a/Terminal.Gui/Views/SpinnerView/SpinnerView.cs +++ b/Terminal.Gui/Views/SpinnerView/SpinnerView.cs @@ -146,7 +146,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (DateTime.Now - _lastRender > TimeSpan.FromMilliseconds (SpinDelay)) { //_currentIdx = (_currentIdx + 1) % Sequence.Length; @@ -186,7 +186,7 @@ namespace Terminal.Gui { _lastRender = DateTime.Now; } - base.Redraw (bounds); + base.OnDrawContent (contentArea); } /// diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index df8570e2a..7ea3766df 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -117,7 +117,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { Move (0, 0); Driver.SetAttribute (GetNormalColor ()); diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 65a36dfaf..c74e7ddac 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -177,26 +177,26 @@ namespace Terminal.Gui { /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { Move (0, 0); Driver.SetAttribute (GetNormalColor ()); if (Style.ShowBorder) { - + // How much space do we need to leave at the bottom to show the tabs int spaceAtBottom = Math.Max (0, GetTabHeight (false) - 1); int startAtY = Math.Max (0, GetTabHeight (true) - 1); - Border.DrawFrame (new Rect (0, startAtY, bounds.Width, - Math.Max (bounds.Height - spaceAtBottom - startAtY, 0)), false); + Border.DrawFrame (new Rect (0, startAtY, Bounds.Width, + Math.Max (Bounds.Height - spaceAtBottom - startAtY, 0)), false); } if (Tabs.Any ()) { - tabsBar.Redraw (tabsBar.Bounds); + tabsBar.OnDrawContent (contentArea); contentView.SetNeedsDisplay (); var savedClip = contentView.ClipToBounds (); - contentView.Redraw (contentView.Bounds); + contentView.Draw (); Driver.Clip = savedClip; } } @@ -468,10 +468,10 @@ namespace Terminal.Gui { return base.OnEnter (view); } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - var tabLocations = host.CalculateViewport (bounds).ToArray (); - var width = bounds.Width; + var tabLocations = host.CalculateViewport (Bounds).ToArray (); + var width = Bounds.Width; Driver.SetAttribute (GetNormalColor ()); if (host.Style.ShowTopLine) { @@ -482,7 +482,6 @@ namespace Terminal.Gui { RenderUnderline (tabLocations, width); Driver.SetAttribute (GetNormalColor ()); - } /// diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 49cf2b567..03b7db565 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -170,7 +170,7 @@ namespace Terminal.Gui { public CollectionNavigatorBase CollectionNavigator { get; set; } /// - /// Initialzies a class using layout. + /// Initializes a class using layout. /// /// The table to display in the control public TableView (ITableSource table) : this () @@ -179,7 +179,7 @@ namespace Terminal.Gui { } /// - /// Initialzies a class using layout. Set the property to begin editing + /// Initializes a class using layout. Set the property to begin editing /// public TableView () : base () { @@ -243,9 +243,9 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); Move (0, 0); @@ -253,12 +253,12 @@ namespace Terminal.Gui { scrollLeftPoint = null; // What columns to render at what X offset in viewport - var columnsToRender = CalculateViewport (bounds).ToArray (); + var columnsToRender = CalculateViewport (Bounds).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 (' ', Bounds.Width)); int line = 0; @@ -270,7 +270,7 @@ namespace Terminal.Gui { └────────────────────┴──────────┴───────────┴──────────────┴─────────┘ */ if (Style.ShowHorizontalHeaderOverline) { - RenderHeaderOverline (line, bounds.Width, columnsToRender); + RenderHeaderOverline (line, Bounds.Width, columnsToRender); line++; } @@ -280,7 +280,7 @@ namespace Terminal.Gui { } if (Style.ShowHorizontalHeaderUnderline) { - RenderHeaderUnderline (line, bounds.Width, columnsToRender); + RenderHeaderUnderline (line, Bounds.Width, columnsToRender); line++; } } @@ -290,7 +290,7 @@ namespace Terminal.Gui { //render the cells for (; line < Bounds.Height; line++) { - ClearLine (line, bounds.Width); + ClearLine (line, Bounds.Width); //work out what Row to render var rowToRender = RowOffset + (line - headerLinesConsumed); @@ -303,7 +303,7 @@ namespace Terminal.Gui { if (rowToRender >= Table.Rows) { if (rowToRender == Table.Rows && Style.ShowHorizontalBottomline) { - RenderBottomLine (line, bounds.Width, columnsToRender); + RenderBottomLine (line, Bounds.Width, columnsToRender); } continue; @@ -373,7 +373,7 @@ namespace Terminal.Gui { } // if the next console column is the lastcolumns end else if (Style.ExpandLastColumn == false && - columnsToRender.Any (r => r.IsVeryLast && r.X + r.Width - 1 == c)) { + columnsToRender.Any (r => r.IsVeryLast && r.X + r.Width - 1 == c)) { rune = Driver.TopTee; } } @@ -419,8 +419,8 @@ namespace Terminal.Gui { private void RenderHeaderUnderline (int row, int availableWidth, ColumnToRender [] columnsToRender) { /* - * First lets work out if we should be rendering scroll indicators - */ + * First lets work out if we should be rendering scroll indicators + */ // are there are visible columns to the left that have been pushed // off the screen due to horizontal scrolling? @@ -445,8 +445,8 @@ namespace Terminal.Gui { } /* - * Now lets draw the line itself - */ + * Now lets draw the line itself + */ // Renders a line below the table headers (when visible) like: // ├──────────┼───────────┼───────────────────┼──────────┼────────┼─────────────┤ @@ -493,7 +493,7 @@ namespace Terminal.Gui { } // if the next console column is the lastcolumns end else if (Style.ExpandLastColumn == false && - columnsToRender.Any (r => r.IsVeryLast && r.X + r.Width - 1 == c)) { + columnsToRender.Any (r => r.IsVeryLast && r.X + r.Width - 1 == c)) { rune = Style.ShowVerticalCellLines ? '┼' : Driver.BottomTee; } } @@ -519,19 +519,16 @@ namespace Terminal.Gui { // for first character render line rune = Driver.LLCorner; - } - // if the next column is the start of a header - else if (columnsToRender.Any (r => r.X == c + 1)) { + } else if (columnsToRender.Any (r => r.X == c + 1)) { + // if the next column is the start of a header rune = Driver.BottomTee; } else if (c == availableWidth - 1) { - // for the last character in the table rune = Driver.LRCorner; - } - // if the next console column is the lastcolumns end - else if (Style.ExpandLastColumn == false && - columnsToRender.Any (r => r.IsVeryLast && r.X + r.Width - 1 == c)) { + } else if (Style.ExpandLastColumn == false && + columnsToRender.Any (r => r.IsVeryLast && r.X + r.Width - 1 == c)) { + // if the next console column is the lastcolumns end rune = Driver.BottomTee; } } @@ -730,7 +727,7 @@ namespace Terminal.Gui { return new string (' ', (int)Math.Floor (toPad / 2.0)) + // round down representation + - new string (' ', (int)Math.Ceiling (toPad / 2.0)); // round up + new string (' ', (int)Math.Ceiling (toPad / 2.0)); // round up } } @@ -739,7 +736,7 @@ namespace Terminal.Gui { } - + /// public override bool ProcessKey (KeyEvent keyEvent) { @@ -1109,7 +1106,7 @@ namespace Terminal.Gui { } return row == SelectedRow && - (col == SelectedColumn || FullRowSelect); + (col == SelectedColumn || FullRowSelect); } private IEnumerable GetMultiSelectedRegionsContaining (int col, int row) @@ -2123,4 +2120,4 @@ namespace Terminal.Gui { } #endregion } -} +} \ No newline at end of file diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index 5ef905de6..a689bf192 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -436,7 +436,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { var selColor = new Attribute (ColorScheme.Focus.Background, ColorScheme.Focus.Foreground); SetSelectedStartSelectedLength (); diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index e85c8568e..f5b9578d7 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -501,7 +501,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (provider == null) { Move (0, 0); @@ -512,7 +512,7 @@ namespace Terminal.Gui { var bgcolor = !IsValid ? Color.BrightRed : ColorScheme.Focus.Background; var textColor = new Attribute (ColorScheme.Focus.Foreground, bgcolor); - var (margin_left, margin_right) = GetMargins (bounds.Width); + var (margin_left, margin_right) = GetMargins (Bounds.Width); Move (0, 0); diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 4c0957e91..912a02f6d 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -197,7 +197,7 @@ namespace Terminal.Gui { var tile = new Tile (); tiles.Add (tile); Add (tile.ContentView); - tile.TitleChanged += (s,e) => SetNeedsDisplay (); + tile.TitleChanged += (s, e) => SetNeedsDisplay (); } LayoutSubviews (); @@ -387,12 +387,12 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { Driver.SetAttribute (ColorScheme.Normal); Clear (); - base.Redraw (bounds); + base.OnDrawContent (contentArea); var lc = new LineCanvas (); @@ -402,11 +402,11 @@ namespace Terminal.Gui { if (IsRootTileView ()) { if (HasBorder ()) { - lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, LineStyle); - lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, LineStyle); + lc.AddLine (new Point (0, 0), Bounds.Width - 1, Orientation.Horizontal, LineStyle); + lc.AddLine (new Point (0, 0), Bounds.Height - 1, Orientation.Vertical, LineStyle); - lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, LineStyle); - lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, LineStyle); + lc.AddLine (new Point (Bounds.Width - 1, Bounds.Height - 1), -Bounds.Width + 1, Orientation.Horizontal, LineStyle); + lc.AddLine (new Point (Bounds.Width - 1, Bounds.Height - 1), -Bounds.Height + 1, Orientation.Vertical, LineStyle); } foreach (var line in allLines) { @@ -432,10 +432,10 @@ namespace Terminal.Gui { } Driver.SetAttribute (ColorScheme.Normal); - foreach (var p in lc.GetMap (bounds)) { + foreach (var p in lc.GetMap (Bounds)) { this.AddRune (p.Key.X, p.Key.Y, p.Value); } - + // Redraw the lines so that focus/drag symbol renders foreach (var line in allLines) { line.DrawSplitterSymbol (); @@ -528,8 +528,8 @@ namespace Terminal.Gui { { bool focusMoved = false; - if(keyEvent.Key == ToggleResizable) { - foreach(var l in splitterLines) { + if (keyEvent.Key == ToggleResizable) { + foreach (var l in splitterLines) { var iniBefore = l.IsInitialized; l.IsInitialized = false; @@ -915,9 +915,9 @@ namespace Terminal.Gui { return base.OnEnter (view); } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); DrawSplitterSymbol (); } diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index 4e8a45098..cbb392e4c 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -751,7 +751,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (!Visible) { return; @@ -759,17 +759,17 @@ namespace Terminal.Gui { if (!_needsDisplay.IsEmpty || _subViewNeedsDisplay || LayoutNeeded) { Driver.SetAttribute (GetNormalColor ()); - Clear (ViewToScreen (bounds)); + Clear (ViewToScreen (Bounds)); LayoutSubviews (); PositionToplevels (); if (this == Application.OverlappedTop) { foreach (var top in Application.OverlappedChildren.AsEnumerable ().Reverse ()) { - if (top.Frame.IntersectsWith (bounds)) { + if (top.Frame.IntersectsWith (Bounds)) { if (top != this && !top.IsCurrentTop && !OutsideTopFrame (top) && top.Visible) { top.SetNeedsLayout (); top.SetNeedsDisplay (top.Bounds); - top.Redraw (top.Bounds); + top.Draw (); top.OnRenderLineCanvas (); } } @@ -777,13 +777,14 @@ namespace Terminal.Gui { } foreach (var view in Subviews) { - if (view.Frame.IntersectsWith (bounds) && !OutsideTopFrame (this)) { + if (view.Frame.IntersectsWith (Bounds) && !OutsideTopFrame (this)) { view.SetNeedsLayout (); view.SetNeedsDisplay (view.Bounds); view.SetSubViewNeedsDisplay (); } } - base.Redraw (Bounds); + + base.OnDrawContent (contentArea); // This is causing the menus drawn incorrectly if UseSubMenusSingleFrame is true //if (this.MenuBar != null && this.MenuBar.IsMenuOpen && this.MenuBar.openMenu != null) { diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs index ec9141f6a..5786315f9 100644 --- a/Terminal.Gui/Views/TreeView/TreeView.cs +++ b/Terminal.Gui/Views/TreeView/TreeView.cs @@ -440,7 +440,7 @@ namespace Terminal.Gui { } /// - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { if (roots == null) { return; @@ -454,20 +454,20 @@ namespace Terminal.Gui { var map = BuildLineMap (); - for (int line = 0; line < bounds.Height; line++) { + for (int line = 0; line < Bounds.Height; line++) { var idxToRender = ScrollOffsetVertical + line; // Is there part of the tree view to render? if (idxToRender < map.Count) { // Render the line - map.ElementAt (idxToRender).Draw (Driver, ColorScheme, line, bounds.Width); + map.ElementAt (idxToRender).Draw (Driver, ColorScheme, line, Bounds.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 (' ', Bounds.Width)); } } } diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index c7af41e1f..42785b00e 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -201,7 +201,7 @@ namespace Terminal.Gui { helpTextView.Width = Dim.Fill (); } else { - contentView.Width = Dim.Fill(); + contentView.Width = Dim.Fill (); } } else { if (helpTextView.Text.Length > 0) { @@ -269,7 +269,8 @@ namespace Terminal.Gui { /// The Wizard will be vertically and horizontally centered in the container. /// After initialization use X, Y, Width, and Height change size and position. /// - public Wizard () : base () { + public Wizard () : base () + { // Using Justify causes the Back and Next buttons to be hard justified against // the left and right edge @@ -302,7 +303,7 @@ namespace Terminal.Gui { AddKeyBinding (Key.Esc, Command.QuitToplevel); } SetNeedsLayout (); - + } private void Wizard_TitleChanged (object sender, TitleEventArgs e) @@ -517,8 +518,8 @@ namespace Terminal.Gui { { SizeStep (newStep); - newStep.EnabledChanged += (s,e)=> UpdateButtonsAndTitle(); - newStep.TitleChanged += (s,e) => UpdateButtonsAndTitle (); + newStep.EnabledChanged += (s, e) => UpdateButtonsAndTitle (); + newStep.TitleChanged += (s, e) => UpdateButtonsAndTitle (); steps.AddLast (newStep); this.Add (newStep); UpdateButtonsAndTitle (); @@ -677,7 +678,7 @@ namespace Terminal.Gui { SetNeedsLayout (); LayoutSubviews (); - Redraw (Bounds); + Draw (); } private void SizeStep (WizardStep step) diff --git a/UICatalog/Scenarios/Animation.cs b/UICatalog/Scenarios/Animation.cs index 541542579..1efddb16e 100644 --- a/UICatalog/Scenarios/Animation.cs +++ b/UICatalog/Scenarios/Animation.cs @@ -15,8 +15,7 @@ using Attribute = Terminal.Gui.Attribute; namespace UICatalog.Scenarios { [ScenarioMetadata (Name: "Animation", Description: "Demonstration of how to render animated images with threading.")] [ScenarioCategory ("Colors")] - public class Animation : Scenario - { + public class Animation : Scenario { private bool isDisposed; public override void Setup () @@ -24,53 +23,50 @@ namespace UICatalog.Scenarios { base.Setup (); var imageView = new ImageView () { - Width = Dim.Fill(), - Height = Dim.Fill()-2, + Width = Dim.Fill (), + Height = Dim.Fill () - 2, }; Win.Add (imageView); - var lbl = new Label("Image by Wikiscient"){ - Y = Pos.AnchorEnd(2) + var lbl = new Label ("Image by Wikiscient") { + Y = Pos.AnchorEnd (2) }; - Win.Add(lbl); + Win.Add (lbl); - var lbl2 = new Label("https://commons.wikimedia.org/wiki/File:Spinning_globe.gif"){ - Y = Pos.AnchorEnd(1) + var lbl2 = new Label ("https://commons.wikimedia.org/wiki/File:Spinning_globe.gif") { + Y = Pos.AnchorEnd (1) }; - Win.Add(lbl2); + Win.Add (lbl2); - var dir = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); - - var f = new FileInfo( - Path.Combine(dir.FullName,"Scenarios","Spinning_globe_dark_small.gif")); - if(!f.Exists) - { - MessageBox.ErrorQuery("Could not find gif","Could not find "+ f.FullName,"Ok"); + var dir = new DirectoryInfo (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location)); + + var f = new FileInfo ( + Path.Combine (dir.FullName, "Scenarios", "Spinning_globe_dark_small.gif")); + if (!f.Exists) { + MessageBox.ErrorQuery ("Could not find gif", "Could not find " + f.FullName, "Ok"); return; } - imageView.SetImage(Image.Load (File.ReadAllBytes (f.FullName))); + imageView.SetImage (Image.Load (File.ReadAllBytes (f.FullName))); - Task.Run(()=>{ - while(!isDisposed) - { + Task.Run (() => { + while (!isDisposed) { // When updating from a Thread/Task always use Invoke - Application.MainLoop.Invoke(()=> - { - imageView.NextFrame(); - imageView.SetNeedsDisplay(); + Application.MainLoop.Invoke (() => { + imageView.NextFrame (); + imageView.SetNeedsDisplay (); }); - Task.Delay(100).Wait(); + Task.Delay (100).Wait (); } }); } - protected override void Dispose(bool disposing) + protected override void Dispose (bool disposing) { isDisposed = true; - base.Dispose(disposing); + base.Dispose (disposing); } // This is a C# port of https://github.com/andraaspar/bitmap-to-braille by Andraaspar @@ -78,18 +74,17 @@ namespace UICatalog.Scenarios { /// /// Renders an image as unicode Braille. /// - public class BitmapToBraille - { + public class BitmapToBraille { public const int CHAR_WIDTH = 2; public const int CHAR_HEIGHT = 4; const string CHARS = " ⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿"; - public int WidthPixels {get; } + public int WidthPixels { get; } public int HeightPixels { get; } - public Func PixelIsLit {get;} + public Func PixelIsLit { get; } public BitmapToBraille (int widthPixels, int heightPixels, Func pixelIsLit) { @@ -98,14 +93,15 @@ namespace UICatalog.Scenarios { PixelIsLit = pixelIsLit; } - public string GenerateImage() { - int imageHeightChars = (int) Math.Ceiling((double)HeightPixels / CHAR_HEIGHT); - int imageWidthChars = (int) Math.Ceiling((double)WidthPixels / CHAR_WIDTH); + public string GenerateImage () + { + int imageHeightChars = (int)Math.Ceiling ((double)HeightPixels / CHAR_HEIGHT); + int imageWidthChars = (int)Math.Ceiling ((double)WidthPixels / CHAR_WIDTH); - var result = new StringBuilder(); + var result = new StringBuilder (); for (int y = 0; y < imageHeightChars; y++) { - + for (int x = 0; x < imageWidthChars; x++) { int baseX = x * CHAR_WIDTH; int baseY = y * CHAR_HEIGHT; @@ -119,28 +115,28 @@ namespace UICatalog.Scenarios { int bitmapY = baseY + charY; bool pixelExists = bitmapX < WidthPixels && bitmapY < HeightPixels; - if (pixelExists && PixelIsLit(bitmapX, bitmapY)) { + if (pixelExists && PixelIsLit (bitmapX, bitmapY)) { charIndex += value; } value *= 2; } } - result.Append(CHARS[charIndex]); + result.Append (CHARS [charIndex]); } - result.Append('\n'); + result.Append ('\n'); } - return result.ToString().TrimEnd(); - } + return result.ToString ().TrimEnd (); + } } class ImageView : View { private int frameCount; private int currentFrame = 0; - private Image[] fullResImages; - private Image[] matchSizes; - private string[] brailleCache; + private Image [] fullResImages; + private Image [] matchSizes; + private string [] brailleCache; Rect oldSize = Rect.Empty; @@ -148,82 +144,76 @@ namespace UICatalog.Scenarios { { frameCount = image.Frames.Count; - fullResImages = new Image[frameCount]; - matchSizes = new Image[frameCount]; - brailleCache = new string[frameCount]; + fullResImages = new Image [frameCount]; + matchSizes = new Image [frameCount]; + brailleCache = new string [frameCount]; - for(int i=0;i[frameCount]; - brailleCache = new string[frameCount]; - oldSize = bounds; + matchSizes = new Image [frameCount]; + brailleCache = new string [frameCount]; + oldSize = Bounds; } - var imgScaled = matchSizes[currentFrame]; - var braille = brailleCache[currentFrame]; + var imgScaled = matchSizes [currentFrame]; + var braille = brailleCache [currentFrame]; + + if (imgScaled == null) { + var imgFull = fullResImages [currentFrame]; - if(imgScaled == null) - { - var imgFull = fullResImages[currentFrame]; - // keep aspect ratio - var newSize = Math.Min(bounds.Width,bounds.Height); + var newSize = Math.Min (Bounds.Width, Bounds.Height); // generate one - matchSizes[currentFrame] = imgScaled = imgFull.Clone ( + matchSizes [currentFrame] = imgScaled = imgFull.Clone ( x => x.Resize ( newSize * BitmapToBraille.CHAR_HEIGHT, newSize * BitmapToBraille.CHAR_HEIGHT)); } - if(braille == null) - { - brailleCache[currentFrame] = braille = GetBraille(matchSizes[currentFrame]); + if (braille == null) { + brailleCache [currentFrame] = braille = GetBraille (matchSizes [currentFrame]); } - var lines = braille.Split('\n'); + var lines = braille.Split ('\n'); - for(int y = 0; y < lines.Length;y++) - { - var line = lines[y]; - for(int x = 0;x img) { - var braille = new BitmapToBraille( + var braille = new BitmapToBraille ( img.Width, img.Height, - (x,y)=>IsLit(img,x,y)); + (x, y) => IsLit (img, x, y)); - return braille.GenerateImage(); + return braille.GenerateImage (); } private bool IsLit (Image img, int x, int y) { - var rgb = img[x,y]; + var rgb = img [x, y]; return rgb.R + rgb.G + rgb.B > 50; } } diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 221afc8d2..f05cd5ec3 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -36,7 +36,7 @@ namespace UICatalog.Scenarios { var jumpLabel = new Label ("Jump To Glyph:") { X = Pos.Right (_charMap) + 1, Y = Pos.Y (_charMap) }; Win.Add (jumpLabel); - var jumpEdit = new TextField () { X = Pos.Right (jumpLabel) + 1, Y = Pos.Y (_charMap), Width = 10, Caption = "e.g. 01BE3"}; + var jumpEdit = new TextField () { X = Pos.Right (jumpLabel) + 1, Y = Pos.Y (_charMap), Width = 10, Caption = "e.g. 01BE3" }; Win.Add (jumpEdit); var errorLabel = new Label ("") { X = Pos.Right (jumpEdit) + 1, Y = Pos.Y (_charMap), ColorScheme = Colors.ColorSchemes ["error"] }; Win.Add (errorLabel); @@ -81,7 +81,7 @@ namespace UICatalog.Scenarios { X = Pos.X (label) + 1, Y = Pos.Bottom (label), Width = radioItems.Max (r => r.radioLabel.Length) + 2, - Height = Dim.Fill(1), + Height = Dim.Fill (1), SelectedItem = 0 }; jumpList.SelectedItemChanged += (s, args) => { @@ -122,18 +122,23 @@ namespace UICatalog.Scenarios { set { _selected = value; int row = (int)_selected / 16; - int height = (Bounds.Height / ROW_HEIGHT) - 1; + int height = (Bounds.Height / ROW_HEIGHT) - (ShowHorizontalScrollIndicator ? 2 : 1); if (row + ContentOffset.Y < 0) { // Moving up. - ContentOffset = new Point (0, row); + ContentOffset = new Point (ContentOffset.X, row); } else if (row + ContentOffset.Y >= height) { // Moving down. - ContentOffset = new Point (0, Math.Min (row, (row - height) + 1)); - - } else { - //ContentOffset = new Point (0, Math.Min (row, (row - height) - 1)); + ContentOffset = new Point (ContentOffset.X, Math.Min (row, row - height + ROW_HEIGHT)); + } + int col = (((int)_selected - (row * 16)) * COLUMN_WIDTH); + int width = (Bounds.Width / COLUMN_WIDTH * COLUMN_WIDTH) - (ShowVerticalScrollIndicator ? RowLabelWidth + 1 : RowLabelWidth); + if (col + ContentOffset.X < 0) { + // Moving left. + ContentOffset = new Point (col, ContentOffset.Y); + } else if (col + ContentOffset.X >= width) { + // Moving right. + ContentOffset = new Point (Math.Min (col, col - width + COLUMN_WIDTH), ContentOffset.Y); } - SetNeedsDisplay (); } } @@ -146,7 +151,7 @@ namespace UICatalog.Scenarios { public static uint MaxCodePointVal => 0x10FFFF; - public static int RowLabelWidth => $"U+{MaxCodePointVal:x5}".Length + 1; + public static int RowLabelWidth => $"U+{MaxCodePointVal:x5}".Length + 1; public static int RowWidth => RowLabelWidth + (COLUMN_WIDTH * 16); public CharMap () @@ -154,20 +159,7 @@ namespace UICatalog.Scenarios { ColorScheme = Colors.Dialog; CanFocus = true; - ContentSize = new Size (CharMap.RowWidth, (int)(MaxCodePointVal / 16 + 1)); - ShowVerticalScrollIndicator = true; - ShowHorizontalScrollIndicator = false; - LayoutComplete += (s, args) => { - if (Bounds.Width < RowWidth) { - ShowHorizontalScrollIndicator = true; - } else { - ShowHorizontalScrollIndicator = false; - // Snap 1st column into view if it's been scrolled horizontally - ContentOffset = new Point (0, ContentOffset.Y); - SetNeedsDisplay (); - } - }; - DrawContent += CharMap_DrawContent; + ContentSize = new Size (CharMap.RowWidth, (int)(MaxCodePointVal / 16 + (ShowHorizontalScrollIndicator ? 2 : 1))); AddCommand (Command.ScrollUp, () => { if (SelectedGlyph >= 16) { @@ -188,19 +180,19 @@ namespace UICatalog.Scenarios { return true; }); AddCommand (Command.ScrollRight, () => { - if (SelectedGlyph < MaxCodePointVal - 1) { + if (SelectedGlyph < MaxCodePointVal) { SelectedGlyph++; } return true; }); AddCommand (Command.PageUp, () => { var page = (uint)(Bounds.Height / ROW_HEIGHT - 1) * 16; - SelectedGlyph -= Math.Min(page, SelectedGlyph); + SelectedGlyph -= Math.Min (page, SelectedGlyph); return true; }); AddCommand (Command.PageDown, () => { var page = (uint)(Bounds.Height / ROW_HEIGHT - 1) * 16; - SelectedGlyph += Math.Min(page, MaxCodePointVal -SelectedGlyph); + SelectedGlyph += Math.Min (page, MaxCodePointVal - SelectedGlyph); return true; }); AddCommand (Command.TopHome, () => { @@ -211,6 +203,11 @@ namespace UICatalog.Scenarios { SelectedGlyph = MaxCodePointVal; return true; }); + AddKeyBinding (Key.Enter, Command.Accept); + AddCommand (Command.Accept, () => { + MessageBox.Query ("Glyph", $"{new Rune ((uint)SelectedGlyph)} U+{SelectedGlyph:x4}", "Ok"); + return true; + }); MouseClick += Handle_MouseClick; Application.Driver.SetCursorVisibility (CursorVisibility.Invisible); @@ -226,9 +223,35 @@ namespace UICatalog.Scenarios { Clipboard.Contents = $"{new Rune (SelectedGlyph)}"; } - private void CharMap_DrawContent (object sender, DrawEventArgs e) + public override void OnDrawContent (Rect contentArea) { - Rect viewport = e.Rect; + base.OnDrawContent (contentArea); + + if (ShowHorizontalScrollIndicator && ContentSize.Height < (int)(MaxCodePointVal / 16 + 2)) { + ContentSize = new Size (CharMap.RowWidth, (int)(MaxCodePointVal / 16 + 2)); + int row = (int)_selected / 16; + int col = (((int)_selected - (row * 16)) * COLUMN_WIDTH); + int width = (Bounds.Width / COLUMN_WIDTH * COLUMN_WIDTH) - (ShowVerticalScrollIndicator ? RowLabelWidth + 1 : RowLabelWidth); + if (col + ContentOffset.X >= width) { + // Snap to the selected glyph. + ContentOffset = new Point (Math.Min (col, col - width + COLUMN_WIDTH), ContentOffset.Y == -ContentSize.Height + Bounds.Height ? ContentOffset.Y - 1 : ContentOffset.Y); + } else { + ContentOffset = new Point (ContentOffset.X - col, ContentOffset.Y == -ContentSize.Height + Bounds.Height ? ContentOffset.Y - 1 : ContentOffset.Y); + } + SetNeedsDisplay (); + } else if (!ShowHorizontalScrollIndicator && ContentSize.Height > (int)(MaxCodePointVal / 16 + 1)) { + ContentSize = new Size (CharMap.RowWidth, (int)(MaxCodePointVal / 16 + 1)); + // Snap 1st column into view if it's been scrolled horizontally + ContentOffset = new Point (0, ContentOffset.Y < -ContentSize.Height + Bounds.Height ? ContentOffset.Y - 1 : ContentOffset.Y); + SetNeedsDisplay (); + } + } + + public override void OnDrawContentComplete (Rect contentArea) + { + Rect viewport = new Rect (ContentOffset, + new Size (Math.Max (Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0), + Math.Max (Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0), 0))); var oldClip = Driver.Clip; Driver.Clip = Bounds; @@ -330,12 +353,6 @@ namespace UICatalog.Scenarios { _contextMenu.Show (); } } - - protected override void Dispose (bool disposing) - { - DrawContent -= CharMap_DrawContent; - base.Dispose (disposing); - } } class UnicodeRange { @@ -348,7 +365,7 @@ namespace UICatalog.Scenarios { this.End = end; this.Category = category; } - + public static List Ranges = new List { new UnicodeRange (0x0000, 0x001F, "ASCII Control Characters"), new UnicodeRange (0x0080, 0x009F, "C0 Control Characters"), @@ -359,8 +376,8 @@ namespace UICatalog.Scenarios { new UnicodeRange(0x2190, 0x21ff,"Arrows" ), new UnicodeRange(0x2200, 0x22ff,"Mathematical symbols"), new UnicodeRange(0x2300, 0x23ff,"Miscellaneous Technical"), - new UnicodeRange(0x24B6, 0x24e9,"Circled Latin Capital Letters"), - new UnicodeRange(0x1F130, 0x1F149,"Squared Latin Capital Letters"), + new UnicodeRange(0x24B6, 0x24e9,"Circled Latin Capital Letters"), + new UnicodeRange(0x1F130, 0x1F149,"Squared Latin Capital Letters"), new UnicodeRange(0x2500, 0x25ff,"Box Drawing & Geometric Shapes"), new UnicodeRange(0x2600, 0x26ff,"Miscellaneous Symbols"), new UnicodeRange(0x2700, 0x27ff,"Dingbats"), @@ -496,5 +513,5 @@ namespace UICatalog.Scenarios { new UnicodeRange((uint)(CharMap.MaxCodePointVal - 16), (uint)CharMap.MaxCodePointVal,"End"), }; } - + } diff --git a/UICatalog/Scenarios/LabelsAsButtons.cs b/UICatalog/Scenarios/LabelsAsButtons.cs index bfdaf8152..e55a83eb1 100644 --- a/UICatalog/Scenarios/LabelsAsButtons.cs +++ b/UICatalog/Scenarios/LabelsAsButtons.cs @@ -73,7 +73,7 @@ namespace UICatalog.Scenarios { Win.Add (colorLabel); x += colorLabel.Text.Length + 2; } - Application.Top.Ready += (s,e) => Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Ready += (s,e) => Application.Top.Draw (); Label Label; Win.Add (Label = new Label ("A super long _Label that will probably expose a bug in clipping or wrapping of text. Will it?") { diff --git a/UICatalog/Scenarios/LineDrawing.cs b/UICatalog/Scenarios/LineDrawing.cs index 58b617349..3101a3bc4 100644 --- a/UICatalog/Scenarios/LineDrawing.cs +++ b/UICatalog/Scenarios/LineDrawing.cs @@ -68,16 +68,16 @@ namespace UICatalog.Scenarios { grid.AddLine (new Point (0, 2), width + 1, Orientation.Horizontal, LineStyle.Single); grid.AddLine (new Point (0, 4), width + 1, Orientation.Horizontal, LineStyle.Single); } - public override void Redraw (Rect bounds) + + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); Driver.SetAttribute (new Terminal.Gui.Attribute (Color.DarkGray, ColorScheme.Normal.Background)); - - - foreach(var p in grid.GetMap(bounds)) - { - this.AddRune(p.Key.X,p.Key.Y,p.Value); + + + foreach (var p in grid.GetMap (Bounds)) { + this.AddRune (p.Key.X, p.Key.Y, p.Value); } foreach (var swatch in swatches) { @@ -192,9 +192,9 @@ namespace UICatalog.Scenarios { currentColor = canvases.Count - 1; } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); foreach (var kvp in colorLayers) { @@ -202,12 +202,12 @@ namespace UICatalog.Scenarios { var canvas = canvases [kvp.Value]; - foreach(var p in canvas.GetMap(bounds)) - { - this.AddRune(p.Key.X,p.Key.Y,p.Value); + foreach (var p in canvas.GetMap (Bounds)) { + this.AddRune (p.Key.X, p.Key.Y, p.Value); } } } + public override bool OnMouseEvent (MouseEvent mouseEvent) { @@ -229,13 +229,12 @@ namespace UICatalog.Scenarios { length = end.X - start.X; } - if(length > 0) { + if (length > 0) { length++; - } - else { + } else { length--; } - + canvases [currentColor].AddLine ( start, diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs index 033e99e1c..d844753a1 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -27,7 +27,7 @@ namespace UICatalog.Scenarios { throw new NotImplementedException (); } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { //Point pos = new Point (region.X, region.Y); Driver.SetAttribute (ColorScheme.Focus); @@ -60,7 +60,7 @@ namespace UICatalog.Scenarios { return new Size (w, h); } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { Driver.SetAttribute (ColorScheme.Focus); var f = Frame; diff --git a/UICatalog/Scenarios/Snake.cs b/UICatalog/Scenarios/Snake.cs index 8799d177f..b6a5ae2eb 100644 --- a/UICatalog/Scenarios/Snake.cs +++ b/UICatalog/Scenarios/Snake.cs @@ -59,7 +59,7 @@ namespace UICatalog.Scenarios { private class SnakeView : View { - private Attribute red = new Terminal.Gui.Attribute (Color.Red,Color.Black); + private Attribute red = new Terminal.Gui.Attribute (Color.Red, Color.Black); private Attribute white = new Terminal.Gui.Attribute (Color.White, Color.Black); public SnakeState State { get; } @@ -78,9 +78,9 @@ namespace UICatalog.Scenarios { }; } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { - base.Redraw (bounds); + base.OnDrawContent (contentArea); Driver.SetAttribute (white); Clear (); @@ -110,7 +110,7 @@ namespace UICatalog.Scenarios { } - foreach(var p in canvas.GetMap (bounds)) { + foreach (var p in canvas.GetMap (Bounds)) { AddRune (p.Key.X, p.Key.Y, p.Value); } @@ -195,7 +195,7 @@ namespace UICatalog.Scenarios { Apple = GetNewRandomApplePoint (); var delta = 5; - if(SleepAfterAdvancingState < 40) { + if (SleepAfterAdvancingState < 40) { delta = 3; } if (SleepAfterAdvancingState < 30) { diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs index e6df95c3c..ae357912c 100644 --- a/UICatalog/Scenarios/Text.cs +++ b/UICatalog/Scenarios/Text.cs @@ -32,8 +32,8 @@ namespace UICatalog.Scenarios { void TextField_TextChanging (object sender, TextChangingEventArgs e) { singleWordGenerator.AllSuggestions = Regex.Matches (e.NewText.ToString (), "\\w+") - .Select (s => s.Value) - .Distinct ().ToList (); + .Select (s => s.Value) + .Distinct ().ToList (); } Win.Add (textField); @@ -62,8 +62,8 @@ namespace UICatalog.Scenarios { void TextView_DrawContent (object sender, DrawEventArgs e) { singleWordGenerator.AllSuggestions = Regex.Matches (textView.Text.ToString (), "\\w+") - .Select (s => s.Value) - .Distinct ().ToList (); + .Select (s => s.Value) + .Distinct ().ToList (); } Win.Add (textView); @@ -78,7 +78,7 @@ namespace UICatalog.Scenarios { // Use ContentChanged to detect if the user has typed something in a TextView. // The TextChanged property is only fired if the TextView.Text property is // explicitly set - textView.ContentsChanged += (s,a) => { + textView.ContentsChanged += (s, a) => { labelMirroringTextView.Enabled = !labelMirroringTextView.Enabled; labelMirroringTextView.Text = textView.Text; }; @@ -97,7 +97,7 @@ namespace UICatalog.Scenarios { Y = Pos.Top (chxMultiline), Checked = textView.WordWrap }; - chxWordWrap.Toggled += (s,e) => textView.WordWrap = (bool)e.NewValue; + chxWordWrap.Toggled += (s, e) => textView.WordWrap = (bool)e.NewValue; Win.Add (chxWordWrap); // TextView captures Tabs (so users can enter /t into text) by default; @@ -121,7 +121,7 @@ namespace UICatalog.Scenarios { Key keyTab = textView.GetKeyFromCommand (Command.Tab); Key keyBackTab = textView.GetKeyFromCommand (Command.BackTab); - chxCaptureTabs.Toggled += (s,e) => { + chxCaptureTabs.Toggled += (s, e) => { if (e.NewValue == true) { textView.AddKeyBinding (keyTab, Command.Tab); textView.AddKeyBinding (keyBackTab, Command.BackTab); @@ -149,7 +149,7 @@ namespace UICatalog.Scenarios { }; var array = ((MemoryStream)hexEditor.Source).ToArray (); labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length); - hexEditor.Edited += (s,kv) => { + hexEditor.Edited += (s, kv) => { hexEditor.ApplyEdits (); var array = ((MemoryStream)hexEditor.Source).ToArray (); labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length); @@ -232,9 +232,9 @@ namespace UICatalog.Scenarios { X = 1 }; var appendAutocompleteTextField = new TextField () { - X = Pos.Right(labelAppendAutocomplete), + X = Pos.Right (labelAppendAutocomplete), Y = labelAppendAutocomplete.Y, - Width = Dim.Fill() + Width = Dim.Fill () }; appendAutocompleteTextField.Autocomplete = new AppendAutocomplete (appendAutocompleteTextField); appendAutocompleteTextField.Autocomplete.SuggestionGenerator = new SingleWordSuggestionGenerator { diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index 698e179e4..07dbbc4aa 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -420,9 +420,9 @@ namespace Terminal.Gui.ApplicationTests { Init (); var top = Application.Top; var count = 0; - top.Loaded += (s,e) => count++; - top.Ready += (s,e) => count++; - top.Unloaded += (s,e) => count++; + top.Loaded += (s, e) => count++; + top.Ready += (s, e) => count++; + top.Unloaded += (s, e) => count++; Application.Iteration = () => Application.RequestStop (); Application.Run (); Application.Shutdown (); @@ -461,7 +461,7 @@ namespace Terminal.Gui.ApplicationTests { #endregion [Fact, AutoInitShutdown] - public void Begin_Sets_Application_Top_To_Console_Size() + public void Begin_Sets_Application_Top_To_Console_Size () { Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame); @@ -485,15 +485,15 @@ namespace Terminal.Gui.ApplicationTests { // t1, t2, t3, d, t4 var iterations = 5; - t1.Ready += (s,e) => { + t1.Ready += (s, e) => { Assert.Equal (t1, Application.Top); Application.Run (t2); }; - t2.Ready += (s,e) => { + t2.Ready += (s, e) => { Assert.Equal (t2, Application.Top); Application.Run (t3); }; - t3.Ready += (s,e) => { + t3.Ready += (s, e) => { Assert.Equal (t3, Application.Top); Application.Run (d); }; @@ -509,7 +509,7 @@ namespace Terminal.Gui.ApplicationTests { t2.RequestStop (); }; // Now this will close the OverlappedContainer when all OverlappedChildren was closed - t2.Closed += (s,_) => { + t2.Closed += (s, _) => { t1.RequestStop (); }; Application.Iteration += () => { @@ -741,7 +741,7 @@ namespace Terminal.Gui.ApplicationTests { var top = Application.Top; var isQuiting = false; - top.Closing += (s,e) => { + top.Closing += (s, e) => { isQuiting = true; e.Cancel = true; }; @@ -902,7 +902,9 @@ namespace Terminal.Gui.ApplicationTests { Assert.Null (Application.MouseGrabView); } else if (iterations == 1) { - Assert.Equal (sv, Application.MouseGrabView); + // Application.MouseGrabView is null because + // another toplevel (Dialog) was opened + Assert.Null (Application.MouseGrabView); ReflectionTools.InvokePrivate ( typeof (Application), @@ -913,7 +915,7 @@ namespace Terminal.Gui.ApplicationTests { Flags = MouseFlags.ReportMousePosition }); - Assert.Equal (sv, Application.MouseGrabView); + Assert.Null (Application.MouseGrabView); ReflectionTools.InvokePrivate ( typeof (Application), diff --git a/UnitTests/ConsoleDrivers/ColorTests.cs b/UnitTests/ConsoleDrivers/ColorTests.cs index 2ac8ad14d..ef619945f 100644 --- a/UnitTests/ConsoleDrivers/ColorTests.cs +++ b/UnitTests/ConsoleDrivers/ColorTests.cs @@ -41,7 +41,7 @@ namespace Terminal.Gui.DriverTests { var scheme = new ColorScheme (); var lbl = new Label (); lbl.ColorScheme = scheme; - lbl.Redraw (lbl.Bounds); + lbl.Draw (); } [Fact] diff --git a/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs b/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs index 4efde7001..a6b061021 100644 --- a/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs +++ b/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs @@ -270,7 +270,7 @@ namespace Terminal.Gui.DriverTests { Assert.Equal (new Rect (0, 0, 20, 8), pos); Assert.True (dlg.ProcessKey (new KeyEvent (Key.Tab, new KeyModifiers ()))); - dlg.Redraw (dlg.Bounds); + dlg.Draw (); expected = @" ┌──────────────────┐ diff --git a/UnitTests/Drawing/LineCanvasTests.cs b/UnitTests/Drawing/LineCanvasTests.cs index a06cb2d9f..cff1953d9 100644 --- a/UnitTests/Drawing/LineCanvasTests.cs +++ b/UnitTests/Drawing/LineCanvasTests.cs @@ -417,7 +417,7 @@ namespace Terminal.Gui.DrawingTests { var v = GetCanvas (out var canvas); canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, style); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -431,7 +431,7 @@ namespace Terminal.Gui.DrawingTests { var v = GetCanvas (out var canvas); canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Double); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -447,7 +447,7 @@ namespace Terminal.Gui.DrawingTests { var v = GetCanvas (out var canvas); canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, style); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -462,7 +462,7 @@ namespace Terminal.Gui.DrawingTests { var v = GetCanvas (out var canvas); canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, LineStyle.Double); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -482,7 +482,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Single); canvas.AddLine (new Point (0, 1), 2, Orientation.Vertical, LineStyle.Single); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -502,7 +502,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, LineStyle.Single); canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, LineStyle.Single); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -591,7 +591,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Rounded); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Rounded); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -617,7 +617,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Double); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Double); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -645,7 +645,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, thinStyle); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Double); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -674,7 +674,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Double); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, thinStyle); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -703,7 +703,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Heavy); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Heavy); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -732,7 +732,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, thinStyle); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Heavy); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -762,7 +762,7 @@ namespace Terminal.Gui.DrawingTests { canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Heavy); canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, thinStyle); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" @@ -858,7 +858,7 @@ namespace Terminal.Gui.DrawingTests { lc.AddLine (new Point (x1, y1), length, o1, s1); - v.Redraw (v.Bounds); + v.Draw (); TestHelpers.AssertDriverContentsAre (expected, output); } diff --git a/UnitTests/FileServices/FileDialogTests.cs b/UnitTests/FileServices/FileDialogTests.cs index 1d73f0ad4..aa0f8ea16 100644 --- a/UnitTests/FileServices/FileDialogTests.cs +++ b/UnitTests/FileServices/FileDialogTests.cs @@ -381,8 +381,8 @@ namespace Terminal.Gui.FileServicesTests { fd.Style.Culture = new CultureInfo ("en-US"); - fd.Redraw (fd.Bounds); - + fd.Draw (); + string expected = @" ┌──────────────────────────────────────────────────────────────────┐ @@ -416,7 +416,7 @@ namespace Terminal.Gui.FileServicesTests { fd.Style.Culture = new CultureInfo ("en-US"); - fd.Redraw (fd.Bounds); + fd.Draw (); string expected = @@ -465,7 +465,7 @@ namespace Terminal.Gui.FileServicesTests { var exe = new Attribute (Color.BrightYellow); fd.Style.ColorSchemeExeOrRecommended = GetColorScheme (exe); - fd.Redraw (fd.Bounds); + fd.Draw (); TestHelpers.AssertDriverUsedColors (other,dir,img,exe); } diff --git a/UnitTests/Input/ResponderTests.cs b/UnitTests/Input/ResponderTests.cs index 66b8b85f7..eaeb54dca 100644 --- a/UnitTests/Input/ResponderTests.cs +++ b/UnitTests/Input/ResponderTests.cs @@ -40,7 +40,7 @@ namespace Terminal.Gui.InputTests { { } - + public class DerivedView : View { public DerivedView () { @@ -80,10 +80,10 @@ namespace Terminal.Gui.InputTests { // OnKeyDown is defined on DerivedView Assert.True (Responder.IsOverridden (new DerivedView () { Text = "DerivedView overrides OnKeyDown" }, "OnKeyDown")); - + // ScrollBarView overrides both MouseEvent (from Responder) and Redraw (from View) Assert.True (Responder.IsOverridden (new ScrollBarView () { Text = "ScrollBarView overrides MouseEvent" }, "MouseEvent")); - Assert.True (Responder.IsOverridden (new ScrollBarView () { Text = "ScrollBarView overrides Redraw" }, "Redraw")); + Assert.True (Responder.IsOverridden (new ScrollBarView () { Text = "ScrollBarView overrides OnDrawContent" }, "OnDrawContent")); Assert.True (Responder.IsOverridden (new Button () { Text = "Button overrides MouseEvent" }, "MouseEvent")); } diff --git a/UnitTests/Text/AutocompleteTests.cs b/UnitTests/Text/AutocompleteTests.cs index f9de6e9c8..85dd047d8 100644 --- a/UnitTests/Text/AutocompleteTests.cs +++ b/UnitTests/Text/AutocompleteTests.cs @@ -93,7 +93,7 @@ namespace Terminal.Gui.TextTests { Assert.Equal (0, tv.Autocomplete.SelectedIdx); Assert.Empty (tv.Autocomplete.Suggestions); Assert.True (tv.ProcessKey (new KeyEvent (Key.F, new KeyModifiers ()))); - top.Redraw (tv.Bounds); + top.Draw (); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); Assert.Equal (2, tv.Autocomplete.Suggestions.Count); @@ -102,7 +102,7 @@ namespace Terminal.Gui.TextTests { Assert.Equal (0, tv.Autocomplete.SelectedIdx); Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions[tv.Autocomplete.SelectedIdx].Replacement); Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); - top.Redraw (tv.Bounds); + top.Draw (); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); Assert.Equal (2, tv.Autocomplete.Suggestions.Count); @@ -111,7 +111,7 @@ namespace Terminal.Gui.TextTests { Assert.Equal (1, tv.Autocomplete.SelectedIdx); Assert.Equal ("feature", tv.Autocomplete.Suggestions[tv.Autocomplete.SelectedIdx].Replacement); Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); - top.Redraw (tv.Bounds); + top.Draw (); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); Assert.Equal (2, tv.Autocomplete.Suggestions.Count); @@ -120,7 +120,7 @@ namespace Terminal.Gui.TextTests { Assert.Equal (0, tv.Autocomplete.SelectedIdx); Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions[tv.Autocomplete.SelectedIdx].Replacement); Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()))); - top.Redraw (tv.Bounds); + top.Draw (); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); Assert.Equal (2, tv.Autocomplete.Suggestions.Count); @@ -129,7 +129,7 @@ namespace Terminal.Gui.TextTests { Assert.Equal (1, tv.Autocomplete.SelectedIdx); Assert.Equal ("feature", tv.Autocomplete.Suggestions[tv.Autocomplete.SelectedIdx].Replacement); Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()))); - top.Redraw (tv.Bounds); + top.Draw (); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); Assert.Equal (2, tv.Autocomplete.Suggestions.Count); @@ -138,14 +138,14 @@ namespace Terminal.Gui.TextTests { Assert.Equal (0, tv.Autocomplete.SelectedIdx); Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions[tv.Autocomplete.SelectedIdx].Replacement); Assert.True (tv.Autocomplete.Visible); - top.Redraw (tv.Bounds); + top.Draw (); Assert.True (tv.ProcessKey (new KeyEvent (tv.Autocomplete.CloseKey, new KeyModifiers ()))); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); Assert.Empty (tv.Autocomplete.Suggestions); Assert.Equal (3, g.AllSuggestions.Count); Assert.False (tv.Autocomplete.Visible); - top.Redraw (tv.Bounds); + top.Draw (); Assert.True (tv.ProcessKey (new KeyEvent (tv.Autocomplete.Reopen, new KeyModifiers ()))); Assert.Equal ($"F Fortunately super feature.", tv.Text); Assert.Equal (new Point (1, 0), tv.CursorPosition); diff --git a/UnitTests/Types/RectTests.cs b/UnitTests/Types/RectTests.cs index 06fbfa82c..8cc596c1d 100644 --- a/UnitTests/Types/RectTests.cs +++ b/UnitTests/Types/RectTests.cs @@ -371,5 +371,43 @@ namespace Terminal.Gui.TypeTests { Assert.Equal (new Rect (-2, -2, 9, 9), result); } + [Fact] + public void Rect_Contains () + { + var rect = new Rect (0, 0, 3, 3); + Assert.True (rect.Contains (new Point (1, 1))); + Assert.True (rect.Contains (new Point (1, 2))); + Assert.True (rect.Contains (new Point (2, 1))); + Assert.True (rect.Contains (new Point (2, 2))); + + Assert.False (rect.Contains (new Point (-1, 1))); + Assert.False (rect.Contains (new Point (1, -1))); + Assert.False (rect.Contains (new Point (3, 2))); + Assert.False (rect.Contains (new Point (2, 3))); + Assert.False (rect.Contains (new Point (3, 3))); + + Assert.True (rect.Contains (new Rect (1, 1, 2, 2))); + Assert.True (rect.Contains (new Rect (1, 2, 2, 1))); + Assert.True (rect.Contains (new Rect (2, 1, 1, 2))); + Assert.True (rect.Contains (new Rect (2, 2, 1, 1))); + Assert.True (rect.Contains (new Rect (0, 0, 3, 3))); + + Assert.False (rect.Contains (new Rect (-1, 1, 3, 3))); + Assert.False (rect.Contains (new Rect (1, -1, 3, 3))); + Assert.False (rect.Contains (new Rect (3, 2, 3, 3))); + Assert.False (rect.Contains (new Rect (2, 3, 3, 3))); + Assert.False (rect.Contains (new Rect (3, 3, 3, 3))); + + Assert.True (rect.Contains (1, 1)); + Assert.True (rect.Contains (1, 2)); + Assert.True (rect.Contains (2, 1)); + Assert.True (rect.Contains (2, 2)); + + Assert.False (rect.Contains (-1, 1)); + Assert.False (rect.Contains (1, -1)); + Assert.False (rect.Contains (3, 2)); + Assert.False (rect.Contains (2, 3)); + Assert.False (rect.Contains (3, 3)); + } } } diff --git a/UnitTests/View/Layout/LayoutTests.cs b/UnitTests/View/Layout/LayoutTests.cs index 598c34647..03d5258ef 100644 --- a/UnitTests/View/Layout/LayoutTests.cs +++ b/UnitTests/View/Layout/LayoutTests.cs @@ -542,7 +542,7 @@ Y Assert.Equal (new Rect (0, 0, 3, 1), lbl._needsDisplay); Assert.Equal (new Rect (0, 0, 0, 0), lbl.SuperView._needsDisplay); Assert.True (lbl.SuperView.LayoutNeeded); - lbl.SuperView.Redraw (lbl.SuperView.Bounds); + lbl.SuperView.Draw (); Assert.Equal ("12 ", GetContents ()); string GetContents () @@ -624,7 +624,7 @@ Y Assert.Equal (new Rect (0, 0, 32, 32), pos); verticalView.Text = $"最初の行{Environment.NewLine}二行目"; - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); Assert.Equal (new Rect (0, 3, 2, 20), verticalView.Frame); expected = @" ┌──────────────────────────────┐ @@ -1051,7 +1051,7 @@ Y Assert.Equal (new Rect (0, 0, 22, 22), pos); verticalView.Text = $"最初_の行二行目"; - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); Assert.True (horizontalView.AutoSize); Assert.True (verticalView.AutoSize); // height was initialized with 8 and can only grow or keep initial value @@ -1652,8 +1652,8 @@ Y break; } _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); - } + [Theory, AutoInitShutdown] [InlineData (1)] [InlineData (2)] @@ -1721,8 +1721,7 @@ Y │ │ │ │ │ │ -└─┘ -"; +└─┘"; break; case 4: Assert.Equal (new Rect (0, 0, 1, 4), subview.Frame); diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index f9b9fdd2d..138bf61d4 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -656,14 +656,14 @@ namespace Terminal.Gui.ViewTests { win.SetFocus (); Assert.False (button.HasFocus); Assert.False (win.HasFocus); - top.Redraw (top.Bounds); + top.Draw (); Assert.True (RunesCount () == 0); win.Visible = true; win.FocusFirst (); Assert.True (button.HasFocus); Assert.True (win.HasFocus); - top.Redraw (top.Bounds); + top.Draw (); Assert.True (RunesCount () > 0); Application.RequestStop (); @@ -715,7 +715,7 @@ namespace Terminal.Gui.ViewTests { Assert.Equal (top2, v2.GetTopSuperView ()); } - + [Fact, AutoInitShutdown] public void Clear_Can_Use_Driver_AddRune_Or_AddStr_Methods () @@ -734,6 +734,7 @@ namespace Terminal.Gui.ViewTests { } } Application.Driver.Clip = savedClip; + e.Cancel = true; }; Application.Top.Add (view); Application.Begin (Application.Top); @@ -781,6 +782,7 @@ namespace Terminal.Gui.ViewTests { } } Application.Driver.Clip = savedClip; + e.Cancel = true; }; Application.Top.Add (view); Application.Begin (Application.Top); @@ -1040,7 +1042,7 @@ cccccccccccccccccccc", output); return true; } - public override void Redraw (Rect bounds) + public override void OnDrawContent (Rect contentArea) { var idx = 0; // BUGBUG: v2 - this should use Boudns, not Frame @@ -1078,7 +1080,7 @@ cccccccccccccccccccc", output); top.Add (label, view); Application.Begin (top); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1091,7 +1093,7 @@ At 0,0 view.LayoutStyle = LayoutStyle.Absolute; Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 10, 1), view._needsDisplay); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 A text wit", output); @@ -1112,7 +1114,7 @@ At 0,0 top.Add (label, view); Application.Begin (top); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1126,7 +1128,7 @@ At 0,0 Assert.Equal (new Rect (1, 1, 10, 1), view.Frame); Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 30, 2), view._needsDisplay); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 A text wit", output); @@ -1147,7 +1149,7 @@ At 0,0 top.Add (label, view); Application.Begin (top); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1160,7 +1162,7 @@ At 0,0 view.LayoutStyle = LayoutStyle.Absolute; Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 10, 1), view._needsDisplay); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 A text wit @@ -1183,7 +1185,7 @@ At 0,0 top.Add (label, view); Application.Begin (top); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1197,7 +1199,7 @@ At 0,0 Assert.Equal (new Rect (1, 1, 10, 1), view.Frame); Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 30, 2), view._needsDisplay); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 A text wit @@ -1232,7 +1234,7 @@ At 0,0 view.LayoutStyle = LayoutStyle.Absolute; Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 10, 1), view._needsDisplay); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1255,7 +1257,7 @@ At 0,0 top.Add (label, view); Application.Begin (top); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1269,7 +1271,7 @@ At 0,0 Assert.Equal (new Rect (3, 3, 10, 1), view.Frame); Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 30, 2), view._needsDisplay); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1292,7 +1294,7 @@ At 0,0 top.Add (label, view); Application.Begin (top); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1302,7 +1304,7 @@ At 0,0 view.Frame = new Rect (3, 3, 10, 1); Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 10, 1), view._needsDisplay); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1325,7 +1327,7 @@ At 0,0 top.Add (label, view); Application.Begin (top); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1339,7 +1341,7 @@ At 0,0 Assert.Equal (new Rect (3, 3, 10, 1), view.Frame); Assert.Equal (new Rect (0, 0, 10, 1), view.Bounds); Assert.Equal (new Rect (0, 0, 30, 2), view._needsDisplay); - view.Redraw (view.Bounds); + view.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" At 0,0 @@ -1362,7 +1364,7 @@ At 0,0 v.Add (bottom); v.LayoutSubviews (); - v.Redraw (v.Bounds); + v.Draw (); string looksLike = @" diff --git a/UnitTests/Views/AppendAutocompleteTests.cs b/UnitTests/Views/AppendAutocompleteTests.cs index 1146d05bf..a90e21013 100644 --- a/UnitTests/Views/AppendAutocompleteTests.cs +++ b/UnitTests/Views/AppendAutocompleteTests.cs @@ -24,18 +24,18 @@ namespace Terminal.Gui.TextTests { var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator; generator.AllSuggestions = new List { "fish" }; - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("", output); tf.ProcessKey (new KeyEvent (Key.f, new KeyModifiers ())); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("fish", tf.Text.ToString ()); @@ -56,7 +56,7 @@ namespace Terminal.Gui.TextTests { var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator; generator.AllSuggestions = new List { "FISH" }; - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("", output); tf.ProcessKey (new KeyEvent (Key.m, new KeyModifiers ())); tf.ProcessKey (new KeyEvent (Key.y, new KeyModifiers ())); @@ -64,13 +64,13 @@ namespace Terminal.Gui.TextTests { tf.ProcessKey (new KeyEvent (Key.f, new KeyModifiers ())); // Even though there is no match on case we should still get the suggestion - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("my fISH", output); Assert.Equal ("my f", tf.Text.ToString ()); // When tab completing the case of the whole suggestion should be applied Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("my FISH", output); Assert.Equal ("my FISH", tf.Text.ToString ()); } @@ -82,7 +82,7 @@ namespace Terminal.Gui.TextTests { // f is typed and suggestion is "fish" Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); @@ -90,7 +90,7 @@ namespace Terminal.Gui.TextTests { Application.Driver.SendKeys ('e', ConsoleKey.Escape, false, false, false); // Suggestion should disapear - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("f", output); Assert.Equal ("f", tf.Text.ToString ()); @@ -109,7 +109,7 @@ namespace Terminal.Gui.TextTests { // f is typed and suggestion is "fish" Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); @@ -117,13 +117,13 @@ namespace Terminal.Gui.TextTests { Application.Driver.SendKeys ('e', ConsoleKey.Escape, false, false, false); // Suggestion should disapear - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("f", output); Assert.Equal ("f", tf.Text.ToString ()); // Should reapear when you press next letter Application.Driver.SendKeys ('i', ConsoleKey.I, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); // BUGBUG: v2 - I broke this test and don't have time to figure out why. @tznind - help! //TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("fi", tf.Text.ToString ()); @@ -139,7 +139,7 @@ namespace Terminal.Gui.TextTests { // f is typed we should only see 'f' up to size of View (10) Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre (expectRender, output); Assert.Equal ("f", tf.Text.ToString ()); } @@ -153,20 +153,20 @@ namespace Terminal.Gui.TextTests { // f is typed and suggestion is "fish" Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); // When cycling autocomplete Application.Driver.SendKeys (' ', cycleKey, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("friend", output); Assert.Equal ("f", tf.Text.ToString ()); // Should be able to cycle in circles endlessly Application.Driver.SendKeys (' ', cycleKey, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); } @@ -178,13 +178,13 @@ namespace Terminal.Gui.TextTests { // f is typed and suggestion is "fish" Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); // x is typed and suggestion should disapear Application.Driver.SendKeys ('x', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fx", output); Assert.Equal ("fx", tf.Text.ToString ()); } @@ -196,7 +196,7 @@ namespace Terminal.Gui.TextTests { // f is typed and suggestion is "fish" Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text.ToString ()); @@ -204,7 +204,7 @@ namespace Terminal.Gui.TextTests { Application.Driver.SendKeys (' ', ConsoleKey.Spacebar, false, false, false); Application.Driver.SendKeys ('<', ConsoleKey.LeftArrow, false, false, false); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("f", output); Assert.Equal ("f ", tf.Text.ToString ()); } @@ -218,7 +218,7 @@ namespace Terminal.Gui.TextTests { var generator = (SingleWordSuggestionGenerator)tf.Autocomplete.SuggestionGenerator; generator.AllSuggestions = suggestions.ToList (); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("", output); return tf; diff --git a/UnitTests/Views/ComboBoxTests.cs b/UnitTests/Views/ComboBoxTests.cs index 8b3f38938..a5cf6681d 100644 --- a/UnitTests/Views/ComboBoxTests.cs +++ b/UnitTests/Views/ComboBoxTests.cs @@ -816,7 +816,7 @@ Three Assert.True (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); - cb.Redraw (cb.Bounds); + cb.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ▼ One @@ -843,7 +843,7 @@ Three ", output); Assert.True (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); - cb.Redraw (cb.Bounds); + cb.Draw (); TestHelpers.AssertDriverColorsAre (@" 000000 222222 @@ -855,7 +855,7 @@ Three ", output); Assert.True (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); - cb.Redraw (cb.Bounds); + cb.Draw (); TestHelpers.AssertDriverColorsAre (@" 000000 222222 @@ -873,7 +873,7 @@ Three ", output); Assert.True (cb.IsShow); Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); - cb.Redraw (cb.Bounds); + cb.Draw (); TestHelpers.AssertDriverColorsAre (@" 000000 222222 @@ -885,7 +885,7 @@ Three ", output); Assert.True (cb.IsShow); Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); - cb.Redraw (cb.Bounds); + cb.Draw (); TestHelpers.AssertDriverColorsAre (@" 000000 222222 @@ -897,7 +897,7 @@ Three ", output); Assert.True (cb.IsShow); Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); - cb.Redraw (cb.Bounds); + cb.Draw (); TestHelpers.AssertDriverColorsAre (@" 000000 000002 diff --git a/UnitTests/Views/ContextMenuTests.cs b/UnitTests/Views/ContextMenuTests.cs index af2e16a83..033b72cc1 100644 --- a/UnitTests/Views/ContextMenuTests.cs +++ b/UnitTests/Views/ContextMenuTests.cs @@ -302,7 +302,7 @@ namespace Terminal.Gui.ViewsTests { cm.Show (); Assert.Equal (new Point (70, 24), cm.Position); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" ┌──────┐ @@ -336,7 +336,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Point (10, 5), cm.Position); cm.Show (); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); Assert.Equal (new Point (10, 5), cm.Position); var expected = @" @@ -357,7 +357,7 @@ namespace Terminal.Gui.ViewsTests { cm.Host.Height = 3; cm.Show (); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); Assert.Equal (new Point (5, 12), cm.Position); expected = @" @@ -590,7 +590,7 @@ namespace Terminal.Gui.ViewsTests { tf.ContextMenu.Show (); Assert.True (ContextMenu.IsShow); Assert.Equal (new Point (9, 3), tf.ContextMenu.Position); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" File Edit @@ -654,7 +654,7 @@ namespace Terminal.Gui.ViewsTests { tf.ContextMenu.Show (); Assert.True (ContextMenu.IsShow); Assert.Equal (new Point (10, 5), tf.ContextMenu.Position); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" File Edit ┌──────────────────────────────────────────┐ diff --git a/UnitTests/Views/GraphViewTests.cs b/UnitTests/Views/GraphViewTests.cs index 8059103e4..10a77ed92 100644 --- a/UnitTests/Views/GraphViewTests.cs +++ b/UnitTests/Views/GraphViewTests.cs @@ -68,7 +68,7 @@ namespace Terminal.Gui.ViewsTests { // be the last one throw new Exception ("A test did not call shutdown correctly. Test stack trace was:" + LastInitFakeDriver); } - + driver.Init (() => { }); LastInitFakeDriver = Environment.StackTrace; @@ -257,7 +257,7 @@ namespace Terminal.Gui.ViewsTests { { var gv = new GraphView (); gv.BeginInit (); gv.EndInit (); - + gv.Bounds = new Rect (0, 0, 20, 10); // Each cell of screen is responsible for rendering 5 units in graph data model @@ -344,7 +344,7 @@ namespace Terminal.Gui.ViewsTests { gv.Bounds = new Rect (0, 0, 50, 30); gv.Series.Add (new ScatterSeries () { Points = new List { new PointF (1, 1) } }); gv.CellSize = new PointF (0, 5); - var ex = Assert.Throws (() => gv.Redraw (gv.Bounds)); + var ex = Assert.Throws (() => gv.Draw ()); Assert.Equal ("CellSize cannot be 0", ex.Message); @@ -425,7 +425,7 @@ namespace Terminal.Gui.ViewsTests { gv.Series.Add (series); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.Equal (new RectangleF (0, 0, 50, 30), fullGraphBounds); Assert.Equal (new Rect (0, 0, 50, 30), graphScreenBounds); @@ -438,7 +438,7 @@ namespace Terminal.Gui.ViewsTests { // Even with a margin the graph should be drawn from // the origin, we just get less visible width/height gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.Equal (new RectangleF (0, 0, 45, 28), fullGraphBounds); // The screen space the graph will be rendered into should @@ -476,7 +476,7 @@ namespace Terminal.Gui.ViewsTests { gv.Series.Add (series); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); // Since each cell of the console is 2x5 of graph space the graph // bounds to be rendered are larger Assert.Equal (new RectangleF (0, 0, 100, 150), fullGraphBounds); @@ -490,7 +490,7 @@ namespace Terminal.Gui.ViewsTests { // Even with a margin the graph should be drawn from // the origin, we just get less visible width/height gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.Equal (new RectangleF (0, 0, 90, 140), fullGraphBounds); // The screen space the graph will be rendered into should @@ -626,12 +626,12 @@ namespace Terminal.Gui.ViewsTests { FakeHAxis fakeXAxis; // don't show axis labels that means any labels - // that appaer are explicitly from the bars + // that appear are explicitly from the bars gv.AxisX = fakeXAxis = new FakeHAxis () { Increment = 0 }; gv.AxisY = new FakeVAxis () { Increment = 0 }; gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); // Since bar series has no bars yet no labels should be displayed Assert.Empty (fakeXAxis.LabelPoints); @@ -639,7 +639,7 @@ namespace Terminal.Gui.ViewsTests { multibarSeries.AddBars ("hey", 'M', 0.5001f, 0.5001f); fakeXAxis.LabelPoints.Clear (); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.Equal (4, fakeXAxis.LabelPoints.Single ()); @@ -647,7 +647,7 @@ namespace Terminal.Gui.ViewsTests { multibarSeries.AddBars ("bob", 'M', 1, 2); fakeXAxis.LabelPoints.Clear (); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.Equal (3, fakeXAxis.LabelPoints.Count); Assert.Equal (4, fakeXAxis.LabelPoints [0]); @@ -703,7 +703,7 @@ namespace Terminal.Gui.ViewsTests { { var graph = GetGraph (out FakeBarSeries barSeries, out FakeHAxis axisX, out FakeVAxis axisY); - graph.Redraw (graph.Bounds); + graph.Draw (); // no bars Assert.Empty (barSeries.BarScreenStarts); @@ -715,7 +715,7 @@ namespace Terminal.Gui.ViewsTests { barSeries.Orientation = Orientation.Vertical; // redraw graph - graph.Redraw (graph.Bounds); + graph.Draw (); // bar should not be drawn Assert.Empty (barSeries.BarScreenStarts); @@ -737,7 +737,7 @@ namespace Terminal.Gui.ViewsTests { { var graph = GetGraph (out FakeBarSeries barSeries, out FakeHAxis axisX, out FakeVAxis axisY); - graph.Redraw (graph.Bounds); + graph.Draw (); // no bars Assert.Empty (barSeries.BarScreenStarts); @@ -760,7 +760,7 @@ namespace Terminal.Gui.ViewsTests { barSeries.Orientation = Orientation.Vertical; // redraw graph - graph.Redraw (graph.Bounds); + graph.Draw (); // bar should be drawn at BarEvery 1f + offset 0.5f = 3 screen units Assert.Equal (3, barSeries.BarScreenStarts [0].X); @@ -790,7 +790,7 @@ namespace Terminal.Gui.ViewsTests { { var graph = GetGraph (out FakeBarSeries barSeries, out FakeHAxis axisX, out FakeVAxis axisY); - graph.Redraw (graph.Bounds); + graph.Draw (); // no bars Assert.Empty (barSeries.BarScreenStarts); @@ -816,7 +816,7 @@ namespace Terminal.Gui.ViewsTests { new BarSeries.Bar ("hi2", new GraphCellToRender ('.'), 5)); // redraw graph - graph.Redraw (graph.Bounds); + graph.Draw (); // since bars are horizontal all have the same X start cordinates Assert.Equal (0, barSeries.BarScreenStarts [0].X); @@ -910,7 +910,7 @@ namespace Terminal.Gui.ViewsTests { { var gv = GetGraph (out FakeHAxis axis); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.DoesNotContain (new Point (-1, 29), axis.DrawAxisLinePoints); Assert.Contains (new Point (0, 29), axis.DrawAxisLinePoints); @@ -934,7 +934,7 @@ namespace Terminal.Gui.ViewsTests { gv.MarginBottom = 10; gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.DoesNotContain (new Point (-1, 19), axis.DrawAxisLinePoints); Assert.Contains (new Point (0, 19), axis.DrawAxisLinePoints); @@ -958,7 +958,7 @@ namespace Terminal.Gui.ViewsTests { gv.MarginLeft = 5; gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.DoesNotContain (new Point (4, 29), axis.DrawAxisLinePoints); Assert.Contains (new Point (5, 29), axis.DrawAxisLinePoints); @@ -990,7 +990,7 @@ namespace Terminal.Gui.ViewsTests { var gv = GetGraph (out FakeVAxis axis); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.DoesNotContain (new Point (0, -1), axis.DrawAxisLinePoints); Assert.Contains (new Point (0, 1), axis.DrawAxisLinePoints); @@ -1014,7 +1014,7 @@ namespace Terminal.Gui.ViewsTests { gv.MarginBottom = 10; gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.DoesNotContain (new Point (0, -1), axis.DrawAxisLinePoints); Assert.Contains (new Point (0, 1), axis.DrawAxisLinePoints); @@ -1039,7 +1039,7 @@ namespace Terminal.Gui.ViewsTests { gv.MarginLeft = 5; gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); Assert.DoesNotContain (new Point (5, -1), axis.DrawAxisLinePoints); Assert.Contains (new Point (5, 1), axis.DrawAxisLinePoints); @@ -1077,7 +1077,7 @@ namespace Terminal.Gui.ViewsTests { ScreenPosition = new Point (3, 1) }); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1091,7 +1091,7 @@ namespace Terminal.Gui.ViewsTests { // user scrolls up one unit of graph space gv.ScrollOffset = new PointF (0, 1f); - gv.Redraw (gv.Bounds); + gv.Draw (); // we expect no change in the location of the annotation (only the axis label changes) // this is because screen units are constant and do not change as the viewport into @@ -1121,7 +1121,7 @@ namespace Terminal.Gui.ViewsTests { }); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1135,7 +1135,7 @@ namespace Terminal.Gui.ViewsTests { // user scrolls up one unit of graph space gv.ScrollOffset = new PointF (0, 1f); - gv.Redraw (gv.Bounds); + gv.Draw (); // we expect the text annotation to go down one line since // the scroll offset means that that point of graph space is @@ -1166,7 +1166,7 @@ namespace Terminal.Gui.ViewsTests { }); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); // long text should get truncated // margin takes up 1 units @@ -1197,7 +1197,7 @@ namespace Terminal.Gui.ViewsTests { }); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); // Text is off the screen (graph x axis runs to 8 not 9) var expected = @@ -1233,7 +1233,7 @@ namespace Terminal.Gui.ViewsTests { points.Points.Add (new PointF (7, 2)); gv.Series.Add (points); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1267,7 +1267,7 @@ namespace Terminal.Gui.ViewsTests { legend.AddEntry (new GraphCellToRender ('B'), "Bat"); gv.Annotations.Add (legend); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1295,7 +1295,7 @@ namespace Terminal.Gui.ViewsTests { legend.Border = false; gv.Annotations.Add (legend); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1337,7 +1337,7 @@ namespace Terminal.Gui.ViewsTests { gv.Annotations.Add (path); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1375,7 +1375,7 @@ namespace Terminal.Gui.ViewsTests { gv.MarginLeft = 1; gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1412,9 +1412,9 @@ namespace Terminal.Gui.ViewsTests { // reserve 3 cells of the left for the margin gv.MarginLeft = 3; gv.MarginBottom = 1; - + gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1445,7 +1445,7 @@ namespace Terminal.Gui.ViewsTests { }); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1469,7 +1469,7 @@ namespace Terminal.Gui.ViewsTests { }); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1499,7 +1499,7 @@ namespace Terminal.Gui.ViewsTests { gv.Annotations.Add (path); gv.LayoutSubviews (); - gv.Redraw (gv.Bounds); + gv.Draw (); var expected = @" @@ -1552,14 +1552,14 @@ namespace Terminal.Gui.ViewsTests { // render view lbl1.ColorScheme = new ColorScheme (); Assert.Equal (1, lbl1.Height); - mount.Redraw (mount.Bounds); + mount.Draw (); // should have the initial text TestHelpers.AssertDriverContentsAre ("ff", null); // change the text and redraw lbl1.Text = "ff1234"; - mount.Redraw (mount.Bounds); + mount.Draw (); // should have the new text rendered TestHelpers.AssertDriverContentsAre ("ff1234", null); diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index 8feb25db4..b9b7612f9 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -18,7 +18,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (string.Empty, label.Text); Application.Top.Add (label); var rs = Application.Begin (Application.Top); - + Assert.Equal (TextAlignment.Left, label.TextAlignment); Assert.True (label.AutoSize); Assert.False (label.CanFocus); @@ -27,7 +27,7 @@ namespace Terminal.Gui.ViewsTests { var expected = @""; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); - + label = new Label ("ARGS", true) { Text = "Test" }; Assert.True (label.AutoSize); Assert.Equal ("Test", label.Text); @@ -41,7 +41,7 @@ Test "; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); - + label = new Label (3, 4, "Test", true); Assert.Equal ("Test", label.Text); Application.Top.Add (label); @@ -269,7 +269,7 @@ Test TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } - + [Fact, AutoInitShutdown] public void Pos_Center_Layout_AutoSize_True () { @@ -301,7 +301,7 @@ Test [Fact, AutoInitShutdown] public void Pos_Center_Layout_AutoSize_False () - { + { var Label = new Label ("012345678901") { X = Pos.Center (), Y = Pos.Center (), @@ -329,7 +329,7 @@ Test "; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } - + //[Fact, AutoInitShutdown] //public void Label_HotKeyChanged_EventFires () //{ @@ -343,14 +343,14 @@ Test // args = e; // }; - + // label.HotKey = Key.r; // Assert.Same (label, sender); // Assert.Equal (Key.Y, args.OldKey); // Assert.Equal (Key.r, args.NewKey); //} - + [Fact, AutoInitShutdown] public void Label_HotKeyChanged_EventFires_WithNone () { @@ -889,7 +889,7 @@ This TextFormatter (tf2) with fill will be cleared on rewritten. ", output); view.Text = "This view is rewritten."; - view.Redraw (view.Bounds); + view.Draw (); tf1.Text = "This TextFormatter (tf1) is rewritten."; tf1.Draw (new Rect (new Point (0, 1), tf1Size), view.GetNormalColor (), view.ColorScheme.HotNormal, default, false); diff --git a/UnitTests/Views/ListViewTests.cs b/UnitTests/Views/ListViewTests.cs index b499f0566..69503c7be 100644 --- a/UnitTests/Views/ListViewTests.cs +++ b/UnitTests/Views/ListViewTests.cs @@ -213,7 +213,7 @@ namespace Terminal.Gui.ViewsTests { Assert.False (rendered); lv.SetSource (source); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.True (rendered); } @@ -231,7 +231,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new (' ', 7), GetContents (1)); lv.MoveUp (); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal ("First ", GetContents (0)); Assert.Equal (new (' ', 7), GetContents (1)); @@ -278,7 +278,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.ScrollDown (10)); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (-1, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -295,7 +295,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.MoveDown ()); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (0, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -312,7 +312,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.MoveEnd ()); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (19, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -329,7 +329,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.ScrollUp (20)); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (19, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -346,7 +346,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.MoveDown ()); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (19, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -363,7 +363,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.ScrollUp (20)); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (19, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -380,7 +380,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.MoveDown ()); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (19, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -397,7 +397,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.MoveHome ()); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (0, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -414,7 +414,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.ScrollDown (20)); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (0, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ @@ -431,7 +431,7 @@ namespace Terminal.Gui.ViewsTests { └──────────┘", output); Assert.True (lv.MoveUp ()); - lv.Redraw (lv.Bounds); + lv.Draw (); Assert.Equal (0, lv.SelectedItem); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ diff --git a/UnitTests/Views/MenuTests.cs b/UnitTests/Views/MenuTests.cs index ab4e2d90d..abf39ecd2 100644 --- a/UnitTests/Views/MenuTests.cs +++ b/UnitTests/Views/MenuTests.cs @@ -147,7 +147,7 @@ namespace Terminal.Gui.ViewsTests { Assert.True (menu.IsMenuOpen); isMenuClosed = !menu.IsMenuOpen; Assert.False (isMenuClosed); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Edit ┌──────────────────────────────┐ @@ -160,7 +160,7 @@ Edit Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (isMenuClosed); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Edit ┌──────────────────────────────┐ @@ -173,7 +173,7 @@ Edit Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); Assert.True (isMenuClosed); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Edit "; @@ -706,7 +706,7 @@ Edit Assert.Equal (Point.Empty, new Point (menu.Frame.X, menu.Frame.Y)); Assert.False (menu.UseSubMenusSingleFrame); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Numbers "; @@ -714,7 +714,7 @@ Edit var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -727,7 +727,7 @@ Edit pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.CursorDown, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -741,7 +741,7 @@ Edit pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [2].ProcessKey (new KeyEvent (Key.CursorLeft, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -754,7 +754,7 @@ Edit pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.Esc, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers "; @@ -782,7 +782,7 @@ Edit Assert.Equal (Point.Empty, new Point (menu.Frame.X, menu.Frame.Y)); Assert.False (menu.UseSubMenusSingleFrame); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Numbers "; @@ -796,7 +796,7 @@ Edit Flags = MouseFlags.Button1Pressed, View = menu })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -815,7 +815,7 @@ Edit Flags = MouseFlags.ReportMousePosition, View = Application.Top.Subviews [1] })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -835,7 +835,7 @@ Edit Flags = MouseFlags.ReportMousePosition, View = Application.Top.Subviews [1] })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -854,7 +854,7 @@ Edit Flags = MouseFlags.Button1Clicked, View = Application.Top })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers "; @@ -885,7 +885,7 @@ Edit menu.UseSubMenusSingleFrame = true; Assert.True (menu.UseSubMenusSingleFrame); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Numbers "; @@ -894,7 +894,7 @@ Edit Assert.Equal (new Rect (1, 0, 8, 1), pos); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -909,7 +909,7 @@ Edit Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.CursorDown, null))); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.Enter, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌─────────────┐ @@ -924,7 +924,7 @@ Edit Assert.Equal (new Rect (1, 0, 15, 7), pos); Assert.True (Application.Top.Subviews [2].ProcessKey (new KeyEvent (Key.Enter, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -938,7 +938,7 @@ Edit Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.Esc, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers "; @@ -969,7 +969,7 @@ Edit menu.UseSubMenusSingleFrame = true; Assert.True (menu.UseSubMenusSingleFrame); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Numbers "; @@ -983,7 +983,7 @@ Edit Flags = MouseFlags.Button1Pressed, View = menu })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -1002,7 +1002,7 @@ Edit Flags = MouseFlags.Button1Clicked, View = Application.Top.Subviews [1] })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌─────────────┐ @@ -1022,7 +1022,7 @@ Edit Flags = MouseFlags.Button1Clicked, View = Application.Top.Subviews [2] })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ┌────────┐ @@ -1041,7 +1041,7 @@ Edit Flags = MouseFlags.Button1Clicked, View = Application.Top })); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers "; @@ -1074,7 +1074,7 @@ Edit Assert.False (menu.OnKeyDown (new (Key.AltMask, new KeyModifiers () { Alt = true }))); Assert.True (menu.OnKeyUp (new (Key.AltMask, new KeyModifiers () { Alt = true }))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" File Edit "; @@ -1088,7 +1088,7 @@ Edit Assert.True (menu.ProcessHotKey (new (Key.AltMask, new KeyModifiers () { Alt = true }))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" File Edit "; @@ -1206,13 +1206,13 @@ Edit Application.Top.Add (menu); Application.Begin (Application.Top); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); for (var i = 0; i < expectedMenu.Menus.Length; i++) { menu.OpenMenu (i); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (i), output); } } @@ -1251,7 +1251,7 @@ Edit Assert.True (menu.ProcessHotKey (new (Key.AltMask | Key.F, new KeyModifiers () { Alt = true }))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.N, null))); @@ -1260,7 +1260,7 @@ Edit Assert.True (menu.ProcessHotKey (new (Key.AltMask | Key.E, new KeyModifiers () { Alt = true }))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.C, null))); @@ -1297,19 +1297,19 @@ Edit // Open first Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); // Open second Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.CursorRight, null))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); // Close menu Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); Application.Top.Remove (menu); @@ -1329,19 +1329,19 @@ Edit // Open first Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); // Open second Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.CursorRight, null))); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); // Close menu Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } @@ -1373,13 +1373,13 @@ Edit Assert.True (menu.MouseEvent (new MouseEvent () { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu })); Assert.True (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu })); Assert.False (menu.IsMenuOpen); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } @@ -1436,37 +1436,37 @@ Edit Assert.True (menu.MouseEvent (new MouseEvent () { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 8, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 15, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (2), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 8, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 1, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 8, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu })); Assert.False (menu.IsMenuOpen); Assert.True (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } @@ -1499,40 +1499,40 @@ Edit Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); // Right - Edit has no sub menu; this tests that no sub menu shows Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); // Right - Format Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (2), output); // Left - Edit Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); Assert.True (tf.HasFocus); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } @@ -1596,7 +1596,7 @@ Edit Flags = MouseFlags.Button1Pressed, View = menu })); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverColorsAre (@" 11111100000000 00000000000000 @@ -1612,7 +1612,7 @@ Edit Flags = MouseFlags.Button1Clicked, View = top.Subviews [1] })); - top.Subviews [1].Redraw (top.Bounds); + top.Subviews [1].Draw (); TestHelpers.AssertDriverColorsAre (@" 11111100000000 00000000000000 @@ -1628,7 +1628,7 @@ Edit Flags = MouseFlags.ReportMousePosition, View = top.Subviews [1] })); - top.Subviews [1].Redraw (top.Bounds); + top.Subviews [1].Draw (); TestHelpers.AssertDriverColorsAre (@" 11111100000000 00000000000000 @@ -1689,7 +1689,7 @@ Edit └──────────────────────────────────────┘", output); Assert.True (win.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────────────────────────┐ │ File Edit │ @@ -1713,7 +1713,7 @@ Edit └──────────────────────────────────────┘", output); Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────────────────────────┐ │ File Edit │ @@ -1725,7 +1725,7 @@ Edit └──────────────────────────────────────┘", output); Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - top.Redraw (top.Bounds); + top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────────────────────────┐ │ File Edit │ @@ -1983,7 +1983,7 @@ wo Assert.False (menu.UseSubMenusSingleFrame); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Numbers One @@ -1994,7 +1994,7 @@ wo _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.CursorDown, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers One @@ -2029,7 +2029,7 @@ wo Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); var expected = @" Numbers One @@ -2041,7 +2041,7 @@ wo Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.CursorDown, null))); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.Enter, null))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" Numbers ◄ Two diff --git a/UnitTests/Views/ProgressBarTests.cs b/UnitTests/Views/ProgressBarTests.cs index 14e058f52..ffcb87dfa 100644 --- a/UnitTests/Views/ProgressBarTests.cs +++ b/UnitTests/Views/ProgressBarTests.cs @@ -171,9 +171,12 @@ namespace Terminal.Gui.ViewsTests { ProgressBarStyle = ProgressBarStyle.MarqueeBlocks }; + pb.BeginInit (); + pb.EndInit (); + for (int i = 0; i < 38; i++) { pb.Pulse (); - pb.Redraw (pb.Bounds); + pb.Draw (); if (i == 0) { Assert.Equal (driver.BlocksMeterSegment, (double)driver.Contents [0, 0, 0]); Assert.Equal (' ', (double)driver.Contents [0, 1, 0]); @@ -798,9 +801,12 @@ namespace Terminal.Gui.ViewsTests { BidirectionalMarquee = false }; + pb.BeginInit (); + pb.EndInit (); + for (int i = 0; i < 38; i++) { pb.Pulse (); - pb.Redraw (pb.Bounds); + pb.Draw (); if (i == 0) { Assert.Equal (driver.BlocksMeterSegment, (double)driver.Contents [0, 0, 0]); Assert.Equal (' ', (double)driver.Contents [0, 1, 0]); @@ -1423,9 +1429,12 @@ namespace Terminal.Gui.ViewsTests { Width = 5 }; + pb.BeginInit (); + pb.EndInit (); + for (int i = 0; i <= pb.Frame.Width; i++) { pb.Fraction += 0.2F; - pb.Redraw (pb.Bounds); + pb.Draw (); if (i == 0) { Assert.Equal (driver.BlocksMeterSegment, (double)driver.Contents [0, 0, 0]); Assert.Equal (' ', (double)driver.Contents [0, 1, 0]); diff --git a/UnitTests/Views/ScrollBarViewTests.cs b/UnitTests/Views/ScrollBarViewTests.cs index f70818172..22680e23f 100644 --- a/UnitTests/Views/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -58,7 +58,7 @@ namespace Terminal.Gui.ViewsTests { Host = super, ShowScrollIndicator = true, IsVertical = true - }; + }; super.Add (sbv); Application.Begin (Application.Top); @@ -355,7 +355,7 @@ namespace Terminal.Gui.ViewsTests { AddHandlers (); _hostView.SuperView.LayoutSubviews (); - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.Equal (_scrollBar.Position, _hostView.Top); Assert.Equal (_scrollBar.Size, _hostView.Lines); @@ -431,11 +431,11 @@ namespace Terminal.Gui.ViewsTests { AddHandlers (); _hostView.Top = 3; - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.Equal (_scrollBar.Position, _hostView.Top); _hostView.Left = 6; - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left); } @@ -534,7 +534,7 @@ namespace Terminal.Gui.ViewsTests { AddHandlers (); - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.True (_scrollBar.ShowScrollIndicator); Assert.True (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); @@ -551,7 +551,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); _hostView.Lines = 10; - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.False (_scrollBar.ShowScrollIndicator); Assert.False (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); @@ -568,7 +568,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); _hostView.Cols = 60; - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.False (_scrollBar.ShowScrollIndicator); Assert.False (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); @@ -585,7 +585,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); _hostView.Lines = 40; - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.True (_scrollBar.ShowScrollIndicator); Assert.True (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); @@ -602,7 +602,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); _hostView.Cols = 120; - _hostView.Redraw (_hostView.Bounds); + _hostView.Draw (); Assert.True (_scrollBar.ShowScrollIndicator); Assert.True (_scrollBar.Visible); Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ()); @@ -961,6 +961,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (0, textView.LeftColumn); Assert.Equal (0, scrollBar.Position); Assert.Equal (0, scrollBar.OtherScrollBarView.Position); + Assert.True (scrollBar.ShowScrollIndicator); expected = @" ┌────────┐ │This ▲│ @@ -1014,7 +1015,7 @@ This is a tes▼ Assert.False (sbv.OtherScrollBarView.ShowScrollIndicator); Assert.False (sbv.Visible); Assert.False (sbv.OtherScrollBarView.Visible); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test This is a test @@ -1032,7 +1033,7 @@ This is a test Assert.True (sbv.OtherScrollBarView.ShowScrollIndicator); Assert.True (sbv.Visible); Assert.True (sbv.OtherScrollBarView.Visible); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ @@ -1073,7 +1074,7 @@ This is a tes▼ Assert.Equal (0, sbv.Size); Assert.False (sbv.ShowScrollIndicator); Assert.False (sbv.Visible); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test This is a test @@ -1108,8 +1109,7 @@ This is a test[ Click Me! ] This is a test This is a test This is a test -This is a test -", output); +This is a test ", output); ReflectionTools.InvokePrivate ( typeof (Application), @@ -1129,14 +1129,14 @@ This is a test Assert.Equal (5, sbv.Size); Assert.False (sbv.ShowScrollIndicator); Assert.True (sbv.Visible); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); + Assert.False (sbv.Visible); TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test[ Click Me! ] This is a test This is a test This is a test -This is a test -", output); +This is a test ", output); ReflectionTools.InvokePrivate ( typeof (Application), @@ -1157,7 +1157,6 @@ This is a test [Fact, AutoInitShutdown] public void ClearOnVisibleFalse_Gets_Sets () { - var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test"; var label = new Label (text); Application.Top.Add (label); @@ -1180,7 +1179,7 @@ This is a tes▼ sbv.Visible = false; Assert.False (sbv.Visible); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test This is a test @@ -1192,7 +1191,7 @@ This is a test sbv.Visible = true; Assert.True (sbv.Visible); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs index c0b571910..e9727491c 100644 --- a/UnitTests/Views/ScrollViewTests.cs +++ b/UnitTests/Views/ScrollViewTests.cs @@ -199,7 +199,7 @@ namespace Terminal.Gui.ViewsTests { Assert.False (sv.AutoHideScrollBars); Assert.True (sv.ShowHorizontalScrollIndicator); Assert.True (sv.ShowVerticalScrollIndicator); - sv.Redraw (sv.Bounds); + sv.Draw (); TestHelpers.AssertDriverContentsAre (@" ▲ ┬ @@ -219,7 +219,7 @@ namespace Terminal.Gui.ViewsTests { Assert.False (sv.AutoHideScrollBars); Assert.False (sv.ShowHorizontalScrollIndicator); Assert.True (sv.ShowVerticalScrollIndicator); - sv.Redraw (sv.Bounds); + sv.Draw (); TestHelpers.AssertDriverContentsAre (@" ▲ ┬ @@ -238,7 +238,7 @@ namespace Terminal.Gui.ViewsTests { Assert.False (sv.AutoHideScrollBars); Assert.True (sv.ShowHorizontalScrollIndicator); Assert.False (sv.ShowVerticalScrollIndicator); - sv.Redraw (sv.Bounds); + sv.Draw (); TestHelpers.AssertDriverContentsAre (@" @@ -258,7 +258,7 @@ namespace Terminal.Gui.ViewsTests { Assert.False (sv.AutoHideScrollBars); Assert.False (sv.ShowHorizontalScrollIndicator); Assert.False (sv.ShowVerticalScrollIndicator); - sv.Redraw (sv.Bounds); + sv.Draw (); TestHelpers.AssertDriverContentsAre (@" @@ -293,7 +293,7 @@ namespace Terminal.Gui.ViewsTests { sv.ShowHorizontalScrollIndicator = true; sv.ShowVerticalScrollIndicator = true; sv.LayoutSubviews (); - sv.Redraw (sv.Bounds); + sv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ▲ ┬ @@ -645,7 +645,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -669,7 +669,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -693,7 +693,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -717,7 +717,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -741,7 +741,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -765,7 +765,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -789,7 +789,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -812,7 +812,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CtrlMask | Key.End, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -836,7 +836,7 @@ namespace Terminal.Gui.ViewsTests { Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Home, new KeyModifiers ()))); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -859,7 +859,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -882,7 +882,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ @@ -905,7 +905,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ()))); - Application.Top.Redraw (Application.Top.Bounds); + Application.Top.Draw (); expected = @" ┌──────────────────┐ diff --git a/UnitTests/Views/SpinnerViewTests.cs b/UnitTests/Views/SpinnerViewTests.cs index abb1b5ef9..fe727fa2e 100644 --- a/UnitTests/Views/SpinnerViewTests.cs +++ b/UnitTests/Views/SpinnerViewTests.cs @@ -40,19 +40,19 @@ namespace Terminal.Gui.ViewsTests { { var view = GetSpinnerView (); - view.Redraw (view.Bounds); + view.Draw (); var expected = @"\"; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.SetNeedsDisplay (); - view.Redraw (view.Bounds); + view.Draw (); expected = @"\"; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.SetNeedsDisplay (); - view.Redraw (view.Bounds); + view.Draw (); expected = @"\"; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); @@ -60,7 +60,7 @@ namespace Terminal.Gui.ViewsTests { Task.Delay (400).Wait(); view.SetNeedsDisplay (); - view.Redraw (view.Bounds); + view.Draw (); expected = "|"; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); @@ -71,13 +71,13 @@ namespace Terminal.Gui.ViewsTests { var view = GetSpinnerView (); view.SpinDelay = 0; - view.Redraw (view.Bounds); + view.Draw (); var expected = "|"; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); view.SetNeedsDisplay (); - view.Redraw (view.Bounds); + view.Draw (); expected = "/"; TestHelpers.AssertDriverContentsWithFrameAre (expected, output); diff --git a/UnitTests/Views/StatusBarTests.cs b/UnitTests/Views/StatusBarTests.cs index 8cc44f3d6..f798b8075 100644 --- a/UnitTests/Views/StatusBarTests.cs +++ b/UnitTests/Views/StatusBarTests.cs @@ -106,14 +106,14 @@ namespace Terminal.Gui.ViewsTests { }); Application.Top.Add (sb); - sb.Redraw (sb.Bounds); + sb.OnDrawContent (sb.Bounds); string expected = @$" ^O Open {Application.Driver.VLine} Q, CtrlMask to Quit! "; TestHelpers.AssertDriverContentsAre (expected, output); } - + [Fact] [AutoInitShutdown] public void Redraw_Output_CTRLQ () @@ -123,7 +123,7 @@ namespace Terminal.Gui.ViewsTests { new StatusItem (Key.CtrlMask | Key.Q, "~CTRL-Q~ Quit", null) }); Application.Top.Add (sb); - sb.Redraw (sb.Bounds); + sb.OnDrawContent (sb.Bounds); string expected = @$" CTRL-O Open {Application.Driver.VLine} CTRL-Q Quit diff --git a/UnitTests/Views/TabViewTests.cs b/UnitTests/Views/TabViewTests.cs index 75e2ec816..339f18a59 100644 --- a/UnitTests/Views/TabViewTests.cs +++ b/UnitTests/Views/TabViewTests.cs @@ -255,7 +255,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ @@ -266,7 +266,7 @@ namespace Terminal.Gui.ViewsTests { tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ @@ -280,7 +280,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌───────┐ @@ -291,7 +291,7 @@ namespace Terminal.Gui.ViewsTests { //switch to tab2 tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ @@ -304,7 +304,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "abcdefghijklmnopq"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌───────┐ @@ -330,7 +330,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" │12│13 @@ -341,7 +341,7 @@ namespace Terminal.Gui.ViewsTests { tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" 12│13│ @@ -356,7 +356,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" │1234567│ @@ -367,7 +367,7 @@ namespace Terminal.Gui.ViewsTests { //switch to tab2 tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" │13│ @@ -380,7 +380,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "abcdefghijklmnopq"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" │abcdefg│ @@ -398,7 +398,7 @@ namespace Terminal.Gui.ViewsTests { tv.Height = 5; tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─┐ @@ -418,7 +418,7 @@ namespace Terminal.Gui.ViewsTests { tv.ApplyStyleChanges (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" │T│ @@ -436,7 +436,7 @@ namespace Terminal.Gui.ViewsTests { tv.Height = 5; tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌┐ @@ -456,7 +456,7 @@ namespace Terminal.Gui.ViewsTests { tv.ApplyStyleChanges (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ││ @@ -482,7 +482,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -495,7 +495,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -506,7 +506,7 @@ namespace Terminal.Gui.ViewsTests { //switch to tab2 tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -519,7 +519,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "abcdefghijklmnopq"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -545,7 +545,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -556,7 +556,7 @@ namespace Terminal.Gui.ViewsTests { tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -571,7 +571,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "13"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -582,7 +582,7 @@ namespace Terminal.Gui.ViewsTests { //switch to tab2 tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -595,7 +595,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "12345678910"; tab2.Text = "abcdefghijklmnopq"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ @@ -615,7 +615,7 @@ namespace Terminal.Gui.ViewsTests { tv.ApplyStyleChanges (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ @@ -635,7 +635,7 @@ namespace Terminal.Gui.ViewsTests { tv.ApplyStyleChanges (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ @@ -655,7 +655,7 @@ namespace Terminal.Gui.ViewsTests { tv.ApplyStyleChanges (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─┐ @@ -675,7 +675,7 @@ namespace Terminal.Gui.ViewsTests { tv.ApplyStyleChanges (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─┐ @@ -697,7 +697,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "Tab0"; tab2.Text = "Les Mise" + Char.ConvertFromUtf32 (Int32.Parse ("0301", NumberStyles.HexNumber)) + "rables"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────┐ @@ -708,7 +708,7 @@ namespace Terminal.Gui.ViewsTests { tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────┐ @@ -732,7 +732,7 @@ namespace Terminal.Gui.ViewsTests { tab1.Text = "Tab0"; tab2.Text = "Les Mise" + Char.ConvertFromUtf32 (Int32.Parse ("0301", NumberStyles.HexNumber)) + "rables"; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────┐ @@ -743,7 +743,7 @@ namespace Terminal.Gui.ViewsTests { tv.SelectedTab = tab2; - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────┐ @@ -763,7 +763,7 @@ namespace Terminal.Gui.ViewsTests { tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); var tabRow = tv.Subviews[0]; Assert.Equal("TabRowView",tabRow.GetType().Name); diff --git a/UnitTests/Views/TableViewTests.cs b/UnitTests/Views/TableViewTests.cs index fd4907d19..e33b52cbe 100644 --- a/UnitTests/Views/TableViewTests.cs +++ b/UnitTests/Views/TableViewTests.cs @@ -19,6 +19,7 @@ namespace Terminal.Gui.ViewsTests { { this.output = output; } + [Fact] public void EnsureValidScrollOffsets_WithNoCells () { @@ -84,10 +85,10 @@ namespace Terminal.Gui.ViewsTests { // Set a table with 1 column tableView.Table = BuildTable (1, 50, out var dt); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); dt.Columns.Remove (dt.Columns [0]); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); } [Fact] @@ -454,7 +455,7 @@ namespace Terminal.Gui.ViewsTests { tv.Style.ShowHorizontalHeaderOverline = false; tv.Style.ShowHorizontalHeaderUnderline = false; - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" │1│2│ @@ -471,7 +472,7 @@ namespace Terminal.Gui.ViewsTests { tv.Style.ShowHorizontalHeaderOverline = true; tv.Style.ShowHorizontalHeaderUnderline = false; - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -492,7 +493,7 @@ namespace Terminal.Gui.ViewsTests { tv.Style.ShowHorizontalScrollIndicators = true; - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ├─┼─► @@ -514,7 +515,7 @@ namespace Terminal.Gui.ViewsTests { tv.Style.ShowHorizontalScrollIndicators = true; - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -532,7 +533,7 @@ namespace Terminal.Gui.ViewsTests { // the thing we are testing tv.Style.ExpandLastColumn = true; - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬──────┐ @@ -554,7 +555,7 @@ namespace Terminal.Gui.ViewsTests { // the thing we are testing tv.Style.ExpandLastColumn = false; - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┬────┐ @@ -578,7 +579,7 @@ namespace Terminal.Gui.ViewsTests { // width exactly matches the max col widths tv.Bounds = new Rect (0, 0, 5, 4); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -815,7 +816,7 @@ namespace Terminal.Gui.ViewsTests { // when the view is/isn't focused setFocusMethod.Invoke (tv, new object [] { focused, tv, true }); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -859,7 +860,7 @@ namespace Terminal.Gui.ViewsTests { // when the view is/isn't focused setFocusMethod.Invoke (tv, new object [] { focused, tv, true }); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -915,7 +916,7 @@ namespace Terminal.Gui.ViewsTests { // when the view is/isn't focused setFocusMethod.Invoke (tv, new object [] { focused, tv, true }); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -946,7 +947,7 @@ namespace Terminal.Gui.ViewsTests { // the value 2) dt.Rows [0] [1] = 5; - tv.Redraw (tv.Bounds); + tv.Draw (); expected = @" ┌─┬─┐ │A│B│ @@ -1005,7 +1006,7 @@ namespace Terminal.Gui.ViewsTests { // when the view is/isn't focused setFocusMethod.Invoke (tv, new object [] { focused, tv, true }); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" ┌─┬─┐ @@ -1036,7 +1037,7 @@ namespace Terminal.Gui.ViewsTests { // the value 2) dt.Rows [0] [1] = 5; - tv.Redraw (tv.Bounds); + tv.Draw (); expected = @" ┌─┬─┐ │A│B│ @@ -1149,7 +1150,7 @@ namespace Terminal.Gui.ViewsTests { // select last visible column tableView.SelectedColumn = 2; // column C - tableView.Redraw (tableView.Bounds); + tableView.Draw (); string expected = @" @@ -1161,7 +1162,7 @@ namespace Terminal.Gui.ViewsTests { // Scroll right tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight }); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // Note that with SmoothHorizontalScrolling only a single new column // is exposed when scrolling right. This is not always the case though @@ -1210,7 +1211,7 @@ namespace Terminal.Gui.ViewsTests { // select last visible column tableView.SelectedColumn = 2; // column C - tableView.Redraw (tableView.Bounds); + tableView.Draw (); string expected = @" @@ -1222,7 +1223,7 @@ namespace Terminal.Gui.ViewsTests { // Scroll right tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight }); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // notice that without smooth scrolling we just update the first column // rendered in the table to the newly exposed column (D). This is fast @@ -1276,7 +1277,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Style.GetOrCreateColumnStyle (1).Visible = false; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); string expected = @" @@ -1296,7 +1297,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Style.GetOrCreateColumnStyle (0).Visible = false; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); string expected = @" @@ -1315,7 +1316,6 @@ namespace Terminal.Gui.ViewsTests { for (int i = 0; i < 6; i++) { tableView.Style.GetOrCreateColumnStyle (i).Visible = false; } - tableView.LayoutSubviews (); // expect nothing to be rendered when all columns are invisible @@ -1323,13 +1323,13 @@ namespace Terminal.Gui.ViewsTests { @" "; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); TestHelpers.AssertDriverContentsAre (expected, output); // expect behavior to match when Table is null tableView.Table = null; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); TestHelpers.AssertDriverContentsAre (expected, output); } @@ -1341,7 +1341,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Style.ShowHorizontalScrollIndicators = true; tableView.Style.ShowHorizontalHeaderUnderline = true; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // normally we should have scroll indicators because DEF are of screen string expected = @@ -1362,7 +1362,7 @@ namespace Terminal.Gui.ViewsTests { │A│B│C│ ├─┼─┼─┤ │1│2│3│"; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); TestHelpers.AssertDriverContentsAre (expected, output); } @@ -1376,7 +1376,7 @@ namespace Terminal.Gui.ViewsTests { tableView.ColumnOffset = 1; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // normally we should have scroll indicators because A,E and F are of screen string expected = @@ -1396,7 +1396,7 @@ namespace Terminal.Gui.ViewsTests { │B│C│D│ ◄─┼─┼─┤ │2│3│4│"; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); TestHelpers.AssertDriverContentsAre (expected, output); // now also A is invisible so we cannot scroll in either direction @@ -1407,7 +1407,7 @@ namespace Terminal.Gui.ViewsTests { │B│C│D│ ├─┼─┼─┤ │2│3│4│"; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); TestHelpers.AssertDriverContentsAre (expected, output); } [Fact, AutoInitShutdown] @@ -1532,8 +1532,8 @@ namespace Terminal.Gui.ViewsTests { // user has rectangular selection tableView.MultiSelectedRegions.Push ( new TableView.TableSelection ( - new Point (0, 0), - new Rect (0, 0, 3, 1)) + new Point (0, 0), + new Rect (0, 0, 3, 1)) ); Assert.Equal (3, tableView.GetAllSelectedCells ().Count ()); @@ -1816,7 +1816,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Table = new DataTableSource (dt); tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // default behaviour of TableView is not to render // columns unless there is sufficient space @@ -1838,7 +1838,7 @@ namespace Terminal.Gui.ViewsTests { style.MaxWidth = 10; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" │A│B│Very Long Column │ @@ -1859,7 +1859,7 @@ namespace Terminal.Gui.ViewsTests { }; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" │A│B│Very Long Column │ @@ -1885,7 +1885,7 @@ namespace Terminal.Gui.ViewsTests { style.MinAcceptableWidth = 5; tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" │A│B│Very Long Column │ @@ -1903,7 +1903,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Bounds = new Rect (0, 0, 9, 5); tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" │A│B │ @@ -1919,7 +1919,7 @@ namespace Terminal.Gui.ViewsTests { // symbol (e.g. ┤ or │) tableView.Bounds = new Rect (0, 0, 10, 5); tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" │A│B│Very│ @@ -1962,7 +1962,7 @@ namespace Terminal.Gui.ViewsTests { // select last visible column tableView.SelectedColumn = 2; // column C - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // user can only scroll right so sees right indicator // Because first column in table is A @@ -1979,7 +1979,7 @@ namespace Terminal.Gui.ViewsTests { // since A is now pushed off screen we get indicator showing // that user can scroll left to see first column - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" @@ -1993,7 +1993,7 @@ namespace Terminal.Gui.ViewsTests { tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight }); tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight }); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); expected = @" @@ -2028,7 +2028,7 @@ namespace Terminal.Gui.ViewsTests { Application.Top.Add (tv); Application.Begin (Application.Top); - tv.Redraw (tv.Bounds); + tv.Draw (); var expected = @" @@ -2062,7 +2062,7 @@ namespace Terminal.Gui.ViewsTests { } - tv.Redraw (tv.Bounds); + tv.Draw (); expected = @" 00000000000000000000 @@ -2091,7 +2091,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Style.SmoothHorizontalScrolling = true; tableView.Style.ShowHorizontalBottomline = true; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // user can only scroll right so sees right indicator // Because first column in table is A @@ -2121,7 +2121,7 @@ namespace Terminal.Gui.ViewsTests { tableView.Style.ShowHorizontalBottomline = true; tableView.Style.ShowVerticalCellLines = false; - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // user can only scroll right so sees right indicator // Because first column in table is A @@ -2160,7 +2160,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (2, tv.SelectedRow); - tv.Redraw (tv.Bounds); + tv.OnDrawContent (tv.Bounds); string expected = @" @@ -2176,7 +2176,7 @@ namespace Terminal.Gui.ViewsTests { var normal = tv.ColorScheme.Normal; var focus = tv.ColorScheme.HotFocus = new Attribute (Color.Magenta, Color.White); - tv.Redraw (tv.Bounds); + tv.Draw (); // HotFocus color (1) should be used for rendering the selected line // But should not spill into the borders. Normal color (0) should be @@ -2218,7 +2218,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (2, tv.SelectedRow); - tv.Redraw (tv.Bounds); + tv.OnDrawContent (tv.Bounds); string expected = @" @@ -2234,7 +2234,7 @@ namespace Terminal.Gui.ViewsTests { var normal = tv.ColorScheme.Normal; var focus = tv.ColorScheme.HotFocus = new Attribute (Color.Magenta, Color.White); - tv.Redraw (tv.Bounds); + tv.Draw (); // HotFocus color (1) should be used for cells only because // AlwaysUseNormalColorForVerticalCellLines is true @@ -2274,7 +2274,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (2, tv.SelectedRow); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" @@ -2289,7 +2289,7 @@ A B C var normal = tv.ColorScheme.Normal; var focus = tv.ColorScheme.HotFocus = new Attribute (Color.Magenta, Color.White); - tv.Redraw (tv.Bounds); + tv.Draw (); // HotFocus color (1) should be used for rendering the selected line // Note that because there are no vertical cell lines we use the hot focus @@ -2344,7 +2344,7 @@ A B C tableView.BeginInit (); tableView.EndInit (); tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // user can only scroll right so sees right indicator // Because first column in table is A @@ -2409,7 +2409,7 @@ A B C var tableView = GetTwoRowSixColumnTable (); tableView.LayoutSubviews (); - tableView.Redraw (tableView.Bounds); + tableView.Draw (); // user can only scroll right so sees right indicator // Because first column in table is A @@ -2505,7 +2505,7 @@ A B C tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" @@ -2534,7 +2534,7 @@ A B C tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); string expected = @" diff --git a/UnitTests/Views/TextFieldTests.cs b/UnitTests/Views/TextFieldTests.cs index 8261708bd..502dcda8a 100644 --- a/UnitTests/Views/TextFieldTests.cs +++ b/UnitTests/Views/TextFieldTests.cs @@ -1457,19 +1457,19 @@ Les Miśerables", output); { var tf = GetTextFieldsInView (); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("", output); // Caption has no effect when focused tf.Caption = "Enter txt"; Assert.True (tf.HasFocus); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("", output); Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false); Assert.False (tf.HasFocus); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("Enter txt", output); } @@ -1480,7 +1480,7 @@ Les Miśerables", output); { var tf = GetTextFieldsInView (); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("", output); tf.Caption = "Enter txt"; @@ -1488,12 +1488,12 @@ Les Miśerables", output); // Caption should appear when not focused and no text Assert.False (tf.HasFocus); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("Enter txt", output); // but disapear when text is added tf.Text = content; - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre (content, output); } @@ -1511,7 +1511,7 @@ Les Miśerables", output); Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false); Assert.False (tf.HasFocus); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre ("Misérables", output); } @@ -1526,7 +1526,7 @@ Les Miśerables", output); Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false); Assert.False (tf.HasFocus); - tf.Redraw (tf.Bounds); + tf.Draw (); TestHelpers.AssertDriverContentsAre (expectedRender, output); } diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index 4b6b81af8..dd463d46a 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -2077,7 +2077,7 @@ namespace Terminal.Gui.ViewsTests { Application.Top.Add (tv); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is @@ -2160,7 +2160,7 @@ a Application.Top.Add (tv); Application.Top.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first @@ -2175,7 +2175,7 @@ line. tv.CursorPosition = new Point (6, 2); Assert.Equal (new Point (5, 2), tv.CursorPosition); Application.Top.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first @@ -2564,17 +2564,17 @@ line. Assert.NotNull (tv.Autocomplete); Assert.Empty (g.AllSuggestions); Assert.True (tv.ProcessKey (new KeyEvent (Key.F, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}This is the third line.F", tv.Text); Assert.Equal (new Point (24, 2), tv.CursorPosition); Assert.Empty (tv.Autocomplete.Suggestions); Assert.True (tv.ProcessKey (new KeyEvent (Key.Z | Key.CtrlMask, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}This is the third line.", tv.Text); Assert.Equal (new Point (23, 2), tv.CursorPosition); Assert.Empty (tv.Autocomplete.Suggestions); Assert.True (tv.ProcessKey (new KeyEvent (Key.R | Key.CtrlMask, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}This is the third line.F", tv.Text); Assert.Equal (new Point (24, 2), tv.CursorPosition); Assert.Empty (tv.Autocomplete.Suggestions); @@ -2593,7 +2593,7 @@ line. Assert.Equal ("second", g.AllSuggestions [5]); Assert.Equal ("third", g.AllSuggestions [^1]); Assert.True (tv.ProcessKey (new KeyEvent (Key.F, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}This is the third line.F", tv.Text); Assert.Equal (new Point (24, 2), tv.CursorPosition); Assert.Single (tv.Autocomplete.Suggestions); @@ -6112,7 +6112,7 @@ This is the second line. tv.WordWrap = true; tv.CursorPosition = new Point (12, 0); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (12, 0), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); TestHelpers.AssertDriverContentsWithFrameAre (@" @@ -6121,7 +6121,7 @@ This is the second line. ", output); ((FakeDriver)Application.Driver).SetBufferSize (6, 25); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (4, 2), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); TestHelpers.AssertDriverContentsWithFrameAre (@" @@ -6140,7 +6140,7 @@ line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (0, 3), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); TestHelpers.AssertDriverContentsWithFrameAre (@" @@ -6159,7 +6159,7 @@ line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (1, 3), tv.CursorPosition); Assert.Equal (new Point (13, 0), cp); TestHelpers.AssertDriverContentsWithFrameAre (@" @@ -6178,7 +6178,7 @@ line. ", output); Assert.True (tv.MouseEvent (new MouseEvent () { X = 0, Y = 3, Flags = MouseFlags.Button1Pressed })); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (0, 3), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); TestHelpers.AssertDriverContentsWithFrameAre (@" @@ -6221,7 +6221,7 @@ This is the second line. tv.CursorPosition = new Point (3, 0); Assert.Equal (new Point (3, 0), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (2, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6231,14 +6231,14 @@ This is the second line. tv.CursorPosition = new Point (0, 1); Assert.Equal (new Point (0, 1), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (22, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (0, 1), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6278,7 +6278,7 @@ This is the second line. tv.CursorPosition = new Point (3, 0); Assert.Equal (new Point (3, 0), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (2, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6288,14 +6288,14 @@ This is the second line. tv.CursorPosition = new Point (0, 1); Assert.Equal (new Point (0, 1), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (22, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (0, 1), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6334,7 +6334,7 @@ This is the second line. tv.CursorPosition = new Point (2, 0); Assert.Equal (new Point (2, 0), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (2, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6344,14 +6344,14 @@ This is the second line. tv.CursorPosition = new Point (22, 0); Assert.Equal (new Point (22, 0), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (22, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (0, 1), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6391,7 +6391,7 @@ This is the second line. tv.CursorPosition = new Point (2, 0); Assert.Equal (new Point (2, 0), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (2, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. @@ -6401,14 +6401,14 @@ This is the second line. tv.CursorPosition = new Point (22, 0); Assert.Equal (new Point (22, 0), tv.CursorPosition); Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (22, 0), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); - tv.Redraw (tv.Bounds); + tv.Draw (); Assert.Equal (new Point (0, 1), tv.CursorPosition); TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 2fa05c3c5..be77b936c 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1026,7 +1026,7 @@ namespace Terminal.Gui.ViewsTests { Assert.Equal (new Rect (1, 3, 10, 5), view.Frame); Assert.Equal (new Rect (0, 0, 10, 5), view._needsDisplay); - view.Redraw (view.Bounds); + view.OnDrawContent (view.Bounds); view.Frame = new Rect (1, 3, 10, 5); Assert.Equal (new Rect (1, 3, 10, 5), view.Frame); Assert.Equal (new Rect (0, 0, 10, 5), view._needsDisplay); @@ -1421,7 +1421,7 @@ namespace Terminal.Gui.ViewsTests { var savedClip = Application.Driver.Clip; Application.Driver.Clip = top.Frame; - view.Redraw (view.Bounds); + view.Draw (); top.Move (2, 15); View.Driver.AddStr ("One"); top.Move (2, 16); diff --git a/UnitTests/Views/TreeViewTests.cs b/UnitTests/Views/TreeViewTests.cs index 7d37ab2b7..f08409a08 100644 --- a/UnitTests/Views/TreeViewTests.cs +++ b/UnitTests/Views/TreeViewTests.cs @@ -740,7 +740,7 @@ namespace Terminal.Gui.ViewsTests { tv.ColorScheme = new ColorScheme (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsAre ( @"├-normal @@ -757,7 +757,7 @@ namespace Terminal.Gui.ViewsTests { tv.Collapse (n1); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsAre ( @"├+normal @@ -789,7 +789,7 @@ namespace Terminal.Gui.ViewsTests { tv.ColorScheme = new ColorScheme (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsAre ( @"├-normal @@ -806,7 +806,7 @@ namespace Terminal.Gui.ViewsTests { tv.Collapse (n1); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsAre ( @"├+normal @@ -821,7 +821,7 @@ namespace Terminal.Gui.ViewsTests { tv.ScrollOffsetVertical = 1; tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); TestHelpers.AssertDriverContentsAre ( @"└─pink @@ -852,7 +852,7 @@ namespace Terminal.Gui.ViewsTests { tv.ColorScheme = new ColorScheme (); tv.LayoutSubviews (); - tv.Redraw (tv.Bounds); + tv.Draw (); // Normal drawing of the tree view TestHelpers.AssertDriverContentsAre ( @@ -882,7 +882,7 @@ namespace Terminal.Gui.ViewsTests { // redraw now that the custom color // delegate is registered - tv.Redraw (tv.Bounds); + tv.Draw (); // Same text TestHelpers.AssertDriverContentsAre (