Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions Terminal.Gui/View/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1756,18 +1756,15 @@ protected void ClearNeedsDisplay ()
/// <returns></returns>
public virtual bool OnDrawFrames ()
{
if (!IsInitialized) {
return false;
}
//if (!IsInitialized) {
Comment thread
BDisp marked this conversation as resolved.
Outdated
// return false;
//}

var prevClip = Driver.Clip;
Driver.Clip = ViewToScreen (Frame);

// TODO: Figure out what we should do if we have no superview
//if (SuperView != null) {
// TODO: Clipping is disabled for now to ensure we see errors
Driver.Clip = new Rect (0, 0, Driver.Cols, Driver.Rows);// screenBounds;// SuperView.ClipToBounds ();
//}
if (SuperView != null) {
Comment thread
BDisp marked this conversation as resolved.
Outdated
Driver.Clip = SuperView.ClipToBounds ();
}

// Each of these renders lines to either this View's LineCanvas
// Those lines will be finally rendered in OnRenderLineCanvas
Expand Down Expand Up @@ -1805,6 +1802,8 @@ public virtual void Redraw (Rect bounds)

OnDrawFrames ();

OnRenderLineCanvas ();
Comment thread
BDisp marked this conversation as resolved.
Outdated

var prevClip = ClipToBounds ();

if (ColorScheme != null) {
Expand Down Expand Up @@ -1844,8 +1843,6 @@ public virtual void Redraw (Rect bounds)
OnDrawContentComplete (bounds);
Driver.Clip = prevClip;

OnRenderLineCanvas ();

// BUGBUG: v2 - We should be able to use View.SetClip here and not have to resort to knowing Driver details.
ClearLayoutNeeded ();
ClearNeedsDisplay ();
Expand Down
3 changes: 1 addition & 2 deletions Terminal.Gui/Views/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ internal Attribute DetermineColorSchemeFor (MenuItem item, int index)

public override void Redraw (Rect bounds)
{

if (barItems.Children == null) {
return;
}
Expand All @@ -547,6 +546,7 @@ public override void Redraw (Rect bounds)
Driver.SetAttribute (GetNormalColor ());

OnDrawFrames ();
OnRenderLineCanvas ();

for (int i = Bounds.Y; i < barItems.Children.Length; i++) {
if (i < 0)
Expand Down Expand Up @@ -646,7 +646,6 @@ public override void Redraw (Rect bounds)
}
Driver.Clip = savedClip;

OnRenderLineCanvas ();
PositionCursor ();
}

Expand Down
158 changes: 79 additions & 79 deletions UnitTests/Views/ContextMenuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -905,84 +905,84 @@ public void Key_Open_And_Close_The_ContextMenu ()
}

// BUGBUG: Broke this test with #2483 - @bdisp I need your help figuring out why
// [Fact, AutoInitShutdown]
// public void Draw_A_ContextManu_Over_A_Dialog ()
// {
// var top = Application.Top;
// var win = new Window ();
// top.Add (win);
// Application.Begin (top);
// ((FakeDriver)Application.Driver).SetBufferSize (20, 15);

// Assert.Equal (new Rect (0, 0, 20, 15), win.Frame);
// TestHelpers.AssertDriverContentsWithFrameAre (@"
//┌──────────────────┐
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//└──────────────────┘", output);

// var dialog = new Dialog () { X = 2, Y = 2, Width = 15, Height = 4 };
// dialog.Add (new TextField ("Test") { X = Pos.Center (), Width = 10 });
// var rs = Application.Begin (dialog);

// Assert.Equal (new Rect (2, 2, 15, 4), dialog.Frame);
// TestHelpers.AssertDriverContentsWithFrameAre (@"
//┌──────────────────┐
//│ │
//│ ┌─────────────┐ │
//│ │ Test │ │
//│ │ │ │
//│ └─────────────┘ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//│ │
//└──────────────────┘", output);

// ReflectionTools.InvokePrivate (
// typeof (Application),
// "ProcessMouseEvent",
// new MouseEvent () {
// X = 9,
// Y = 3,
// Flags = MouseFlags.Button3Clicked
// });

// var firstIteration = false;
// Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
// TestHelpers.AssertDriverContentsWithFrameAre (@"
//┌──────────────────┐
//│ │
//│ ┌─────────────┐ │
//│ │ Test │ │
//┌───────────────────
//│ Select All Ctrl+
//│ Delete All Ctrl+
//│ Copy Ctrl+
//│ Cut Ctrl+
//│ Paste Ctrl+
//│ Undo Ctrl+
//│ Redo Ctrl+
//└───────────────────
//│ │
//└──────────────────┘", output);

// Application.End (rs);
// }
[Fact, AutoInitShutdown]
public void Draw_A_ContextManu_Over_A_Dialog ()
{
var top = Application.Top;
var win = new Window ();
top.Add (win);
Application.Begin (top);
((FakeDriver)Application.Driver).SetBufferSize (20, 15);

Assert.Equal (new Rect (0, 0, 20, 15), win.Frame);
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌──────────────────┐
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────┘", output);

var dialog = new Dialog () { X = 2, Y = 2, Width = 15, Height = 4 };
dialog.Add (new TextField ("Test") { X = Pos.Center (), Width = 10 });
var rs = Application.Begin (dialog);

Assert.Equal (new Rect (2, 2, 15, 4), dialog.Frame);
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌──────────────────┐
│ │
│ ┌─────────────┐ │
│ │ Test │ │
│ │ │ │
│ └─────────────┘ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────┘", output);

ReflectionTools.InvokePrivate (
typeof (Application),
"ProcessMouseEvent",
new MouseEvent () {
X = 9,
Y = 3,
Flags = MouseFlags.Button3Clicked
});

var firstIteration = false;
Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌──────────────────┐
│ │
│ ┌─────────────┐ │
│ │ Test │ │
┌───────────────────
│ Select All Ctrl+
│ Delete All Ctrl+
│ Copy Ctrl+
│ Cut Ctrl+
│ Paste Ctrl+
│ Undo Ctrl+
│ Redo Ctrl+
└───────────────────
│ │
└──────────────────┘", output);

Application.End (rs);
}
}
}
2 changes: 1 addition & 1 deletion UnitTests/Views/MenuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ public void Menu_With_Separator ()
File
┌────────────────────────────┐
│ Open Open a file Ctrl+O │
────────────────────────────
────────────────────────────
│ Quit │
└────────────────────────────┘", output);
}
Expand Down
Loading