mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
LineCanvas - Exclude
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -106,7 +106,6 @@ public class Border : Adornment
|
||||
{
|
||||
DrawIndicator.AdvanceAnimation (false);
|
||||
DrawIndicator.Render ();
|
||||
Parent?.LineCanvas.Exclusions.Add (DrawIndicator.ViewportToScreen (new Point (0,0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -29,6 +29,7 @@ public class LayoutEditor : EditorBase
|
||||
|
||||
protected override void OnViewToEditChanged ()
|
||||
{
|
||||
Enabled = ViewToEdit is not Adornment;
|
||||
|
||||
if (_xEditor is { })
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user