mirror of
https://github.com/dnwSilver/tld.git
synced 2024-11-25 16:42:07 +00:00
♻️ Rename classes.
This commit is contained in:
parent
074365652d
commit
3b56c7207b
@ -12,13 +12,12 @@ public class CellsComponentBase : ComponentBase, IComponent
|
||||
|
||||
private readonly IEnumerable<string> _cells;
|
||||
|
||||
|
||||
public CellsComponentBase(IEnumerable<string> cells)
|
||||
{
|
||||
_cells = cells;
|
||||
}
|
||||
|
||||
public void Render(AlignmentHorizontal alignmentHorizontal, Size size)
|
||||
public void Render(Horizontal horizontal, Size size)
|
||||
{
|
||||
var content = new StringBuilder();
|
||||
foreach (var cell in _cells)
|
||||
@ -30,7 +29,7 @@ public class CellsComponentBase : ComponentBase, IComponent
|
||||
// base.Render(content, position, size);
|
||||
}
|
||||
|
||||
public override Sketch Draw()
|
||||
public override Sketch DrawComponent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class Dashboard : ComponentBase, IComponent
|
||||
_title = title;
|
||||
}
|
||||
|
||||
public void Render(AlignmentHorizontal alignmentHorizontal, Size size)
|
||||
public void Render(Horizontal horizontal, Size size)
|
||||
{
|
||||
var dashboardBuilder = new StringBuilder();
|
||||
|
||||
@ -61,7 +61,7 @@ public class Dashboard : ComponentBase, IComponent
|
||||
dashboardBuilder.Append(Symbols.Angles.RightBottom);
|
||||
}
|
||||
|
||||
public override Sketch Draw()
|
||||
public override Sketch DrawComponent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -1,47 +1,33 @@
|
||||
using TUI.Components.Controls.Statics;
|
||||
using TUI.Components.Controls.Statics.Hints;
|
||||
using TUI.Engine.Nodes;
|
||||
using TUI.Engine.Nodes.Attributes;
|
||||
using TUI.Engine.Nodes.Attributes.Alignments;
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
using TUI.Engine.Nodes.Attributes.Resizings;
|
||||
using TUI.Engine.Nodes.Containers;
|
||||
using TUI.Engine.Theme;
|
||||
|
||||
namespace TUI.Components.Controls;
|
||||
|
||||
public abstract class ContainerBase : IContainer
|
||||
{
|
||||
public Orientation Orientation => Orientation.Horizontal;
|
||||
|
||||
public Resizing ResizingHorizontal => Resizing.Adaptive;
|
||||
|
||||
public Resizing ResizingVertical => Resizing.Hug;
|
||||
|
||||
public Size Fixed { get; }
|
||||
|
||||
public abstract Nodes GetNodes();
|
||||
}
|
||||
|
||||
public class HeaderContainer : ContainerBase, IContainer
|
||||
{
|
||||
public override Nodes GetNodes()
|
||||
{
|
||||
var versionHints = new VersionHints()
|
||||
.Set(Indentation.Default);
|
||||
var versionHints = new VersionHints();
|
||||
versionHints.SetPadding(Indentation.Default);
|
||||
|
||||
var tagsHints = new TagHints()
|
||||
.Set(Indentation.Default);
|
||||
var tagsHints = new TagHints();
|
||||
tagsHints.SetPadding(Indentation.Default);
|
||||
|
||||
var appTypeHints = new AppTypeHints()
|
||||
.Set(Indentation.Default);
|
||||
var appTypeHints = new AppTypeHints();
|
||||
appTypeHints.SetPadding(Indentation.Default);
|
||||
|
||||
var hotkeysHints = new HotkeysHint()
|
||||
.Set(Indentation.Default);
|
||||
var hotkeysHints = new HotkeysHint();
|
||||
hotkeysHints.SetPadding(Indentation.Default);
|
||||
|
||||
var logo = new Logo()
|
||||
.Set(AlignmentHorizontal.Right)
|
||||
.Set(left: Indentation.Default, bottom: Indentation.Default, right: Indentation.Default);
|
||||
var logo = new Logo();
|
||||
logo.SetAlignment(Horizontal.Right);
|
||||
logo.SetPaddingLeft(Indentation.Default);
|
||||
logo.SetPaddingBottom(Indentation.Default);
|
||||
logo.SetPaddingRight(Indentation.Default);
|
||||
|
||||
return new Nodes { versionHints, tagsHints, appTypeHints, hotkeysHints, logo };
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class Tag : ComponentBase
|
||||
_gitType = gitType;
|
||||
}
|
||||
|
||||
public void Render(AlignmentHorizontal alignmentHorizontal, Size size)
|
||||
public void Render(Horizontal horizontal, Size size)
|
||||
{
|
||||
var tagBuilder = new StringBuilder();
|
||||
|
||||
@ -59,7 +59,7 @@ public class Tag : ComponentBase
|
||||
_ => Symbols.Git
|
||||
};
|
||||
|
||||
public override Sketch Draw()
|
||||
public override Sketch DrawComponent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using TUI.Components.Controls;
|
||||
using TUI.Engine.Nodes;
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
using TUI.Engine.Nodes.Attributes.Resizings;
|
||||
using TUI.Engine.Nodes.Attributes.Resizing;
|
||||
using TUI.Engine.Nodes.Components;
|
||||
using TUI.Engine.Nodes.Containers;
|
||||
|
||||
|
@ -18,12 +18,12 @@ public class DependenciesView : ComponentBase, IComponent
|
||||
_developmentStack = developmentStack;
|
||||
}
|
||||
|
||||
public void Render(AlignmentHorizontal alignmentHorizontal, Size size)
|
||||
public void Render(Horizontal horizontal, Size size)
|
||||
{
|
||||
var dashboardTitle = _developmentStack.Icon + Symbols.Space + ViewName;
|
||||
var dashboard = new Dashboard(dashboardTitle);
|
||||
|
||||
Add(dashboard);
|
||||
// Add(dashboard);
|
||||
}
|
||||
|
||||
// private const int TitleWidth = 25;
|
||||
@ -153,7 +153,7 @@ public class DependenciesView : ComponentBase, IComponent
|
||||
// {
|
||||
// _table.Previous();
|
||||
// }
|
||||
public override Sketch Draw()
|
||||
public override Sketch DrawComponent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
namespace TUI.Engine.Nodes.Attributes.Alignments;
|
||||
|
||||
public record Alignment(AlignmentHorizontal AlignmentHorizontal, Vertical Vertical);
|
||||
public record Alignment(Horizontal Horizontal, Vertical Vertical);
|
@ -1,6 +1,6 @@
|
||||
namespace TUI.Engine.Nodes.Attributes.Alignments;
|
||||
|
||||
public enum AlignmentHorizontal
|
||||
public enum Horizontal
|
||||
{
|
||||
Left = 0,
|
||||
Center = 1,
|
10
src/TUI/Engine/Nodes/Attributes/Alignments/IAlignable.cs
Normal file
10
src/TUI/Engine/Nodes/Attributes/Alignments/IAlignable.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace TUI.Engine.Nodes.Attributes.Alignments;
|
||||
|
||||
public interface IAlignable
|
||||
{
|
||||
Alignment Alignment { get; }
|
||||
|
||||
void SetAlignment(Vertical vertical);
|
||||
|
||||
void SetAlignment(Horizontal horizontal);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
namespace TUI.Engine.Nodes.Attributes.Alignments;
|
||||
|
||||
public interface IWithAlignment<out TNode> where TNode : INode
|
||||
{
|
||||
public Alignment Alignment { get; }
|
||||
|
||||
public TNode Set(AlignmentHorizontal alignmentHorizontal = AlignmentHorizontal.Left, Vertical vertical = Vertical.Top);
|
||||
}
|
14
src/TUI/Engine/Nodes/Attributes/Paddings/IPaddingable.cs
Normal file
14
src/TUI/Engine/Nodes/Attributes/Paddings/IPaddingable.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using TUI.Engine.Theme;
|
||||
|
||||
namespace TUI.Engine.Nodes.Attributes.Paddings;
|
||||
|
||||
public interface IPaddingable
|
||||
{
|
||||
Padding? Padding { get; }
|
||||
|
||||
void SetPadding(Level level);
|
||||
void SetPaddingLeft(Level level);
|
||||
void SetPaddingTop(Level level);
|
||||
void SetPaddingBottom(Level level);
|
||||
void SetPaddingRight(Level level);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using TUI.Engine.Theme;
|
||||
|
||||
namespace TUI.Engine.Nodes.Attributes.Paddings;
|
||||
|
||||
public interface IWithPadding<out TNode> where TNode : INode
|
||||
{
|
||||
public Padding? Padding { get; }
|
||||
|
||||
public TNode Set(Level padding);
|
||||
|
||||
public TNode Set(
|
||||
Level? left = Level.None,
|
||||
Level? top = Level.None,
|
||||
Level? right = Level.None,
|
||||
Level? bottom = Level.None
|
||||
);
|
||||
}
|
@ -3,10 +3,10 @@ using TUI.Engine.Theme;
|
||||
namespace TUI.Engine.Nodes.Attributes.Paddings;
|
||||
|
||||
public record Padding(
|
||||
Level? Left = Level.None,
|
||||
Level? Top = Level.None,
|
||||
Level? Right = Level.None,
|
||||
Level? Bottom = Level.None
|
||||
Level Left = Level.None,
|
||||
Level Top = Level.None,
|
||||
Level Right = Level.None,
|
||||
Level Bottom = Level.None
|
||||
)
|
||||
{
|
||||
public Padding(Level padding) : this(Left: padding, Top: padding, Right: padding, Bottom: padding)
|
||||
|
14
src/TUI/Engine/Nodes/Attributes/Resizing/IResizable.cs
Normal file
14
src/TUI/Engine/Nodes/Attributes/Resizing/IResizable.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
|
||||
namespace TUI.Engine.Nodes.Attributes.Resizing;
|
||||
|
||||
public interface IResizable
|
||||
{
|
||||
Resizing ResizingHorizontal { get; }
|
||||
|
||||
Resizing ResizingVertical { get; }
|
||||
|
||||
void SetAdaptive(Orientation orientation);
|
||||
void SetHug(Orientation orientation);
|
||||
void SetFixed(Orientation orientation, int value);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace TUI.Engine.Nodes.Attributes.Resizings;
|
||||
namespace TUI.Engine.Nodes.Attributes.Resizing;
|
||||
|
||||
public enum Resizing
|
||||
{
|
@ -1,10 +0,0 @@
|
||||
namespace TUI.Engine.Nodes.Attributes.Resizings;
|
||||
|
||||
public interface IWithResizing
|
||||
{
|
||||
Resizing ResizingHorizontal { get; }
|
||||
|
||||
Resizing ResizingVertical { get; }
|
||||
|
||||
Size Fixed { get; }
|
||||
}
|
@ -1,21 +1,46 @@
|
||||
using TUI.Engine.Nodes.Attributes;
|
||||
using TUI.Engine.Nodes.Attributes.Alignments;
|
||||
using TUI.Engine.Nodes.Attributes.Paddings;
|
||||
using TUI.Engine.Nodes.Attributes.Resizing;
|
||||
using TUI.Engine.Theme;
|
||||
|
||||
|
||||
namespace TUI.Engine.Nodes.Components;
|
||||
|
||||
public abstract class ComponentBase : List<IComponent>, IComponent
|
||||
|
||||
public abstract class ComponentBase : NodeBase, IComponent
|
||||
{
|
||||
public abstract Sketch Draw();
|
||||
private Size _sketchSize;
|
||||
|
||||
public abstract Sketch DrawComponent();
|
||||
|
||||
public Sketch Draw()
|
||||
{
|
||||
var sketch = DrawComponent();
|
||||
_sketchSize = sketch.GetSize();
|
||||
return sketch;
|
||||
}
|
||||
|
||||
public Resizing ResizingHorizontal { get; }
|
||||
|
||||
// protected override Size GetAllowableSize() =>
|
||||
// new(
|
||||
// AllowableSize.Width <= _sketchSize.Width ? _sketchSize.Width : AllowableSize.Width,
|
||||
// AllowableSize.Height <= _sketchSize.Height ? _sketchSize.Height : AllowableSize.Height
|
||||
// );
|
||||
|
||||
#region Alignments
|
||||
|
||||
public Alignment Alignment { get; private set; } = new(AlignmentHorizontal.Center, Vertical.Top);
|
||||
public Alignment Alignment { get; private set; } = new(Horizontal.Center, Vertical.Top);
|
||||
|
||||
public IComponent Set(AlignmentHorizontal alignmentHorizontal = AlignmentHorizontal.Left, Vertical vertical = Vertical.Top)
|
||||
public void SetAlignment(Vertical vertical)
|
||||
{
|
||||
Alignment = new Alignment(alignmentHorizontal, vertical);
|
||||
return this;
|
||||
Alignment = Alignment with { Vertical = vertical };
|
||||
}
|
||||
|
||||
public void SetAlignment(Horizontal horizontal)
|
||||
{
|
||||
Alignment = Alignment with { Horizontal = horizontal };
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -24,22 +49,15 @@ public abstract class ComponentBase : List<IComponent>, IComponent
|
||||
|
||||
public Padding Padding { get; private set; } = new(Level.None);
|
||||
|
||||
public IComponent Set(Level padding)
|
||||
{
|
||||
Padding = new Padding(padding);
|
||||
return this;
|
||||
}
|
||||
public void SetPadding(Level level) => Padding = new Padding(level);
|
||||
|
||||
public IComponent Set(
|
||||
Level? left = Level.None,
|
||||
Level? top = Level.None,
|
||||
Level? right = Level.None,
|
||||
Level? bottom = Level.None
|
||||
)
|
||||
{
|
||||
Padding = new Padding(left, top, right, bottom);
|
||||
return this;
|
||||
}
|
||||
public void SetPaddingTop(Level level) => Padding = Padding with { Top = level };
|
||||
|
||||
public void SetPaddingRight(Level level) => Padding = Padding with { Right = level };
|
||||
|
||||
public void SetPaddingBottom(Level level) => Padding = Padding with { Bottom = level };
|
||||
|
||||
public void SetPaddingLeft(Level level) => Padding = Padding with { Left = level };
|
||||
|
||||
#endregion
|
||||
}
|
@ -8,7 +8,7 @@ public abstract class ComponentStaticBase : ComponentBase
|
||||
|
||||
protected abstract void RenderWithCache(StringBuilder builder);
|
||||
|
||||
public override Sketch Draw()
|
||||
public override Sketch DrawComponent()
|
||||
{
|
||||
if (_cache is not null)
|
||||
{
|
||||
|
@ -3,9 +3,7 @@ using TUI.Engine.Nodes.Attributes.Paddings;
|
||||
|
||||
namespace TUI.Engine.Nodes.Components;
|
||||
|
||||
public interface IComponent : INode,
|
||||
IWithAlignment<IComponent>,
|
||||
IWithPadding<IComponent>
|
||||
public interface IComponent : INode, IAlignable, IPaddingable
|
||||
{
|
||||
Sketch Draw();
|
||||
}
|
10
src/TUI/Engine/Nodes/Containers/ContainerBase.cs
Normal file
10
src/TUI/Engine/Nodes/Containers/ContainerBase.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
|
||||
namespace TUI.Engine.Nodes.Containers;
|
||||
|
||||
public abstract class ContainerBase : NodeBase, IContainer
|
||||
{
|
||||
public Orientation Orientation => Orientation.Horizontal;
|
||||
|
||||
public abstract Nodes GetNodes();
|
||||
}
|
@ -7,6 +7,27 @@ namespace TUI.Engine.Nodes.Containers;
|
||||
|
||||
public static class ContainerExtension
|
||||
{
|
||||
// public static Position GetNextNodePosition(this INode node,
|
||||
// Orientation orientation,
|
||||
// Size allowableSize,
|
||||
// Position currentChildrenPosition)
|
||||
// {
|
||||
// var nodeSize = node.GetSize(allowableSize);
|
||||
//
|
||||
// return orientation switch
|
||||
// {
|
||||
// Orientation.Horizontal => currentChildrenPosition with
|
||||
// {
|
||||
// Left = currentChildrenPosition.Left + nodeSize.Width
|
||||
// },
|
||||
// Orientation.Vertical => currentChildrenPosition with
|
||||
// {
|
||||
// Top = currentChildrenPosition.Top + nodeSize.Height
|
||||
// },
|
||||
// _ => throw new ArgumentOutOfRangeException()
|
||||
// };
|
||||
// }
|
||||
|
||||
public static Size GetSize(this IContainer container, Size allowableSize)
|
||||
{
|
||||
var nodeCount = container.GetNodes().Count;
|
||||
@ -27,19 +48,19 @@ public static class ComponentExtensions
|
||||
Size actualSize)
|
||||
{
|
||||
var left = sketchPosition.Left + (int)(component.Padding?.Left ?? 0) +
|
||||
CompensationLeft(component.Alignment.AlignmentHorizontal, allowableSize, actualSize);
|
||||
CompensationLeft(component.Alignment.Horizontal, allowableSize, actualSize);
|
||||
var top = sketchPosition.Top + (int)(component.Padding?.Top ?? 0) +
|
||||
CompensationTop(component.Alignment.Vertical, allowableSize, actualSize);
|
||||
return new Position(left, top);
|
||||
}
|
||||
|
||||
private static int CompensationLeft(AlignmentHorizontal componentAlignmentHorizontal, Size defaultSize,
|
||||
private static int CompensationLeft(Horizontal componentHorizontal, Size defaultSize,
|
||||
Size realSize) =>
|
||||
componentAlignmentHorizontal switch
|
||||
componentHorizontal switch
|
||||
{
|
||||
AlignmentHorizontal.Left => 0,
|
||||
AlignmentHorizontal.Center => (defaultSize.Width - realSize.Width) / 2,
|
||||
AlignmentHorizontal.Right => defaultSize.Width - realSize.Width,
|
||||
Horizontal.Left => 0,
|
||||
Horizontal.Center => (defaultSize.Width - realSize.Width) / 2,
|
||||
Horizontal.Right => defaultSize.Width - realSize.Width,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
using TUI.Engine.Nodes.Attributes.Resizings;
|
||||
|
||||
namespace TUI.Engine.Nodes.Containers;
|
||||
|
||||
public interface IContainer : INode,
|
||||
IWithOrientation,
|
||||
IWithResizing
|
||||
IWithOrientation
|
||||
{
|
||||
public Nodes GetNodes();
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
using TUI.Engine.Nodes.Attributes.Resizing;
|
||||
|
||||
namespace TUI.Engine.Nodes;
|
||||
|
||||
public interface INode
|
||||
public interface INode : IResizable
|
||||
{
|
||||
}
|
64
src/TUI/Engine/Nodes/NodeBase.cs
Normal file
64
src/TUI/Engine/Nodes/NodeBase.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
using TUI.Engine.Nodes.Attributes.Resizing;
|
||||
|
||||
namespace TUI.Engine.Nodes;
|
||||
|
||||
public abstract class NodeBase : INode
|
||||
{
|
||||
private int _fixedWidth;
|
||||
private int _fixedHeight;
|
||||
|
||||
#region Resizing
|
||||
|
||||
public Resizing ResizingHorizontal { get; private set; } = Resizing.Adaptive;
|
||||
public Resizing ResizingVertical { get; private set; } = Resizing.Hug;
|
||||
|
||||
public void SetAdaptive(Orientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case Orientation.Horizontal:
|
||||
ResizingHorizontal = Resizing.Adaptive;
|
||||
break;
|
||||
case Orientation.Vertical:
|
||||
ResizingVertical = Resizing.Adaptive;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHug(Orientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case Orientation.Horizontal:
|
||||
ResizingHorizontal = Resizing.Hug;
|
||||
break;
|
||||
case Orientation.Vertical:
|
||||
ResizingVertical = Resizing.Hug;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFixed(Orientation orientation, int value)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case Orientation.Horizontal:
|
||||
ResizingHorizontal = Resizing.Fixed;
|
||||
_fixedWidth = value;
|
||||
break;
|
||||
case Orientation.Vertical:
|
||||
ResizingVertical = Resizing.Fixed;
|
||||
_fixedHeight = value;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Resizing
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
using System.Diagnostics;
|
||||
using TUI.Engine.Nodes;
|
||||
using TUI.Engine.Nodes.Attributes;
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
@ -68,3 +67,22 @@ public sealed class ContainerCraftsman : CraftsmanBase, IDrawable<IContainer>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private int GetWidth() =>
|
||||
// ResizingHorizontal switch
|
||||
// {
|
||||
// Resizing.Fixed => _fixedWidth,
|
||||
// Resizing.Hug => GetAllowableSize().Width,
|
||||
// Resizing.Adaptive => GetAllowableSize().Width,
|
||||
// _ => 0
|
||||
// };
|
||||
//
|
||||
// private int GetHeight() =>
|
||||
// ResizingVertical switch
|
||||
// {
|
||||
// Resizing.Fixed => _fixedHeight,
|
||||
// Resizing.Hug => GetAllowableSize().Height,
|
||||
// Resizing.Adaptive => GetAllowableSize().Height,
|
||||
// _ => 0
|
||||
// };
|
||||
|
@ -1,5 +1,3 @@
|
||||
using TUI.Engine.Nodes.Attributes;
|
||||
|
||||
namespace TUI.Engine.Rendering;
|
||||
|
||||
public interface ICanvas
|
||||
|
@ -21,9 +21,10 @@ public class DependenciesPage
|
||||
var nodeCraftsman = new NodeCraftsman(componentCraftsman, containerCraftsman);
|
||||
|
||||
var header = new HeaderContainer();
|
||||
var copyright = new Copyright()
|
||||
.Set(right: Level.Normal)
|
||||
.Set(AlignmentHorizontal.Right, Vertical.Bottom);
|
||||
var copyright = new Copyright();
|
||||
copyright.SetPaddingRight(Level.Normal);
|
||||
copyright.SetAlignment(Horizontal.Right);
|
||||
copyright.SetAlignment(Vertical.Bottom);
|
||||
|
||||
var layout = new DashboardLayout().AddHeader(header).AddFooter(copyright);
|
||||
// CommandLine = new CommandLine();
|
||||
|
@ -10,16 +10,17 @@ public class ComponentBaseTests
|
||||
[Fact]
|
||||
public void WhenUseChainingSaveAllChange()
|
||||
{
|
||||
var component = new Logo()
|
||||
.Set(Level.Normal)
|
||||
.Set(vertical: Vertical.Center, alignmentHorizontal: AlignmentHorizontal.Center);
|
||||
var logo = new Logo();
|
||||
logo.SetPadding(Level.Normal);
|
||||
logo.SetAlignment(Vertical.Center);
|
||||
logo.SetAlignment(Horizontal.Center);
|
||||
|
||||
component.Padding.Top.Should().Be(Level.Normal);
|
||||
component.Padding.Left.Should().Be(Level.Normal);
|
||||
component.Padding.Bottom.Should().Be(Level.Normal);
|
||||
component.Padding.Right.Should().Be(Level.Normal);
|
||||
component.Alignment.AlignmentHorizontal.Should().Be(AlignmentHorizontal.Center);
|
||||
component.Alignment.Vertical.Should().Be(Vertical.Center);
|
||||
logo.Padding.Top.Should().Be(Level.Normal);
|
||||
logo.Padding.Left.Should().Be(Level.Normal);
|
||||
logo.Padding.Bottom.Should().Be(Level.Normal);
|
||||
logo.Padding.Right.Should().Be(Level.Normal);
|
||||
logo.Alignment.Horizontal.Should().Be(Horizontal.Center);
|
||||
logo.Alignment.Vertical.Should().Be(Vertical.Center);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -27,7 +28,7 @@ public class ComponentBaseTests
|
||||
{
|
||||
var component = new Logo();
|
||||
|
||||
component.Set(Level.Normal);
|
||||
component.SetPadding(Level.Normal);
|
||||
|
||||
component.Padding.Top.Should().Be(Level.Normal);
|
||||
component.Padding.Left.Should().Be(Level.Normal);
|
||||
@ -43,22 +44,21 @@ public class ComponentBaseTests
|
||||
{
|
||||
var component = new Logo();
|
||||
|
||||
component.Set(vertical: alignment);
|
||||
component.SetAlignment(alignment);
|
||||
|
||||
component.Alignment.Vertical.Should().Be(alignment);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(AlignmentHorizontal.Left)]
|
||||
[InlineData(AlignmentHorizontal.Center)]
|
||||
[InlineData(AlignmentHorizontal.Right)]
|
||||
public void WhenSetHorizontalAlignSaveAllChange(AlignmentHorizontal alignment)
|
||||
[InlineData(Horizontal.Left)]
|
||||
[InlineData(Horizontal.Center)]
|
||||
[InlineData(Horizontal.Right)]
|
||||
public void WhenSetHorizontalAlignSaveAllChange(Horizontal alignment)
|
||||
{
|
||||
var component = new Logo();
|
||||
|
||||
component.Set(alignmentHorizontal: alignment);
|
||||
component.SetAlignment(alignment);
|
||||
|
||||
component.Alignment.AlignmentHorizontal.Should().Be(alignment);
|
||||
component.Alignment.Horizontal.Should().Be(alignment);
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,7 @@ using Moq;
|
||||
using TUI.Engine.Nodes;
|
||||
using TUI.Engine.Nodes.Attributes.Alignments;
|
||||
using TUI.Engine.Nodes.Attributes.Orientations;
|
||||
using TUI.Engine.Nodes.Attributes.Resizings;
|
||||
using TUI.Engine.Nodes.Attributes.Resizing;
|
||||
using TUI.Engine.Nodes.Components;
|
||||
using TUI.Engine.Nodes.Containers;
|
||||
using TUI.Engine.Rendering;
|
||||
@ -17,7 +17,7 @@ public class NodeCraftsmanTests
|
||||
{
|
||||
_component = Mock.Of<IComponent>(c =>
|
||||
c.Draw() == new Sketch("Lorem") &&
|
||||
c.Alignment == new Alignment(AlignmentHorizontal.Left, Vertical.Top));
|
||||
c.Alignment == new Alignment(Horizontal.Left, Vertical.Top));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -36,14 +36,14 @@ public class NodeCraftsmanTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(AlignmentHorizontal.Left, "Lorem", 10, 0)]
|
||||
[InlineData(AlignmentHorizontal.Center, "Lorem", 10, 2)]
|
||||
[InlineData(AlignmentHorizontal.Center, "Lo", 10, 4)]
|
||||
[InlineData(AlignmentHorizontal.Center, "Lorem", 9, 2)]
|
||||
[InlineData(AlignmentHorizontal.Center, "Lorem", 11, 3)]
|
||||
[InlineData(AlignmentHorizontal.Right, "Lorem", 10, 5)]
|
||||
[InlineData(AlignmentHorizontal.Right, "Lo", 10, 8)]
|
||||
public void DrawWithHorizontalAlignment(AlignmentHorizontal alignment, string content, int canvasSize,
|
||||
[InlineData(Horizontal.Left, "Lorem", 10, 0)]
|
||||
[InlineData(Horizontal.Center, "Lorem", 10, 2)]
|
||||
[InlineData(Horizontal.Center, "Lo", 10, 4)]
|
||||
[InlineData(Horizontal.Center, "Lorem", 9, 2)]
|
||||
[InlineData(Horizontal.Center, "Lorem", 11, 3)]
|
||||
[InlineData(Horizontal.Right, "Lorem", 10, 5)]
|
||||
[InlineData(Horizontal.Right, "Lo", 10, 8)]
|
||||
public void DrawWithHorizontalAlignment(Horizontal alignment, string content, int canvasSize,
|
||||
int expectedPosition)
|
||||
{
|
||||
var canvas = Mock.Of<ICanvas>(w => w.Width == canvasSize && w.Height == canvasSize);
|
||||
@ -79,7 +79,7 @@ public class NodeCraftsmanTests
|
||||
{
|
||||
var canvas = Mock.Of<ICanvas>(w => w.Width == canvasSize && w.Height == canvasSize);
|
||||
var component = Mock.Of<IComponent>(c => c.Draw() == new Sketch(content) &&
|
||||
c.Alignment == new Alignment(AlignmentHorizontal.Left, alignment));
|
||||
c.Alignment == new Alignment(Horizontal.Left, alignment));
|
||||
var nodes = new Nodes { component };
|
||||
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes);
|
||||
|
||||
@ -94,21 +94,21 @@ public class NodeCraftsmanTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(AlignmentHorizontal.Left, Vertical.Top, 0, 0)]
|
||||
[InlineData(AlignmentHorizontal.Left, Vertical.Center, 0, 2)]
|
||||
[InlineData(AlignmentHorizontal.Left, Vertical.Bottom, 0, 4)]
|
||||
[InlineData(AlignmentHorizontal.Center, Vertical.Top, 2, 0)]
|
||||
[InlineData(AlignmentHorizontal.Center, Vertical.Center, 2, 2)]
|
||||
[InlineData(AlignmentHorizontal.Center, Vertical.Bottom, 2, 4)]
|
||||
[InlineData(AlignmentHorizontal.Right, Vertical.Top, 4, 0)]
|
||||
[InlineData(AlignmentHorizontal.Right, Vertical.Center, 4, 2)]
|
||||
[InlineData(AlignmentHorizontal.Right, Vertical.Bottom, 4, 4)]
|
||||
public void DrawWithAlignment(AlignmentHorizontal alignmentHorizontal, Vertical vertical, int expectedLeft,
|
||||
[InlineData(Horizontal.Left, Vertical.Top, 0, 0)]
|
||||
[InlineData(Horizontal.Left, Vertical.Center, 0, 2)]
|
||||
[InlineData(Horizontal.Left, Vertical.Bottom, 0, 4)]
|
||||
[InlineData(Horizontal.Center, Vertical.Top, 2, 0)]
|
||||
[InlineData(Horizontal.Center, Vertical.Center, 2, 2)]
|
||||
[InlineData(Horizontal.Center, Vertical.Bottom, 2, 4)]
|
||||
[InlineData(Horizontal.Right, Vertical.Top, 4, 0)]
|
||||
[InlineData(Horizontal.Right, Vertical.Center, 4, 2)]
|
||||
[InlineData(Horizontal.Right, Vertical.Bottom, 4, 4)]
|
||||
public void DrawWithAlignment(Horizontal horizontal, Vertical vertical, int expectedLeft,
|
||||
int expectedTop)
|
||||
{
|
||||
var canvas = Mock.Of<ICanvas>(w => w.Width == 6 && w.Height == 5);
|
||||
var component = Mock.Of<IComponent>(c => c.Draw() == new Sketch("VV") &&
|
||||
c.Alignment == new Alignment(alignmentHorizontal, vertical));
|
||||
c.Alignment == new Alignment(horizontal, vertical));
|
||||
var nodes = new Nodes { component };
|
||||
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes);
|
||||
|
||||
@ -157,7 +157,7 @@ public class NodeCraftsmanTests
|
||||
{
|
||||
var canvas = Mock.Of<ICanvas>(w => w.Width == 10 && w.Height == 1);
|
||||
var nodes = new Nodes { _component, _component };
|
||||
var container = Mock.Of<IContainer>(g => g.GetNodes() == nodes);
|
||||
var container = Mock.Of<ContainerBase>(g => g.GetNodes() == nodes);
|
||||
|
||||
var componentCraftsman = new ComponentCraftsman(canvas);
|
||||
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
|
||||
|
Loading…
Reference in New Issue
Block a user