Răsfoiți Sursa

Refactored View editors 2

Tig 9 luni în urmă
părinte
comite
98d0454df9

+ 9 - 16
Terminal.Gui/View/Adornment/Adornment.cs

@@ -42,7 +42,8 @@ public class Adornment : View, IDesignable
     #region Thickness
 
     /// <summary>
-    ///     Gets or sets whether the Adornment will draw diagnostic information. This is a bit-field of <see cref="ViewDiagnosticFlags"/>.
+    ///     Gets or sets whether the Adornment will draw diagnostic information. This is a bit-field of
+    ///     <see cref="ViewDiagnosticFlags"/>.
     /// </summary>
     /// <remarks>
     ///     The <see cref="View.Diagnostics"/> static property is used as the default value for this property.
@@ -152,6 +153,7 @@ public class Adornment : View, IDesignable
                 return Point.Empty;
             }
         }
+
         return parentOrSuperView.ScreenToFrame (new (location.X - Frame.X, location.Y - Frame.Y));
     }
 
@@ -176,17 +178,11 @@ public class Adornment : View, IDesignable
         return true;
     }
 
-    /// <inheritdoc />
-    protected override bool OnDrawingText (Rectangle viewport)
-    {
-        return Thickness == Thickness.Empty;
-    }
+    /// <inheritdoc/>
+    protected override bool OnDrawingText (Rectangle viewport) { return Thickness == Thickness.Empty; }
 
-    /// <inheritdoc />
-    protected override bool OnDrawingSubviews (Rectangle viewport)
-    {
-        return Thickness == Thickness.Empty;
-    }
+    /// <inheritdoc/>
+    protected override bool OnDrawingSubviews (Rectangle viewport) { return Thickness == Thickness.Empty; }
 
     /// <summary>Does nothing for Adornment</summary>
     /// <returns></returns>
@@ -202,11 +198,8 @@ public class Adornment : View, IDesignable
         set => throw new InvalidOperationException (@"Adornment can only render to their Parent or Parent's Superview.");
     }
 
-    /// <inheritdoc />
-    protected override bool OnDrawComplete (Rectangle viewport)
-    {
-        return Thickness == Thickness.Empty;
-    }
+    /// <inheritdoc/>
+    protected override bool OnDrawComplete (Rectangle viewport) { return Thickness == Thickness.Empty; }
 
     /// <summary>
     ///     Indicates whether the specified Parent's SuperView-relative coordinates are within the Adornment's Thickness.

+ 0 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -56,7 +56,6 @@ public class Border : Adornment
     public Border (View parent) : base (parent)
     {
         Parent = parent;
-        Id = $"{Parent.Id}.{Border}";
         CanFocus = false;
         TabStop = TabBehavior.TabGroup;
 

+ 5 - 0
Terminal.Gui/View/View.cs

@@ -288,6 +288,11 @@ public partial class View : Responder, ISupportInitializeNotification
             OnEnabledChanged ();
             SetNeedsDisplay ();
 
+            if (Border is { })
+            {
+                Border.Enabled = _enabled;
+            }
+
             if (_subviews is null)
             {
                 return;

+ 32 - 28
UICatalog/Scenarios/AllViewsTester.cs

@@ -7,14 +7,14 @@ using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
-[Scenario.ScenarioMetadata ("All Views Tester", "Provides a test UI for all classes derived from View.")]
-[Scenario.ScenarioCategory ("Layout")]
-[Scenario.ScenarioCategory ("Tests")]
-[Scenario.ScenarioCategory ("Controls")]
-[Scenario.ScenarioCategory ("Adornments")]
+[ScenarioMetadata ("All Views Tester", "Provides a test UI for all classes derived from View.")]
+[ScenarioCategory ("Layout")]
+[ScenarioCategory ("Tests")]
+[ScenarioCategory ("Controls")]
+[ScenarioCategory ("Adornments")]
+[ScenarioCategory ("Arrangement")]
 public class AllViewsTester : Scenario
 {
-
     private Dictionary<string, Type>? _viewClasses;
     private ListView? _classListView;
     private AdornmentsEditor? _adornmentsEditor;
@@ -92,7 +92,7 @@ public class AllViewsTester : Scenario
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             BorderStyle = LineStyle.Single,
             AutoSelectViewToEdit = false,
-            AutoSelectAdornments = false,
+            AutoSelectAdornments = false
         };
 
         var expandButton = new ExpanderButton
@@ -107,13 +107,14 @@ public class AllViewsTester : Scenario
             Title = "Layout [_3]",
             X = Pos.Right (_adornmentsEditor),
             Y = 0,
+
             //Width = Dim.Fill (), // set below
             Height = Dim.Auto (),
             CanFocus = true,
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             BorderStyle = LineStyle.Rounded,
             AutoSelectViewToEdit = false,
-            AutoSelectAdornments = false,
+            AutoSelectAdornments = false
         };
 
         _settingsPane = new ()
@@ -170,7 +171,7 @@ public class AllViewsTester : Scenario
 
         _settingsPane.Add (label, _demoTextView);
 
-        _eventLog = new EventLog ()
+        _eventLog = new()
         {
             // X = Pos.Right(_layoutEditor)
         };
@@ -178,20 +179,24 @@ public class AllViewsTester : Scenario
         _eventLog.Y = 0;
 
         _eventLog.Height = Dim.Height (_classListView);
+
         //_eventLog.Width = 30;
 
-        _layoutEditor.Width = Dim.Fill (Dim.Func ((() =>
-                                                   {
-                                                       if (_eventLog.NeedsLayout)
-                                                       {
-                                                           // We have two choices:
-                                                           // 1) Call Layout explicitly
-                                                           // 2) Throw LayoutException so Layout tries again
-                                                           //_eventLog.Layout ();
-                                                           throw new LayoutException ("_eventLog");
-                                                       }
-                                                       return _eventLog.Frame.Width;
-                                                   })));
+        _layoutEditor.Width = Dim.Fill (
+                                        Dim.Func (
+                                                  () =>
+                                                  {
+                                                      if (_eventLog.NeedsLayout)
+                                                      {
+                                                          // We have two choices:
+                                                          // 1) Call Layout explicitly
+                                                          // 2) Throw LayoutException so Layout tries again
+                                                          //_eventLog.Layout ();
+                                                          throw new LayoutException ("_eventLog");
+                                                      }
+
+                                                      return _eventLog.Frame.Width;
+                                                  }));
 
         _hostPane = new ()
         {
@@ -248,6 +253,7 @@ public class AllViewsTester : Scenario
 
         // Instantiate view
         var view = (View)Activator.CreateInstance (type)!;
+
         if (view is IDesignable designable)
         {
             designable.EnableForDesign (ref _demoText);
@@ -297,7 +303,8 @@ public class AllViewsTester : Scenario
     private static List<Type> GetAllViewClassesCollection ()
     {
         List<Type> types = typeof (View).Assembly.GetTypes ()
-                                        .Where (myType => myType is { IsClass: true, IsAbstract: false, IsPublic: true }
+                                        .Where (
+                                                myType => myType is { IsClass: true, IsAbstract: false, IsPublic: true }
                                                           && myType.IsSubclassOf (typeof (View)))
                                         .ToList ();
 
@@ -306,10 +313,7 @@ public class AllViewsTester : Scenario
         return types;
     }
 
-    private void CurrentView_LayoutComplete (object? sender, LayoutEventArgs args)
-    {
-        UpdateHostTitle (_curView);
-    }
+    private void CurrentView_LayoutComplete (object? sender, LayoutEventArgs args) { UpdateHostTitle (_curView); }
 
     private void UpdateHostTitle (View? view) { _hostPane!.Title = $"{view!.GetType ().Name} [_0]"; }
 
@@ -320,12 +324,12 @@ public class AllViewsTester : Scenario
             return;
         }
 
-        if (!view.Width!.Has<DimAuto> (out _) || (view.Width is null))
+        if (!view.Width!.Has<DimAuto> (out _) || view.Width is null)
         {
             view.Width = Dim.Fill ();
         }
 
-        if (!view.Height!.Has<DimAuto> (out _) || (view.Height is null))
+        if (!view.Height!.Has<DimAuto> (out _) || view.Height is null)
         {
             view.Height = Dim.Fill ();
         }

+ 12 - 11
UICatalog/Scenarios/Arrangement.cs

@@ -1,14 +1,12 @@
-using System.Threading;
-using System.Timers;
-using Terminal.Gui;
+using Terminal.Gui;
 using Timer = System.Timers.Timer;
 
 namespace UICatalog.Scenarios;
 
-[Scenario.ScenarioMetadata ("Arrangement", "Arrangement Tester")]
-[Scenario.ScenarioCategory ("Mouse and Keyboard")]
-[Scenario.ScenarioCategory ("Layout")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[ScenarioMetadata ("Arrangement", "Arrangement Tester")]
+[ScenarioCategory ("Mouse and Keyboard")]
+[ScenarioCategory ("Layout")]
+[ScenarioCategory ("Arrangement")]
 public class Arrangement : Scenario
 {
     private int _hotkeyCount;
@@ -34,9 +32,11 @@ public class Arrangement : Scenario
 
         app.Add (adornmentsEditor);
 
-        adornmentsEditor.ExpanderButton!.Collapsed = true;
+        adornmentsEditor.ExpanderButton.Orientation = Orientation.Horizontal;
 
-        var arrangementEditor = new ArrangementEditor ()
+        //  adornmentsEditor.ExpanderButton!.Collapsed = true;
+
+        var arrangementEditor = new ArrangementEditor
         {
             X = Pos.Right (adornmentsEditor),
             Y = 0,
@@ -233,8 +233,9 @@ public class Arrangement : Scenario
             BorderStyle = LineStyle.Single,
             CanFocus = true,
             TabStop = TabBehavior.TabStop,
-            Arrangement = ViewArrangement.Resizable,
-//            SuperViewRendersLineCanvas = true
+            Arrangement = ViewArrangement.Resizable
+
+            //            SuperViewRendersLineCanvas = true
         };
 
         return tiled;

+ 1 - 1
UICatalog/Scenarios/CsvEditor.cs

@@ -16,7 +16,7 @@ namespace UICatalog.Scenarios;
 [Scenario.ScenarioCategory ("Dialogs")]
 [Scenario.ScenarioCategory ("Text and Formatting")]
 [Scenario.ScenarioCategory ("Dialogs")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Arrangement")]
 [Scenario.ScenarioCategory ("Files and IO")]
 public class CsvEditor : Scenario
 {

+ 1 - 1
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -9,7 +9,7 @@ using Terminal.Gui;
 namespace UICatalog.Scenarios;
 
 [Scenario.ScenarioMetadata ("Dynamic MenuBar", "Demonstrates how to change a MenuBar dynamically.")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Arrangement")]
 [Scenario.ScenarioCategory ("Menus")]
 public class DynamicMenuBar : Scenario
 {

+ 1 - 1
UICatalog/Scenarios/DynamicStatusBar.cs

@@ -10,7 +10,7 @@ using Terminal.Gui;
 namespace UICatalog.Scenarios;
 
 [Scenario.ScenarioMetadata ("Dynamic StatusBar", "Demonstrates how to add and remove a StatusBar and change items dynamically.")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Arrangement")]
 public class DynamicStatusBar : Scenario
 {
     public override void Main ()

+ 1 - 1
UICatalog/Scenarios/Editor.cs

@@ -16,7 +16,7 @@ namespace UICatalog.Scenarios;
 [Scenario.ScenarioCategory ("Controls")]
 [Scenario.ScenarioCategory ("Dialogs")]
 [Scenario.ScenarioCategory ("Text and Formatting")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Arrangement")]
 [Scenario.ScenarioCategory ("Files and IO")]
 [Scenario.ScenarioCategory ("TextView")]
 [Scenario.ScenarioCategory ("Menus")]

+ 34 - 38
UICatalog/Scenarios/Editors/AdornmentEditor.cs

@@ -15,7 +15,7 @@ public class AdornmentEditor : EditorBase
         BoxWidth = 1,
         BoxHeight = 1,
         BorderStyle = LineStyle.Single,
-        SuperViewRendersLineCanvas = true,
+        SuperViewRendersLineCanvas = true
     };
 
     private readonly ColorPicker16 _foregroundColorPicker = new ()
@@ -24,20 +24,21 @@ public class AdornmentEditor : EditorBase
         BoxWidth = 1,
         BoxHeight = 1,
         BorderStyle = LineStyle.Single,
-        SuperViewRendersLineCanvas = true,
+        SuperViewRendersLineCanvas = true
     };
 
-
     private CheckBox? _diagThicknessCheckBox;
     private CheckBox? _diagRulerCheckBox;
 
-
     private Adornment? _adornment;
+
     public Adornment? AdornmentToEdit
     {
         get => _adornment;
         set
         {
+            Enabled = value is { };
+
             if (value == _adornment)
             {
                 return;
@@ -45,8 +46,6 @@ public class AdornmentEditor : EditorBase
 
             _adornment = value;
 
-            Enabled = _adornment is { };
-
             if (_adornment is null)
             {
                 return;
@@ -61,10 +60,9 @@ public class AdornmentEditor : EditorBase
 
                 _adornment.Initialized += (sender, args) =>
                                           {
-                                              var cs = _adornment.ColorScheme;
+                                              ColorScheme? cs = _adornment.ColorScheme;
                                               _foregroundColorPicker.SelectedColor = cs.Normal.Foreground.GetClosestNamedColor16 ();
                                               _backgroundColorPicker.SelectedColor = cs.Normal.Background.GetClosestNamedColor16 ();
-
                                           };
             }
 
@@ -74,16 +72,10 @@ public class AdornmentEditor : EditorBase
 
     public event EventHandler<EventArgs>? AdornmentChanged;
 
-    public void OnAdornmentChanged ()
-    {
-        AdornmentChanged?.Invoke (this, EventArgs.Empty);
-    }
+    public void OnAdornmentChanged () { AdornmentChanged?.Invoke (this, EventArgs.Empty); }
 
-    /// <inheritdoc />
-    protected override void OnViewToEditChanged ()
-    {
-        AdornmentToEdit = ViewToEdit as Adornment;
-    }
+    /// <inheritdoc/>
+    protected override void OnViewToEditChanged () { AdornmentToEdit = ViewToEdit as Adornment; }
 
     private NumericUpDown<int>? _topEdit;
     private NumericUpDown<int>? _leftEdit;
@@ -101,7 +93,7 @@ public class AdornmentEditor : EditorBase
         _topEdit = new ()
         {
             X = Pos.Center (), Y = 0,
-            Format = "{0, 2}",
+            Format = "{0, 2}"
         };
 
         _topEdit.ValueChanging += Top_ValueChanging;
@@ -110,7 +102,7 @@ public class AdornmentEditor : EditorBase
         _leftEdit = new ()
         {
             X = Pos.Left (_topEdit) - Pos.Func (() => _topEdit.Text.Length) - 2, Y = Pos.Bottom (_topEdit),
-            Format = _topEdit.Format,
+            Format = _topEdit.Format
         };
 
         _leftEdit.ValueChanging += Left_ValueChanging;
@@ -119,7 +111,7 @@ public class AdornmentEditor : EditorBase
         _rightEdit = new ()
         {
             X = Pos.Right (_leftEdit) + 5, Y = Pos.Bottom (_topEdit),
-            Format = _topEdit.Format,
+            Format = _topEdit.Format
         };
 
         _rightEdit.ValueChanging += Right_ValueChanging;
@@ -128,7 +120,7 @@ public class AdornmentEditor : EditorBase
         _bottomEdit = new ()
         {
             X = Pos.Center (), Y = Pos.Bottom (_leftEdit),
-            Format = _topEdit.Format,
+            Format = _topEdit.Format
         };
 
         _bottomEdit.ValueChanging += Bottom_ValueChanging;
@@ -136,14 +128,14 @@ public class AdornmentEditor : EditorBase
 
         var copyTop = new Button
         {
-            X = Pos.Center (), Y = Pos.Bottom (_bottomEdit), Text = "Cop_y Top",
+            X = Pos.Center (), Y = Pos.Bottom (_bottomEdit), Text = "Cop_y Top"
         };
 
         copyTop.Accepting += (s, e) =>
-                          {
-                              AdornmentToEdit!.Thickness = new (_topEdit.Value);
-                              _leftEdit.Value = _rightEdit.Value = _bottomEdit.Value = _topEdit.Value;
-                          };
+                             {
+                                 AdornmentToEdit!.Thickness = new (_topEdit.Value);
+                                 _leftEdit.Value = _rightEdit.Value = _bottomEdit.Value = _topEdit.Value;
+                             };
         Add (copyTop);
 
         // Foreground ColorPicker.
@@ -166,9 +158,11 @@ public class AdornmentEditor : EditorBase
         _bottomEdit.Value = AdornmentToEdit?.Thickness.Bottom ?? 0;
 
         _diagThicknessCheckBox = new () { Text = "_Thickness Diag." };
+
         if (AdornmentToEdit is { })
         {
-            _diagThicknessCheckBox.CheckedState = AdornmentToEdit.Diagnostics.FastHasFlags (ViewDiagnosticFlags.Thickness) ? CheckState.Checked : CheckState.UnChecked;
+            _diagThicknessCheckBox.CheckedState =
+                AdornmentToEdit.Diagnostics.FastHasFlags (ViewDiagnosticFlags.Thickness) ? CheckState.Checked : CheckState.UnChecked;
         }
         else
         {
@@ -176,21 +170,22 @@ public class AdornmentEditor : EditorBase
         }
 
         _diagThicknessCheckBox.CheckedStateChanging += (s, e) =>
-                                                     {
-                                                         if (e.NewValue == CheckState.Checked)
-                                                         {
-                                                             AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Thickness;
-                                                         }
-                                                         else
-                                                         {
-                                                             AdornmentToEdit!.Diagnostics &= ~ViewDiagnosticFlags.Thickness;
-                                                         }
-                                                     };
+                                                       {
+                                                           if (e.NewValue == CheckState.Checked)
+                                                           {
+                                                               AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Thickness;
+                                                           }
+                                                           else
+                                                           {
+                                                               AdornmentToEdit!.Diagnostics &= ~ViewDiagnosticFlags.Thickness;
+                                                           }
+                                                       };
 
         Add (_diagThicknessCheckBox);
         _diagThicknessCheckBox.Y = Pos.Bottom (_backgroundColorPicker);
 
         _diagRulerCheckBox = new () { Text = "_Ruler" };
+
         if (AdornmentToEdit is { })
         {
             _diagRulerCheckBox.CheckedState = AdornmentToEdit.Diagnostics.FastHasFlags (ViewDiagnosticFlags.Ruler) ? CheckState.Checked : CheckState.UnChecked;
@@ -224,6 +219,7 @@ public class AdornmentEditor : EditorBase
                    {
                        return;
                    }
+
                    AdornmentToEdit.ColorScheme = new (AdornmentToEdit.ColorScheme)
                    {
                        Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
@@ -278,4 +274,4 @@ public class AdornmentEditor : EditorBase
 
         AdornmentToEdit.Thickness = new (AdornmentToEdit.Thickness.Left, AdornmentToEdit.Thickness.Top, AdornmentToEdit.Thickness.Right, e.NewValue);
     }
-}
+}

+ 27 - 37
UICatalog/Scenarios/Editors/AdornmentsEditor.cs

@@ -20,43 +20,31 @@ public class AdornmentsEditor : EditorBase
         Initialized += AdornmentsEditor_Initialized;
     }
 
-    private MarginEditor? _marginEditor;
-    private BorderEditor? _borderEditor;
-    private PaddingEditor? _paddingEditor;
+    public MarginEditor? MarginEditor { get; set; }
+    public BorderEditor? BorderEditor { get; private set; }
+    public PaddingEditor? PaddingEditor { get; private set; }
 
-    /// <inheritdoc />
+    /// <inheritdoc/>
     protected override void OnViewToEditChanged ()
     {
-
-        if (_marginEditor is { })
+        if (MarginEditor is { })
         {
-            _marginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
+            MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
         }
 
-        if (_borderEditor is { })
+        if (BorderEditor is { })
         {
-            _borderEditor.AdornmentToEdit = ViewToEdit?.Border ?? null;
+            BorderEditor.AdornmentToEdit = ViewToEdit?.Border ?? null;
         }
 
-        if (_paddingEditor is { })
-        {
-            _paddingEditor.AdornmentToEdit = ViewToEdit?.Padding ?? null;
-        }
-
-        if (ViewToEdit is not Adornment)
-        {
-            Enabled = true;
-        }
-        else
+        if (PaddingEditor is { })
         {
-            Enabled = false;
+            PaddingEditor.AdornmentToEdit = ViewToEdit?.Padding ?? null;
         }
 
         Padding.Text = $"View: {GetIdentifyingString (ViewToEdit)}";
     }
 
-
-
     private string GetIdentifyingString (View? view)
     {
         if (view is null)
@@ -100,34 +88,36 @@ public class AdornmentsEditor : EditorBase
 
     private void AdornmentsEditor_Initialized (object? sender, EventArgs e)
     {
-        _marginEditor = new ()
+        MarginEditor = new ()
         {
             X = 0,
             Y = 0,
-            SuperViewRendersLineCanvas = true,
+            SuperViewRendersLineCanvas = true
         };
-        Add (_marginEditor);
+        Add (MarginEditor);
 
-        _borderEditor = new ()
+        BorderEditor = new ()
         {
-            X = Pos.Left (_marginEditor),
-            Y = Pos.Bottom (_marginEditor),
+            X = Pos.Left (MarginEditor),
+            Y = Pos.Bottom (MarginEditor),
             SuperViewRendersLineCanvas = true
         };
-        Add (_borderEditor);
+        Add (BorderEditor);
 
-        _paddingEditor = new ()
+        PaddingEditor = new ()
         {
-            X = Pos.Left (_borderEditor),
-            Y = Pos.Bottom (_borderEditor),
+            X = Pos.Left (BorderEditor),
+            Y = Pos.Bottom (BorderEditor),
             SuperViewRendersLineCanvas = true
         };
-        Add (_paddingEditor);
-
+        Add (PaddingEditor);
 
-        _marginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
-        _borderEditor.AdornmentToEdit = ViewToEdit?.Border ?? null;
-        _paddingEditor.AdornmentToEdit = ViewToEdit?.Padding ?? null;
+        MarginEditor.ExpanderButton.Collapsed = true;
+        BorderEditor.ExpanderButton.Collapsed = true;
+        PaddingEditor.ExpanderButton.Collapsed = true;
 
+        MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
+        BorderEditor.AdornmentToEdit = ViewToEdit?.Border ?? null;
+        PaddingEditor.AdornmentToEdit = ViewToEdit?.Padding ?? null;
     }
 }

+ 29 - 143
UICatalog/Scenarios/Editors/ArrangementEditor.cs

@@ -1,7 +1,6 @@
 #nullable enable
 using System;
 using System.Collections.Generic;
-using System.Text;
 using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
@@ -9,17 +8,11 @@ namespace UICatalog.Scenarios;
 /// <summary>
 ///     Provides an editor UI for the Margin, Border, and Padding of a View.
 /// </summary>
-public sealed class ArrangementEditor : View
+public sealed class ArrangementEditor : EditorBase
 {
     public ArrangementEditor ()
     {
         Title = "ArrangementEditor";
-
-        Width = Dim.Auto (DimAutoStyle.Content);
-        Height = Dim.Auto (DimAutoStyle.Content);
-
-        CanFocus = true;
-
         TabStop = TabBehavior.TabGroup;
 
         Initialized += ArrangementEditor_Initialized;
@@ -61,181 +54,74 @@ public sealed class ArrangementEditor : View
                 Legend = ViewArrangement.Overlapped.ToString (),
                 Data = ViewArrangement.Overlapped
             }
-
         ];
 
         Add (_arrangementSlider);
     }
 
-    private View? _viewToEdit;
-
-    private Label? _lblView; // Text describing the view being edited
-
-    private readonly Slider<ViewArrangement> _arrangementSlider = new Slider<ViewArrangement> ()
+    private readonly Slider<ViewArrangement> _arrangementSlider = new()
     {
         Orientation = Orientation.Vertical,
         UseMinimumSize = true,
         Type = SliderType.Multiple,
         AllowEmpty = true,
         BorderStyle = LineStyle.Dotted,
-        Title = "_Arrangement",
+        Title = "_Arrangement"
     };
 
-    /// <summary>
-    ///     Gets or sets whether the ArrangementEditor should automatically select the View to edit
-    ///     based on the values of <see cref="AutoSelectSuperView"/>.
-    /// </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; }
-
-    public View? ViewToEdit
-    {
-        get => _viewToEdit;
-        set
-        {
-            if (_viewToEdit == value)
-            {
-                return;
-            }
-
-            _arrangementSlider.OptionsChanged -= ArrangementSliderOnOptionsChanged;
-
-            _viewToEdit = value;
-            // Set the appropriate options in the slider based on _viewToEdit.Arrangement
-            if (_viewToEdit is { })
-            {
-                _arrangementSlider.Options.ForEach (option =>
-                                                    {
-                                                        _arrangementSlider.ChangeOption (_arrangementSlider.Options.IndexOf (option), (_viewToEdit.Arrangement & option.Data) == option.Data);
-                                                    });
-            }
-
-            _arrangementSlider.OptionsChanged += ArrangementSliderOnOptionsChanged;
-
-            if (_lblView is { })
-            {
-                _lblView.Text = $"{_viewToEdit?.GetType ().Name}: {_viewToEdit?.Id}" ?? string.Empty;
-            }
-        }
-    }
-
-
-    private void NavigationOnFocusedChanged (object? sender, EventArgs e)
-    {
-        if (AutoSelectSuperView is null)
-        {
-            return;
-        }
-
-        View? view = Application.Navigation!.GetFocused ();
-
-        if (ApplicationNavigation.IsInHierarchy (this, view))
-        {
-            return;
-        }
-
-        if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, view))
-        {
-            return;
-        }
-
-        if (view is { } and not Adornment)
-        {
-            ViewToEdit = view;
-        }
-    }
-
-    private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
+    protected override void OnViewToEditChanged ()
     {
-        if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
-        {
-            return;
-        }
+        _arrangementSlider.OptionsChanged -= ArrangementSliderOnOptionsChanged;
 
-        if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
-            || FrameToScreen ().Contains (e.Position))
+        // Set the appropriate options in the slider based on _viewToEdit.Arrangement
+        if (ViewToEdit is { })
         {
-            return;
+            _arrangementSlider.Options.ForEach (
+                                                option =>
+                                                {
+                                                    _arrangementSlider.ChangeOption (
+                                                                                     _arrangementSlider.Options.IndexOf (option),
+                                                                                     (ViewToEdit.Arrangement & option.Data) == option.Data);
+                                                });
         }
 
-        View? view = e.View;
-
-        if (view is Adornment adornment)
-        {
-            view = adornment.Parent;
-        }
-
-        if (view is { } and not Adornment)
-        {
-            ViewToEdit = view;
-        }
-    }
-
-    private void ArrangementEditor_Initialized (object? sender, EventArgs e)
-    {
-        BorderStyle = LineStyle.Dotted;
-
-        var expandButton = new ExpanderButton
-        {
-            Orientation = Orientation.Horizontal
-        };
-        Border.Add (expandButton);
-
-        _lblView = new ()
-        {
-            X = 0,
-            Y = 0,
-            Height = 2
-        };
-        _lblView.TextFormatter.WordWrap = true;
-        _lblView.TextFormatter.MultiLine = true;
-        _lblView.HotKeySpecifier = (Rune)'\uffff';
-        _lblView.Width = Dim.Width (_arrangementSlider);
-        Add (_lblView);
-
-        _arrangementSlider.Y = Pos.Bottom (_lblView);
-
         _arrangementSlider.OptionsChanged += ArrangementSliderOnOptionsChanged;
-
-        Application.MouseEvent += ApplicationOnMouseEvent;
-        Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
     }
 
+    private void ArrangementEditor_Initialized (object? sender, EventArgs e) { _arrangementSlider.OptionsChanged += ArrangementSliderOnOptionsChanged; }
+
     private void ArrangementSliderOnOptionsChanged (object? sender, SliderEventArgs<ViewArrangement> e)
     {
-        if (_viewToEdit is { })
+        if (ViewToEdit is { })
         {
             // Set the arrangement based on the selected options
-            ViewArrangement arrangement = ViewArrangement.Fixed;
-            foreach (var option in e.Options)
+            var arrangement = ViewArrangement.Fixed;
+
+            foreach (KeyValuePair<int, SliderOption<ViewArrangement>> option in e.Options)
             {
                 arrangement |= option.Value.Data;
             }
 
-            _viewToEdit.Arrangement = arrangement;
+            ViewToEdit.Arrangement = arrangement;
 
-            if (_viewToEdit.Arrangement.HasFlag (ViewArrangement.Overlapped))
+            if (ViewToEdit.Arrangement.HasFlag (ViewArrangement.Overlapped))
             {
-                _viewToEdit.ShadowStyle = ShadowStyle.Transparent;
-                _viewToEdit.ColorScheme = Colors.ColorSchemes ["Toplevel"];
+                ViewToEdit.ShadowStyle = ShadowStyle.Transparent;
+                ViewToEdit.ColorScheme = Colors.ColorSchemes ["Toplevel"];
             }
             else
             {
-                _viewToEdit.ShadowStyle = ShadowStyle.None;
-                _viewToEdit.ColorScheme = _viewToEdit!.SuperView!.ColorScheme;
+                ViewToEdit.ShadowStyle = ShadowStyle.None;
+                ViewToEdit.ColorScheme = ViewToEdit!.SuperView!.ColorScheme;
             }
 
-            if (_viewToEdit.Arrangement.HasFlag (ViewArrangement.Movable))
+            if (ViewToEdit.Arrangement.HasFlag (ViewArrangement.Movable))
             {
-                _viewToEdit.BorderStyle = LineStyle.Double;
+                ViewToEdit.BorderStyle = LineStyle.Double;
             }
             else
             {
-                _viewToEdit.BorderStyle = LineStyle.Single;
+                ViewToEdit.BorderStyle = LineStyle.Single;
             }
         }
     }

+ 1 - 1
UICatalog/Scenarios/HexEditor.cs

@@ -8,7 +8,7 @@ namespace UICatalog.Scenarios;
 [Scenario.ScenarioCategory ("Controls")]
 [Scenario.ScenarioCategory ("Dialogs")]
 [Scenario.ScenarioCategory ("Text and Formatting")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Navigation")]
 [Scenario.ScenarioCategory ("Files and IO")]
 public class HexEditor : Scenario
 {

+ 0 - 1
UICatalog/Scenarios/ListColumns.cs

@@ -11,7 +11,6 @@ namespace UICatalog.Scenarios;
 [Scenario.ScenarioCategory ("Controls")]
 [Scenario.ScenarioCategory ("Dialogs")]
 [Scenario.ScenarioCategory ("Text and Formatting")]
-[Scenario.ScenarioCategory ("Overlapped")]
 [Scenario.ScenarioCategory ("Scrolling")]
 public class ListColumns : Scenario
 {

+ 1 - 1
UICatalog/Scenarios/Navigation.cs

@@ -6,7 +6,7 @@ namespace UICatalog.Scenarios;
 [Scenario.ScenarioMetadata ("Navigation", "Navigation Tester")]
 [Scenario.ScenarioCategory ("Mouse and Keyboard")]
 [Scenario.ScenarioCategory ("Layout")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Navigation")]
 public class Navigation : Scenario
 {
     private int _hotkeyCount;

+ 1 - 11
UICatalog/Scenarios/NumericUpDownDemo.cs

@@ -18,18 +18,9 @@ public class NumericUpDownDemo : Scenario
             BorderStyle = LineStyle.None
         };
 
-        var editor = new AdornmentsEditor
-        {
-            X = 0,
-            Y = 0,
-            AutoSelectViewToEdit = true,
-            ShowViewIdentifier = true,
-        };
-        app.Add (editor);
-
         NumericUpDownEditor<int> intEditor = new ()
         {
-            X = Pos.Right (editor),
+            X = 0,
             Y = 0,
             Title = "int",
         };
@@ -52,7 +43,6 @@ public class NumericUpDownDemo : Scenario
             floatEditor!.NumericUpDown!.Format = "{0:0.0}";
         }
 
-        editor.AutoSelectSuperView = app;
         intEditor.SetFocus ();
 
         Application.Run (app);

+ 0 - 1
UICatalog/Scenarios/RunTExample.cs

@@ -4,7 +4,6 @@ namespace UICatalog.Scenarios;
 
 [Scenario.ScenarioMetadata ("Run<T> Example", "Illustrates using Application.Run<T> to run a custom class")]
 [Scenario.ScenarioCategory ("Runnable")]
-[Scenario.ScenarioCategory ("Overlapped")]
 public class RunTExample : Scenario
 {
     public override void Main ()

+ 3 - 1
UICatalog/Scenarios/ShadowStyles.cs

@@ -9,6 +9,7 @@ namespace UICatalog.Scenarios;
 
 [Scenario.ScenarioMetadata ("ShadowStyles Demo", "Demonstrates ShadowStyles Effects.")]
 [Scenario.ScenarioCategory ("Layout")]
+[Scenario.ScenarioCategory ("Adornments")]
 public class ShadowStyles : Scenario
 {
     public override void Main ()
@@ -25,8 +26,9 @@ public class ShadowStyles : Scenario
         {
             AutoSelectViewToEdit = true,
             ShowViewIdentifier = true,
-
         };
+        editor.Initialized += (sender, args) => editor.MarginEditor.ExpanderButton.Collapsed = false;
+
         app.Add (editor);
 
         Window win = new ()

+ 1 - 1
UICatalog/Scenarios/SingleBackgroundWorker.cs

@@ -9,7 +9,7 @@ namespace UICatalog.Scenarios;
 
 [Scenario.ScenarioMetadata ("Single BackgroundWorker", "A single BackgroundWorker threading opening another Toplevel")]
 [Scenario.ScenarioCategory ("Threading")]
-[Scenario.ScenarioCategory ("Overlapped")]
+[Scenario.ScenarioCategory ("Arrangement")]
 [Scenario.ScenarioCategory ("Runnable")]
 public class SingleBackgroundWorker : Scenario
 {

+ 0 - 1
UICatalog/Scenarios/TableEditor.cs

@@ -14,7 +14,6 @@ namespace UICatalog.Scenarios;
 [Scenario.ScenarioCategory ("Controls")]
 [Scenario.ScenarioCategory ("Dialogs")]
 [Scenario.ScenarioCategory ("Text and Formatting")]
-[Scenario.ScenarioCategory ("Overlapped")]
 public class TableEditor : Scenario
 {
     private readonly HashSet<FileSystemInfo> _checkedFileSystemInfos = new ();

+ 0 - 1
UICatalog/Scenarios/Wizards.cs

@@ -6,7 +6,6 @@ namespace UICatalog.Scenarios;
 
 [Scenario.ScenarioMetadata ("Wizards", "Demonstrates the Wizard class")]
 [Scenario.ScenarioCategory ("Dialogs")]
-[Scenario.ScenarioCategory ("Overlapped")]
 [Scenario.ScenarioCategory ("Wizards")]
 [Scenario.ScenarioCategory ("Runnable")]