using System; using Spectre.Console.Rendering; namespace Spectre.Console { /// /// Represents a grid column. /// public sealed class GridColumn : IColumn, IHasDirtyState { private bool _isDirty; private int? _width; private bool _noWrap; private Padding? _padding; private Justify? _alignment; /// bool IHasDirtyState.IsDirty => _isDirty; /// /// Gets or sets the width of the column. /// If null, the column will adapt to it's contents. /// public int? Width { get => _width; set => MarkAsDirty(() => _width = value); } /// /// Gets or sets a value indicating whether wrapping of /// text within the column should be prevented. /// public bool NoWrap { get => _noWrap; set => MarkAsDirty(() => _noWrap = value); } /// /// Gets or sets the padding of the column. /// Vertical padding (top and bottom) is ignored. /// public Padding? Padding { get => _padding; set => MarkAsDirty(() => _padding = value); } /// /// Gets or sets the alignment of the column. /// public Justify? Alignment { get => _alignment; set => MarkAsDirty(() => _alignment = value); } /// /// Gets a value indicating whether the user /// has set an explicit padding for this column. /// internal bool HasExplicitPadding => Padding != null; private void MarkAsDirty(Action action) { action(); _isDirty = true; } } }