Fixes 2094. View does not clear it's background.

This commit is contained in:
BDisp
2022-10-19 20:24:03 +01:00
parent a823b622ab
commit 516e7e25de
2 changed files with 22 additions and 15 deletions

View File

@@ -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;
}
/// <summary>
/// Check if the <paramref name="method"/> is overridden in the <paramref name="view"/>.
/// </summary>
/// <param name="view">The view.</param>
/// <param name="method">The method name.</param>
/// <returns><see langword="true"/> if it's overridden, <see langword="false"/>otherwise.</returns>
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);
}
}
}

View File

@@ -13,7 +13,6 @@
using System;
using System.Linq;
using System.Reflection;
namespace Terminal.Gui {
/// <summary>
@@ -217,7 +216,7 @@ namespace Terminal.Gui {
/// <param name="view">The view to add to the scrollview.</param>
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);
}
/// <summary>
/// Gets or sets the visibility for the horizontal scroll indicator.
/// </summary>
@@ -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;