diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index 7f42e23fc..aa121d131 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -14,6 +14,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
+using System.Reflection;
using NStack;
namespace Terminal.Gui {
@@ -1495,16 +1496,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) {
@@ -3050,5 +3054,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;
diff --git a/UnitTests/ViewTests.cs b/UnitTests/ViewTests.cs
index 5218060ab..eeb606d65 100644
--- a/UnitTests/ViewTests.cs
+++ b/UnitTests/ViewTests.cs
@@ -2123,6 +2123,28 @@ Y
Assert.Equal (new Rect (0, 0, 8, 4), pos);
}
+ [Fact, AutoInitShutdown]
+ public void DrawFrame_With_Minimum_Size ()
+ {
+ var view = new View (new Rect (0, 0, 2, 2));
+
+ view.DrawContent += (_) => view.DrawFrame (view.Bounds, 0, true);
+
+ Assert.Equal (Point.Empty, new Point (view.Frame.X, view.Frame.Y));
+ Assert.Equal (new Size (2, 2), new Size (view.Frame.Width, view.Frame.Height));
+
+ Application.Top.Add (view);
+ Application.Begin (Application.Top);
+
+ var expected = @"
+┌┐
+└┘
+";
+
+ var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
+ Assert.Equal (new Rect (0, 0, 2, 2), pos);
+ }
+
[Fact, AutoInitShutdown]
public void DrawFrame_With_Negative_Positions ()
{
@@ -2452,7 +2474,7 @@ Y
Width = Dim.Fill (),
Height = Dim.Fill ()
};
- view.LayoutComplete += e => {
+ view.DrawContent += e => {
view.DrawFrame (view.Bounds);
var savedClip = Application.Driver.Clip;
Application.Driver.Clip = new Rect (1, 1, view.Bounds.Width - 2, view.Bounds.Height - 2);
@@ -2500,7 +2522,7 @@ Y
Width = Dim.Fill (),
Height = Dim.Fill ()
};
- view.LayoutComplete += e => {
+ view.DrawContent += e => {
view.DrawFrame (view.Bounds);
var savedClip = Application.Driver.Clip;
Application.Driver.Clip = new Rect (1, 1, view.Bounds.Width - 2, view.Bounds.Height - 2);