Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
afc8d97
POC
tig Apr 11, 2023
9da0678
View.DrawFrame now uses LineCanvas
tig Apr 11, 2023
a06a345
Fixes #2531. Toplevel should redraw only if it's needed.
BDisp Apr 11, 2023
970f0dc
Fix toplevel when mdi is enabled preventing clear the screen twice.
BDisp Apr 11, 2023
3afddc5
Massive LineCanvis updates
tig Apr 11, 2023
abd7eba
Fixes #2534. Bounds isn't updating when the Frame is changed.
BDisp Apr 13, 2023
2f66e7b
Almost everything works!
tig Apr 13, 2023
9958fcb
Had to disable a few tests but all unit test now pass again
tig Apr 13, 2023
9a222ed
Deleted ConsoleDriver.DrawWindowFrame; hacked ProgressBar
tig Apr 13, 2023
c41581a
Deleted ConsoleDriver.DrawWindowTitle; moved to Frame.DrawTitle
tig Apr 13, 2023
a57ffed
Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_autojoin…
tig Apr 13, 2023
d8b2fef
Renames BorderFrame to Border
tig Apr 13, 2023
3f9059d
Removed old commented code
tig Apr 13, 2023
0508d55
Tweaked scenario
tig Apr 13, 2023
3348848
Added auto convert \r\n to Enviornment.NewLine in TestHelpers.AssertE…
tig Apr 13, 2023
43458d5
Resolving merge conflicts.
BDisp Apr 13, 2023
27efe26
Resolving merge conflicts.
BDisp Apr 13, 2023
ea8322f
Fix merge errors.
BDisp Apr 13, 2023
0d4b1df
Fix AssertEqual newlines to platform-specific.
BDisp Apr 13, 2023
1ad43b2
Refactored frames drawing; view adds to its lineview, superview rende…
tig Apr 13, 2023
cf00926
Merge pull request #12 from BDisp/v2_autojoin_borders_fixes_2483-fix
tig Apr 13, 2023
6a4a970
New titlebar style based on Border.Top size; fixed bugs
tig Apr 13, 2023
8bbbc0c
wzard bug
tig Apr 13, 2023
baddc34
Merged bdisp's latest menu pr; hacked stuff to make work
tig Apr 13, 2023
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
14 changes: 0 additions & 14 deletions Terminal.Gui/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,9 +1223,6 @@ public static void RunMainLoopIteration (ref RunState state, bool wait, ref bool
if (!state.Toplevel._needsDisplay.IsEmpty || state.Toplevel._childNeedsDisplay || state.Toplevel.LayoutNeeded
|| MdiChildNeedsDisplay ()) {
state.Toplevel.Redraw (state.Toplevel.Bounds);
if (_debugDrawBounds) {
DrawBounds (state.Toplevel);
}
state.Toplevel.PositionCursor ();
Driver.Refresh ();
} else {
Expand Down Expand Up @@ -1269,17 +1266,6 @@ static bool MdiChildNeedsDisplay ()
return false;
}

internal static bool _debugDrawBounds = false;

// Need to look into why this does not work properly.
static void DrawBounds (View v)
{
v.DrawFrame (v.Frame, padding: 0, fill: false);
if (v.InternalSubviews != null && v.InternalSubviews.Count > 0)
foreach (var sub in v.InternalSubviews)
DrawBounds (sub);
}

/// <summary>
/// Runs the application by calling <see cref="Run(Toplevel, Func{Exception, bool})"/> with the value of <see cref="Top"/>.
/// </summary>
Expand Down
226 changes: 4 additions & 222 deletions Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -917,30 +917,6 @@ public virtual void FillRect (Rect rect, System.Rune rune = default)
}
}

/// <summary>
/// Draws the title for a Window-style view incorporating padding.
/// </summary>
/// <param name="region">Screen relative region where the frame will be drawn.</param>
/// <param name="title">The title for the window. The title will only be drawn if <c>title</c> is not null or empty and paddingTop is greater than 0.</param>
/// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
/// <param name="paddingTop">Number of rows to pad on the top (if 0 the border and title will not appear on the top).</param>
/// <param name="paddingRight">Number of columns to pad on the right (if 0 the border will not appear on the right).</param>
/// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
/// <param name="textAlignment">Not yet implemented.</param>
/// <remarks></remarks>
public virtual void DrawWindowTitle (Rect region, ustring title, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, TextAlignment textAlignment = TextAlignment.Left)
{
var width = region.Width - (paddingLeft + 1) * 2;
if (!ustring.IsNullOrEmpty (title) && width > 2 && region.Y + paddingTop <= region.Y + paddingBottom) {
Move (region.X + 2 + paddingLeft, region.Y + paddingTop);
//AddRune (' ');
var str = title.Sum (r => Math.Max (Rune.ColumnWidth (r), 1)) >= width
? TextFormatter.Format (title, width - 2, false, false) [0] : title;
AddStr (str);
//AddRune (' ');
}
}

/// <summary>
/// Enables diagnostic functions
/// </summary>
Expand All @@ -951,13 +927,13 @@ public enum DiagnosticFlags : uint {
/// </summary>
Off = 0b_0000_0000,
/// <summary>
/// When enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, LineStyle)"/> will draw a
/// When enabled, <see cref="Frame.OnDrawFrames"/> will draw a
/// ruler in the frame for any side with a padding value greater than 0.
/// </summary>
FrameRuler = 0b_0000_0001,
/// <summary>
/// When Enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, LineStyle)"/> will use
/// 'L', 'R', 'T', and 'B' for padding instead of ' '.
/// When enabled, <see cref="Frame.OnDrawFrames"/> will draw a
/// 'L', 'R', 'T', and 'B' when clearing <see cref="Thickness"/>'s instead of ' '.
/// </summary>
FramePadding = 0b_0000_0010,
}
Expand All @@ -966,201 +942,7 @@ public enum DiagnosticFlags : uint {
/// Set flags to enable/disable <see cref="ConsoleDriver"/> diagnostics.
/// </summary>
public static DiagnosticFlags Diagnostics { get; set; }

/// <summary>
/// Draws a frame for a window with padding and an optional visible border inside the padding.
/// </summary>
/// <param name="region">Screen relative region where the frame will be drawn.</param>
/// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
/// <param name="paddingTop">Number of rows to pad on the top (if 0 the border and title will not appear on the top).</param>
/// <param name="paddingRight">Number of columns to pad on the right (if 0 the border will not appear on the right).</param>
/// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
/// <param name="border">If set to <c>true</c> and any padding dimension is > 0 the border will be drawn.</param>
/// <param name="fill">If set to <c>true</c> it will clear the content area (the area inside the padding) with the current color, otherwise the content area will be left untouched.</param>
/// <param name="lineStyle">The line style to be used.</param>
[ObsoleteAttribute ("This method is obsolete in v2. Use use LineCanvas or Frame instead.", false)]
public virtual void DrawWindowFrame (Rect region, int paddingLeft = 0, int paddingTop = 0, int paddingRight = 0,
int paddingBottom = 0, bool border = true, bool fill = false, LineStyle lineStyle = LineStyle.Single)
{
char clearChar = ' ';
char leftChar = clearChar;
char rightChar = clearChar;
char topChar = clearChar;
char bottomChar = clearChar;

if ((Diagnostics & DiagnosticFlags.FramePadding) == DiagnosticFlags.FramePadding) {
leftChar = 'L';
rightChar = 'R';
topChar = 'T';
bottomChar = 'B';
clearChar = 'C';
}

void AddRuneAt (int col, int row, Rune ch)
{
Move (col, row);
AddRune (ch);
}

// fwidth is count of hLine chars
int fwidth = (int)(region.Width - (paddingRight + paddingLeft));

// fheight is count of vLine chars
int fheight = (int)(region.Height - (paddingBottom + paddingTop));

// fleft is location of left frame line
int fleft = region.X + paddingLeft - 1;

// fright is location of right frame line
int fright = fleft + fwidth + 1;

// ftop is location of top frame line
int ftop = region.Y + paddingTop - 1;

// fbottom is location of bottom frame line
int fbottom = ftop + fheight + 1;

var borderStyle = lineStyle;

Rune hLine = default, vLine = default,
uRCorner = default, uLCorner = default, lLCorner = default, lRCorner = default;

if (border) {
switch (borderStyle) {
case LineStyle.None:
break;
case LineStyle.Single:
hLine = HLine;
vLine = VLine;
uRCorner = URCorner;
uLCorner = ULCorner;
lLCorner = LLCorner;
lRCorner = LRCorner;
break;
case LineStyle.Double:
hLine = HDLine;
vLine = VDLine;
uRCorner = URDCorner;
uLCorner = ULDCorner;
lLCorner = LLDCorner;
lRCorner = LRDCorner;
break;
case LineStyle.Rounded:
hLine = HRLine;
vLine = VRLine;
uRCorner = URRCorner;
uLCorner = ULRCorner;
lLCorner = LLRCorner;
lRCorner = LRRCorner;
break;
}
} else {
hLine = vLine = uRCorner = uLCorner = lLCorner = lRCorner = clearChar;
}

// Outside top
if (paddingTop > 1) {
for (int r = region.Y; r < ftop; r++) {
for (int c = region.X; c < region.X + region.Width; c++) {
AddRuneAt (c, r, topChar);
}
}
}

// Outside top-left
for (int c = region.X; c < fleft; c++) {
AddRuneAt (c, ftop, leftChar);
}

// Frame top-left corner
AddRuneAt (fleft, ftop, paddingTop >= 0 ? (paddingLeft >= 0 ? uLCorner : hLine) : leftChar);

// Frame top
for (int c = fleft + 1; c < fleft + 1 + fwidth; c++) {
AddRuneAt (c, ftop, paddingTop > 0 ? hLine : topChar);
}

// Frame top-right corner
if (fright > fleft) {
AddRuneAt (fright, ftop, paddingTop >= 0 ? (paddingRight >= 0 ? uRCorner : hLine) : rightChar);
}

// Outside top-right corner
for (int c = fright + 1; c < fright + paddingRight; c++) {
AddRuneAt (c, ftop, rightChar);
}

// Left, Fill, Right
if (fbottom > ftop) {
for (int r = ftop + 1; r < fbottom; r++) {
// Outside left
for (int c = region.X; c < fleft; c++) {
AddRuneAt (c, r, leftChar);
}

// Frame left
AddRuneAt (fleft, r, paddingLeft > 0 ? vLine : leftChar);

// Fill
if (fill) {
for (int x = fleft + 1; x < fright; x++) {
AddRuneAt (x, r, clearChar);
}
}

// Frame right
if (fright > fleft) {
var v = vLine;
if ((Diagnostics & DiagnosticFlags.FrameRuler) == DiagnosticFlags.FrameRuler) {
v = (char)(((int)'0') + ((r - ftop) % 10)); // vLine;
}
AddRuneAt (fright, r, paddingRight > 0 ? v : rightChar);
}

// Outside right
for (int c = fright + 1; c < fright + paddingRight; c++) {
AddRuneAt (c, r, rightChar);
}
}

// Outside Bottom
for (int c = region.X; c < region.X + region.Width; c++) {
AddRuneAt (c, fbottom, leftChar);
}

// Frame bottom-left
AddRuneAt (fleft, fbottom, paddingLeft > 0 ? lLCorner : leftChar);

if (fright > fleft) {
// Frame bottom
for (int c = fleft + 1; c < fright; c++) {
var h = hLine;
if ((Diagnostics & DiagnosticFlags.FrameRuler) == DiagnosticFlags.FrameRuler) {
h = (char)(((int)'0') + ((c - fleft) % 10)); // hLine;
}
AddRuneAt (c, fbottom, paddingBottom > 0 ? h : bottomChar);
}

// Frame bottom-right
AddRuneAt (fright, fbottom, paddingRight > 0 ? (paddingBottom > 0 ? lRCorner : hLine) : rightChar);
}

// Outside right
for (int c = fright + 1; c < fright + paddingRight; c++) {
AddRuneAt (c, fbottom, rightChar);
}
}

// Out bottom - ensure top is always drawn if we overlap
if (paddingBottom > 0) {
for (int r = fbottom + 1; r < fbottom + paddingBottom; r++) {
for (int c = region.X; c < region.X + region.Width; c++) {
AddRuneAt (c, r, bottomChar);
}
}
}
}


/// <summary>
/// Suspend the application, typically needs to save the state, suspend the app and upon return, reset the console driver.
/// </summary>
Expand Down
Loading