From 69200a2f85cb77b2d20ad083c265aa0fed23e146 Mon Sep 17 00:00:00 2001 From: BDisp Date: Thu, 15 Jul 2021 18:37:44 +0100 Subject: [PATCH] Reverting the draw text. --- Terminal.Gui/Core/View.cs | 42 ++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 4d6db10ec..7d575c851 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -1338,7 +1338,18 @@ namespace Terminal.Gui { var clipRect = new Rect (Point.Empty, frame.Size); - DrawText (); + if (ColorScheme != null) { + Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal); + } + + if (!ustring.IsNullOrEmpty (Text) || (this is Label && !AutoSize)) { + Clear (); + // Draw any Text + if (textFormatter != null) { + textFormatter.NeedsFormat = true; + } + textFormatter?.Draw (ViewToScreen (Bounds), HasFocus ? ColorScheme.Focus : ColorScheme.Normal, HasFocus ? ColorScheme.HotFocus : ColorScheme.HotNormal); + } // Invoke DrawContentEvent OnDrawContent (bounds); @@ -1366,33 +1377,6 @@ namespace Terminal.Gui { ClearNeedsDisplay (); } - void DrawText () - { - if (ColorScheme != null) { - Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal); - } - - if (!ustring.IsNullOrEmpty (Text)) { - var savedClip = ClipToBounds (); - Rect viewBounds = Bounds; - if (SuperView != null && viewBounds.Width > SuperView.Bounds.Width) { - viewBounds.Width = SuperView.Bounds.Width; - } - if (SuperView != null && viewBounds.Height > SuperView.Bounds.Height) { - viewBounds.Height = SuperView.Bounds.Height; - } - var viewFrame = ViewToScreen (viewBounds); - Clear (viewFrame); - // Draw any Text - if (textFormatter != null) { - textFormatter.NeedsFormat = true; - } - textFormatter?.Draw (viewFrame, HasFocus ? ColorScheme.Focus : ColorScheme.Normal, HasFocus ? ColorScheme.HotFocus : ColorScheme.HotNormal); - - Driver.Clip = savedClip; - } - } - /// /// Event invoked when the content area of the View is to be drawn. /// @@ -2276,7 +2260,7 @@ namespace Terminal.Gui { /// public bool Visible { get; set; } = true; - internal bool CanBeVisible (View view) + bool CanBeVisible (View view) { if (!view.Visible) { return false;