Made Arrangement = ViewArrangement.Fixed the default for Toplevels

This commit is contained in:
Tig
2024-04-15 17:08:12 -06:00
parent de1a844787
commit 069089ee27
8 changed files with 45 additions and 28 deletions

View File

@@ -355,7 +355,8 @@ public abstract class ConsoleDriver
{
Contents [r, c] = new Cell
{
Rune = (Rune)' ', Attribute = CurrentAttribute, IsDirty = true
Rune = (rune != default ? rune : (Rune)' '),
Attribute = CurrentAttribute, IsDirty = true
};
_dirtyLines [r] = true;
}

View File

@@ -56,6 +56,7 @@ public class Dialog : Window
/// </remarks>
public Dialog ()
{
Arrangement = ViewArrangement.Movable;
X = Pos.Center ();
Y = Pos.Center ();
ValidatePosDim = true;

View File

@@ -29,7 +29,7 @@ public partial class Toplevel : View
/// </summary>
public Toplevel ()
{
Arrangement = ViewArrangement.Movable;
Arrangement = ViewArrangement.Fixed;
Width = Dim.Fill ();
Height = Dim.Fill ();

View File

@@ -30,6 +30,7 @@ public class Adornments : Scenario
var window = new Window
{
Title = "The _Window",
Arrangement = ViewArrangement.Movable,
X = Pos.Right(editor),
Width = Dim.Percent (60),
Height = Dim.Percent (80),

View File

@@ -36,6 +36,7 @@ public class BackgroundWorkerCollection : Scenario
public OverlappedMain ()
{
Arrangement = ViewArrangement.Movable;
Data = "OverlappedMain";
IsOverlappedContainer = true;
@@ -258,6 +259,8 @@ public class BackgroundWorkerCollection : Scenario
public StagingUIController ()
{
Arrangement = ViewArrangement.Movable;
X = Pos.Center ();
Y = Pos.Center ();
Width = Dim.Percent (85);
@@ -338,6 +341,8 @@ public class BackgroundWorkerCollection : Scenario
public WorkerApp ()
{
Arrangement = ViewArrangement.Movable;
Data = "WorkerApp";
Title = "Worker collection Log";

View File

@@ -10,18 +10,19 @@ namespace UICatalog.Scenarios;
[ScenarioCategory ("Text and Formatting")]
public class TextFormatterDemo : Scenario
{
public override void Setup ()
public override void Main ()
{
// TODO: Move this to another Scenario that specifically tests `Views` that have no subviews.
//Top.Text = "Press CTRL-Q to Quit. This is the Text for the TopLevel View. TextAlignment.Centered was specified. It is intentionally very long to illustrate word wrap.\n" +
// "<-- There is a new line here to show a hard line break. You should see this text bleed underneath the subviews, which start at Y = 3.";
//Top.TextAlignment = TextAlignment.Centered;
//Top.ColorScheme = Colors.ColorSchemes ["Base"];
Application.Init ();
var app = new Window ()
{
Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
};
// Make Win smaller so sizing the window horizontally will make the
// labels shrink to zero-width
Win.X = 10;
Win.Width = Dim.Fill (10);
app.X = 10;
app.Width = Dim.Fill (10);
var text = "Hello world, how are you today? Pretty neat!\nSecond line\n\nFourth Line.";
@@ -35,7 +36,7 @@ public class TextFormatterDemo : Scenario
Y = 0,
AutoSize = false,
Height = 10,
Width = Dim.Fill ()
Width = Dim.Fill (),
};
var block = new StringBuilder ();
@@ -50,17 +51,17 @@ public class TextFormatterDemo : Scenario
block.AppendLine (" ░ ░ ░ ░ ░ ░ ░ ");
block.AppendLine (" ░ ░ ");
blockText.Text = block.ToString (); // .Replace(" ", "\u00A0"); // \u00A0 is 'non-breaking space
Win.Add (blockText);
app.Add (blockText);
var unicodeCheckBox = new CheckBox
{
X = 0,
Y = Pos.Bottom (blockText) + 1,
Text = "Unicode",
Checked = Top.HotKeySpecifier == (Rune)' '
Checked = app.HotKeySpecifier == (Rune)' '
};
Win.Add (unicodeCheckBox);
app.Add (unicodeCheckBox);
List<TextAlignment> alignments = Enum.GetValues (typeof (TextAlignment)).Cast<TextAlignment> ().ToList ();
Label [] singleLines = new Label [alignments.Count];
@@ -97,26 +98,26 @@ public class TextFormatterDemo : Scenario
{
Y = Pos.Bottom (unicodeCheckBox) + 1, Text = "Demonstrating multi-line and word wrap:"
};
Win.Add (label);
app.Add (label);
foreach (TextAlignment alignment in alignments)
{
label = new Label { Y = Pos.Bottom (label), Text = $"{alignment}:" };
Win.Add (label);
app.Add (label);
singleLines [(int)alignment].Y = Pos.Bottom (label);
Win.Add (singleLines [(int)alignment]);
app.Add (singleLines [(int)alignment]);
label = singleLines [(int)alignment];
}
label = new Label { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
Win.Add (label);
app.Add (label);
foreach (TextAlignment alignment in alignments)
{
label = new Label { Y = Pos.Bottom (label), Text = $"{alignment}:" };
Win.Add (label);
app.Add (label);
multipleLines [(int)alignment].Y = Pos.Bottom (label);
Win.Add (multipleLines [(int)alignment]);
app.Add (multipleLines [(int)alignment]);
label = multipleLines [(int)alignment];
}
@@ -128,5 +129,8 @@ public class TextFormatterDemo : Scenario
multipleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
}
};
Application.Run (app);
app.Dispose ();
}
}

View File

@@ -809,7 +809,11 @@ public class ApplicationTests
Init ();
// Don't use Dialog here as it has more layout logic. Use Window instead.
var w = new Window { Width = 5, Height = 5 };
var w = new Window
{
Width = 5, Height = 5,
Arrangement = ViewArrangement.Movable
};
((FakeDriver)Application.Driver).SetBufferSize (10, 10);
RunState rs = Application.Begin (w);

View File

@@ -26,10 +26,10 @@ public class ToplevelTests
}
[Fact]
public void Arrangement_Is_Movable ()
public void Arrangement_Default_Is_Fixed ()
{
var top = new Toplevel ();
Assert.Equal (ViewArrangement.Movable, top.Arrangement);
Assert.Equal (ViewArrangement.Fixed, top.Arrangement);
}
#if BROKE_IN_2927
@@ -869,7 +869,8 @@ public class ToplevelTests
X = 2,
Y = 2,
Width = 10,
Height = 3
Height = 3,
Arrangement = ViewArrangement.Movable
};
Application.Run (testWindow);
}
@@ -964,7 +965,7 @@ public class ToplevelTests
[AutoInitShutdown]
public void Mouse_Drag_On_Top_With_Superview_Not_Null ()
{
var win = new Window { X = 3, Y = 2, Width = 10, Height = 5 };
var win = new Window { X = 3, Y = 2, Width = 10, Height = 5, Arrangement = ViewArrangement.Movable };
Toplevel top = new ();
top.Add (win);
@@ -1331,7 +1332,7 @@ public class ToplevelTests
Height = 16,
ContentSize = new (200, 100)
};
var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3) };
var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), Arrangement = ViewArrangement.Movable };
scrollView.Add (win);
Toplevel top = new ();
top.Add (scrollView);
@@ -1380,7 +1381,7 @@ public class ToplevelTests
public void Window_Viewport_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom ()
{
Toplevel top = new ();
var window = new Window { Width = 20, Height = 3 };
var window = new Window { Width = 20, Height = 3, Arrangement = ViewArrangement.Movable};
RunState rsTop = Application.Begin (top);
((FakeDriver)Application.Driver).SetBufferSize (40, 10);
RunState rsWindow = Application.Begin (window);
@@ -1471,7 +1472,7 @@ public class ToplevelTests
public void Modal_As_Top_Will_Drag_Cleanly ()
{
// Don't use Dialog as a Top, use a Window instead - dialog has complex layout behavior that is not needed here.
var window = new Window { Width = 10, Height = 3 };
var window = new Window { Width = 10, Height = 3, Arrangement = ViewArrangement.Movable };
window.Add (
new Label