|
@@ -1,4 +1,5 @@
|
|
-namespace Terminal.Gui;
|
|
|
|
|
|
+#nullable enable
|
|
|
|
+namespace Terminal.Gui;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// A <see cref="View"/> consisting of a moveable bar that divides the display area into resizeable
|
|
/// A <see cref="View"/> consisting of a moveable bar that divides the display area into resizeable
|
|
@@ -7,15 +8,13 @@
|
|
public class TileView : View
|
|
public class TileView : View
|
|
{
|
|
{
|
|
private Orientation _orientation = Orientation.Vertical;
|
|
private Orientation _orientation = Orientation.Vertical;
|
|
- private List<Pos> _splitterDistances;
|
|
|
|
- private List<TileViewLineView> _splitterLines;
|
|
|
|
- private List<Tile> _tiles;
|
|
|
|
- private TileView _parentTileView;
|
|
|
|
|
|
+ private List<Pos>? _splitterDistances;
|
|
|
|
+ private List<TileViewLineView>? _splitterLines;
|
|
|
|
+ private List<Tile>? _tiles;
|
|
|
|
+ private TileView? _parentTileView;
|
|
|
|
|
|
/// <summary>Creates a new instance of the <see cref="TileView"/> class with 2 tiles (i.e. left and right).</summary>
|
|
/// <summary>Creates a new instance of the <see cref="TileView"/> class with 2 tiles (i.e. left and right).</summary>
|
|
- public TileView () : this (2)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
|
|
+ public TileView () : this (2) { }
|
|
|
|
|
|
/// <summary>Creates a new instance of the <see cref="TileView"/> class with <paramref name="tiles"/> number of tiles.</summary>
|
|
/// <summary>Creates a new instance of the <see cref="TileView"/> class with <paramref name="tiles"/> number of tiles.</summary>
|
|
/// <param name="tiles"></param>
|
|
/// <param name="tiles"></param>
|
|
@@ -23,6 +22,23 @@ public class TileView : View
|
|
{
|
|
{
|
|
CanFocus = true;
|
|
CanFocus = true;
|
|
RebuildForTileCount (tiles);
|
|
RebuildForTileCount (tiles);
|
|
|
|
+
|
|
|
|
+ SubviewLayout += (_, _) =>
|
|
|
|
+ {
|
|
|
|
+ Rectangle viewport = Viewport;
|
|
|
|
+
|
|
|
|
+ if (HasBorder ())
|
|
|
|
+ {
|
|
|
|
+ viewport = new (
|
|
|
|
+ viewport.X + 1,
|
|
|
|
+ viewport.Y + 1,
|
|
|
|
+ Math.Max (0, viewport.Width - 2),
|
|
|
|
+ Math.Max (0, viewport.Height - 2)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Setup (viewport);
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>The line style to use when drawing the splitter lines.</summary>
|
|
/// <summary>The line style to use when drawing the splitter lines.</summary>
|
|
@@ -34,20 +50,24 @@ public class TileView : View
|
|
get => _orientation;
|
|
get => _orientation;
|
|
set
|
|
set
|
|
{
|
|
{
|
|
- _orientation = value;
|
|
|
|
-
|
|
|
|
- if (IsInitialized)
|
|
|
|
|
|
+ if (_orientation == value)
|
|
{
|
|
{
|
|
- LayoutSubviews ();
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ _orientation = value;
|
|
|
|
+
|
|
|
|
+ SetNeedsDraw ();
|
|
|
|
+ SetNeedsLayout ();
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>The splitter locations. Note that there will be N-1 splitters where N is the number of <see cref="Tiles"/>.</summary>
|
|
/// <summary>The splitter locations. Note that there will be N-1 splitters where N is the number of <see cref="Tiles"/>.</summary>
|
|
- public IReadOnlyCollection<Pos> SplitterDistances => _splitterDistances.AsReadOnly ();
|
|
|
|
|
|
+ public IReadOnlyCollection<Pos> SplitterDistances => _splitterDistances!.AsReadOnly ();
|
|
|
|
|
|
/// <summary>The sub sections hosted by the view</summary>
|
|
/// <summary>The sub sections hosted by the view</summary>
|
|
- public IReadOnlyCollection<Tile> Tiles => _tiles.AsReadOnly ();
|
|
|
|
|
|
+ public IReadOnlyCollection<Tile> Tiles => _tiles!.AsReadOnly ();
|
|
|
|
|
|
// TODO: Update to use Key instead of KeyCode
|
|
// TODO: Update to use Key instead of KeyCode
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -63,7 +83,7 @@ public class TileView : View
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <remarks>Use <see cref="IsRootTileView"/> to determine if the returned value is the root.</remarks>
|
|
/// <remarks>Use <see cref="IsRootTileView"/> to determine if the returned value is the root.</remarks>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public TileView GetParentTileView () { return _parentTileView; }
|
|
|
|
|
|
+ public TileView? GetParentTileView () { return _parentTileView; }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Returns the index of the first <see cref="Tile"/> in <see cref="Tiles"/> which contains
|
|
/// Returns the index of the first <see cref="Tile"/> in <see cref="Tiles"/> which contains
|
|
@@ -71,9 +91,9 @@ public class TileView : View
|
|
/// </summary>
|
|
/// </summary>
|
|
public int IndexOf (View toFind, bool recursive = false)
|
|
public int IndexOf (View toFind, bool recursive = false)
|
|
{
|
|
{
|
|
- for (var i = 0; i < _tiles.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < _tiles!.Count; i++)
|
|
{
|
|
{
|
|
- View v = _tiles [i].ContentView;
|
|
|
|
|
|
+ View v = _tiles [i].ContentView!;
|
|
|
|
|
|
if (v == toFind)
|
|
if (v == toFind)
|
|
{
|
|
{
|
|
@@ -102,14 +122,14 @@ public class TileView : View
|
|
/// line
|
|
/// line
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <param name="idx"></param>
|
|
- public Tile InsertTile (int idx)
|
|
|
|
|
|
+ public Tile? InsertTile (int idx)
|
|
{
|
|
{
|
|
Tile [] oldTiles = Tiles.ToArray ();
|
|
Tile [] oldTiles = Tiles.ToArray ();
|
|
RebuildForTileCount (oldTiles.Length + 1);
|
|
RebuildForTileCount (oldTiles.Length + 1);
|
|
|
|
|
|
- Tile toReturn = null;
|
|
|
|
|
|
+ Tile? toReturn = null;
|
|
|
|
|
|
- for (var i = 0; i < _tiles.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < _tiles?.Count; i++)
|
|
{
|
|
{
|
|
if (i != idx)
|
|
if (i != idx)
|
|
{
|
|
{
|
|
@@ -117,12 +137,12 @@ public class TileView : View
|
|
|
|
|
|
// remove the new empty View
|
|
// remove the new empty View
|
|
Remove (_tiles [i].ContentView);
|
|
Remove (_tiles [i].ContentView);
|
|
- _tiles [i].ContentView.Dispose ();
|
|
|
|
|
|
+ _tiles [i].ContentView?.Dispose ();
|
|
_tiles [i].ContentView = null;
|
|
_tiles [i].ContentView = null;
|
|
|
|
|
|
// restore old Tile and View
|
|
// restore old Tile and View
|
|
_tiles [i] = oldTile;
|
|
_tiles [i] = oldTile;
|
|
- _tiles [i].ContentView.TabStop = TabStop;
|
|
|
|
|
|
+ _tiles [i].ContentView!.TabStop = TabStop;
|
|
Add (_tiles [i].ContentView);
|
|
Add (_tiles [i].ContentView);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -131,12 +151,8 @@ public class TileView : View
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- SetNeedsDisplay ();
|
|
|
|
-
|
|
|
|
- if (IsInitialized)
|
|
|
|
- {
|
|
|
|
- LayoutSubviews ();
|
|
|
|
- }
|
|
|
|
|
|
+ SetNeedsDraw ();
|
|
|
|
+ SetNeedsLayout ();
|
|
|
|
|
|
return toReturn;
|
|
return toReturn;
|
|
}
|
|
}
|
|
@@ -155,44 +171,22 @@ public class TileView : View
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public bool IsRootTileView () { return _parentTileView == null; }
|
|
public bool IsRootTileView () { return _parentTileView == null; }
|
|
|
|
|
|
- /// <inheritdoc/>
|
|
|
|
- public override void LayoutSubviews ()
|
|
|
|
- {
|
|
|
|
- if (!IsInitialized)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Rectangle viewport = Viewport;
|
|
|
|
-
|
|
|
|
- if (HasBorder ())
|
|
|
|
- {
|
|
|
|
- viewport = new (
|
|
|
|
- viewport.X + 1,
|
|
|
|
- viewport.Y + 1,
|
|
|
|
- Math.Max (0, viewport.Width - 2),
|
|
|
|
- Math.Max (0, viewport.Height - 2)
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Setup (viewport);
|
|
|
|
- base.LayoutSubviews ();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// BUG: v2 fix this hack
|
|
// BUG: v2 fix this hack
|
|
// QUESTION: Does this need to be fixed before events are refactored?
|
|
// QUESTION: Does this need to be fixed before events are refactored?
|
|
/// <summary>Overridden so no Frames get drawn</summary>
|
|
/// <summary>Overridden so no Frames get drawn</summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public override bool OnDrawAdornments () { return false; }
|
|
|
|
|
|
+ protected override bool OnDrawingBorderAndPadding () { return true; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override void OnDrawContent (Rectangle viewport)
|
|
|
|
- {
|
|
|
|
- Driver.SetAttribute (ColorScheme.Normal);
|
|
|
|
-
|
|
|
|
- Clear ();
|
|
|
|
|
|
+ protected override bool OnRenderingLineCanvas () { return false; }
|
|
|
|
|
|
- base.OnDrawContent (viewport);
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ protected override void OnDrawComplete ()
|
|
|
|
+ {
|
|
|
|
+ if (ColorScheme is { })
|
|
|
|
+ {
|
|
|
|
+ SetAttribute (ColorScheme.Normal);
|
|
|
|
+ }
|
|
|
|
|
|
var lc = new LineCanvas ();
|
|
var lc = new LineCanvas ();
|
|
|
|
|
|
@@ -207,14 +201,14 @@ public class TileView : View
|
|
lc.AddLine (Point.Empty, Viewport.Height, Orientation.Vertical, LineStyle);
|
|
lc.AddLine (Point.Empty, Viewport.Height, Orientation.Vertical, LineStyle);
|
|
|
|
|
|
lc.AddLine (
|
|
lc.AddLine (
|
|
- new Point (Viewport.Width - 1, Viewport.Height - 1),
|
|
|
|
|
|
+ new (Viewport.Width - 1, Viewport.Height - 1),
|
|
-Viewport.Width,
|
|
-Viewport.Width,
|
|
Orientation.Horizontal,
|
|
Orientation.Horizontal,
|
|
LineStyle
|
|
LineStyle
|
|
);
|
|
);
|
|
|
|
|
|
lc.AddLine (
|
|
lc.AddLine (
|
|
- new Point (Viewport.Width - 1, Viewport.Height - 1),
|
|
|
|
|
|
+ new (Viewport.Width - 1, Viewport.Height - 1),
|
|
-Viewport.Height,
|
|
-Viewport.Height,
|
|
Orientation.Vertical,
|
|
Orientation.Vertical,
|
|
LineStyle
|
|
LineStyle
|
|
@@ -223,7 +217,7 @@ public class TileView : View
|
|
|
|
|
|
foreach (TileViewLineView line in allLines)
|
|
foreach (TileViewLineView line in allLines)
|
|
{
|
|
{
|
|
- bool isRoot = _splitterLines.Contains (line);
|
|
|
|
|
|
+ bool isRoot = _splitterLines!.Contains (line);
|
|
|
|
|
|
Rectangle screen = line.ViewportToScreen (Rectangle.Empty);
|
|
Rectangle screen = line.ViewportToScreen (Rectangle.Empty);
|
|
Point origin = ScreenToFrame (screen.Location);
|
|
Point origin = ScreenToFrame (screen.Location);
|
|
@@ -247,7 +241,10 @@ public class TileView : View
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- Driver.SetAttribute (ColorScheme.Normal);
|
|
|
|
|
|
+ if (ColorScheme is { })
|
|
|
|
+ {
|
|
|
|
+ SetAttribute (ColorScheme.Normal);
|
|
|
|
+ }
|
|
|
|
|
|
foreach (KeyValuePair<Point, Rune> p in lc.GetMap (Viewport))
|
|
foreach (KeyValuePair<Point, Rune> p in lc.GetMap (Viewport))
|
|
{
|
|
{
|
|
@@ -282,6 +279,8 @@ public class TileView : View
|
|
AddRune (renderAt.X + i, renderAt.Y, (Rune)title [i]);
|
|
AddRune (renderAt.X + i, renderAt.Y, (Rune)title [i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
//// BUGBUG: Why is this not handled by a key binding???
|
|
//// BUGBUG: Why is this not handled by a key binding???
|
|
@@ -292,7 +291,7 @@ public class TileView : View
|
|
|
|
|
|
if (key.KeyCode == ToggleResizable)
|
|
if (key.KeyCode == ToggleResizable)
|
|
{
|
|
{
|
|
- foreach (TileViewLineView l in _splitterLines)
|
|
|
|
|
|
+ foreach (TileViewLineView l in _splitterLines!)
|
|
{
|
|
{
|
|
bool iniBefore = l.IsInitialized;
|
|
bool iniBefore = l.IsInitialized;
|
|
l.IsInitialized = false;
|
|
l.IsInitialized = false;
|
|
@@ -319,8 +318,8 @@ public class TileView : View
|
|
/// <param name="count"></param>
|
|
/// <param name="count"></param>
|
|
public void RebuildForTileCount (int count)
|
|
public void RebuildForTileCount (int count)
|
|
{
|
|
{
|
|
- _tiles = new List<Tile> ();
|
|
|
|
- _splitterDistances = new List<Pos> ();
|
|
|
|
|
|
+ _tiles = new ();
|
|
|
|
+ _splitterDistances = new ();
|
|
|
|
|
|
if (_splitterLines is { })
|
|
if (_splitterLines is { })
|
|
{
|
|
{
|
|
@@ -330,13 +329,13 @@ public class TileView : View
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- _splitterLines = new List<TileViewLineView> ();
|
|
|
|
|
|
+ _splitterLines = new ();
|
|
|
|
|
|
RemoveAll ();
|
|
RemoveAll ();
|
|
|
|
|
|
foreach (Tile tile in _tiles)
|
|
foreach (Tile tile in _tiles)
|
|
{
|
|
{
|
|
- tile.ContentView.Dispose ();
|
|
|
|
|
|
+ tile.ContentView?.Dispose ();
|
|
tile.ContentView = null;
|
|
tile.ContentView = null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -361,15 +360,14 @@ public class TileView : View
|
|
|
|
|
|
var tile = new Tile ();
|
|
var tile = new Tile ();
|
|
_tiles.Add (tile);
|
|
_tiles.Add (tile);
|
|
- tile.ContentView.Id = $"Tile.ContentView {i}";
|
|
|
|
|
|
+ tile.ContentView!.Id = $"Tile.ContentView {i}";
|
|
Add (tile.ContentView);
|
|
Add (tile.ContentView);
|
|
- tile.TitleChanged += (s, e) => SetNeedsDisplay ();
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (IsInitialized)
|
|
|
|
- {
|
|
|
|
- LayoutSubviews ();
|
|
|
|
|
|
+ // BUGBUG: This should not be needed:
|
|
|
|
+ tile.TitleChanged += (s, e) => SetNeedsLayout ();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ SetNeedsLayout ();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -378,7 +376,7 @@ public class TileView : View
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public Tile RemoveTile (int idx)
|
|
|
|
|
|
+ public Tile? RemoveTile (int idx)
|
|
{
|
|
{
|
|
Tile [] oldTiles = Tiles.ToArray ();
|
|
Tile [] oldTiles = Tiles.ToArray ();
|
|
|
|
|
|
@@ -391,14 +389,14 @@ public class TileView : View
|
|
|
|
|
|
RebuildForTileCount (oldTiles.Length - 1);
|
|
RebuildForTileCount (oldTiles.Length - 1);
|
|
|
|
|
|
- for (var i = 0; i < _tiles.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < _tiles?.Count; i++)
|
|
{
|
|
{
|
|
int oldIdx = i >= idx ? i + 1 : i;
|
|
int oldIdx = i >= idx ? i + 1 : i;
|
|
Tile oldTile = oldTiles [oldIdx];
|
|
Tile oldTile = oldTiles [oldIdx];
|
|
|
|
|
|
// remove the new empty View
|
|
// remove the new empty View
|
|
Remove (_tiles [i].ContentView);
|
|
Remove (_tiles [i].ContentView);
|
|
- _tiles [i].ContentView.Dispose ();
|
|
|
|
|
|
+ _tiles [i].ContentView?.Dispose ();
|
|
_tiles [i].ContentView = null;
|
|
_tiles [i].ContentView = null;
|
|
|
|
|
|
// restore old Tile and View
|
|
// restore old Tile and View
|
|
@@ -406,9 +404,6 @@ public class TileView : View
|
|
Add (_tiles [i].ContentView);
|
|
Add (_tiles [i].ContentView);
|
|
}
|
|
}
|
|
|
|
|
|
- SetNeedsDisplay ();
|
|
|
|
- LayoutSubviews ();
|
|
|
|
-
|
|
|
|
return removed;
|
|
return removed;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -439,15 +434,20 @@ public class TileView : View
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- _splitterDistances [idx] = value;
|
|
|
|
- GetRootTileView ().LayoutSubviews ();
|
|
|
|
|
|
+ if (_splitterDistances is { })
|
|
|
|
+ {
|
|
|
|
+ _splitterDistances [idx] = value;
|
|
|
|
+ }
|
|
|
|
+
|
|
OnSplitterMoved (idx);
|
|
OnSplitterMoved (idx);
|
|
|
|
+ SetNeedsDraw ();
|
|
|
|
+ SetNeedsLayout ();
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>Invoked when any of the <see cref="SplitterDistances"/> is changed.</summary>
|
|
/// <summary>Invoked when any of the <see cref="SplitterDistances"/> is changed.</summary>
|
|
- public event SplitterEventHandler SplitterMoved;
|
|
|
|
|
|
+ public event SplitterEventHandler? SplitterMoved;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Converts of <see cref="Tiles"/> element <paramref name="idx"/> from a regular <see cref="View"/> to a new
|
|
/// Converts of <see cref="Tiles"/> element <paramref name="idx"/> from a regular <see cref="View"/> to a new
|
|
@@ -469,10 +469,10 @@ public class TileView : View
|
|
{
|
|
{
|
|
// when splitting a view into 2 sub views we will need to migrate
|
|
// when splitting a view into 2 sub views we will need to migrate
|
|
// the title too
|
|
// the title too
|
|
- Tile tile = _tiles [idx];
|
|
|
|
|
|
+ Tile tile = _tiles! [idx];
|
|
|
|
|
|
string title = tile.Title;
|
|
string title = tile.Title;
|
|
- View toMove = tile.ContentView;
|
|
|
|
|
|
+ View? toMove = tile.ContentView;
|
|
|
|
|
|
if (toMove is TileView existing)
|
|
if (toMove is TileView existing)
|
|
{
|
|
{
|
|
@@ -487,7 +487,7 @@ public class TileView : View
|
|
};
|
|
};
|
|
|
|
|
|
// Take everything out of the View we are moving
|
|
// Take everything out of the View we are moving
|
|
- View [] childViews = toMove.Subviews.ToArray ();
|
|
|
|
|
|
+ View [] childViews = toMove!.Subviews.ToArray ();
|
|
toMove.RemoveAll ();
|
|
toMove.RemoveAll ();
|
|
|
|
|
|
// Remove the view itself and replace it with the new TileView
|
|
// Remove the view itself and replace it with the new TileView
|
|
@@ -499,16 +499,16 @@ public class TileView : View
|
|
|
|
|
|
tile.ContentView = newContainer;
|
|
tile.ContentView = newContainer;
|
|
|
|
|
|
- View newTileView1 = newContainer._tiles [0].ContentView;
|
|
|
|
|
|
+ View newTileView1 = newContainer!._tiles? [0].ContentView!;
|
|
|
|
|
|
// Add the original content into the first view of the new container
|
|
// Add the original content into the first view of the new container
|
|
foreach (View childView in childViews)
|
|
foreach (View childView in childViews)
|
|
{
|
|
{
|
|
- newTileView1.Add (childView);
|
|
|
|
|
|
+ newTileView1!.Add (childView);
|
|
}
|
|
}
|
|
|
|
|
|
// Move the title across too
|
|
// Move the title across too
|
|
- newContainer._tiles [0].Title = title;
|
|
|
|
|
|
+ newContainer._tiles! [0].Title = title;
|
|
tile.Title = string.Empty;
|
|
tile.Title = string.Empty;
|
|
|
|
|
|
result = newContainer;
|
|
result = newContainer;
|
|
@@ -522,14 +522,14 @@ public class TileView : View
|
|
foreach (Tile tile in Tiles)
|
|
foreach (Tile tile in Tiles)
|
|
{
|
|
{
|
|
Remove (tile.ContentView);
|
|
Remove (tile.ContentView);
|
|
- tile.ContentView.Dispose ();
|
|
|
|
|
|
+ tile.ContentView?.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
base.Dispose (disposing);
|
|
base.Dispose (disposing);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>Raises the <see cref="SplitterMoved"/> event</summary>
|
|
/// <summary>Raises the <see cref="SplitterMoved"/> event</summary>
|
|
- protected virtual void OnSplitterMoved (int idx) { SplitterMoved?.Invoke (this, new SplitterEventArgs (this, idx, _splitterDistances [idx])); }
|
|
|
|
|
|
+ protected virtual void OnSplitterMoved (int idx) { SplitterMoved?.Invoke (this, new (this, idx, _splitterDistances! [idx])); }
|
|
|
|
|
|
private List<TileViewLineView> GetAllLineViewsRecursively (View v)
|
|
private List<TileViewLineView> GetAllLineViewsRecursively (View v)
|
|
{
|
|
{
|
|
@@ -556,14 +556,14 @@ public class TileView : View
|
|
return lines;
|
|
return lines;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<TileTitleToRender> GetAllTitlesToRenderRecursively (TileView v, int depth = 0)
|
|
|
|
|
|
+ private List<TileTitleToRender> GetAllTitlesToRenderRecursively (TileView? v, int depth = 0)
|
|
{
|
|
{
|
|
List<TileTitleToRender> titles = new ();
|
|
List<TileTitleToRender> titles = new ();
|
|
|
|
|
|
- foreach (Tile sub in v.Tiles)
|
|
|
|
|
|
+ foreach (Tile sub in v!.Tiles)
|
|
{
|
|
{
|
|
// Don't render titles for invisible stuff!
|
|
// Don't render titles for invisible stuff!
|
|
- if (!sub.ContentView.Visible)
|
|
|
|
|
|
+ if (!sub.ContentView!.Visible)
|
|
{
|
|
{
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -579,7 +579,7 @@ public class TileView : View
|
|
{
|
|
{
|
|
if (sub.Title.Length > 0)
|
|
if (sub.Title.Length > 0)
|
|
{
|
|
{
|
|
- titles.Add (new TileTitleToRender (v, sub, depth));
|
|
|
|
|
|
+ titles.Add (new (v, sub, depth));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -599,20 +599,20 @@ public class TileView : View
|
|
return root;
|
|
return root;
|
|
}
|
|
}
|
|
|
|
|
|
- private Dim GetTileWidthOrHeight (int i, int space, Tile [] visibleTiles, TileViewLineView [] visibleSplitterLines)
|
|
|
|
|
|
+ private Dim GetTileWidthOrHeight (int i, int space, Tile? [] visibleTiles, TileViewLineView? [] visibleSplitterLines)
|
|
{
|
|
{
|
|
// last tile
|
|
// last tile
|
|
if (i + 1 >= visibleTiles.Length)
|
|
if (i + 1 >= visibleTiles.Length)
|
|
{
|
|
{
|
|
- return Dim.Fill (HasBorder () ? 1 : 0);
|
|
|
|
|
|
+ return Dim.Fill (HasBorder () ? 1 : 0)!;
|
|
}
|
|
}
|
|
|
|
|
|
- TileViewLineView nextSplitter = visibleSplitterLines [i];
|
|
|
|
- Pos nextSplitterPos = Orientation == Orientation.Vertical ? nextSplitter.X : nextSplitter.Y;
|
|
|
|
|
|
+ TileViewLineView? nextSplitter = visibleSplitterLines [i];
|
|
|
|
+ Pos? nextSplitterPos = Orientation == Orientation.Vertical ? nextSplitter!.X : nextSplitter!.Y;
|
|
int nextSplitterDistance = nextSplitterPos.GetAnchor (space);
|
|
int nextSplitterDistance = nextSplitterPos.GetAnchor (space);
|
|
|
|
|
|
- TileViewLineView lastSplitter = i >= 1 ? visibleSplitterLines [i - 1] : null;
|
|
|
|
- Pos lastSplitterPos = Orientation == Orientation.Vertical ? lastSplitter?.X : lastSplitter?.Y;
|
|
|
|
|
|
+ TileViewLineView? lastSplitter = i >= 1 ? visibleSplitterLines [i - 1] : null;
|
|
|
|
+ Pos? lastSplitterPos = Orientation == Orientation.Vertical ? lastSplitter?.X : lastSplitter?.Y;
|
|
int lastSplitterDistance = lastSplitterPos?.GetAnchor (space) ?? 0;
|
|
int lastSplitterDistance = lastSplitterPos?.GetAnchor (space) ?? 0;
|
|
|
|
|
|
int distance = nextSplitterDistance - lastSplitterDistance;
|
|
int distance = nextSplitterDistance - lastSplitterDistance;
|
|
@@ -629,19 +629,19 @@ public class TileView : View
|
|
|
|
|
|
private void HideSplittersBasedOnTileVisibility ()
|
|
private void HideSplittersBasedOnTileVisibility ()
|
|
{
|
|
{
|
|
- if (_splitterLines.Count == 0)
|
|
|
|
|
|
+ if (_splitterLines is { Count: 0 })
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- foreach (TileViewLineView line in _splitterLines)
|
|
|
|
|
|
+ foreach (TileViewLineView line in _splitterLines!)
|
|
{
|
|
{
|
|
line.Visible = true;
|
|
line.Visible = true;
|
|
}
|
|
}
|
|
|
|
|
|
- for (var i = 0; i < _tiles.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < _tiles!.Count; i++)
|
|
{
|
|
{
|
|
- if (!_tiles [i].ContentView.Visible)
|
|
|
|
|
|
+ if (!_tiles [i].ContentView!.Visible)
|
|
{
|
|
{
|
|
// when a tile is not visible, prefer hiding
|
|
// when a tile is not visible, prefer hiding
|
|
// the splitter on it's left
|
|
// the splitter on it's left
|
|
@@ -665,7 +665,7 @@ public class TileView : View
|
|
private bool IsValidNewSplitterPos (int idx, Pos value, int fullSpace)
|
|
private bool IsValidNewSplitterPos (int idx, Pos value, int fullSpace)
|
|
{
|
|
{
|
|
int newSize = value.GetAnchor (fullSpace);
|
|
int newSize = value.GetAnchor (fullSpace);
|
|
- bool isGettingBigger = newSize > _splitterDistances [idx].GetAnchor (fullSpace);
|
|
|
|
|
|
+ bool isGettingBigger = newSize > _splitterDistances! [idx].GetAnchor (fullSpace);
|
|
int lastSplitterOrBorder = HasBorder () ? 1 : 0;
|
|
int lastSplitterOrBorder = HasBorder () ? 1 : 0;
|
|
int nextSplitterOrBorder = HasBorder () ? fullSpace - 1 : fullSpace;
|
|
int nextSplitterOrBorder = HasBorder () ? fullSpace - 1 : fullSpace;
|
|
|
|
|
|
@@ -724,7 +724,7 @@ public class TileView : View
|
|
}
|
|
}
|
|
|
|
|
|
// don't grow if it would take us below min size of right panel
|
|
// don't grow if it would take us below min size of right panel
|
|
- if (spaceForNext < _tiles [idx + 1].MinSize)
|
|
|
|
|
|
+ if (spaceForNext < _tiles! [idx + 1].MinSize)
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -740,7 +740,7 @@ public class TileView : View
|
|
}
|
|
}
|
|
|
|
|
|
// don't shrink if it would take us below min size of left panel
|
|
// don't shrink if it would take us below min size of left panel
|
|
- if (spaceForLast < _tiles [idx].MinSize)
|
|
|
|
|
|
+ if (spaceForLast < _tiles! [idx].MinSize)
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -774,7 +774,7 @@ public class TileView : View
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- for (var i = 0; i < _splitterLines.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < _splitterLines!.Count; i++)
|
|
{
|
|
{
|
|
TileViewLineView line = _splitterLines [i];
|
|
TileViewLineView line = _splitterLines [i];
|
|
|
|
|
|
@@ -791,19 +791,19 @@ public class TileView : View
|
|
|
|
|
|
if (_orientation == Orientation.Vertical)
|
|
if (_orientation == Orientation.Vertical)
|
|
{
|
|
{
|
|
- line.X = _splitterDistances [i];
|
|
|
|
|
|
+ line.X = _splitterDistances! [i];
|
|
line.Y = 0;
|
|
line.Y = 0;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- line.Y = _splitterDistances [i];
|
|
|
|
|
|
+ line.Y = _splitterDistances! [i];
|
|
line.X = 0;
|
|
line.X = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
HideSplittersBasedOnTileVisibility ();
|
|
HideSplittersBasedOnTileVisibility ();
|
|
|
|
|
|
- Tile [] visibleTiles = _tiles.Where (t => t.ContentView.Visible).ToArray ();
|
|
|
|
|
|
+ Tile [] visibleTiles = _tiles!.Where (t => t.ContentView!.Visible).ToArray ();
|
|
TileViewLineView [] visibleSplitterLines = _splitterLines.Where (l => l.Visible).ToArray ();
|
|
TileViewLineView [] visibleSplitterLines = _splitterLines.Where (l => l.Visible).ToArray ();
|
|
|
|
|
|
for (var i = 0; i < visibleTiles.Length; i++)
|
|
for (var i = 0; i < visibleTiles.Length; i++)
|
|
@@ -812,26 +812,27 @@ public class TileView : View
|
|
|
|
|
|
if (Orientation == Orientation.Vertical)
|
|
if (Orientation == Orientation.Vertical)
|
|
{
|
|
{
|
|
- tile.ContentView.X = i == 0 ? viewport.X : Pos.Right (visibleSplitterLines [i - 1]);
|
|
|
|
|
|
+ tile.ContentView!.X = i == 0 ? viewport.X : Pos.Right (visibleSplitterLines [i - 1]);
|
|
tile.ContentView.Y = viewport.Y;
|
|
tile.ContentView.Y = viewport.Y;
|
|
tile.ContentView.Height = viewport.Height;
|
|
tile.ContentView.Height = viewport.Height;
|
|
tile.ContentView.Width = GetTileWidthOrHeight (i, Viewport.Width, visibleTiles, visibleSplitterLines);
|
|
tile.ContentView.Width = GetTileWidthOrHeight (i, Viewport.Width, visibleTiles, visibleSplitterLines);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- tile.ContentView.X = viewport.X;
|
|
|
|
|
|
+ tile.ContentView!.X = viewport.X;
|
|
tile.ContentView.Y = i == 0 ? viewport.Y : Pos.Bottom (visibleSplitterLines [i - 1]);
|
|
tile.ContentView.Y = i == 0 ? viewport.Y : Pos.Bottom (visibleSplitterLines [i - 1]);
|
|
tile.ContentView.Width = viewport.Width;
|
|
tile.ContentView.Width = viewport.Width;
|
|
tile.ContentView.Height = GetTileWidthOrHeight (i, Viewport.Height, visibleTiles, visibleSplitterLines);
|
|
tile.ContentView.Height = GetTileWidthOrHeight (i, Viewport.Height, visibleTiles, visibleSplitterLines);
|
|
}
|
|
}
|
|
|
|
+
|
|
// BUGBUG: This should not be needed. If any of the pos/dim setters above actually changed values, NeedsDisplay should have already been set.
|
|
// BUGBUG: This should not be needed. If any of the pos/dim setters above actually changed values, NeedsDisplay should have already been set.
|
|
- tile.ContentView.SetNeedsDisplay ();
|
|
|
|
|
|
+ tile.ContentView.SetNeedsDraw ();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private class TileTitleToRender
|
|
private class TileTitleToRender
|
|
{
|
|
{
|
|
- public TileTitleToRender (TileView parent, Tile tile, int depth)
|
|
|
|
|
|
+ public TileTitleToRender (TileView? parent, Tile tile, int depth)
|
|
{
|
|
{
|
|
Parent = parent;
|
|
Parent = parent;
|
|
Tile = tile;
|
|
Tile = tile;
|
|
@@ -839,8 +840,8 @@ public class TileView : View
|
|
}
|
|
}
|
|
|
|
|
|
public int Depth { get; }
|
|
public int Depth { get; }
|
|
- public TileView Parent { get; }
|
|
|
|
- public Tile Tile { get; }
|
|
|
|
|
|
+ public TileView? Parent { get; }
|
|
|
|
+ public Tile? Tile { get; }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Translates the <see cref="Tile"/> title location from its local coordinate space
|
|
/// Translates the <see cref="Tile"/> title location from its local coordinate space
|
|
@@ -848,21 +849,22 @@ public class TileView : View
|
|
/// </summary>
|
|
/// </summary>
|
|
public Point GetLocalCoordinateForTitle (TileView intoCoordinateSpace)
|
|
public Point GetLocalCoordinateForTitle (TileView intoCoordinateSpace)
|
|
{
|
|
{
|
|
- Rectangle screen = Tile.ContentView.ViewportToScreen (Rectangle.Empty);
|
|
|
|
|
|
+ Rectangle screen = Tile!.ContentView!.ViewportToScreen (Rectangle.Empty);
|
|
|
|
+
|
|
return intoCoordinateSpace.ScreenToFrame (new (screen.X, screen.Y - 1));
|
|
return intoCoordinateSpace.ScreenToFrame (new (screen.X, screen.Y - 1));
|
|
}
|
|
}
|
|
|
|
|
|
internal string GetTrimmedTitle ()
|
|
internal string GetTrimmedTitle ()
|
|
{
|
|
{
|
|
- Dim spaceDim = Tile.ContentView.Width;
|
|
|
|
|
|
+ Dim? spaceDim = Tile?.ContentView?.Width;
|
|
|
|
|
|
- int spaceAbs = spaceDim.GetAnchor (Parent.Viewport.Width);
|
|
|
|
|
|
+ int spaceAbs = spaceDim!.GetAnchor (Parent!.Viewport.Width);
|
|
|
|
|
|
- var title = $" {Tile.Title} ";
|
|
|
|
|
|
+ var title = $" {Tile!.Title} ";
|
|
|
|
|
|
if (title.Length > spaceAbs)
|
|
if (title.Length > spaceAbs)
|
|
{
|
|
{
|
|
- return title.Substring (0, spaceAbs);
|
|
|
|
|
|
+ return title!.Substring (0, spaceAbs);
|
|
}
|
|
}
|
|
|
|
|
|
return title;
|
|
return title;
|
|
@@ -873,7 +875,7 @@ public class TileView : View
|
|
{
|
|
{
|
|
public Point? moveRuneRenderLocation;
|
|
public Point? moveRuneRenderLocation;
|
|
|
|
|
|
- private Pos dragOrignalPos;
|
|
|
|
|
|
+ private Pos? dragOrignalPos;
|
|
private Point? dragPosition;
|
|
private Point? dragPosition;
|
|
|
|
|
|
public TileViewLineView (TileView parent, int idx)
|
|
public TileViewLineView (TileView parent, int idx)
|
|
@@ -883,13 +885,13 @@ public class TileView : View
|
|
|
|
|
|
Parent = parent;
|
|
Parent = parent;
|
|
Idx = idx;
|
|
Idx = idx;
|
|
- AddCommand (Command.Right, () => { return MoveSplitter (1, 0); });
|
|
|
|
|
|
+ AddCommand (Command.Right, () => MoveSplitter (1, 0));
|
|
|
|
|
|
- AddCommand (Command.Left, () => { return MoveSplitter (-1, 0); });
|
|
|
|
|
|
+ AddCommand (Command.Left, () => MoveSplitter (-1, 0));
|
|
|
|
|
|
- AddCommand (Command.Up, () => { return MoveSplitter (0, -1); });
|
|
|
|
|
|
+ AddCommand (Command.Up, () => MoveSplitter (0, -1));
|
|
|
|
|
|
- AddCommand (Command.Down, () => { return MoveSplitter (0, 1); });
|
|
|
|
|
|
+ AddCommand (Command.Down, () => MoveSplitter (0, 1));
|
|
|
|
|
|
KeyBindings.Add (Key.CursorRight, Command.Right);
|
|
KeyBindings.Add (Key.CursorRight, Command.Right);
|
|
KeyBindings.Add (Key.CursorLeft, Command.Left);
|
|
KeyBindings.Add (Key.CursorLeft, Command.Left);
|
|
@@ -956,7 +958,7 @@ public class TileView : View
|
|
moveRuneRenderLocation = new Point (0, Math.Max (1, Math.Min (Viewport.Height - 2, mouseEvent.Position.Y)));
|
|
moveRuneRenderLocation = new Point (0, Math.Max (1, Math.Min (Viewport.Height - 2, mouseEvent.Position.Y)));
|
|
}
|
|
}
|
|
|
|
|
|
- Parent.SetNeedsDisplay ();
|
|
|
|
|
|
+ Parent.SetNeedsLayout ();
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -969,7 +971,7 @@ public class TileView : View
|
|
|
|
|
|
//Driver.UncookMouse ();
|
|
//Driver.UncookMouse ();
|
|
FinalisePosition (
|
|
FinalisePosition (
|
|
- dragOrignalPos,
|
|
|
|
|
|
+ dragOrignalPos!,
|
|
Orientation == Orientation.Horizontal ? Y : X
|
|
Orientation == Orientation.Horizontal ? Y : X
|
|
);
|
|
);
|
|
dragPosition = null;
|
|
dragPosition = null;
|
|
@@ -979,11 +981,14 @@ public class TileView : View
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- public override void OnDrawContent (Rectangle viewport)
|
|
|
|
- {
|
|
|
|
- base.OnDrawContent (viewport);
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ protected override bool OnClearingViewport () { return true; }
|
|
|
|
|
|
|
|
+ protected override bool OnDrawingContent ()
|
|
|
|
+ {
|
|
DrawSplitterSymbol ();
|
|
DrawSplitterSymbol ();
|
|
|
|
+
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
public override Point? PositionCursor ()
|
|
public override Point? PositionCursor ()
|
|
@@ -1015,7 +1020,7 @@ public class TileView : View
|
|
float position = p.GetAnchor (parentLength) + 0.5f;
|
|
float position = p.GetAnchor (parentLength) + 0.5f;
|
|
|
|
|
|
// Calculate the percentage
|
|
// Calculate the percentage
|
|
- int percent = (int)Math.Round ((position / parentLength) * 100);
|
|
|
|
|
|
+ var percent = (int)Math.Round (position / parentLength * 100);
|
|
|
|
|
|
// Return a new PosPercent object
|
|
// Return a new PosPercent object
|
|
return Pos.Percent (percent);
|
|
return Pos.Percent (percent);
|
|
@@ -1036,6 +1041,10 @@ public class TileView : View
|
|
/// <param name="newValue"></param>
|
|
/// <param name="newValue"></param>
|
|
private bool FinalisePosition (Pos oldValue, Pos newValue)
|
|
private bool FinalisePosition (Pos oldValue, Pos newValue)
|
|
{
|
|
{
|
|
|
|
+ SetNeedsDraw ();
|
|
|
|
+
|
|
|
|
+ SetNeedsLayout ();
|
|
|
|
+
|
|
if (oldValue is PosPercent)
|
|
if (oldValue is PosPercent)
|
|
{
|
|
{
|
|
if (Orientation == Orientation.Horizontal)
|
|
if (Orientation == Orientation.Horizontal)
|
|
@@ -1078,10 +1087,10 @@ public class TileView : View
|
|
private Pos Offset (Pos pos, int delta)
|
|
private Pos Offset (Pos pos, int delta)
|
|
{
|
|
{
|
|
int posAbsolute = pos.GetAnchor (
|
|
int posAbsolute = pos.GetAnchor (
|
|
- Orientation == Orientation.Horizontal
|
|
|
|
- ? Parent.Viewport.Height
|
|
|
|
- : Parent.Viewport.Width
|
|
|
|
- );
|
|
|
|
|
|
+ Orientation == Orientation.Horizontal
|
|
|
|
+ ? Parent.Viewport.Height
|
|
|
|
+ : Parent.Viewport.Width
|
|
|
|
+ );
|
|
|
|
|
|
return posAbsolute + delta;
|
|
return posAbsolute + delta;
|
|
}
|
|
}
|
|
@@ -1089,4 +1098,4 @@ public class TileView : View
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>Represents a method that will handle splitter events.</summary>
|
|
/// <summary>Represents a method that will handle splitter events.</summary>
|
|
-public delegate void SplitterEventHandler (object sender, SplitterEventArgs e);
|
|
|
|
|
|
+public delegate void SplitterEventHandler (object? sender, SplitterEventArgs e);
|