mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixes #2983. View need a alternative DrawFrame for the v2.
This commit is contained in:
@@ -503,5 +503,25 @@ namespace Terminal.Gui {
|
|||||||
DrawContentComplete?.Invoke (this, new DrawEventArgs (contentArea));
|
DrawContentComplete?.Invoke (this, new DrawEventArgs (contentArea));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw a frame based on the passed bounds to the screen relative.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bounds">The bounds view relative.</param>
|
||||||
|
/// <param name="lineStyle">The line style.</param>
|
||||||
|
/// <param name="attribute">The color to use.</param>
|
||||||
|
public void DrawFrame (Rect bounds, LineStyle lineStyle, Attribute? attribute = null)
|
||||||
|
{
|
||||||
|
var vts = ViewToScreen (bounds);
|
||||||
|
LineCanvas.AddLine (new Point (vts.X, vts.Y), vts.Width,
|
||||||
|
Orientation.Horizontal, lineStyle, attribute);
|
||||||
|
LineCanvas.AddLine (new Point (vts.Right - 1, vts.Y), vts.Height,
|
||||||
|
Orientation.Vertical, lineStyle, attribute);
|
||||||
|
LineCanvas.AddLine (new Point (vts.X, vts.Bottom - 1), vts.Width,
|
||||||
|
Orientation.Horizontal, lineStyle, attribute);
|
||||||
|
LineCanvas.AddLine (new Point (vts.X, vts.Y), vts.Height,
|
||||||
|
Orientation.Vertical, lineStyle, attribute);
|
||||||
|
|
||||||
|
OnRenderLineCanvas ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,6 +334,23 @@ t ", output);
|
|||||||
Application.Refresh ();
|
Application.Refresh ();
|
||||||
TestHelpers.AssertDriverContentsWithFrameAre ("", output);
|
TestHelpers.AssertDriverContentsWithFrameAre ("", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact, AutoInitShutdown]
|
||||||
|
public void DrawFrame_Test ()
|
||||||
|
{
|
||||||
|
var label = new View () { X = Pos.Center (), Y = Pos.Center (), Text = "test", AutoSize = true };
|
||||||
|
var view = new View () { Width = 10, Height = 5 };
|
||||||
|
view.DrawContentComplete += (s, e) => view.DrawFrame (view.Bounds, LineStyle.Single);
|
||||||
|
view.Add (label);
|
||||||
|
Application.Top.Add (view);
|
||||||
|
Application.Begin (Application.Top);
|
||||||
|
|
||||||
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||||
|
┌────────┐
|
||||||
|
│ │
|
||||||
|
│ test │
|
||||||
|
│ │
|
||||||
|
└────────┘", output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user