mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
Rename SplitView to TileView
This commit is contained in:
@@ -7,11 +7,11 @@ namespace Terminal.Gui {
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="View"/> consisting of a moveable bar that divides
|
||||
/// the display area into resizeable views.
|
||||
/// the display area into resizeable <see cref="Tiles"/>.
|
||||
/// </summary>
|
||||
public class SplitView : View {
|
||||
public class TileView : View {
|
||||
|
||||
SplitView parentSplitView;
|
||||
TileView parentTileView;
|
||||
|
||||
/// TODO: Might be able to make Border virtual and override here
|
||||
/// To make this more API friendly
|
||||
@@ -38,7 +38,7 @@ namespace Terminal.Gui {
|
||||
|
||||
List<Tile> tiles;
|
||||
private List<Pos> splitterDistances;
|
||||
private List<SplitContainerLineView> splitterLines;
|
||||
private List<TileViewLineView> splitterLines;
|
||||
|
||||
/// <summary>
|
||||
/// The sub sections hosted by the view
|
||||
@@ -54,13 +54,13 @@ namespace Terminal.Gui {
|
||||
private Orientation orientation = Orientation.Vertical;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the SplitContainer class.
|
||||
/// Creates a new instance of the TileView class.
|
||||
/// </summary>
|
||||
public SplitView () : this (2)
|
||||
public TileView () : this (2)
|
||||
{
|
||||
}
|
||||
|
||||
public SplitView (int tiles)
|
||||
public TileView (int tiles)
|
||||
{
|
||||
CanFocus = true;
|
||||
RebuildForTileCount (tiles);
|
||||
@@ -89,7 +89,7 @@ namespace Terminal.Gui {
|
||||
tiles = new List<Tile> ();
|
||||
// TODO: keep these if growing
|
||||
splitterDistances = new List<Pos> ();
|
||||
splitterLines = new List<SplitContainerLineView> ();
|
||||
splitterLines = new List<TileViewLineView> ();
|
||||
|
||||
RemoveAll ();
|
||||
tiles.Clear ();
|
||||
@@ -105,7 +105,7 @@ namespace Terminal.Gui {
|
||||
if (i > 0) {
|
||||
var currentPos = Pos.Percent ((100 / count) * i);
|
||||
splitterDistances.Add (currentPos);
|
||||
var line = new SplitContainerLineView (this, i - 1);
|
||||
var line = new TileViewLineView (this, i - 1);
|
||||
Add (line);
|
||||
splitterLines.Add (line);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace Terminal.Gui {
|
||||
contentArea.Y + 1,
|
||||
Math.Max (0, contentArea.Width - 2),
|
||||
Math.Max (0, contentArea.Height - 2));
|
||||
} else if (HasAnyTitles () && IsRootSplitContainer ()) {
|
||||
} else if (HasAnyTitles () && IsRootTileView ()) {
|
||||
// TODO: Bound with Max/Min
|
||||
contentArea = new Rect (
|
||||
contentArea.X,
|
||||
@@ -241,7 +241,7 @@ namespace Terminal.Gui {
|
||||
}
|
||||
|
||||
splitterDistances [idx] = value;
|
||||
GetRootSplitContainer ().LayoutSubviews ();
|
||||
GetRootTileView ().LayoutSubviews ();
|
||||
OnSplitterMoved (idx);
|
||||
}
|
||||
|
||||
@@ -264,9 +264,9 @@ namespace Terminal.Gui {
|
||||
|
||||
var lc = new LineCanvas ();
|
||||
|
||||
var allLines = GetAllChildSplitContainerLineViewRecursively (this);
|
||||
var allLines = GetAllChildTileViewLineViewRecursively (this);
|
||||
|
||||
if (IsRootSplitContainer ()) {
|
||||
if (IsRootTileView ()) {
|
||||
if (HasBorder ()) {
|
||||
|
||||
lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, IntegratedBorder);
|
||||
@@ -336,19 +336,19 @@ namespace Terminal.Gui {
|
||||
|
||||
/// <summary>
|
||||
/// Converts <see cref="View1"/> from a regular <see cref="View"/>
|
||||
/// container to a new nested <see cref="SplitView"/>. If <see cref="View1"/>
|
||||
/// is already a <see cref="SplitView"/> then returns false.
|
||||
/// container to a new nested <see cref="TileView"/>. If <see cref="View1"/>
|
||||
/// is already a <see cref="TileView"/> then returns false.
|
||||
/// </summary>
|
||||
/// <remarks>After successful splitting, the returned container's <see cref="View1"/>
|
||||
/// will contain the original content and <see cref="View1Title"/> (if any) while
|
||||
/// <see cref="View2"/> will be empty and available for adding to.
|
||||
/// for adding to.</remarks>
|
||||
/// <param name="result">The new <see cref="SplitView"/> now showing in
|
||||
/// <param name="result">The new <see cref="TileView"/> now showing in
|
||||
/// <see cref="View1"/> or the existing one if it was already been converted before.</param>
|
||||
/// <returns><see langword="true"/> if a <see cref="View"/> was converted to a new nested
|
||||
/// <see cref="SplitView"/>. <see langword="false"/> if it was already a nested
|
||||
/// <see cref="SplitView"/></returns>
|
||||
public bool TrySplitView(int idx, int panels, out SplitView result)
|
||||
/// <see cref="TileView"/>. <see langword="false"/> if it was already a nested
|
||||
/// <see cref="TileView"/></returns>
|
||||
public bool TryTileView(int idx, int panels, out TileView result)
|
||||
{
|
||||
// when splitting a view into 2 sub views we will need to migrate
|
||||
// the title too
|
||||
@@ -356,22 +356,22 @@ namespace Terminal.Gui {
|
||||
var title = tile.Title;
|
||||
View toMove = tile.View;
|
||||
|
||||
if (toMove is SplitView existing) {
|
||||
if (toMove is TileView existing) {
|
||||
result = existing;
|
||||
return false;
|
||||
}
|
||||
|
||||
var newContainer = new SplitView(panels) {
|
||||
var newContainer = new TileView(panels) {
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
parentSplitView = this,
|
||||
parentTileView = this,
|
||||
};
|
||||
|
||||
// Take everything out of the View we are moving
|
||||
var childViews = toMove.Subviews.ToArray();
|
||||
toMove.RemoveAll ();
|
||||
|
||||
// Remove the view itself and replace it with the new SplitContainer
|
||||
// Remove the view itself and replace it with the new TileView
|
||||
Remove (toMove);
|
||||
Add (newContainer);
|
||||
|
||||
@@ -388,34 +388,34 @@ namespace Terminal.Gui {
|
||||
}
|
||||
|
||||
|
||||
private List<SplitContainerLineView> GetAllChildSplitContainerLineViewRecursively (View v)
|
||||
private List<TileViewLineView> GetAllChildTileViewLineViewRecursively (View v)
|
||||
{
|
||||
var lines = new List<SplitContainerLineView> ();
|
||||
var lines = new List<TileViewLineView> ();
|
||||
|
||||
foreach (var sub in v.Subviews) {
|
||||
if (sub is SplitContainerLineView s) {
|
||||
if (s.Parent.GetRootSplitContainer () == this) {
|
||||
if (sub is TileViewLineView s) {
|
||||
if (s.Parent.GetRootTileView () == this) {
|
||||
lines.Add (s);
|
||||
}
|
||||
} else {
|
||||
lines.AddRange (GetAllChildSplitContainerLineViewRecursively (sub));
|
||||
lines.AddRange (GetAllChildTileViewLineViewRecursively (sub));
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private bool IsRootSplitContainer ()
|
||||
private bool IsRootTileView ()
|
||||
{
|
||||
// TODO: don't want to layout subviews since the parent recursively lays them all out
|
||||
return parentSplitView == null;
|
||||
return parentTileView == null;
|
||||
}
|
||||
private SplitView GetRootSplitContainer ()
|
||||
private TileView GetRootTileView ()
|
||||
{
|
||||
SplitView root = this;
|
||||
TileView root = this;
|
||||
|
||||
while (root.parentSplitView != null) {
|
||||
root = root.parentSplitView;
|
||||
while (root.parentTileView != null) {
|
||||
root = root.parentTileView;
|
||||
}
|
||||
|
||||
return root;
|
||||
@@ -551,15 +551,15 @@ namespace Terminal.Gui {
|
||||
}
|
||||
}
|
||||
|
||||
private class SplitContainerLineView : LineView {
|
||||
public SplitView Parent { get; private set; }
|
||||
private class TileViewLineView : LineView {
|
||||
public TileView Parent { get; private set; }
|
||||
public int Idx { get; }
|
||||
|
||||
Point? dragPosition;
|
||||
Pos dragOrignalPos;
|
||||
public Point? moveRuneRenderLocation;
|
||||
|
||||
public SplitContainerLineView (SplitView parent, int idx)
|
||||
public TileViewLineView (TileView parent, int idx)
|
||||
{
|
||||
CanFocus = true;
|
||||
TabStop = true;
|
||||
@@ -731,7 +731,7 @@ namespace Terminal.Gui {
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Moves <see cref="Parent"/> <see cref="SplitView.SplitterDistance"/> to
|
||||
/// Moves <see cref="Parent"/> <see cref="TileView.SplitterDistance"/> to
|
||||
/// <see cref="Pos"/> <paramref name="newValue"/> preserving <see cref="Pos"/> format
|
||||
/// (absolute / relative) that <paramref name="oldValue"/> had.
|
||||
/// </para>
|
||||
@@ -785,8 +785,8 @@ namespace Terminal.Gui {
|
||||
|
||||
private class ChildSplitterLine {
|
||||
|
||||
readonly SplitContainerLineView currentLine;
|
||||
internal ChildSplitterLine (SplitContainerLineView currentLine)
|
||||
readonly TileViewLineView currentLine;
|
||||
internal ChildSplitterLine (TileViewLineView currentLine)
|
||||
{
|
||||
this.currentLine = currentLine;
|
||||
}
|
||||
@@ -805,34 +805,34 @@ namespace Terminal.Gui {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="SplitContainer"/> events.
|
||||
/// Provides data for <see cref="TileView"/> events.
|
||||
/// </summary>
|
||||
public class SplitterEventArgs : EventArgs {
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="SplitterEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="splitContainer"></param>
|
||||
/// <param name="tileView"></param>
|
||||
/// <param name="splitterDistance"></param>
|
||||
public SplitterEventArgs (SplitView splitContainer, int idx, Pos splitterDistance)
|
||||
public SplitterEventArgs (TileView tileView, int idx, Pos splitterDistance)
|
||||
{
|
||||
SplitterDistance = splitterDistance;
|
||||
SplitContainer = splitContainer;
|
||||
TileView = tileView;
|
||||
Idx = idx;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New position of the <see cref="SplitView.SplitterDistance"/>
|
||||
/// New position of the <see cref="TileView.SplitterDistance"/>
|
||||
/// </summary>
|
||||
public Pos SplitterDistance { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Container (sender) of the event.
|
||||
/// </summary>
|
||||
public SplitView SplitContainer { get; }
|
||||
public TileView TileView { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The splitter that is being moved (use when <see cref="SplitContainer"/>
|
||||
/// The splitter that is being moved (use when <see cref="TileView"/>
|
||||
/// has more than 2 panels).
|
||||
/// </summary>
|
||||
public int Idx { get; }
|
||||
@@ -40,7 +40,7 @@ namespace UICatalog.Scenarios {
|
||||
tabView.ApplyStyleChanges ();
|
||||
|
||||
// Start with only a single view but support splitting to show side by side
|
||||
var split = new SplitView(1) {
|
||||
var split = new TileView(1) {
|
||||
X = 0,
|
||||
Y = 1,
|
||||
Width = Dim.Fill (),
|
||||
@@ -130,7 +130,7 @@ namespace UICatalog.Scenarios {
|
||||
private void Split (int offset, Orientation orientation,TabView sender, OpenedFile tab)
|
||||
{
|
||||
|
||||
var split = (SplitView)sender.SuperView.SuperView;
|
||||
var split = (TileView)sender.SuperView.SuperView;
|
||||
var tileIndex = split.IndexOf(sender);
|
||||
|
||||
if(tileIndex == -1)
|
||||
@@ -140,7 +140,7 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
if(orientation != split.Orientation)
|
||||
{
|
||||
split.TrySplitView(tileIndex,1,out split);
|
||||
split.TryTileView(tileIndex,1,out split);
|
||||
split.Orientation = orientation;
|
||||
tileIndex = 0;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
if(tv.Tabs.Count == 0) {
|
||||
|
||||
var split = (SplitView)tv.SuperView.SuperView;
|
||||
var split = (TileView)tv.SuperView.SuperView;
|
||||
var tileIndex = split.IndexOf (tv);
|
||||
split.RemoveTile (tileIndex);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ using Terminal.Gui.Graphs;
|
||||
using System.Linq;
|
||||
|
||||
namespace UICatalog.Scenarios {
|
||||
[ScenarioMetadata (Name: "Split View Nesting", Description: "Nest SplitViews")]
|
||||
[ScenarioMetadata (Name: "Split View Nesting", Description: "Nest TileViews")]
|
||||
[ScenarioCategory ("Controls")]
|
||||
[ScenarioCategory ("LineView")]
|
||||
public class SplitViewNesting : Scenario {
|
||||
public class TileViewNesting : Scenario {
|
||||
|
||||
private View workArea;
|
||||
private TextField textField;
|
||||
@@ -36,28 +36,28 @@ namespace UICatalog.Scenarios {
|
||||
Text = "2",
|
||||
};
|
||||
|
||||
textField.TextChanged += (s) => SetupSplitView ();
|
||||
textField.TextChanged += (s) => SetupTileView ();
|
||||
|
||||
|
||||
cbHorizontal = new CheckBox ("Horizontal") {
|
||||
X = Pos.Right (textField) + 1
|
||||
};
|
||||
cbHorizontal.Toggled += (s) => SetupSplitView ();
|
||||
cbHorizontal.Toggled += (s) => SetupTileView ();
|
||||
|
||||
cbBorder = new CheckBox ("Border") {
|
||||
X = Pos.Right (cbHorizontal) + 1
|
||||
};
|
||||
cbBorder.Toggled += (s) => SetupSplitView ();
|
||||
cbBorder.Toggled += (s) => SetupTileView ();
|
||||
|
||||
cbTitles = new CheckBox ("Titles") {
|
||||
X = Pos.Right (cbBorder) + 1
|
||||
};
|
||||
cbTitles.Toggled += (s) => SetupSplitView ();
|
||||
cbTitles.Toggled += (s) => SetupTileView ();
|
||||
|
||||
cbUseLabels = new CheckBox ("Use Labels") {
|
||||
X = Pos.Right (cbTitles) + 1
|
||||
};
|
||||
cbUseLabels.Toggled += (s) => SetupSplitView ();
|
||||
cbUseLabels.Toggled += (s) => SetupTileView ();
|
||||
|
||||
workArea = new View {
|
||||
X = 0,
|
||||
@@ -79,14 +79,14 @@ namespace UICatalog.Scenarios {
|
||||
Win.Add (cbUseLabels);
|
||||
Win.Add (workArea);
|
||||
|
||||
SetupSplitView ();
|
||||
SetupTileView ();
|
||||
|
||||
Application.Top.Add (menu);
|
||||
|
||||
Win.Loaded += () => loaded = true;
|
||||
}
|
||||
|
||||
private void SetupSplitView ()
|
||||
private void SetupTileView ()
|
||||
{
|
||||
int numberOfViews = GetNumberOfViews ();
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace UICatalog.Scenarios {
|
||||
return;
|
||||
}
|
||||
|
||||
var root = CreateSplitView (1,startHorizontal ?
|
||||
var root = CreateTileView (1,startHorizontal ?
|
||||
Terminal.Gui.Graphs.Orientation.Horizontal :
|
||||
Terminal.Gui.Graphs.Orientation.Vertical);
|
||||
|
||||
@@ -157,41 +157,41 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
}
|
||||
|
||||
private void AddMoreViews (SplitView to)
|
||||
private void AddMoreViews (TileView to)
|
||||
{
|
||||
if (viewsCreated == viewsToCreate) {
|
||||
return;
|
||||
}
|
||||
if (!(to.Tiles.ElementAt(0).View is SplitView)) {
|
||||
if (!(to.Tiles.ElementAt(0).View is TileView)) {
|
||||
Split(to,true);
|
||||
}
|
||||
|
||||
if (!(to.Tiles.ElementAt (1).View is SplitView)) {
|
||||
if (!(to.Tiles.ElementAt (1).View is TileView)) {
|
||||
Split(to,false);
|
||||
}
|
||||
|
||||
if (to.Tiles.ElementAt (0).View is SplitView && to.Tiles.ElementAt (1).View is SplitView) {
|
||||
if (to.Tiles.ElementAt (0).View is TileView && to.Tiles.ElementAt (1).View is TileView) {
|
||||
|
||||
AddMoreViews ((SplitView)to.Tiles.ElementAt (0).View);
|
||||
AddMoreViews ((SplitView)to.Tiles.ElementAt (1).View);
|
||||
AddMoreViews ((TileView)to.Tiles.ElementAt (0).View);
|
||||
AddMoreViews ((TileView)to.Tiles.ElementAt (1).View);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Split(SplitView to, bool left)
|
||||
private void Split(TileView to, bool left)
|
||||
{
|
||||
if (viewsCreated == viewsToCreate) {
|
||||
return;
|
||||
}
|
||||
|
||||
SplitView newView;
|
||||
TileView newView;
|
||||
|
||||
if (left) {
|
||||
to.TrySplitView(0,2,out newView);
|
||||
to.TryTileView(0,2,out newView);
|
||||
|
||||
}
|
||||
else {
|
||||
to.TrySplitView (1,2,out newView);
|
||||
to.TryTileView (1,2,out newView);
|
||||
}
|
||||
|
||||
viewsCreated++;
|
||||
@@ -208,9 +208,9 @@ namespace UICatalog.Scenarios {
|
||||
newView.Tiles.ElementAt (1).View.Add (CreateContentControl(viewsCreated));
|
||||
}
|
||||
|
||||
private SplitView CreateSplitView (int titleNumber, Orientation orientation)
|
||||
private TileView CreateTileView (int titleNumber, Orientation orientation)
|
||||
{
|
||||
var toReturn = new SplitView {
|
||||
var toReturn = new TileView {
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
// flip the orientation
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace UICatalog {
|
||||
public MenuItem miIsMouseDisabled;
|
||||
public MenuItem miHeightAsBuffer;
|
||||
|
||||
public SplitView ContentPane;
|
||||
public TileView ContentPane;
|
||||
public ListView CategoryListView;
|
||||
public ListView ScenarioListView;
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace UICatalog {
|
||||
OS
|
||||
};
|
||||
|
||||
ContentPane = new SplitView () {
|
||||
ContentPane = new TileView () {
|
||||
X = 0,
|
||||
Y = 1, // for menu
|
||||
Width = Dim.Fill (),
|
||||
|
||||
@@ -5,21 +5,21 @@ using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace UnitTests {
|
||||
public class SplitViewTests {
|
||||
public class TileViewTests {
|
||||
|
||||
readonly ITestOutputHelper output;
|
||||
|
||||
public SplitViewTests (ITestOutputHelper output)
|
||||
public TileViewTests (ITestOutputHelper output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical ()
|
||||
public void TestTileView_Vertical ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -30,16 +30,16 @@ namespace UnitTests {
|
||||
|
||||
// Keyboard movement on splitter should have no effect if it is not focused
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
}
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_WithBorder ()
|
||||
public void TestTileView_Vertical_WithBorder ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line, true);
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
var tileView = Get11By3TileView (out var line, true);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -50,18 +50,18 @@ namespace UnitTests {
|
||||
|
||||
// Keyboard movement on splitter should have no effect if it is not focused
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
}
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_Focused ()
|
||||
public void TestTileView_Vertical_Focused ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
SetInputFocusLine (splitContainer);
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
SetInputFocusLine (tileView);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -72,7 +72,7 @@ namespace UnitTests {
|
||||
|
||||
// Now while focused move the splitter 1 unit right
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -85,7 +85,7 @@ namespace UnitTests {
|
||||
// and 2 to the left
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -96,12 +96,12 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_Focused_WithBorder ()
|
||||
public void TestTileView_Vertical_Focused_WithBorder ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line, true);
|
||||
SetInputFocusLine (splitContainer);
|
||||
var tileView = Get11By3TileView (out var line, true);
|
||||
SetInputFocusLine (tileView);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -112,7 +112,7 @@ namespace UnitTests {
|
||||
|
||||
// Now while focused move the splitter 1 unit right
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -125,7 +125,7 @@ namespace UnitTests {
|
||||
// and 2 to the left
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -137,13 +137,13 @@ namespace UnitTests {
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_Focused_50PercentSplit ()
|
||||
public void TestTileView_Vertical_Focused_50PercentSplit ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
SetInputFocusLine (splitContainer);
|
||||
splitContainer.SetSplitterPos(0,Pos.Percent (50));
|
||||
Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistances.ElementAt(0));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
SetInputFocusLine (tileView);
|
||||
tileView.SetSplitterPos(0,Pos.Percent (50));
|
||||
Assert.IsType<Pos.PosFactor> (tileView.SplitterDistances.ElementAt(0));
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -154,7 +154,7 @@ namespace UnitTests {
|
||||
|
||||
// Now while focused move the splitter 1 unit right
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -164,13 +164,13 @@ namespace UnitTests {
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
// Even when moving the splitter location it should stay a Percentage based one
|
||||
Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistances.ElementAt(0));
|
||||
Assert.IsType<Pos.PosFactor> (tileView.SplitterDistances.ElementAt(0));
|
||||
|
||||
|
||||
// and 2 to the left
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -179,15 +179,15 @@ namespace UnitTests {
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
// Even when moving the splitter location it should stay a Percentage based one
|
||||
Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistances.ElementAt (0));
|
||||
Assert.IsType<Pos.PosFactor> (tileView.SplitterDistances.ElementAt (0));
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Horizontal ()
|
||||
public void TestTileView_Horizontal ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
tileView.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -198,26 +198,26 @@ namespace UnitTests {
|
||||
|
||||
// Keyboard movement on splitter should have no effect if it is not focused
|
||||
line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
}
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_View1MinSize_Absolute ()
|
||||
public void TestTileView_Vertical_View1MinSize_Absolute ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
SetInputFocusLine (splitContainer);
|
||||
splitContainer.Tiles.ElementAt(0).MinSize = 6;
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
SetInputFocusLine (tileView);
|
||||
tileView.Tiles.ElementAt(0).MinSize = 6;
|
||||
|
||||
// distance is too small (below 6)
|
||||
splitContainer.SetSplitterPos(0, 2);
|
||||
tileView.SetSplitterPos(0, 2);
|
||||
|
||||
// Should bound the value to the minimum distance
|
||||
Assert.Equal (6, splitContainer.SplitterDistances.ElementAt (0));
|
||||
Assert.Equal (6, tileView.SplitterDistances.ElementAt (0));
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 6
|
||||
string looksLike =
|
||||
@@ -230,14 +230,14 @@ namespace UnitTests {
|
||||
// Keyboard movement on splitter should have no effect because it
|
||||
// would take us below the minimum splitter size
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
// but we can continue to move the splitter right if we want
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -250,19 +250,19 @@ namespace UnitTests {
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_View1MinSize_Absolute_WithBorder ()
|
||||
public void TestTileView_Vertical_View1MinSize_Absolute_WithBorder ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line,true);
|
||||
SetInputFocusLine (splitContainer);
|
||||
splitContainer.Tiles.ElementAt(0).MinSize = 5;
|
||||
var tileView = Get11By3TileView (out var line,true);
|
||||
SetInputFocusLine (tileView);
|
||||
tileView.Tiles.ElementAt(0).MinSize = 5;
|
||||
|
||||
// distance is too small (below 5)
|
||||
splitContainer.SetSplitterPos(0,2);
|
||||
tileView.SetSplitterPos(0,2);
|
||||
|
||||
// Should bound the value to the minimum distance
|
||||
Assert.Equal (6, splitContainer.SplitterDistances.ElementAt(0));
|
||||
Assert.Equal (6, tileView.SplitterDistances.ElementAt(0));
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 5
|
||||
string looksLike =
|
||||
@@ -275,14 +275,14 @@ namespace UnitTests {
|
||||
// Keyboard movement on splitter should have no effect because it
|
||||
// would take us below the minimum splitter size
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
// but we can continue to move the splitter right if we want
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -294,19 +294,19 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_View2MinSize_Absolute ()
|
||||
public void TestTileView_Vertical_View2MinSize_Absolute ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
SetInputFocusLine (splitContainer);
|
||||
splitContainer.Tiles.ElementAt(1).MinSize = 6;
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
SetInputFocusLine (tileView);
|
||||
tileView.Tiles.ElementAt(1).MinSize = 6;
|
||||
|
||||
// distance leaves too little space for view2 (less than 6 would remain)
|
||||
splitContainer.SetSplitterPos(0,8);
|
||||
tileView.SetSplitterPos(0,8);
|
||||
|
||||
// Should bound the value to the minimum distance
|
||||
Assert.Equal (4, splitContainer.SplitterDistances.ElementAt(0));
|
||||
Assert.Equal (4, tileView.SplitterDistances.ElementAt(0));
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 6
|
||||
string looksLike =
|
||||
@@ -319,14 +319,14 @@ namespace UnitTests {
|
||||
// Keyboard movement on splitter should have no effect because it
|
||||
// would take us below the minimum splitter size
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
// but we can continue to move the splitter left if we want
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -338,19 +338,19 @@ namespace UnitTests {
|
||||
|
||||
}
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Vertical_View2MinSize_Absolute_WithBorder ()
|
||||
public void TestTileView_Vertical_View2MinSize_Absolute_WithBorder ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line, true);
|
||||
SetInputFocusLine (splitContainer);
|
||||
splitContainer.Tiles.ElementAt(1).MinSize = 5;
|
||||
var tileView = Get11By3TileView (out var line, true);
|
||||
SetInputFocusLine (tileView);
|
||||
tileView.Tiles.ElementAt(1).MinSize = 5;
|
||||
|
||||
// distance leaves too little space for view2 (less than 5 would remain)
|
||||
splitContainer.SetSplitterPos(0,8);
|
||||
tileView.SetSplitterPos(0,8);
|
||||
|
||||
// Should bound the value to the minimum distance
|
||||
Assert.Equal (4, splitContainer.SplitterDistances.ElementAt(0));
|
||||
Assert.Equal (4, tileView.SplitterDistances.ElementAt(0));
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 6
|
||||
string looksLike =
|
||||
@@ -363,14 +363,14 @@ namespace UnitTests {
|
||||
// Keyboard movement on splitter should have no effect because it
|
||||
// would take us below the minimum splitter size
|
||||
line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
// but we can continue to move the splitter left if we want
|
||||
line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
||||
splitContainer.SetNeedsDisplay ();
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.SetNeedsDisplay ();
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
looksLike =
|
||||
@"
|
||||
@@ -382,14 +382,14 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_InsertPanelAtStart ()
|
||||
public void TestTileView_InsertPanelAtStart ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line, true);
|
||||
SetInputFocusLine (splitContainer);
|
||||
var tileView = Get11By3TileView (out var line, true);
|
||||
SetInputFocusLine (tileView);
|
||||
|
||||
splitContainer.InsertTile (0);
|
||||
tileView.InsertTile (0);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 6
|
||||
string looksLike =
|
||||
@@ -401,14 +401,14 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_InsertPanelMiddle()
|
||||
public void TestTileView_InsertPanelMiddle()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line, true);
|
||||
SetInputFocusLine (splitContainer);
|
||||
var tileView = Get11By3TileView (out var line, true);
|
||||
SetInputFocusLine (tileView);
|
||||
|
||||
splitContainer.InsertTile (1);
|
||||
tileView.InsertTile (1);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 6
|
||||
string looksLike =
|
||||
@@ -420,14 +420,14 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_InsertPanelAtEnd ()
|
||||
public void TestTileView_InsertPanelAtEnd ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line, true);
|
||||
SetInputFocusLine (splitContainer);
|
||||
var tileView = Get11By3TileView (out var line, true);
|
||||
SetInputFocusLine (tileView);
|
||||
|
||||
splitContainer.InsertTile (2);
|
||||
tileView.InsertTile (2);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
// so should ignore the 2 distance and stick to 6
|
||||
string looksLike =
|
||||
@@ -439,14 +439,14 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Horizontal_Focused ()
|
||||
public void TestTileView_Horizontal_Focused ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
|
||||
splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
SetInputFocusLine (splitContainer);
|
||||
tileView.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
SetInputFocusLine (tileView);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -458,7 +458,7 @@ namespace UnitTests {
|
||||
// Now move splitter line down
|
||||
line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
looksLike =
|
||||
@"
|
||||
11111111111
|
||||
@@ -469,7 +469,7 @@ namespace UnitTests {
|
||||
// And 2 up
|
||||
line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
||||
line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
looksLike =
|
||||
@"
|
||||
─────◊─────
|
||||
@@ -480,19 +480,19 @@ namespace UnitTests {
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_Horizontal_View1MinSize_Absolute ()
|
||||
public void TestTileView_Horizontal_View1MinSize_Absolute ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView (out var line);
|
||||
var tileView = Get11By3TileView (out var line);
|
||||
|
||||
splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
SetInputFocusLine (splitContainer);
|
||||
splitContainer.Tiles.ElementAt(0).MinSize = 1;
|
||||
tileView.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
SetInputFocusLine (tileView);
|
||||
tileView.Tiles.ElementAt(0).MinSize = 1;
|
||||
|
||||
// 0 should not be allowed because it brings us below minimum size of View1
|
||||
splitContainer.SetSplitterPos(0,0);
|
||||
Assert.Equal ((Pos)1, splitContainer.SplitterDistances.ElementAt(0));
|
||||
tileView.SetSplitterPos(0,0);
|
||||
Assert.Equal ((Pos)1, tileView.SplitterDistances.ElementAt(0));
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -503,7 +503,7 @@ namespace UnitTests {
|
||||
|
||||
// Now move splitter line down (allowed
|
||||
line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
looksLike =
|
||||
@"
|
||||
11111111111
|
||||
@@ -514,7 +514,7 @@ namespace UnitTests {
|
||||
// And up 2 (only 1 is allowed because of minimum size of 1 on view1)
|
||||
line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
||||
line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
looksLike =
|
||||
@"
|
||||
11111111111
|
||||
@@ -524,34 +524,34 @@ namespace UnitTests {
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestSplitView_CannotSetSplitterPosToFuncEtc ()
|
||||
public void TestTileView_CannotSetSplitterPosToFuncEtc ()
|
||||
{
|
||||
var splitContainer = Get11By3SplitView ();
|
||||
var tileView = Get11By3TileView ();
|
||||
|
||||
var ex = Assert.Throws<ArgumentException> (() => splitContainer.SetSplitterPos(0,Pos.Right (splitContainer)));
|
||||
var ex = Assert.Throws<ArgumentException> (() => tileView.SetSplitterPos(0,Pos.Right (tileView)));
|
||||
Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosCombine", ex.Message);
|
||||
|
||||
|
||||
ex = Assert.Throws<ArgumentException> (() => splitContainer.SetSplitterPos(0,Pos.Function (() => 1)));
|
||||
ex = Assert.Throws<ArgumentException> (() => tileView.SetSplitterPos(0,Pos.Function (() => 1)));
|
||||
Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosFunc", ex.Message);
|
||||
|
||||
// Also not allowed because this results in a PosCombine
|
||||
ex = Assert.Throws<ArgumentException> (() => splitContainer.SetSplitterPos(0, Pos.Percent (50) - 1));
|
||||
ex = Assert.Throws<ArgumentException> (() => tileView.SetSplitterPos(0, Pos.Percent (50) - 1));
|
||||
Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosCombine", ex.Message);
|
||||
}
|
||||
|
||||
[Fact,AutoInitShutdown]
|
||||
public void TestNestedContainer2LeftAnd1Right_RendersNicely()
|
||||
{
|
||||
var splitContainer = GetNestedContainer2Left1Right (false);
|
||||
var tileView = GetNestedContainer2Left1Right (false);
|
||||
|
||||
Assert.Equal (20,splitContainer.Frame.Width);
|
||||
Assert.Equal (10, splitContainer.Tiles.ElementAt(0).View.Frame.Width);
|
||||
Assert.Equal (9, splitContainer.Tiles.ElementAt (1).View.Frame.Width);
|
||||
Assert.Equal (20,tileView.Frame.Width);
|
||||
Assert.Equal (10, tileView.Tiles.ElementAt(0).View.Frame.Width);
|
||||
Assert.Equal (9, tileView.Tiles.ElementAt (1).View.Frame.Width);
|
||||
|
||||
Assert.IsType<SplitView> (splitContainer.Tiles.ElementAt (0).View);
|
||||
var left = (SplitView)splitContainer.Tiles.ElementAt (0).View;
|
||||
Assert.Same (left.SuperView, splitContainer);
|
||||
Assert.IsType<TileView> (tileView.Tiles.ElementAt (0).View);
|
||||
var left = (TileView)tileView.Tiles.ElementAt (0).View;
|
||||
Assert.Same (left.SuperView, tileView);
|
||||
|
||||
|
||||
Assert.Equal(2, left.Tiles.ElementAt (0).View.Subviews.Count);
|
||||
@@ -566,7 +566,7 @@ namespace UnitTests {
|
||||
Assert.Equal (10, onesTop.Frame.Width);
|
||||
Assert.Equal (10, onesBottom.Frame.Width);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -589,9 +589,9 @@ namespace UnitTests {
|
||||
[Fact,AutoInitShutdown]
|
||||
public void TestNestedContainer3RightAnd1Down_RendersNicely()
|
||||
{
|
||||
var splitContainer = GetNestedContainer3Right1Down (false);
|
||||
var tileView = GetNestedContainer3Right1Down (false);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -612,32 +612,32 @@ namespace UnitTests {
|
||||
// anything is sticking out but drawn over
|
||||
|
||||
// 3 panels + 2 splitters
|
||||
Assert.Equal(5,splitContainer.Subviews.Count);
|
||||
Assert.Equal(5,tileView.Subviews.Count);
|
||||
|
||||
|
||||
// Check X and Widths of Tiles
|
||||
Assert.Equal(0,splitContainer.Tiles.ElementAt(0).View.Frame.X);
|
||||
Assert.Equal(6,splitContainer.Tiles.ElementAt(0).View.Frame.Width);
|
||||
Assert.Equal(0,tileView.Tiles.ElementAt(0).View.Frame.X);
|
||||
Assert.Equal(6,tileView.Tiles.ElementAt(0).View.Frame.Width);
|
||||
|
||||
Assert.Equal(7,splitContainer.Tiles.ElementAt(1).View.Frame.X);
|
||||
Assert.Equal(6,splitContainer.Tiles.ElementAt(1).View.Frame.Width);
|
||||
Assert.Equal(7,tileView.Tiles.ElementAt(1).View.Frame.X);
|
||||
Assert.Equal(6,tileView.Tiles.ElementAt(1).View.Frame.Width);
|
||||
|
||||
Assert.Equal(14,splitContainer.Tiles.ElementAt(2).View.Frame.X);
|
||||
Assert.Equal(6,splitContainer.Tiles.ElementAt(2).View.Frame.Width);
|
||||
Assert.Equal(14,tileView.Tiles.ElementAt(2).View.Frame.X);
|
||||
Assert.Equal(6,tileView.Tiles.ElementAt(2).View.Frame.Width);
|
||||
|
||||
|
||||
// Check Y and Heights of Tiles
|
||||
Assert.Equal(0,splitContainer.Tiles.ElementAt(0).View.Frame.Y);
|
||||
Assert.Equal(10,splitContainer.Tiles.ElementAt(0).View.Frame.Height);
|
||||
Assert.Equal(0,tileView.Tiles.ElementAt(0).View.Frame.Y);
|
||||
Assert.Equal(10,tileView.Tiles.ElementAt(0).View.Frame.Height);
|
||||
|
||||
Assert.Equal(0,splitContainer.Tiles.ElementAt(1).View.Frame.Y);
|
||||
Assert.Equal(10,splitContainer.Tiles.ElementAt(1).View.Frame.Height);
|
||||
Assert.Equal(0,tileView.Tiles.ElementAt(1).View.Frame.Y);
|
||||
Assert.Equal(10,tileView.Tiles.ElementAt(1).View.Frame.Height);
|
||||
|
||||
Assert.Equal(0,splitContainer.Tiles.ElementAt(2).View.Frame.Y);
|
||||
Assert.Equal(10,splitContainer.Tiles.ElementAt(2).View.Frame.Height);
|
||||
Assert.Equal(0,tileView.Tiles.ElementAt(2).View.Frame.Y);
|
||||
Assert.Equal(10,tileView.Tiles.ElementAt(2).View.Frame.Height);
|
||||
|
||||
// Check Sub containers in last panel
|
||||
var subSplit = (SplitView)splitContainer.Tiles.ElementAt(2).View;
|
||||
var subSplit = (TileView)tileView.Tiles.ElementAt(2).View;
|
||||
Assert.Equal(0,subSplit.Tiles.ElementAt(0).View.Frame.X);
|
||||
Assert.Equal(6,subSplit.Tiles.ElementAt(0).View.Frame.Width);
|
||||
Assert.Equal(0,subSplit.Tiles.ElementAt(0).View.Frame.Y);
|
||||
@@ -654,9 +654,9 @@ namespace UnitTests {
|
||||
[Fact,AutoInitShutdown]
|
||||
public void TestNestedContainer3RightAnd1Down_WithBorder_RendersNicely()
|
||||
{
|
||||
var splitContainer = GetNestedContainer3Right1Down (true);
|
||||
var tileView = GetNestedContainer3Right1Down (true);
|
||||
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
tileView.Redraw (tileView.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
@@ -676,31 +676,31 @@ namespace UnitTests {
|
||||
// anything is sticking out but drawn over
|
||||
|
||||
// 3 panels + 2 splitters
|
||||
Assert.Equal(5,splitContainer.Subviews.Count);
|
||||
Assert.Equal(5,tileView.Subviews.Count);
|
||||
|
||||
// Check X and Widths of Tiles
|
||||
Assert.Equal(1,splitContainer.Tiles.ElementAt(0).View.Frame.X);
|
||||
Assert.Equal(5,splitContainer.Tiles.ElementAt(0).View.Frame.Width);
|
||||
Assert.Equal(1,tileView.Tiles.ElementAt(0).View.Frame.X);
|
||||
Assert.Equal(5,tileView.Tiles.ElementAt(0).View.Frame.Width);
|
||||
|
||||
Assert.Equal(7,splitContainer.Tiles.ElementAt(1).View.Frame.X);
|
||||
Assert.Equal(6,splitContainer.Tiles.ElementAt(1).View.Frame.Width);
|
||||
Assert.Equal(7,tileView.Tiles.ElementAt(1).View.Frame.X);
|
||||
Assert.Equal(6,tileView.Tiles.ElementAt(1).View.Frame.Width);
|
||||
|
||||
Assert.Equal(14,splitContainer.Tiles.ElementAt(2).View.Frame.X);
|
||||
Assert.Equal(5,splitContainer.Tiles.ElementAt(2).View.Frame.Width);
|
||||
Assert.Equal(14,tileView.Tiles.ElementAt(2).View.Frame.X);
|
||||
Assert.Equal(5,tileView.Tiles.ElementAt(2).View.Frame.Width);
|
||||
|
||||
|
||||
// Check Y and Heights of Tiles
|
||||
Assert.Equal(1,splitContainer.Tiles.ElementAt(0).View.Frame.Y);
|
||||
Assert.Equal(8,splitContainer.Tiles.ElementAt(0).View.Frame.Height);
|
||||
Assert.Equal(1,tileView.Tiles.ElementAt(0).View.Frame.Y);
|
||||
Assert.Equal(8,tileView.Tiles.ElementAt(0).View.Frame.Height);
|
||||
|
||||
Assert.Equal(1,splitContainer.Tiles.ElementAt(1).View.Frame.Y);
|
||||
Assert.Equal(8,splitContainer.Tiles.ElementAt(1).View.Frame.Height);
|
||||
Assert.Equal(1,tileView.Tiles.ElementAt(1).View.Frame.Y);
|
||||
Assert.Equal(8,tileView.Tiles.ElementAt(1).View.Frame.Height);
|
||||
|
||||
Assert.Equal(1,splitContainer.Tiles.ElementAt(2).View.Frame.Y);
|
||||
Assert.Equal(8,splitContainer.Tiles.ElementAt(2).View.Frame.Height);
|
||||
Assert.Equal(1,tileView.Tiles.ElementAt(2).View.Frame.Y);
|
||||
Assert.Equal(8,tileView.Tiles.ElementAt(2).View.Frame.Height);
|
||||
|
||||
// Check Sub containers in last panel
|
||||
var subSplit = (SplitView)splitContainer.Tiles.ElementAt(2).View;
|
||||
var subSplit = (TileView)tileView.Tiles.ElementAt(2).View;
|
||||
Assert.Equal(0,subSplit.Tiles.ElementAt(0).View.Frame.X);
|
||||
Assert.Equal(5,subSplit.Tiles.ElementAt(0).View.Frame.Width);
|
||||
Assert.Equal(0,subSplit.Tiles.ElementAt(0).View.Frame.Y);
|
||||
@@ -721,10 +721,10 @@ namespace UnitTests {
|
||||
/// </summary>
|
||||
/// <param name="withBorder"></param>
|
||||
/// <returns></returns>
|
||||
private SplitView GetNestedContainer2Left1Right(bool withBorder)
|
||||
private TileView GetNestedContainer2Left1Right(bool withBorder)
|
||||
{
|
||||
var container = GetSplitView (20, 10,withBorder);
|
||||
Assert.True (container.TrySplitView (0,2, out var newContainer));
|
||||
var container = GetTileView (20, 10,withBorder);
|
||||
Assert.True (container.TryTileView (0,2, out var newContainer));
|
||||
|
||||
newContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
newContainer.ColorScheme = new ColorScheme ();
|
||||
@@ -740,17 +740,17 @@ namespace UnitTests {
|
||||
/// </summary>
|
||||
/// <param name="withBorder"></param>
|
||||
/// <returns></returns>
|
||||
private SplitView GetNestedContainer3Right1Down(bool withBorder)
|
||||
private TileView GetNestedContainer3Right1Down(bool withBorder)
|
||||
{
|
||||
var container =
|
||||
new SplitView (3)
|
||||
new TileView (3)
|
||||
{
|
||||
Width = 20,
|
||||
Height = 10,
|
||||
IntegratedBorder = withBorder ? BorderStyle.Single : BorderStyle.None
|
||||
};
|
||||
|
||||
Assert.True (container.TrySplitView (2,2, out var newContainer));
|
||||
Assert.True (container.TryTileView (2,2, out var newContainer));
|
||||
|
||||
newContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
|
||||
@@ -777,32 +777,32 @@ namespace UnitTests {
|
||||
return container;
|
||||
}
|
||||
|
||||
private LineView GetLine (SplitView splitContainer)
|
||||
private LineView GetLine (TileView tileView)
|
||||
{
|
||||
return splitContainer.Subviews.OfType<LineView> ().Single ();
|
||||
return tileView.Subviews.OfType<LineView> ().Single ();
|
||||
}
|
||||
|
||||
private void SetInputFocusLine (SplitView splitContainer)
|
||||
private void SetInputFocusLine (TileView tileView)
|
||||
{
|
||||
var line = GetLine (splitContainer);
|
||||
var line = GetLine (tileView);
|
||||
line.SetFocus ();
|
||||
Assert.True (line.HasFocus);
|
||||
}
|
||||
|
||||
private SplitView Get11By3SplitView(out LineView line, bool withBorder = false)
|
||||
private TileView Get11By3TileView(out LineView line, bool withBorder = false)
|
||||
{
|
||||
var split = Get11By3SplitView (withBorder);
|
||||
var split = Get11By3TileView (withBorder);
|
||||
line = GetLine (split);
|
||||
|
||||
return split;
|
||||
}
|
||||
private SplitView Get11By3SplitView (bool withBorder = false)
|
||||
private TileView Get11By3TileView (bool withBorder = false)
|
||||
{
|
||||
return GetSplitView (11, 3, withBorder);
|
||||
return GetTileView (11, 3, withBorder);
|
||||
}
|
||||
private SplitView GetSplitView (int width, int height, bool withBorder = false)
|
||||
private TileView GetTileView (int width, int height, bool withBorder = false)
|
||||
{
|
||||
var container = new SplitView () {
|
||||
var container = new TileView () {
|
||||
Width = width,
|
||||
Height = height,
|
||||
};
|
||||
Reference in New Issue
Block a user