diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index a6cdb4fc8..2690f3659 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -11,11 +11,10 @@ // Optimizations // - Add rendering limitation to the exposed area using System; -using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics; using System.Linq; +using System.Reflection; using NStack; namespace Terminal.Gui { @@ -1502,16 +1501,19 @@ namespace Terminal.Gui { var clipRect = new Rect (Point.Empty, frame.Size); - //if (ColorScheme != null && !(this is Toplevel)) { if (ColorScheme != null) { Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal); } if (Border != null) { Border.DrawContent (this); + } else if ((GetType ().IsPublic || GetType ().IsNestedPublic) && !IsOverridden (this, "Redraw") && + (!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded)) { + + Clear (ViewToScreen (bounds)); } - if (!ustring.IsNullOrEmpty (TextFormatter.Text) || (this is Label && !AutoSize)) { + if (!ustring.IsNullOrEmpty (TextFormatter.Text)) { Clear (); // Draw any Text if (TextFormatter != null) { @@ -3047,5 +3049,19 @@ namespace Terminal.Gui { return top; } + + /// + /// Check if the is overridden in the . + /// + /// The view. + /// The method name. + /// if it's overridden, otherwise. + public bool IsOverridden (View view, string method) + { + Type t = view.GetType (); + MethodInfo m = t.GetMethod (method); + + return (m.DeclaringType == t || m.ReflectedType == t) && m.GetBaseDefinition ().DeclaringType == typeof (Responder); + } } } diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs index 820275178..fc186bc0e 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -13,7 +13,6 @@ using System; using System.Linq; -using System.Reflection; namespace Terminal.Gui { /// @@ -217,7 +216,7 @@ namespace Terminal.Gui { /// The view to add to the scrollview. public override void Add (View view) { - if (!IsOverridden (view)) { + if (!IsOverridden (view, "MouseEvent")) { view.MouseEnter += View_MouseEnter; view.MouseLeave += View_MouseLeave; } @@ -237,14 +236,6 @@ namespace Terminal.Gui { Application.GrabMouse (this); } - bool IsOverridden (View view) - { - Type t = view.GetType (); - MethodInfo m = t.GetMethod ("MouseEvent"); - - return (m.DeclaringType == t || m.ReflectedType == t) && m.GetBaseDefinition ().DeclaringType == typeof (Responder); - } - /// /// Gets or sets the visibility for the horizontal scroll indicator. /// @@ -515,7 +506,7 @@ namespace Terminal.Gui { vertical.MouseEvent (me); } else if (me.Y == horizontal.Frame.Y && ShowHorizontalScrollIndicator) { horizontal.MouseEvent (me); - } else if (IsOverridden (me.View)) { + } else if (IsOverridden (me.View, "MouseEvent")) { Application.UngrabMouse (); } return true;