Refactored View editors

This commit is contained in:
Tig
2024-10-25 16:11:51 -06:00
parent ce900ada49
commit 1cbdb5c71e
9 changed files with 238 additions and 583 deletions

View File

@@ -200,8 +200,9 @@ public class DatePicker : View
ShowHeaders = true,
ShowHorizontalBottomline = true,
ShowVerticalCellLines = true,
ExpandLastColumn = true
}
ExpandLastColumn = true,
},
MultiSelect = false
};
_dateField = new DateField (DateTime.Now)
@@ -286,6 +287,9 @@ public class DatePicker : View
Add (_dateLabel, _dateField, _calendar, _previousMonthButton, _nextMonthButton);
}
/// <inheritdoc />
protected override bool OnDrawingText (Rectangle viewport) { return true; }
private static string StandardizeDateFormat (string format)
{
return format switch

View File

@@ -111,7 +111,9 @@ public class AllViewsTester : Scenario
Height = Dim.Auto (),
CanFocus = true,
ColorScheme = Colors.ColorSchemes ["TopLevel"],
BorderStyle = LineStyle.Rounded
BorderStyle = LineStyle.Rounded,
AutoSelectViewToEdit = false,
AutoSelectAdornments = false,
};
_settingsPane = new ()

View File

@@ -33,7 +33,8 @@ public class Arrangement : Scenario
};
app.Add (adornmentsEditor);
adornmentsEditor.ExpandButton!.Collapsed = true;
adornmentsEditor.ExpanderButton!.Collapsed = true;
var arrangementEditor = new ArrangementEditor ()
{

View File

@@ -7,7 +7,7 @@ namespace UICatalog.Scenarios;
/// <summary>
/// Provides a composable UI for editing the settings of an Adornment.
/// </summary>
public class AdornmentEditor : View
public class AdornmentEditor : EditorBase
{
private readonly ColorPicker16 _backgroundColorPicker = new ()
{
@@ -79,6 +79,12 @@ public class AdornmentEditor : View
AdornmentChanged?.Invoke (this, EventArgs.Empty);
}
/// <inheritdoc />
protected override void OnViewToEditChanged ()
{
AdornmentToEdit = ViewToEdit as Adornment;
}
private NumericUpDown<int>? _topEdit;
private NumericUpDown<int>? _leftEdit;
private NumericUpDown<int>? _bottomEdit;
@@ -86,21 +92,12 @@ public class AdornmentEditor : View
public AdornmentEditor ()
{
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
BorderStyle = LineStyle.Dashed;
Initialized += AdornmentEditor_Initialized;
CanFocus = true;
TabStop = TabBehavior.TabStop;
Initialized += AdornmentEditor_Initialized;
}
private void AdornmentEditor_Initialized (object? sender, EventArgs e)
{
ExpanderButton? expandButton;
Border.Add (expandButton = new ExpanderButton ());
_topEdit = new ()
{
X = Pos.Center (), Y = 0,

View File

@@ -7,89 +7,56 @@ namespace UICatalog.Scenarios;
/// <summary>
/// Provides an editor UI for the Margin, Border, and Padding of a View.
/// </summary>
public class AdornmentsEditor : View
public class AdornmentsEditor : EditorBase
{
public AdornmentsEditor ()
{
Title = "AdornmentsEditor";
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
CanFocus = true;
TabStop = TabBehavior.TabGroup;
ExpandButton = new ()
{
Orientation = Orientation.Horizontal
};
ExpanderButton.Orientation = Orientation.Horizontal;
Initialized += AdornmentsEditor_Initialized;
}
private View? _viewToEdit;
private MarginEditor? _marginEditor;
private BorderEditor? _borderEditor;
private PaddingEditor? _paddingEditor;
/// <summary>
/// Gets or sets whether the AdornmentsEditor should automatically select the View to edit
/// based on the values of <see cref="AutoSelectSuperView"/> and <see cref="AutoSelectAdornments"/>.
/// </summary>
public bool AutoSelectViewToEdit { get; set; }
/// <summary>
/// Gets or sets the View that will scope the behavior of <see cref="AutoSelectViewToEdit"/>.
/// </summary>
public View? AutoSelectSuperView { get; set; }
/// <summary>
/// Gets or sets whether auto select with the mouse will select Adornments or just Views.
/// </summary>
public bool AutoSelectAdornments { get; set; }
public View? ViewToEdit
/// <inheritdoc />
protected override void OnViewToEditChanged ()
{
get => _viewToEdit;
set
if (_marginEditor is { })
{
if (_viewToEdit == value)
{
return;
}
_viewToEdit = value;
if (_marginEditor is { })
{
_marginEditor.AdornmentToEdit = _viewToEdit?.Margin ?? null;
}
if (_borderEditor is { })
{
_borderEditor.AdornmentToEdit = _viewToEdit?.Border ?? null;
}
if (_paddingEditor is { })
{
_paddingEditor.AdornmentToEdit = _viewToEdit?.Padding ?? null;
}
if (_viewToEdit is not Adornment)
{
Enabled = true;
}
else
{
Enabled = false;
}
Padding.Text = $"View: {GetIdentifyingString(_viewToEdit)}";
_marginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
}
if (_borderEditor is { })
{
_borderEditor.AdornmentToEdit = ViewToEdit?.Border ?? null;
}
if (_paddingEditor is { })
{
_paddingEditor.AdornmentToEdit = ViewToEdit?.Padding ?? null;
}
if (ViewToEdit is not Adornment)
{
Enabled = true;
}
else
{
Enabled = false;
}
Padding.Text = $"View: {GetIdentifyingString (ViewToEdit)}";
}
private string GetIdentifyingString (View? view)
{
if (view is null)
@@ -115,59 +82,6 @@ public class AdornmentsEditor : View
return view.GetType ().Name;
}
private void NavigationOnFocusedChanged (object? sender, EventArgs e)
{
if (AutoSelectSuperView is null)
{
return;
}
if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
{
return;
}
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
{
return;
}
ViewToEdit = Application.Navigation!.GetFocused ();
}
private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
{
if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
{
return;
}
if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
|| FrameToScreen ().Contains (e.Position))
{
return;
}
View view = e.View;
if (view is { })
{
if (view is Adornment adornment)
{
ViewToEdit = AutoSelectAdornments ? adornment : adornment.Parent;
}
else
{
ViewToEdit = view;
}
}
}
/// <inheritdoc/>
protected override void Dispose (bool disposing) { base.Dispose (disposing); }
public ExpanderButton? ExpandButton { get; }
public bool ShowViewIdentifier
{
get => Padding.Thickness != Thickness.Empty;
@@ -179,22 +93,18 @@ public class AdornmentsEditor : View
}
else
{
Padding.Thickness =Thickness.Empty;
Padding.Thickness = Thickness.Empty;
}
}
}
private void AdornmentsEditor_Initialized (object? sender, EventArgs e)
{
BorderStyle = LineStyle.Dotted;
Border.Add (ExpandButton!);
_marginEditor = new ()
{
X = 0,
Y = 0,
SuperViewRendersLineCanvas = true
SuperViewRendersLineCanvas = true,
};
Add (_marginEditor);
@@ -215,11 +125,9 @@ public class AdornmentsEditor : View
Add (_paddingEditor);
_marginEditor.AdornmentToEdit = _viewToEdit?.Margin ?? null;
_borderEditor.AdornmentToEdit = _viewToEdit?.Border ?? null;
_paddingEditor.AdornmentToEdit = _viewToEdit?.Padding ?? null;
_marginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
_borderEditor.AdornmentToEdit = ViewToEdit?.Border ?? null;
_paddingEditor.AdornmentToEdit = ViewToEdit?.Padding ?? null;
Application.MouseEvent += ApplicationOnMouseEvent;
Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
}
}

View File

@@ -10,101 +10,26 @@ namespace UICatalog.Scenarios;
/// <summary>
/// Provides an editor UI for the Margin, Border, and Padding of a View.
/// </summary>
public class DimEditor : View
public class DimEditor : EditorBase
{
public DimEditor ()
{
Title = "Dim";
BorderStyle = LineStyle.Rounded;
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
CanFocus = true;
_expandButton = new ()
{
Orientation = Orientation.Vertical
};
TabStop = TabBehavior.TabStop;
Initialized += DimEditor_Initialized;
AddCommand (Command.Accept, () => true);
}
private View? _viewToEdit;
private int _value;
private RadioGroup? _dimRadioGroup;
private TextField? _valueEdit;
/// <summary>
/// Gets or sets whether the DimEditor should automatically select the View to edit
/// based on the values of <see cref="AutoSelectSuperView"/> and <see cref="AutoSelectAdornments"/>.
/// </summary>
public bool AutoSelectViewToEdit { get; set; }
/// <summary>
/// Gets or sets the View that will scope the behavior of <see cref="AutoSelectViewToEdit"/>.
/// </summary>
public View? AutoSelectSuperView { get; set; }
/// <summary>
/// Gets or sets whether auto select with the mouse will select Adornments or just Views.
/// </summary>
public bool AutoSelectAdornments { get; set; }
public View? ViewToEdit
{
get => _viewToEdit;
set
{
if (_viewToEdit == value)
{
return;
}
if (value is null && _viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut -= View_LayoutComplete;
}
_viewToEdit = value;
if (_viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut += View_LayoutComplete;
_viewToEdit.SubviewLayout += (sender, args) =>
{
};
}
}
}
private void View_LayoutComplete (object? sender, LayoutEventArgs args)
{
UpdateSettings ();
}
private bool _updatingSettings = false;
private void UpdateSettings ()
protected override void OnUpdateSettings ()
{
if (ViewToEdit is null)
{
return;
}
_updatingSettings = true;
Dim? dim;
Dim dim;
if (Dimension == Dimension.Width)
{
dim = ViewToEdit.Width;
@@ -116,7 +41,7 @@ public class DimEditor : View
try
{
_dimRadioGroup!.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => dim!.ToString ().StartsWith(s)));
_dimRadioGroup!.SelectedItem = _dimNames.IndexOf (Enumerable.First<string> (_dimNames, s => dim!.ToString ().StartsWith (s)));
}
catch (InvalidOperationException e)
{
@@ -134,7 +59,7 @@ public class DimEditor : View
break;
case DimFill fill:
var margin = fill.Margin as DimAbsolute;
_valueEdit.Enabled = margin is {};
_valueEdit.Enabled = margin is { };
_value = margin?.Size ?? 0;
_valueEdit!.Text = _value.ToString ();
break;
@@ -152,76 +77,12 @@ public class DimEditor : View
_valueEdit!.Text = dim!.ToString ();
break;
}
_updatingSettings = false;
}
private void NavigationOnFocusedChanged (object? sender, EventArgs e)
{
if (AutoSelectSuperView is null)
{
return;
}
if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
{
return;
}
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
{
return;
}
ViewToEdit = Application.Navigation!.GetFocused ();
}
private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
{
if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
{
return;
}
if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
|| FrameToScreen ().Contains (e.Position))
{
return;
}
View? view = e.View;
if (view is null)
{
return;
}
if (view is Adornment adornment)
{
ViewToEdit = AutoSelectAdornments ? adornment : adornment.Parent;
}
else
{
ViewToEdit = view;
}
}
/// <inheritdoc/>
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
}
private readonly ExpanderButton? _expandButton;
public ExpanderButton? ExpandButton => _expandButton;
public Dimension Dimension { get; set; }
private void DimEditor_Initialized (object? sender, EventArgs e)
{
Border.Add (_expandButton!);
var label = new Label
{
X = 0, Y = 0,
@@ -254,9 +115,6 @@ public class DimEditor : View
Add (_valueEdit);
Add (_dimRadioGroup);
Application.MouseEvent += ApplicationOnMouseEvent;
Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
}
private void OnRadioGroupOnSelectedItemChanged (object? s, SelectedItemChangedArgs selected) { DimChanged (); }
@@ -267,7 +125,7 @@ public class DimEditor : View
private void DimChanged ()
{
if (ViewToEdit == null || _updatingSettings)
if (ViewToEdit == null || UpdatingSettings)
{
return;
}

View File

@@ -0,0 +1,155 @@
using System;
using System.Diagnostics;
using System.Linq;
using Terminal.Gui;
namespace UICatalog.Scenarios;
public abstract class EditorBase : View
{
protected EditorBase ()
{
BorderStyle = LineStyle.Rounded;
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
CanFocus = true;
ExpanderButton = new ()
{
Orientation = Orientation.Vertical
};
TabStop = TabBehavior.TabStop;
Initialized += OnInitialized;
void OnInitialized (object sender, EventArgs e)
{
Border.Add (ExpanderButton!);
Application.MouseEvent += ApplicationOnMouseEvent;
Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
}
AddCommand (Command.Accept, () => true);
}
public ExpanderButton ExpanderButton {get; set; }
public bool UpdatingSettings { get; private set; } = false;
private void View_LayoutComplete (object sender, LayoutEventArgs e)
{
UpdatingSettings = true;
OnUpdateSettings ();
UpdatingSettings = false;
}
private View _viewToEdit;
public View ViewToEdit
{
get => _viewToEdit;
set
{
if (_viewToEdit == value)
{
return;
}
if (value is null && _viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut -= View_LayoutComplete;
}
_viewToEdit = value;
if (_viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut += View_LayoutComplete;
}
OnViewToEditChanged ();
}
}
protected virtual void OnViewToEditChanged () { }
protected virtual void OnUpdateSettings () { }
/// <summary>
/// Gets or sets whether the DimEditor should automatically select the View to edit
/// based on the values of <see cref="AutoSelectSuperView"/> and <see cref="AutoSelectAdornments"/>.
/// </summary>
public bool AutoSelectViewToEdit { get; set; }
/// <summary>
/// Gets or sets the View that will scope the behavior of <see cref="AutoSelectViewToEdit"/>.
/// </summary>
public View AutoSelectSuperView { get; set; }
/// <summary>
/// Gets or sets whether auto select with the mouse will select Adornments or just Views.
/// </summary>
public bool AutoSelectAdornments { get; set; }
private void NavigationOnFocusedChanged (object sender, EventArgs e)
{
if (AutoSelectSuperView is null)
{
return;
}
if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
{
return;
}
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
{
return;
}
ViewToEdit = Application.Navigation!.GetFocused ();
}
private void ApplicationOnMouseEvent (object sender, MouseEventArgs e)
{
if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
{
return;
}
if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
|| FrameToScreen ().Contains (e.Position))
{
return;
}
View view = e.View;
if (view is null)
{
return;
}
if (view is Adornment adornment)
{
ViewToEdit = AutoSelectAdornments ? adornment : adornment.Parent;
}
else
{
ViewToEdit = view;
}
}
}

View File

@@ -9,185 +9,50 @@ namespace UICatalog.Scenarios;
/// <summary>
/// Provides an editor UI for the Margin, Border, and Padding of a View.
/// </summary>
public class LayoutEditor : View
public class LayoutEditor : EditorBase
{
public LayoutEditor ()
{
Title = "_LayoutEditor";
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
CanFocus = true;
TabStop = TabBehavior.TabGroup;
_expandButton = new ()
{
Orientation = Orientation.Vertical
};
BorderStyle = LineStyle.Rounded;
Initialized += LayoutEditor_Initialized;
AddCommand (Command.Accept, () => true);
}
private View? _viewToEdit;
private readonly List<string> _dimNames = ["Auto", "Percent", "Fill", "Absolute"];
private PosEditor? _xEditor;
private PosEditor? _yEditor;
private DimEditor? _widthEditor;
private DimEditor? _heightEditor;
/// <summary>
/// Gets or sets whether the LayoutEditor should automatically select the View to edit
/// based on the values of <see cref="AutoSelectSuperView"/> and <see cref="AutoSelectAdornments"/>.
/// </summary>
public bool AutoSelectViewToEdit { get; set; }
/// <summary>
/// Gets or sets the View that will scope the behavior of <see cref="AutoSelectViewToEdit"/>.
/// </summary>
public View? AutoSelectSuperView { get; set; }
/// <summary>
/// Gets or sets whether auto select with the mouse will select Adornments or just Views.
/// </summary>
public bool AutoSelectAdornments { get; set; }
public View? ViewToEdit
protected override void OnViewToEditChanged ()
{
get => _viewToEdit;
set
if (_xEditor is { })
{
if (_viewToEdit == value)
{
return;
}
_xEditor.ViewToEdit = ViewToEdit;
}
if (value is null && _viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut -= View_LayoutComplete;
}
if (_yEditor is { })
{
_yEditor.ViewToEdit = ViewToEdit;
}
_viewToEdit = value;
if (_viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut += View_LayoutComplete;
}
if (_xEditor is { })
{
_xEditor.ViewToEdit = _viewToEdit;
}
if (_yEditor is { })
{
_yEditor.ViewToEdit = _viewToEdit;
}
if (_widthEditor is { })
{
_widthEditor.ViewToEdit = _viewToEdit;
}
if (_heightEditor is { })
{
_heightEditor.ViewToEdit = _viewToEdit;
}
if (_widthEditor is { })
{
_widthEditor.ViewToEdit = ViewToEdit;
}
if (_heightEditor is { })
{
_heightEditor.ViewToEdit = ViewToEdit;
}
}
private void View_LayoutComplete (object? sender, LayoutEventArgs args)
{
UpdateSettings ();
}
private bool _updatingSettings = false;
private void UpdateSettings ()
{
if (ViewToEdit is null)
{
return;
}
_updatingSettings = true;
_updatingSettings = false;
}
private void NavigationOnFocusedChanged (object? sender, EventArgs e)
{
if (AutoSelectSuperView is null)
{
return;
}
if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
{
return;
}
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
{
return;
}
ViewToEdit = Application.Navigation!.GetFocused ();
}
private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
{
if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
{
return;
}
if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
|| FrameToScreen ().Contains (e.Position))
{
return;
}
View? view = e.View;
if (view is null)
{
return;
}
if (view is Adornment adornment)
{
ViewToEdit = AutoSelectAdornments ? adornment : adornment.Parent;
}
else
{
ViewToEdit = view;
}
}
/// <inheritdoc/>
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
}
private readonly ExpanderButton? _expandButton;
public ExpanderButton? ExpandButton => _expandButton;
private void LayoutEditor_Initialized (object? sender, EventArgs e)
{
BorderStyle = LineStyle.Rounded;
Border.Add (_expandButton!);
_xEditor = new ()
{
Title = "_X",
@@ -200,7 +65,7 @@ public class LayoutEditor : View
Title = "_Y",
BorderStyle = LineStyle.None,
Dimension = Dimension.Height,
X = Pos.Right(_xEditor) + 1
X = Pos.Right (_xEditor) + 1
};
@@ -209,7 +74,7 @@ public class LayoutEditor : View
Title = "_Width",
BorderStyle = LineStyle.None,
Dimension = Dimension.Width,
X = Pos.Right(_yEditor) + 1
X = Pos.Right (_yEditor) + 1
};
_heightEditor = new ()
@@ -221,8 +86,5 @@ public class LayoutEditor : View
};
Add (_xEditor, _yEditor, _widthEditor, _heightEditor);
Application.MouseEvent += ApplicationOnMouseEvent;
Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
}
}

View File

@@ -10,94 +10,28 @@ namespace UICatalog.Scenarios;
/// <summary>
/// Provides an editor UI for the Margin, Border, and Padding of a View.
/// </summary>
public class PosEditor : View
public class PosEditor : EditorBase
{
public PosEditor ()
{
Title = "Pos";
BorderStyle = LineStyle.Rounded;
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
CanFocus = true;
_expandButton = new ()
{
Orientation = Orientation.Vertical
};
TabStop = TabBehavior.TabStop;
Initialized += PosEditor_Initialized;
AddCommand (Command.Accept, () => true);
}
private View? _viewToEdit;
private int _value;
private RadioGroup? _posRadioGroup;
private TextField? _valueEdit;
/// <summary>
/// Gets or sets whether the PosEditor should automatically select the View to edit
/// based on the values of <see cref="AutoSelectSuperView"/> and <see cref="AutoSelectAdornments"/>.
/// </summary>
public bool AutoSelectViewToEdit { get; set; }
/// <summary>
/// Gets or sets the View that will scope the behavior of <see cref="AutoSelectViewToEdit"/>.
/// </summary>
public View? AutoSelectSuperView { get; set; }
/// <summary>
/// Gets or sets whether auto select with the mouse will select Adornments or just Views.
/// </summary>
public bool AutoSelectAdornments { get; set; }
public View? ViewToEdit
{
get => _viewToEdit;
set
{
if (_viewToEdit == value)
{
return;
}
if (value is null && _viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut -= View_LayoutComplete;
}
_viewToEdit = value;
if (_viewToEdit is { })
{
_viewToEdit.SubviewsLaidOut += View_LayoutComplete;
}
}
}
private void View_LayoutComplete (object? sender, LayoutEventArgs args)
{
UpdateSettings ();
}
private bool _updatingSettings = false;
private void UpdateSettings ()
protected override void OnUpdateSettings ()
{
if (ViewToEdit is null)
{
return;
}
_updatingSettings = true;
Pos? pos;
if (Dimension == Dimension.Width)
{
@@ -140,76 +74,12 @@ public class PosEditor : View
_valueEdit!.Text = pos.ToString ();
break;
}
_updatingSettings = false;
}
private void NavigationOnFocusedChanged (object? sender, EventArgs e)
{
if (AutoSelectSuperView is null)
{
return;
}
if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
{
return;
}
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
{
return;
}
ViewToEdit = Application.Navigation!.GetFocused ();
}
private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
{
if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
{
return;
}
if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
|| FrameToScreen ().Contains (e.Position))
{
return;
}
View? view = e.View;
if (view is null)
{
return;
}
if (view is Adornment adornment)
{
ViewToEdit = AutoSelectAdornments ? adornment : adornment.Parent;
}
else
{
ViewToEdit = view;
}
}
/// <inheritdoc/>
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
}
private readonly ExpanderButton? _expandButton;
public ExpanderButton? ExpandButton => _expandButton;
public Dimension Dimension { get; set; }
private void PosEditor_Initialized (object? sender, EventArgs e)
{
Border.Add (_expandButton!);
var label = new Label
{
X = 0, Y = 0,
@@ -243,8 +113,6 @@ public class PosEditor : View
Add (_posRadioGroup);
Application.MouseEvent += ApplicationOnMouseEvent;
Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
}
private void OnRadioGroupOnSelectedItemChanged (object? s, SelectedItemChangedArgs selected) { PosChanged (); }
@@ -255,7 +123,7 @@ public class PosEditor : View
private void PosChanged ()
{
if (ViewToEdit == null || _updatingSettings)
if (ViewToEdit == null || UpdatingSettings)
{
return;
}