LineCanvas - Exclude

This commit is contained in:
Tig
2024-11-06 21:05:04 -07:00
parent 45ce64ab86
commit 3d4658df6c
8 changed files with 33 additions and 19 deletions

View File

@@ -158,13 +158,19 @@ public class LineCanvas : IDisposable
{
_cachedViewport = Rectangle.Empty;
_lines.Clear ();
Exclusions.Clear ();
_exclusionRegion = null;
}
private Region? _exclusionRegion;
/// <summary>
/// Gets the list of locations that will be excluded from <see cref="GetCellMap"/> and <see cref="GetMap()"/>.
/// </summary>
public List<Point> Exclusions { get; } = new List<Point> ();
public void Exclude (Region region)
{
_exclusionRegion ??= new Region ();
_exclusionRegion.Union (region);
}
/// <summary>
/// Clears any cached states from the canvas Call this method if you make changes to lines that have already been
@@ -194,10 +200,9 @@ public class LineCanvas : IDisposable
Cell? cell = GetCellForIntersects (Application.Driver, intersects);
Point location = new (x, y);
if (cell is { } && !Exclusions.Contains (location))
if (cell is { } && _exclusionRegion?.Contains (x, y) is null or false)
{
map.Add (location, cell);
map.Add (new (x, y), cell);
}
}
}
@@ -230,8 +235,7 @@ public class LineCanvas : IDisposable
Rune? rune = GetRuneForIntersects (Application.Driver, intersects);
Point location = new (x, y);
if (rune is { } && !Exclusions.Contains (location))
if (rune is { } && _exclusionRegion?.Contains (x, y) is null or false)
{
map.Add (new (x, y), rune.Value);
}
@@ -257,7 +261,12 @@ public class LineCanvas : IDisposable
{
AddLine (line);
}
Exclusions.AddRange (lineCanvas.Exclusions);
if (lineCanvas._exclusionRegion is { })
{
_exclusionRegion ??= new ();
_exclusionRegion.Union (lineCanvas._exclusionRegion);
}
}
/// <summary>Removes the last line added to the canvas</summary>

View File

@@ -106,7 +106,6 @@ public class Border : Adornment
{
DrawIndicator.AdvanceAnimation (false);
DrawIndicator.Render ();
Parent?.LineCanvas.Exclusions.Add (DrawIndicator.ViewportToScreen (new Point (0,0)));
}
}

View File

@@ -133,6 +133,7 @@ public partial class View // Drawing APIs
foreach (View subview in Border.Subviews)
{
subview.SetNeedsDraw ();
LineCanvas.Exclude (new (subview.FrameToScreen()));
}
Region? saved = Border?.ClipFrame ();

View File

@@ -850,8 +850,8 @@ public class Slider<T> : View, IOrientation
if (IsInitialized)
{
normalAttr = ColorScheme?.Normal ?? Application.Top.ColorScheme.Normal;
setAttr = Style.SetChar.Attribute ?? ColorScheme!.HotNormal;
normalAttr = GetNormalColor();
setAttr = Style.SetChar.Attribute ?? GetHotNormalColor ();
}
bool isVertical = _config._sliderOrientation == Orientation.Vertical;
@@ -1058,8 +1058,8 @@ public class Slider<T> : View, IOrientation
if (IsInitialized)
{
normalAttr = Style.LegendAttributes.NormalAttribute ?? ColorScheme?.Normal ?? ColorScheme.Disabled;
setAttr = Style.LegendAttributes.SetAttribute ?? ColorScheme?.HotNormal ?? ColorScheme.Normal;
normalAttr = Style.LegendAttributes.NormalAttribute ?? GetNormalColor ();
setAttr = Style.LegendAttributes.SetAttribute ?? GetHotNormalColor ();
spaceAttr = Style.LegendAttributes.EmptyAttribute ?? normalAttr;
}

View File

@@ -60,7 +60,7 @@ public class AllViewsTester : Scenario
SelectedItem = 0,
Source = new ListWrapper<string> (new (_viewClasses.Keys.ToList ())),
BorderStyle = LineStyle.Rounded,
SuperViewRendersLineCanvas = true
//SuperViewRendersLineCanvas = true
};
_classListView.SelectedItemChanged += (s, args) =>
@@ -88,7 +88,7 @@ public class AllViewsTester : Scenario
_adornmentsEditor = new ()
{
Title = "Adornments [_2]",
X = Pos.Right (_classListView) - 1,
X = Pos.Right (_classListView),
Y = 0,
Width = Dim.Auto (),
Height = Dim.Auto (),
@@ -96,22 +96,22 @@ public class AllViewsTester : Scenario
BorderStyle = LineStyle.Rounded,
AutoSelectViewToEdit = false,
AutoSelectAdornments = false,
SuperViewRendersLineCanvas = true
//SuperViewRendersLineCanvas = true
};
_adornmentsEditor.ExpanderButton.Orientation = Orientation.Vertical;
_arrangementEditor = new ()
{
Title = "Arrangement [_3]",
X = Pos.Right (_classListView) - 1,
Y = Pos.Bottom (_adornmentsEditor) -1,
X = Pos.Right (_classListView),
Y = Pos.Bottom (_adornmentsEditor),
Width = Dim.Width (_adornmentsEditor),
Height = Dim.Fill (),
ColorScheme = Colors.ColorSchemes ["TopLevel"],
BorderStyle = LineStyle.Rounded,
AutoSelectViewToEdit = false,
AutoSelectAdornments = false,
SuperViewRendersLineCanvas = true
//SuperViewRendersLineCanvas = true
};
_arrangementEditor.ExpanderButton.Orientation = Orientation.Vertical;

View File

@@ -27,6 +27,8 @@ public class AdornmentsEditor : EditorBase
/// <inheritdoc/>
protected override void OnViewToEditChanged ()
{
Enabled = ViewToEdit is Adornment;
if (MarginEditor is { })
{
MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;

View File

@@ -69,6 +69,8 @@ public sealed class ArrangementEditor : EditorBase
protected override void OnViewToEditChanged ()
{
Enabled = ViewToEdit is not Adornment;
_arrangementSlider.OptionsChanged -= ArrangementSliderOnOptionsChanged;
// Set the appropriate options in the slider based on _viewToEdit.Arrangement

View File

@@ -29,6 +29,7 @@ public class LayoutEditor : EditorBase
protected override void OnViewToEditChanged ()
{
Enabled = ViewToEdit is not Adornment;
if (_xEditor is { })
{