2
0
Эх сурвалжийг харах

Fixes #4057 - MASSIVE! Fully implements `ColorScheme`->`Scheme` + `VisualRole` + `Colors.`->`SchemeManager.` (#4062)

* touching publish.yml

* ColorScheme->Scheme

* ColorScheme->Scheme 2

* Prototype of GetAttributeForRole

* Badly broke CM

* Further Badly broke CM

* Refactored CM big-time. View still broken

* All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working.

* Actually:
All unit test pass again.
Tons added.
CM is still WIP, but Schemes is not mostly refactored and working.

* Bug fixes.
DeepMemberWiseClone cleanup

* Further cleanup of Scope<T>, ConfigProperty, etc.

* Made ConfigManager thread safe.

* WIP: Broken

* WIP: new deep clone impl

* WIP: new deep clone impl is done. Now fixing CM

* WIP:
- config.md
- Working on AOT clean up
- Core CM is broken; but known.

* WIP

* Merged.
Removed CM from Application.Init

* WIP

* More WIP; Less broke

* All CM unit tests pass... Not sure if it actually works though

* All unit tests pass... Themes are broken though in UI Cat

* CM Ready for review?

* Fixed failures due to TextStyles PR

* Working on Scheme/Attribute

* Working on Scheme/Attribute 2

* Working on Scheme/Attribute 3

* Working on Scheme/Attribute 4

* Working on Scheme/Attribute 5

* Working on Scheme/Attribute 6

* Added test to show how awful memory usage is

* Improved schema. Updated config.json

* Nade Scope<T> concurrentdictionary and added test to prove

* Made Themes ConcrurrentDictionary. Added bunches of tests

* Code cleanup

* Code cleanup 2

* Code cleanup 3

* Tweaking Scheme

* ClearJsonErrors

* ClearJsonErrors2

* Updated Attribute API

* It all (mostly) works!

* Skip odd unit test

* Messed with Themes

* Theme tweaks

* Code reorg. New .md stuff

* Fixed Enabled. Added mock driver

* Fixed a bunch of View.Enabled related issues

* Scheme -> Get/SetScheme()

* Cleanup

* Cleanup2

* Broke something

* Fixed everything

* Made CM.Enable better

* Text Style Scenario

* Added comments

* Fixed UI Catalog Theme Changing

* Fixed more dynamic CM update stuff

* Warning cleanup

* New Default Theme

* fixed unit test

* Refactoring Scheme and Attribute to fix inheritance

* more unit tests

* ConfigProperty is not updating schemes correctly

* All unit tests pass.
Code cleanup

* All unit tests pass.
Code cleanup2

* Fixed unit tests

* Upgraded TextField and TextView

* Fixed TextView !Enabled bug

* More updates to TextView. More unit tests for SchemeManager

* Upgraded CharMap

* API docs

* Fixe HexView API

* upgrade HexView

* Fixed shortcut KeyView

* Fixed more bugs. Added new themes

* updated themes

* upgraded Border

* Fixed themes memory usage...mostly

* Fixed themes memory usage...mostly2

* Fixed themes memory usage...2

* Fixed themes memory usage...3

* Added new colors

* Fixed GetHardCodedConfig bug

* Added Themes Scenario - WIP

* Added Themes Scenario

* Tweaked Themes Scenario

* Code cleanup

* Fixed json schmea

* updated deepdives

* updated deepdives

* Tweaked Themes Scenario

* Made Schemes a concurrent dict

* Test cleanup

* Thread safe ConfigProperty tests

* trying to make things more thread safe

* more trying to make things more thread safe

* Fixing bugs in shadowview

* Fixing bugs in shadowview 2

* Refactored GetViewsUnderMouse to GetViewsUnderLocation etc...

* Fixed dupe unit tests?

* Added better description of layout and coordiantes to deep dive

* Added better description of layout and coordiantes to deep dive

* Modified tests that call v2.AddTimeout; they were returning true which means restart the timer!
This was causing mac/linux unit test failures.
I think

* Fixed auto scheme.
Broke TextView/TextField selection

* Realized Attribute.IsExplicitlySet is stupid; just use nullable

* Fixed Attribute. Simplified. MOre theme testing

* Updated themes again

* GetViewsUnderMouse to GetViewsUnderLocation broke TransparentMouse.

* Fixing mouseunder bugs

* rewriting...

* All working again.
Shadows are now slick as snot.
GetViewsUnderLocation is rewritten to actually work and be readable.
Tons more low-level unit tests.
Margin is now actually ViewportSettings.Transparent.

* Code cleanup

* Code cleanup

* Code cleanup of color apis

* Fixed Hover/Highlight

* Update Examples/UICatalog/Scenarios/AllViewsTester.cs

Co-authored-by: Copilot <[email protected]>

* Update Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs

Co-authored-by: Copilot <[email protected]>

* Update Examples/UICatalog/Scenarios/Clipping.cs

Co-authored-by: Copilot <[email protected]>

* Fixed race condition?

* reverted

* Simplified Attribute API by removing events from SetAttributeForRole

* Removed recursion from GetViewsAtLocation

* Removed unneeded code

* Code clean up.
Fixed Scheme bug.

* reverted temporary disable

* Adjusted scheme algo

* Upgraded TextValidateField

* Fixed TextValidate bugs

* Tweaks

* Frameview rounded border by default

* API doc cleanup

* Readme fix

* Addressed tznind feeback

* Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true

* Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true 2

* cleanup

---------

Co-authored-by: Copilot <[email protected]>
Tig 3 сар өмнө
parent
commit
3e2eebfd2c
100 өөрчлөгдсөн 2248 нэмэгдсэн , 1494 устгасан
  1. 3 3
      Examples/CommunityToolkitExample/LoginView.cs
  2. 3 3
      Examples/CommunityToolkitExample/LoginViewModel.cs
  3. 2 1
      Examples/CommunityToolkitExample/Program.cs
  4. 2 2
      Examples/CommunityToolkitExample/README.md
  5. 2 2
      Examples/Example/Example.cs
  6. 1 0
      Examples/NativeAot/Program.cs
  7. 2 2
      Examples/ReactiveExample/LoginView.cs
  8. 1 0
      Examples/ReactiveExample/Program.cs
  9. 1 0
      Examples/SelfContained/Program.cs
  10. 12 3
      Examples/UICatalog/Properties/launchSettings.json
  11. 20 31
      Examples/UICatalog/Resources/config.json
  12. 12 10
      Examples/UICatalog/Scenarios/Adornments.cs
  13. 17 68
      Examples/UICatalog/Scenarios/AllViewsTester.cs
  14. 9 9
      Examples/UICatalog/Scenarios/AnsiRequestsScenario.cs
  15. 24 68
      Examples/UICatalog/Scenarios/Arrangement.cs
  16. 1 1
      Examples/UICatalog/Scenarios/Bars.cs
  17. 12 11
      Examples/UICatalog/Scenarios/Buttons.cs
  18. 8 4
      Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs
  19. 1 1
      Examples/UICatalog/Scenarios/Clipping.cs
  20. 1 1
      Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs
  21. 13 11
      Examples/UICatalog/Scenarios/ColorPicker.cs
  22. 1 1
      Examples/UICatalog/Scenarios/ComboBoxIteration.cs
  23. 17 17
      Examples/UICatalog/Scenarios/ComputedLayout.cs
  24. 63 42
      Examples/UICatalog/Scenarios/ConfigurationEditor.cs
  25. 1 1
      Examples/UICatalog/Scenarios/ContextMenus.cs
  26. 1 1
      Examples/UICatalog/Scenarios/Dialogs.cs
  27. 5 5
      Examples/UICatalog/Scenarios/DimAutoDemo.cs
  28. 2 2
      Examples/UICatalog/Scenarios/DynamicMenuBar.cs
  29. 1 1
      Examples/UICatalog/Scenarios/DynamicStatusBar.cs
  30. 0 51
      Examples/UICatalog/Scenarios/Editors/MarginEditor.cs
  31. 6 5
      Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs
  32. 2 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs
  33. 195 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs
  34. 2 2
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ArrangementEditor.cs
  35. 0 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs
  36. 3 3
      Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs
  37. 7 5
      Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs
  38. 0 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs
  39. 0 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs
  40. 0 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs
  41. 90 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs
  42. 0 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/PaddingEditor.cs
  43. 2 2
      Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs
  44. 47 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/SchemeViewer.cs
  45. 121 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ThemeViewer.cs
  46. 127 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewPropertiesEditor.cs
  47. 41 20
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewportSettingsEditor.cs
  48. 39 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/VisualRoleViewer.cs
  49. 9 9
      Examples/UICatalog/Scenarios/GraphViewExample.cs
  50. 12 12
      Examples/UICatalog/Scenarios/HexEditor.cs
  51. 0 57
      Examples/UICatalog/Scenarios/InvertColors.cs
  52. 4 4
      Examples/UICatalog/Scenarios/Keys.cs
  53. 6 6
      Examples/UICatalog/Scenarios/LineCanvasExperiment.cs
  54. 10 10
      Examples/UICatalog/Scenarios/LineDrawing.cs
  55. 6 6
      Examples/UICatalog/Scenarios/ListColumns.cs
  56. 1 1
      Examples/UICatalog/Scenarios/ListViewWithSelection.cs
  57. 3 3
      Examples/UICatalog/Scenarios/ListsAndCombos.cs
  58. 5 5
      Examples/UICatalog/Scenarios/Mazing.cs
  59. 1 1
      Examples/UICatalog/Scenarios/Menus.cs
  60. 1 1
      Examples/UICatalog/Scenarios/MessageBoxes.cs
  61. 7 7
      Examples/UICatalog/Scenarios/Mouse.cs
  62. 5 5
      Examples/UICatalog/Scenarios/MultiColouredTable.cs
  63. 6 6
      Examples/UICatalog/Scenarios/Navigation.cs
  64. 9 9
      Examples/UICatalog/Scenarios/NumericUpDownDemo.cs
  65. 10 10
      Examples/UICatalog/Scenarios/PosAlignDemo.cs
  66. 3 3
      Examples/UICatalog/Scenarios/Progress.cs
  67. 17 15
      Examples/UICatalog/Scenarios/ProgressBarStyles.cs
  68. 6 6
      Examples/UICatalog/Scenarios/RegionScenario.cs
  69. 1 1
      Examples/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs
  70. 2 2
      Examples/UICatalog/Scenarios/ScrollBarDemo.cs
  71. 17 161
      Examples/UICatalog/Scenarios/Scrolling.cs
  72. 25 4
      Examples/UICatalog/Scenarios/ShadowStyles.cs
  73. 180 158
      Examples/UICatalog/Scenarios/Shortcuts.cs
  74. 0 59
      Examples/UICatalog/Scenarios/SimpleDialog.cs
  75. 1 1
      Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs
  76. 216 204
      Examples/UICatalog/Scenarios/Sliders.cs
  77. 2 9
      Examples/UICatalog/Scenarios/Snake.cs
  78. 8 8
      Examples/UICatalog/Scenarios/SyntaxHighlighting.cs
  79. 19 19
      Examples/UICatalog/Scenarios/TableEditor.cs
  80. 36 30
      Examples/UICatalog/Scenarios/TextAlignmentAndDirection.cs
  81. 3 3
      Examples/UICatalog/Scenarios/TextEffectsScenario.cs
  82. 3 3
      Examples/UICatalog/Scenarios/TextFormatterDemo.cs
  83. 56 23
      Examples/UICatalog/Scenarios/TextInputControls.cs
  84. 134 35
      Examples/UICatalog/Scenarios/TextStyles.cs
  85. 276 0
      Examples/UICatalog/Scenarios/Themes.cs
  86. 2 2
      Examples/UICatalog/Scenarios/Threading.cs
  87. 26 12
      Examples/UICatalog/Scenarios/Transparent.cs
  88. 9 8
      Examples/UICatalog/Scenarios/TreeViewFileSystem.cs
  89. 13 14
      Examples/UICatalog/Scenarios/TrueColors.cs
  90. 13 12
      Examples/UICatalog/Scenarios/ViewportSettings.cs
  91. 4 4
      Examples/UICatalog/Scenarios/VkeyPacketSimulator.cs
  92. 16 16
      Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs
  93. 3 3
      Examples/UICatalog/Scenarios/Wizards.cs
  94. 31 25
      Examples/UICatalog/UICatalog.cs
  95. 4 4
      Examples/UICatalog/UICatalog.csproj
  96. 2 0
      Examples/UICatalog/UICatalogCommandLineOptions.cs
  97. 87 71
      Examples/UICatalog/UICatalogTop.cs
  98. 2 2
      Terminal.Gui/Application/Application.Driver.cs
  99. 7 27
      Terminal.Gui/Application/Application.Initialization.cs
  100. 9 9
      Terminal.Gui/Application/Application.Keyboard.cs

+ 3 - 3
Examples/CommunityToolkitExample/LoginView.cs

@@ -47,7 +47,7 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
                 {
                     loginProgressLabel.Text = ViewModel.LoginProgressMessage;
                     validationLabel.Text = ViewModel.ValidationMessage;
-                    validationLabel.ColorScheme = ViewModel.ValidationColorScheme;
+                    validationLabel.SetScheme (ViewModel.ValidationScheme);
                     break;
                 }
             case LoginActions.LoginProgress:
@@ -58,11 +58,11 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
             case LoginActions.Validation:
                 {
                     validationLabel.Text = ViewModel.ValidationMessage;
-                    validationLabel.ColorScheme = ViewModel.ValidationColorScheme;
+                    validationLabel.SetScheme (ViewModel.ValidationScheme);
                     break;
                 }
         }
-        SetText();
+        SetText ();
         // BUGBUG: This should not be needed:
         Application.LayoutAndDraw ();
     }

+ 3 - 3
Examples/CommunityToolkitExample/LoginViewModel.cs

@@ -29,7 +29,7 @@ internal partial class LoginViewModel : ObservableObject
     private string _usernameLengthMessage;
     
     [ObservableProperty]
-    private ColorScheme? _validationColorScheme;
+    private Scheme? _validationScheme;
 
     [ObservableProperty]
     private string _validationMessage;
@@ -107,14 +107,14 @@ internal partial class LoginViewModel : ObservableObject
              case LoginActions.Clear:
                 LoginProgressMessage = message;
                 ValidationMessage = INVALID_LOGIN_MESSAGE;
-                ValidationColorScheme = Colors.ColorSchemes ["Error"];
+                ValidationScheme = SchemeManager.GetScheme ("Error");
                 break;
             case LoginActions.LoginProgress:
                 LoginProgressMessage = message;
                 break;
             case LoginActions.Validation:
                 ValidationMessage = CanLogin ? VALID_LOGIN_MESSAGE : INVALID_LOGIN_MESSAGE;
-                ValidationColorScheme = CanLogin ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"];
+                ValidationScheme = CanLogin ? SchemeManager.GetScheme ("Base") : SchemeManager.GetScheme("Error");
                 break;
         }
         WeakReferenceMessenger.Default.Send (new Message<LoginActions> { Value = loginAction });

+ 2 - 1
Examples/CommunityToolkitExample/Program.cs

@@ -9,10 +9,11 @@ public static class Program
 
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable (ConfigLocations.All);
         Services = ConfigureServices ();
         Application.Init ();
         Application.Run (Services.GetRequiredService<LoginView> ());
-        Application.Top?.Dispose();
+        Application.Top?.Dispose ();
         Application.Shutdown ();
     }
 

+ 2 - 2
Examples/CommunityToolkitExample/README.md

@@ -115,7 +115,7 @@ private void SendMessage (LoginAction loginAction, string message = "")
             break;
         case LoginAction.Validation:
             ValidationMessage = CanLogin ? VALID_LOGIN_MESSAGE : INVALID_LOGIN_MESSAGE;
-            ValidationColorScheme = CanLogin ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"];
+            ValidationScheme = CanLogin ? Colors.Schemes ["Base"] : Colors.Schemes ["Error"];
             break;
     }
     WeakReferenceMessenger.Default.Send (new Message<LoginAction> { Value = loginAction });
@@ -144,7 +144,7 @@ public void Receive (Message<LoginAction> message)
         case LoginAction.Validation:
             {
                 validationLabel.Text = ViewModel.ValidationMessage;
-                validationLabel.ColorScheme = ViewModel.ValidationColorScheme;
+                validationLabel.Scheme = ViewModel.ValidationScheme;
                 break;
             }
     }

+ 2 - 2
Examples/Example/Example.cs

@@ -3,11 +3,11 @@
 
 // A simple Terminal.Gui example in C# - using C# 9.0 Top-level statements
 
-using System;
 using Terminal.Gui;
 
 // Override the default configuration for the application to use the Light theme
 ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }""";
+ConfigurationManager.Enable(ConfigLocations.All);
 
 Application.Run<ExampleWindow> ().Dispose ();
 
@@ -21,7 +21,7 @@ Console.WriteLine ($@"Username: {ExampleWindow.UserName}");
 // Defines a top-level window with border and title
 public class ExampleWindow : Window
 {
-    public static string UserName;
+    public static string UserName { get; set; }
 
     public ExampleWindow ()
     {

+ 1 - 0
Examples/NativeAot/Program.cs

@@ -13,6 +13,7 @@ public static class Program
     [RequiresDynamicCode ("Calls Terminal.Gui.Application.Init(IConsoleDriver, String)")]
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable(ConfigLocations.All);
         Application.Init ();
 
         #region The code in this region is not intended for use in a native Aot self-contained. It's just here to make sure there is no functionality break with localization in Terminal.Gui using self-contained

+ 2 - 2
Examples/ReactiveExample/LoginView.cs

@@ -96,8 +96,8 @@ public class LoginView : Window, IViewFor<LoginViewModel>
 
                 ViewModel
                     .WhenAnyValue (x => x.IsValid)
-                    .Select (valid => valid ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"])
-                    .BindTo (validation, x => x.ColorScheme)
+                    .Select (valid => valid ? SchemeManager.GetScheme ("Base") : SchemeManager.GetScheme ("Error"))
+                    .BindTo (validation, x => x.GetScheme ())
                     .DisposeWith (_disposable);
             })
             .AddControlAfter<Button> ((previous, login) =>

+ 1 - 0
Examples/ReactiveExample/Program.cs

@@ -8,6 +8,7 @@ public static class Program
 {
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable (ConfigLocations.All);
         Application.Init ();
         RxApp.MainThreadScheduler = TerminalScheduler.Default;
         RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;

+ 1 - 0
Examples/SelfContained/Program.cs

@@ -12,6 +12,7 @@ public static class Program
     [RequiresUnreferencedCode ("Calls Terminal.Gui.Application.Run<T>(Func<Exception, Boolean>, IConsoleDriver)")]
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable (ConfigLocations.All);
         Application.Init ();
 
         #region The code in this region is not intended for use in a self-contained single-file. It's just here to make sure there is no functionality break with localization in Terminal.Gui using single-file

+ 12 - 3
Examples/UICatalog/Properties/launchSettings.json

@@ -1,7 +1,8 @@
 {
   "profiles": {
     "UICatalog": {
-      "commandName": "Project"
+      "commandName": "Project",
+      "commandLineArgs": "--debug-log-level Debug"
     },
     "UICatalog --driver NetDriver": {
       "commandName": "Project",
@@ -60,9 +61,17 @@
       "commandName": "Project",
       "commandLineArgs": "\"All Views Tester\" -b -t 5000"
     },
-    "Charmap": {
+    "UICatalog --disable-cm": {
+      "commandName": "Project",
+      "commandLineArgs": "--disable-cm\r\n"
+    },
+    "UICatalog --disable-cm --driver v2win": {
+      "commandName": "Project",
+      "commandLineArgs": "--disable-cm --driver v2win"
+    },
+    "Themes": {
       "commandName": "Project",
-      "commandLineArgs": "Bars -b"
+      "commandLineArgs": "Themes"
     }
   }
 }

+ 20 - 31
Examples/UICatalog/Resources/config.json

@@ -4,37 +4,12 @@
   "FileDialogStyle.DefaultUseColors": false,
   "FileDialogStyle.DefaultUseUnicodeCharacters": false,
   "AppSettings": {
-    "UICatalog.StatusBar": true,
-    "ConfigurationEditor.EditorColorScheme": {
-      "Normal": {
-        "Foreground": "Red",
-        "Background": "White"
-      },
-      "Focus": {
-        "Foreground": "Green",
-        "Background": "White"
-      },
-      "HotNormal": {
-        "Foreground": "Black",
-        "Background": "White"
-      },
-      "HotFocus": {
-        "Foreground": "White",
-        "Background": "BrightRed"
-      },
-      "Disabled": {
-        "Foreground": "DarkGray",
-        "Background": "White"
-      }
-    }
+    "UICatalog.StatusBar": true
   },
   "Themes": [
     {
       "Hot Dog Stand": {
-        "Button.DefaultShadow": "Opaque",
-        "Dialog.DefaultShadow": "Transparent",
-        "Dialog.DefaultButtonAlignment": "Center",
-        "ColorSchemes": [
+        "Schemes": [
           {
             "Toplevel": {
               "Normal": {
@@ -160,10 +135,24 @@
     },
     {
       "UI Catalog Theme": {
-        "Button.DefaultShadow": "Opaque",
-        "Dialog.DefaultShadow": "Transparent",
-        "Dialog.DefaultButtonAlignment": "Center",
-        "ColorSchemes": [
+        "Window.DefaultShadow": "Transparent",
+        "CheckBox.DefaultHighlightStyle": "Hover, Pressed, PressedOutside",
+        "MessageBox.DefaultButtonAlignment": "Start",
+        "StatusBar.DefaultSeparatorLineStyle": "Single",
+        "Dialog.DefaultMinimumWidth": 80,
+        "MessageBox.DefaultBorderStyle": "Dotted",
+        "NerdFonts.Enable": false,
+        "MessageBox.DefaultMinimumWidth": 0,
+        "Window.DefaultBorderStyle": "Double",
+        "Dialog.DefaultShadow": "Opaque",
+        "Dialog.DefaultButtonAlignment": "Start",
+        "Button.DefaultShadow": "Transparent",
+        "FrameView.DefaultBorderStyle": "Double",
+        "MessageBox.DefaultMinimumHeight": 0,
+        "Button.DefaultHighlightStyle": "Hover, Pressed",
+        "Menuv2.DefaultBorderStyle": "Heavy",
+        "MenuBarv2.DefaultBorderStyle": "Heavy",
+        "Schemes": [
           {
             "UI Catalog Scheme": {
               "Normal": {

+ 12 - 10
Examples/UICatalog/Scenarios/Adornments.cs

@@ -36,7 +36,7 @@ public class Adornments : Scenario
             Title = "The _Window",
             Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable,
 
-            Width = Dim.Fill (Dim.Func (() => editor.Frame.Width )),
+            Width = Dim.Fill (Dim.Func (() => editor.Frame.Width)),
             Height = Dim.Fill ()
         };
         app.Add (window);
@@ -47,13 +47,15 @@ public class Adornments : Scenario
 
         color.ColorChanged += (s, e) =>
                               {
-                                  color.SuperView.ColorScheme = new (color.SuperView.ColorScheme)
-                                  {
-                                      Normal = new (
-                                                    color.SuperView.ColorScheme.Normal.Foreground,
-                                                    e.CurrentValue
-                                                   )
-                                  };
+                                  color.SuperView!.SetScheme (
+                                                             new (color.SuperView.GetScheme ())
+                                                             {
+                                                                 Normal = new (
+                                                                               color.SuperView.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                               e.CurrentValue,
+                                                                               color.SuperView.GetAttributeForRole (VisualRole.Normal).Style
+                                                                              )
+                                                             });
                               };
 
         var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Press me!" };
@@ -80,7 +82,7 @@ public class Adornments : Scenario
             Width = 40,
             Height = Dim.Percent (20),
             Text = "Label\nY=AnchorEnd(),Height=Dim.Percent(10)",
-            ColorScheme = Colors.ColorSchemes ["Dialog"]
+            SchemeName = "Dialog"
         };
 
         window.Margin.Data = "Margin";
@@ -94,7 +96,7 @@ public class Adornments : Scenario
         window.Padding.Data = "Padding";
         window.Padding.Text = "Padding Text line 1\nPadding Text line 3\nPadding Text line 3\nPadding Text line 4\nPadding Text line 5";
         window.Padding.Thickness = new (3);
-        window.Padding.ColorScheme = Colors.ColorSchemes ["Error"];
+        window.Padding.SchemeName = "Error";
         window.Padding.CanFocus = true;
 
         var longLabel = new Label

+ 17 - 68
Examples/UICatalog/Scenarios/AllViewsTester.cs

@@ -21,10 +21,7 @@ public class AllViewsTester : Scenario
     private ArrangementEditor? _arrangementEditor;
     private LayoutEditor? _layoutEditor;
     private ViewportSettingsEditor? _viewportSettingsEditor;
-    private FrameView? _settingsPane;
-    private RadioGroup? _orientation;
-    private string _demoText = "This, that, and the other thing.";
-    private TextView? _demoTextView;
+    private ViewPropertiesEditor? _propertiesEditor;
 
     private FrameView? _hostPane;
     private View? _curView;
@@ -38,13 +35,13 @@ public class AllViewsTester : Scenario
         var app = new Window
         {
             Title = GetQuitKeyAndName (),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
         };
 
         // Set the BorderStyle we use for all subviews, but disable the app border thickness
         app.Border!.LineStyle = LineStyle.Heavy;
         app.Border.Thickness = new (0);
 
+
         _viewClasses = GetAllViewClassesCollection ()
                        .OrderBy (t => t.Name)
                        .Select (t => new KeyValuePair<string, Type> (t.Name, t))
@@ -148,9 +145,9 @@ public class AllViewsTester : Scenario
         };
         _viewportSettingsEditor.Border!.Thickness = new (1, 1, 1, 1);
 
-        _settingsPane = new ()
+        _propertiesEditor = new ()
         {
-            Title = "Misc Settings [_6]",
+            Title = "View Properties [_6]",
             X = Pos.Right (_adornmentsEditor) - 1,
             Y = Pos.Bottom (_viewportSettingsEditor) - Pos.Func (() => _viewportSettingsEditor.Frame.Height == 1 ? 0 : 1),
             Width = Dim.Width (_layoutEditor),
@@ -158,49 +155,7 @@ public class AllViewsTester : Scenario
             CanFocus = true,
             SuperViewRendersLineCanvas = true
         };
-        _settingsPane.Border!.Thickness = new (1, 1, 1, 0);
-
-        Label label = new () { X = 0, Y = 0, Text = "_Orientation:" };
-
-        _orientation = new ()
-        {
-            X = Pos.Right (label) + 1,
-            Y = Pos.Top (label),
-            RadioLabels = new [] { "Horizontal", "Vertical" },
-            Orientation = Orientation.Horizontal
-        };
-
-        _orientation.SelectedItemChanged += (s, selected) =>
-                                            {
-                                                if (_curView is IOrientation orientatedView)
-                                                {
-                                                    orientatedView.Orientation = (Orientation)_orientation.SelectedItem;
-                                                }
-                                            };
-        _settingsPane.Add (label, _orientation);
-
-        label = new () { X = 0, Y = Pos.Bottom (_orientation), Text = "_Text:" };
-
-        _demoTextView = new ()
-        {
-            X = Pos.Right (label) + 1,
-            Y = Pos.Top (label),
-            Width = Dim.Fill (),
-            Height = Dim.Auto (minimumContentDim: 2),
-            Text = _demoText
-        };
-
-        _demoTextView.ContentsChanged += (s, e) =>
-                                         {
-                                             _demoText = _demoTextView.Text;
-
-                                             if (_curView is { })
-                                             {
-                                                 _curView.Text = _demoText;
-                                             }
-                                         };
-
-        _settingsPane.Add (label, _demoTextView);
+        _propertiesEditor.Border!.Thickness = new (1, 1, 1, 0);
 
         _eventLog = new ()
         {
@@ -235,22 +190,22 @@ public class AllViewsTester : Scenario
         {
             Id = "_hostPane",
             X = Pos.Right (_adornmentsEditor),
-            Y = Pos.Bottom (_settingsPane),
+            Y = Pos.Bottom (_propertiesEditor),
             Width = Dim.Width (_layoutEditor) - 2,
             Height = Dim.Fill (),
             CanFocus = true,
             TabStop = TabBehavior.TabStop,
-            ColorScheme = Colors.ColorSchemes ["Base"],
+            //SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Base),
             Arrangement = ViewArrangement.LeftResizable | ViewArrangement.BottomResizable | ViewArrangement.RightResizable,
             BorderStyle = LineStyle.Double,
             SuperViewRendersLineCanvas = true
         };
-        _hostPane.Border!.ColorScheme = app.ColorScheme;
+        _hostPane.Border!.SetScheme (app.GetScheme ());
         _hostPane.Padding!.Thickness = new (1);
         _hostPane.Padding.Diagnostics = ViewDiagnosticFlags.Ruler;
-        _hostPane.Padding.ColorScheme = app.ColorScheme;
+        _hostPane.Padding.SetScheme (app.GetScheme ());
 
-        app.Add (_classListView, _adornmentsEditor, _arrangementEditor, _layoutEditor, _viewportSettingsEditor, _settingsPane, _eventLog, _hostPane);
+        app.Add (_classListView, _adornmentsEditor, _arrangementEditor, _layoutEditor, _viewportSettingsEditor, _propertiesEditor, _eventLog, _hostPane);
 
         app.Initialized += App_Initialized;
 
@@ -296,7 +251,7 @@ public class AllViewsTester : Scenario
         // Ensure the type does not contain any generic parameters
         if (type.ContainsGenericParameters)
         {
-            Logging.Warning($"Cannot create an instance of {type} because it contains generic parameters.");
+            Logging.Warning ($"Cannot create an instance of {type} because it contains generic parameters.");
             //throw new ArgumentException ($"Cannot create an instance of {type} because it contains generic parameters.");
             return;
         }
@@ -307,23 +262,15 @@ public class AllViewsTester : Scenario
 
         if (view is IDesignable designable)
         {
-            designable.EnableForDesign (ref _demoText);
+            string settingsEditorDemoText = _propertiesEditor!.DemoText;
+            designable.EnableForDesign (ref settingsEditorDemoText);
         }
         else
         {
-            view.Text = _demoText;
+            view.Text = _propertiesEditor!.DemoText;
             view.Title = "_Test Title";
         }
 
-        if (view is IOrientation orientatedView)
-        {
-            _orientation!.SelectedItem = (int)orientatedView.Orientation;
-            _orientation.Enabled = true;
-        }
-        else
-        {
-            _orientation!.Enabled = false;
-        }
 
         view.Initialized += CurrentView_Initialized;
         view.SubViewsLaidOut += CurrentView_LayoutComplete;
@@ -335,6 +282,7 @@ public class AllViewsTester : Scenario
         _layoutEditor!.ViewToEdit = _curView;
         _viewportSettingsEditor!.ViewToEdit = _curView;
         _arrangementEditor!.ViewToEdit = _curView;
+        _propertiesEditor!.ViewToEdit = _curView;
         _curView.SetNeedsLayout ();
     }
 
@@ -349,6 +297,7 @@ public class AllViewsTester : Scenario
             _layoutEditor!.ViewToEdit = null;
             _viewportSettingsEditor!.ViewToEdit = null;
             _arrangementEditor!.ViewToEdit = null;
+            _propertiesEditor!.ViewToEdit = null;
 
             _curView.Dispose ();
             _curView = null;
@@ -379,7 +328,7 @@ public class AllViewsTester : Scenario
             return;
         }
 
-        if (view.Width == Dim.Absolute(0) || view.Width is null)
+        if (view.Width == Dim.Absolute (0) || view.Width is null)
         {
             view.Width = Dim.Fill ();
         }

+ 9 - 9
Examples/UICatalog/Scenarios/AnsiRequestsScenario.cs

@@ -7,7 +7,7 @@ using Terminal.Gui;
 namespace UICatalog.Scenarios;
 
 [ScenarioMetadata ("AnsiEscapeSequenceRequest", "Ansi Escape Sequence Request")]
-[ScenarioCategory ("Ansi Escape Sequence")]
+[ScenarioCategory ("Tests")]
 public sealed class AnsiEscapeSequenceRequests : Scenario
 {
     private GraphView _graphView;
@@ -169,8 +169,8 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
                                                                           {
                                                                               Request = ansiEscapeSequenceRequest.Request,
                                                                               Terminator = ansiEscapeSequenceRequest.Terminator,
-                                                                              ResponseReceived = (s)=>OnSuccess(s, tvResponse, tvError, tvValue, tvTerminator,lblSuccess),
-                                                                              Abandoned =()=> OnFail (tvResponse, tvError, tvValue, tvTerminator, lblSuccess)
+                                                                              ResponseReceived = (s) => OnSuccess (s, tvResponse, tvError, tvValue, tvTerminator, lblSuccess),
+                                                                              Abandoned = () => OnFail (tvResponse, tvError, tvValue, tvTerminator, lblSuccess)
                                                                           });
                                  };
 
@@ -181,15 +181,15 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
         return w;
     }
 
-    private void OnSuccess (string response, TextView tvResponse, TextView tvError, TextView tvValue, TextView tvTerminator,Label lblSuccess)
+    private void OnSuccess (string response, TextView tvResponse, TextView tvError, TextView tvValue, TextView tvTerminator, Label lblSuccess)
     {
         tvResponse.Text = response;
         tvError.Text = string.Empty;
         tvValue.Text = string.Empty;
         tvTerminator.Text = string.Empty;
 
-            lblSuccess.ColorScheme = Colors.ColorSchemes ["Base"];
-            lblSuccess.Text = "Successful";
+        lblSuccess.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Base);
+        lblSuccess.Text = "Successful";
     }
 
     private void OnFail (TextView tvResponse, TextView tvError, TextView tvValue, TextView tvTerminator, Label lblSuccess)
@@ -199,7 +199,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
         tvValue.Text = string.Empty;
         tvTerminator.Text = string.Empty;
 
-        lblSuccess.ColorScheme = Colors.ColorSchemes ["Error"];
+        lblSuccess.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Error);
         lblSuccess.Text = "Error";
     }
 
@@ -320,7 +320,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
     private void UpdateResponses ()
     {
         _lblSummary.Text = GetSummary ();
-        _lblSummary.SetNeedsDraw();
+        _lblSummary.SetNeedsDraw ();
     }
 
     private string GetSummary ()
@@ -369,7 +369,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
                                         .Select (g => new PointF (g.Key, g.Count ()))
                                         .ToList ();
         //  _graphView.ScrollOffset  = new PointF(,0);
-        _graphView.SetNeedsDraw();
+        _graphView.SetNeedsDraw ();
 
     }
 

+ 24 - 68
Examples/UICatalog/Scenarios/Arrangement.cs

@@ -19,7 +19,8 @@ public class Arrangement : Scenario
         Window app = new ()
         {
             Title = GetQuitKeyAndName (),
-            TabStop = TabBehavior.TabGroup
+            TabStop = TabBehavior.TabGroup,
+            ShadowStyle = ShadowStyle.None
         };
 
         var adornmentsEditor = new AdornmentsEditor
@@ -33,7 +34,7 @@ public class Arrangement : Scenario
 
         app.Add (adornmentsEditor);
 
-        adornmentsEditor.ExpanderButton.Orientation = Orientation.Horizontal;
+        adornmentsEditor!.ExpanderButton!.Orientation = Orientation.Horizontal;
 
         //  adornmentsEditor.ExpanderButton!.Collapsed = true;
 
@@ -165,8 +166,8 @@ public class Arrangement : Scenario
         };
         colorPicker.ApplyStyleChanges ();
 
-        colorPicker.SelectedColor = testFrame.ColorScheme!.Normal.Background;
-        colorPicker.ColorChanged += ColorPicker_ColorChanged;
+        colorPicker.SelectedColor = testFrame.GetAttributeForRole (VisualRole.Normal).Background;
+        colorPicker.ColorChanged += ColorPickerColorChanged;
         overlappedView2.Add (colorPicker);
         overlappedView2.Width = 50;
 
@@ -176,16 +177,22 @@ public class Arrangement : Scenario
             Y = 17,
             Id = "datePicker",
             Title = "Not _Sizeable",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,
             TabStop = TabBehavior.TabGroup,
             Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
         };
 
+        datePicker.SetScheme (new Scheme (
+                                          new Attribute (
+                                                         SchemeManager.GetScheme (Schemes.Toplevel).Normal.Foreground.GetBrighterColor (),
+                                                         SchemeManager.GetScheme (Schemes.Toplevel).Normal.Background.GetBrighterColor (),
+                                                         SchemeManager.GetScheme (Schemes.Toplevel).Normal.Style)));
+
         TransparentView transparentView = new ()
         {
-            Id = "transparentView",
+            Title = "Transparent",
+            ViewportSettings = Terminal.Gui.ViewportSettings.Transparent,
             X = 30,
             Y = 5,
             Width = 35,
@@ -199,7 +206,11 @@ public class Arrangement : Scenario
         testFrame.Add (transparentView);
 
 
-        testFrame.Add (new TransparentView ());
+        testFrame.Add (new TransparentView ()
+        {
+            Title = "Transparent|TransparentMouse",
+            ViewportSettings = Terminal.Gui.ViewportSettings.TransparentMouse | Terminal.Gui.ViewportSettings.Transparent
+        });
 
         adornmentsEditor.AutoSelectSuperView = testFrame;
         arrangementEditor.AutoSelectSuperView = testFrame;
@@ -213,9 +224,9 @@ public class Arrangement : Scenario
 
         return;
 
-        void ColorPicker_ColorChanged (object sender, ColorEventArgs e)
+        void ColorPickerColorChanged (object sender, ColorEventArgs e)
         {
-            testFrame.ColorScheme = testFrame.ColorScheme! with { Normal = new (testFrame.ColorScheme.Normal.Foreground, e.CurrentValue) };
+            testFrame.SetScheme (testFrame.GetScheme () with { Normal = new (testFrame.GetAttributeForRole (VisualRole.Normal).Foreground, e.CurrentValue) });
         }
     }
 
@@ -228,7 +239,7 @@ public class Arrangement : Scenario
             Width = Dim.Auto (minimumContentDim: 15),
             Height = Dim.Auto (minimumContentDim: 3),
             Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel),
             Id = $"Overlapped{id}",
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,
@@ -254,8 +265,6 @@ public class Arrangement : Scenario
             CanFocus = true,
             TabStop = TabBehavior.TabStop,
             Arrangement = ViewArrangement.Resizable
-
-            //            SuperViewRendersLineCanvas = true
         };
 
         return tiled;
@@ -318,16 +327,16 @@ public class Arrangement : Scenario
 
     public class TransparentView : FrameView
     {
-        public TransparentView()
+        public TransparentView ()
         {
             Title = "Transparent";
-            Text = "Text";
+            Text = "TransparentView Text";
             X = 0;
             Y = 0;
             Width = 30;
             Height = 10;
             Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable | ViewArrangement.Movable;
-            ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent;
+            ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent | Terminal.Gui.ViewportSettings.TransparentMouse;
 
             Padding!.Thickness = new Thickness (1);
 
@@ -342,56 +351,3 @@ public class Arrangement : Scenario
     }
 }
 
-public class TransparentView : FrameView
-{
-    public TransparentView ()
-    {
-        Title = "Transparent View";
-        base.Text = "View.Text.\nThis should be opaque.\nNote how clipping works?";
-        TextFormatter.Alignment = Alignment.Center;
-        TextFormatter.VerticalAlignment = Alignment.Center;
-        Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable | ViewArrangement.Movable;
-        ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent | Terminal.Gui.ViewportSettings.TransparentMouse;
-        BorderStyle = LineStyle.RoundedDotted;
-        base.ColorScheme = Colors.ColorSchemes ["Menu"];
-
-        var transparentSubView = new View ()
-        {
-            Text = "Sizable/Movable View with border. Should be opaque. The shadow should be semi-opaque.",
-            Id = "transparentSubView",
-            X = 4,
-            Y = 8,
-            Width = 20,
-            Height = 8,
-            BorderStyle = LineStyle.Dashed,
-            Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
-            ShadowStyle = ShadowStyle.Transparent,
-            //ViewportSettings = Terminal.Gui.ViewportSettings.Transparent
-        };
-        transparentSubView.Border.Thickness = new (1, 1, 1, 1);
-        transparentSubView.ColorScheme = Colors.ColorSchemes ["Dialog"];
-
-        Button button = new Button ()
-        {
-            Title = "_Opaque Shadows No Worky",
-            X = Pos.Center (),
-            Y = 4,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
-        };
-
-        button.ClearingViewport += (sender, args) =>
-                                   {
-                                       args.Cancel = true;
-                                   };
-
-
-        base.Add (button);
-        base.Add (transparentSubView);
-    }
-
-    /// <inheritdoc />
-    protected override bool OnClearingViewport () { return false; }
-
-    /// <inheritdoc />
-    protected override bool OnMouseEvent (MouseEventArgs mouseEvent) { return false; }
-}

+ 1 - 1
Examples/UICatalog/Scenarios/Bars.cs

@@ -38,7 +38,7 @@ public class Bars : Scenario
             X = Pos.AnchorEnd (),
             Width = Dim.Auto (),
             Height = Dim.Fill (), // Make room for some wide things
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "Toplevel",
             Source = new ListWrapper<string> (eventSource)
         };
         eventLog.Border.Thickness = new (0, 1, 0, 0);

+ 12 - 11
Examples/UICatalog/Scenarios/Buttons.cs

@@ -44,7 +44,7 @@ public class Buttons : Scenario
             Width = 45,
             Height = 3,
             Text = "S_wap Default (Size = 45, 3)",
-            ColorScheme = Colors.ColorSchemes ["Error"]
+            SchemeName = "Error"
         };
 
         swapButton.Accepting += (s, e) =>
@@ -80,14 +80,14 @@ public class Buttons : Scenario
 
         View prev = colorButtonsLabel;
 
-        foreach (KeyValuePair<string, ColorScheme> colorScheme in Colors.ColorSchemes)
+        foreach (KeyValuePair<string, Scheme> scheme in SchemeManager.GetSchemesForCurrentTheme ())
         {
             var colorButton = new Button
             {
                 X = Pos.Right (prev),
                 Y = Pos.Y (colorButtonsLabel),
-                Text = $"_{colorScheme.Key}",
-                ColorScheme = colorScheme.Value,
+                Text = $"_{scheme.Key}",
+                SchemeName = scheme.Key,
             };
             DoMessage (colorButton, colorButton.Text);
             main.Add (colorButton);
@@ -138,7 +138,8 @@ public class Buttons : Scenario
         var removeButton = new Button
         {
             X = 2, Y = Pos.Bottom (button) + 1,
-            ColorScheme = Colors.ColorSchemes ["Error"], Text = "Remove this button"
+            SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Error),
+            Text = "Remove this button"
         };
         main.Add (removeButton);
 
@@ -165,7 +166,7 @@ public class Buttons : Scenario
             X = 0,
             Y = Pos.Center () - 1,
             Width = 30,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = "Move This \u263b Button v_ia Pos"
         };
 
@@ -183,7 +184,7 @@ public class Buttons : Scenario
             X = 0,
             Width = 30,
             Text = "Grow This \u263a Button _via Pos",
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
         };
 
         sizeBtn.Accepting += (s, e) =>
@@ -204,7 +205,7 @@ public class Buttons : Scenario
         main.Add (absoluteFrame);
 
         // Demonstrates how changing the View.Frame property can move Views
-        var moveBtnA = new Button { ColorScheme = Colors.ColorSchemes ["Error"], Text = "Move This Button via Frame" };
+        var moveBtnA = new Button { SchemeName = "Error", Text = "Move This Button via Frame" };
 
         moveBtnA.Accepting += (s, e) =>
                            {
@@ -221,7 +222,7 @@ public class Buttons : Scenario
         // Demonstrates how changing the View.Frame property can SIZE Views (#583)
         var sizeBtnA = new Button
         {
-            Y = 2, ColorScheme = Colors.ColorSchemes ["Error"], Text = " ~  s  gui.cs   master ↑_10 = Сохранить"
+            Y = 2, SchemeName = "Error", Text = " ~  s  gui.cs   master ↑_10 = Сохранить"
         };
 
         sizeBtnA.Accepting += (s, e) =>
@@ -294,7 +295,7 @@ public class Buttons : Scenario
             X = 2,
             Y = Pos.Bottom (radioGroup) + 1,
             Width = Dim.Width (computedFrame) - 2,
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Text = mhkb
         };
         moveHotKeyBtn.Accepting += (s, e) =>
@@ -311,7 +312,7 @@ public class Buttons : Scenario
             X = Pos.Left (absoluteFrame) + 1,
             Y = Pos.Bottom (radioGroup) + 1,
             Width = Dim.Width (absoluteFrame) - 2,
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Text = muhkb
         };
         moveUnicodeHotKeyBtn.Accepting += (s, e) =>

+ 8 - 4
Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs

@@ -41,7 +41,9 @@ public class CharacterMap : Scenario
             X = 0,
             Y = 1,
             Width = Dim.Fill (Dim.Func (() => _categoryList!.Frame.Width)),
-            Height = Dim.Fill ()
+            Height = Dim.Fill (),
+           // SchemeName = "Base"
+
         };
         top.Add (_charMap);
 
@@ -50,7 +52,8 @@ public class CharacterMap : Scenario
             X = Pos.Right (_charMap) + 1,
             Y = Pos.Y (_charMap),
             HotKeySpecifier = (Rune)'_',
-            Text = "_Jump To:"
+            Text = "_Jump To:",
+            //SchemeName = "Dialog"
         };
         top.Add (jumpLabel);
 
@@ -60,6 +63,7 @@ public class CharacterMap : Scenario
             Y = Pos.Y (_charMap),
             Width = 17,
             Caption = "e.g. 01BE3 or ✈",
+            //SchemeName = "Dialog"
         };
         top.Add (jumpEdit);
 
@@ -79,10 +83,9 @@ public class CharacterMap : Scenario
         {
             X = Pos.Right (jumpEdit) + 1,
             Y = Pos.Y (_charMap),
-            ColorScheme = Colors.ColorSchemes ["error"],
+            SchemeName = "error",
             Text = "err",
             Visible = false
-
         };
         top.Add (_errorLabel);
 
@@ -92,6 +95,7 @@ public class CharacterMap : Scenario
             X = Pos.Right (_charMap), 
             Y = Pos.Bottom (jumpLabel), 
             Height = Dim.Fill (),
+            //SchemeName = "Dialog"
         };
         _categoryList.FullRowSelect = true;
         _categoryList.MultiSelect = false;

+ 1 - 1
Examples/UICatalog/Scenarios/Clipping.cs

@@ -120,7 +120,7 @@ public class Clipping : Scenario
             Height = Dim.Auto (minimumContentDim: 4),
             Width = Dim.Auto (minimumContentDim: 14),
             Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = SchemeManager.SchemesToSchemeName(Schemes.Toplevel),
             Id = $"Overlapped{id}",
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,

+ 1 - 1
Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs

@@ -82,7 +82,7 @@ public class CollectionNavigatorTester : Scenario
     public override void Main ()
     {
         Application.Init ();
-        top = new Toplevel { ColorScheme = Colors.ColorSchemes ["Base"] };
+        top = new Toplevel { SchemeName = "Base" };
 
         var allowMarking = new MenuItem ("Allow _Marking", "", null)
         {

+ 13 - 11
Examples/UICatalog/Scenarios/ColorPicker.cs

@@ -45,7 +45,8 @@ public class ColorPickers : Scenario
         ///////////////////////////////////////
 
         // Foreground ColorPicker.
-        foregroundColorPicker = new ColorPicker {
+        foregroundColorPicker = new ColorPicker
+        {
             Title = "_Foreground Color",
             BorderStyle = LineStyle.Single,
             Width = Dim.Percent (50)
@@ -154,7 +155,7 @@ public class ColorPickers : Scenario
                                                     backgroundColorPicker.Visible = false;
 
                                                     // Switching to 16 colors
-                                                    ForegroundColor_ColorChanged (null,null);
+                                                    ForegroundColor_ColorChanged (null, null);
                                                     BackgroundColor_ColorChanged (null, null);
                                                 }
                                                 else
@@ -182,10 +183,10 @@ public class ColorPickers : Scenario
         var cbShowTextFields = new CheckBox ()
         {
             Text = "Show _Text Fields",
-            Y = Pos.Bottom (rgColorModel)+1,
+            Y = Pos.Bottom (rgColorModel) + 1,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
-            CheckedState = foregroundColorPicker.Style.ShowTextFields ? CheckState.Checked: CheckState.UnChecked,
+            CheckedState = foregroundColorPicker.Style.ShowTextFields ? CheckState.Checked : CheckState.UnChecked,
         };
 
         cbShowTextFields.CheckedStateChanging += (_, e) =>
@@ -217,8 +218,8 @@ public class ColorPickers : Scenario
         app.Add (cbShowName);
 
         // Set default colors.
-        foregroundColorPicker.SelectedColor = _demoView.SuperView.ColorScheme.Normal.Foreground.GetClosestNamedColor16 ();
-        backgroundColorPicker.SelectedColor = _demoView.SuperView.ColorScheme.Normal.Background.GetClosestNamedColor16 ();
+        foregroundColorPicker.SelectedColor = _demoView.SuperView!.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
+        backgroundColorPicker.SelectedColor = _demoView.SuperView.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
 
         Application.Run (app);
         app.Dispose ();
@@ -259,7 +260,7 @@ public class ColorPickers : Scenario
     /// <summary>Update Demo Label.</summary>
     private void UpdateDemoLabel ()
     {
-        _demoView.ColorScheme = new ColorScheme
+        _demoView.SetScheme (new Scheme
         {
             Normal = new Attribute (
                                     foregroundColorPicker.Visible ?
@@ -269,14 +270,15 @@ public class ColorPickers : Scenario
                                         backgroundColorPicker.SelectedColor :
                                         backgroundColorPicker16.SelectedColor
                                    )
-        };
+        });
     }
 
     public override List<Key> GetDemoKeyStrokes ()
     {
-        var keys = new List<Key> ();
-
-        keys.Add (Key.B.WithAlt);
+        List<Key> keys =
+        [
+            Key.B.WithAlt
+        ];
 
         for (int i = 0; i < 200; i++)
         {

+ 1 - 1
Examples/UICatalog/Scenarios/ComboBoxIteration.cs

@@ -26,7 +26,7 @@ public class ComboBoxIteration : Scenario
 
         var lbComboBox = new Label
         {
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             X = Pos.Right (lbListView) + 1,
             Width = Dim.Percent (40)
         };

+ 17 - 17
Examples/UICatalog/Scenarios/ComputedLayout.cs

@@ -30,7 +30,7 @@ public class ComputedLayout : Scenario
             Y = 0,
             Width = Dim.Fill (),
             Height = 1,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = rule
         };
 
@@ -45,7 +45,7 @@ public class ComputedLayout : Scenario
             Y = 0,
             Width = 1,
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = vrule
         };
 
@@ -103,7 +103,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -115,7 +115,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -127,7 +127,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -139,7 +139,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -165,7 +165,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -177,7 +177,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -189,7 +189,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -201,7 +201,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -231,7 +231,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -243,7 +243,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -255,7 +255,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -267,7 +267,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -281,7 +281,7 @@ public class ComputedLayout : Scenario
             Y = Pos.Percent (50),
             Width = Dim.Percent (80),
             Height = Dim.Percent (10),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"]
+            SchemeName = "TopLevel"
         };
 
         textView.Text =
@@ -384,7 +384,7 @@ public class ComputedLayout : Scenario
         {
             Text = "This Label should be the 3rd to last line (AnchorEnd (3)).",
             TextAlignment = Alignment.Center,
-            ColorScheme = Colors.ColorSchemes ["Menu"],
+            SchemeName = "Menu",
             Width = Dim.Fill (5),
             X = 5,
             Y = Pos.AnchorEnd (3)
@@ -398,7 +398,7 @@ public class ComputedLayout : Scenario
             Text =
                 "This TextField should be the 4th to last line (AnchorEnd (3) - 1).",
             TextAlignment = Alignment.Start,
-            ColorScheme = Colors.ColorSchemes ["Menu"],
+            SchemeName = "Menu",
             Width = Dim.Fill (5),
             X = 5,
             Y = Pos.AnchorEnd (3) - 1 // Pos.Combine

+ 63 - 42
Examples/UICatalog/Scenarios/ConfigurationEditor.cs

@@ -7,41 +7,36 @@ using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
-[ScenarioMetadata ("Configuration Editor", "Edits Terminal.Gui Config Files.")]
+[ScenarioMetadata ("Configuration Editor", "Editor of Terminal.Gui Config Files")]
 [ScenarioCategory ("TabView")]
 [ScenarioCategory ("Colors")]
 [ScenarioCategory ("Files and IO")]
 [ScenarioCategory ("TextView")]
+[ScenarioCategory ("Configuration")]
 public class ConfigurationEditor : Scenario
 {
-    private static ColorScheme _editorColorScheme = new ()
-    {
-        Normal = new Attribute (Color.Red, Color.White),
-        Focus = new Attribute (Color.Red, Color.Black),
-        HotFocus = new Attribute (Color.BrightRed, Color.Black),
-        HotNormal = new Attribute (Color.Magenta, Color.White)
-    };
+    //private static Scheme _editorScheme = SchemeManager.GetScheme (Schemes.Base);
 
-    private static Action? _editorColorSchemeChanged;
+    //private static Action? _editorSchemeChanged;
     private TabView? _tabView;
     private Shortcut? _lenShortcut;
 
-    [SerializableConfigurationProperty (Scope = typeof (AppScope))]
-    public static ColorScheme EditorColorScheme
-    {
-        get => _editorColorScheme;
-        set
-        {
-            _editorColorScheme = value;
-            _editorColorSchemeChanged?.Invoke ();
-        }
-    }
+    //[ConfigurationProperty (Scope = typeof (AppSettingsScope))]
+    //public static Scheme EditorScheme
+    //{
+    //    get => _editorScheme;
+    //    set
+    //    {
+    //        _editorScheme = value;
+    //        _editorSchemeChanged?.Invoke ();
+    //    }
+    //}
 
     public override void Main ()
     {
         Application.Init ();
 
-        Toplevel top = new ();
+        Window? win = new ();
 
         _lenShortcut = new Shortcut ()
         {
@@ -77,34 +72,49 @@ public class ConfigurationEditor : Scenario
             Height = Dim.Fill (Dim.Func (() => statusBar.Frame.Height))
         };
 
-        top.Add (_tabView, statusBar);
+        win.Add (_tabView, statusBar);
 
-        top.Loaded += (s, a) =>
+        win.Loaded += (s, a) =>
                       {
                           Open ();
-                          _editorColorSchemeChanged?.Invoke ();
+                          //_editorSchemeChanged?.Invoke ();
                       };
 
-        void OnEditorColorSchemeChanged ()
-        {
-            if (Application.Top is { })
-            {
-                return;
-            }
 
-            foreach (ConfigTextView t in _tabView.SubViews.OfType<ConfigTextView> ())
-            {
-                t.ColorScheme = EditorColorScheme;
-            }
-        }
 
-        _editorColorSchemeChanged += OnEditorColorSchemeChanged;
+        //_editorSchemeChanged += OnEditorSchemeChanged;
 
-        Application.Run (top);
-        _editorColorSchemeChanged -= OnEditorColorSchemeChanged;
-        top.Dispose ();
+        ConfigurationManager.Applied += ConfigurationManagerOnApplied;
+
+        Application.Run (win);
+        //_editorSchemeChanged -= OnEditorSchemeChanged;
+        win.Dispose ();
+        win = null;
 
         Application.Shutdown ();
+
+        return;
+
+        //void OnEditorSchemeChanged ()
+        //{
+        //    if (Application.Top is { })
+        //    {
+        //        return;
+        //    }
+
+        //    foreach (ConfigTextView t in _tabView.SubViews.OfType<ConfigTextView> ())
+        //    {
+        //        t.SetScheme (EditorScheme);
+        //    }
+        //}
+
+        void ConfigurationManagerOnApplied (object? sender, ConfigurationManagerEventArgs e)
+        {
+            if (win is { })
+            {
+                win.SetNeedsDraw ();
+            }
+        }
     }
     public void Save ()
     {
@@ -116,7 +126,7 @@ public class ConfigurationEditor : Scenario
 
     private void Open ()
     {
-        foreach (var config in ConfigurationManager.Settings!.Sources)
+        foreach (var config in ConfigurationManager.SourcesManager!.Sources)
         {
             var homeDir = $"{Environment.GetFolderPath (Environment.SpecialFolder.UserProfile)}";
             var fileInfo = new FileInfo (config.Value.Replace ("~", homeDir));
@@ -129,6 +139,12 @@ public class ConfigurationEditor : Scenario
                 FileInfo = fileInfo,
             };
 
+            if (config.Value == "HardCoded")
+            {
+                editor.Title = "HardCoded";
+
+            }
+
             Tab tab = new Tab ()
             {
                 View = editor,
@@ -244,15 +260,20 @@ public class ConfigurationEditor : Scenario
                 return;
             }
 
-            if (FileInfo!.FullName.Contains ("RuntimeConfig"))
+            if (FileInfo!.FullName.Contains ("HardCoded"))
+            {
+                Text = ConfigurationManager.GetHardCodedConfig ()!;
+                ReadOnly = true;
+                Enabled = true;
+            }
+            else if (FileInfo!.FullName.Contains ("RuntimeConfig"))
             {
                 Text = ConfigurationManager.RuntimeConfig!;
-
             }
             else if (!FileInfo.Exists)
             {
                 // Create empty config file
-                Text = ConfigurationManager.GetEmptyJson ();
+                Text = ConfigurationManager.GetEmptyConfig ();
             }
             else
             {

+ 1 - 1
Examples/UICatalog/Scenarios/ContextMenus.cs

@@ -24,7 +24,7 @@ public class ContextMenus : Scenario
         {
             Title = GetQuitKeyAndName (),
             Arrangement = ViewArrangement.Fixed,
-            ColorScheme = Colors.ColorSchemes ["Toplevel"]
+            SchemeName = "Toplevel"
         };
 
         var text = "Context Menu";

+ 1 - 1
Examples/UICatalog/Scenarios/Dialogs.cs

@@ -177,7 +177,7 @@ public class Dialogs : Scenario
 
         var buttonPressedLabel = new Label
         {
-            X = Pos.Center (), Y = Pos.Bottom (frame) + 5, ColorScheme = Colors.ColorSchemes ["Error"], Text = " "
+            X = Pos.Center (), Y = Pos.Bottom (frame) + 5, SchemeName = "Error", Text = " "
         };
 
         var showDialogButton = new Button

+ 5 - 5
Examples/UICatalog/Scenarios/DimAutoDemo.cs

@@ -74,7 +74,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (textEdit) + 1,
             Width = Dim.Auto (DimAutoStyle.Text, 1),
             Height = Dim.Auto (DimAutoStyle.Text, 8),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             TextDirection = TextDirection.TopBottom_LeftRight
         };
         vlabel.Id = "vlabel";
@@ -87,7 +87,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (textEdit),
             Width = Dim.Auto (DimAutoStyle.Text, 20),
             Height = Dim.Auto (DimAutoStyle.Text, 1),
-            ColorScheme = Colors.ColorSchemes ["Error"]
+            SchemeName = "Error"
         };
         hlabel.Id = "hlabel";
         dimAutoFrameView.Add (hlabel);
@@ -98,7 +98,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (hlabel) + 1,
             Width = 20,
             Height = Dim.Auto (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Title = "W: 20, H: Auto",
             BorderStyle = LineStyle.Rounded
         };
@@ -111,7 +111,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (hlabel) + 1,
             Width = Dim.Auto (),
             Height = 5,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Title = "W: Auto, H: 5",
             BorderStyle = LineStyle.Rounded
         };
@@ -124,7 +124,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (hlabel) + 1,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Title = "W: Auto, H: Auto",
             BorderStyle = LineStyle.Rounded
         };

+ 2 - 2
Examples/UICatalog/Scenarios/DynamicMenuBar.cs

@@ -594,7 +594,7 @@ public class DynamicMenuBar : Scenario
 
             var lblMenuBar = new Label
             {
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 TextAlignment = Alignment.Center,
                 X = Pos.Right (btnPrevious) + 1,
                 Y = Pos.Top (btnPrevious),
@@ -632,7 +632,7 @@ public class DynamicMenuBar : Scenario
 
             _lstMenus = new ()
             {
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 X = Pos.Right (btnPrevious) + 1,
                 Y = Pos.Top (btnPrevious) + 2,
                 Width = lblMenuBar.Width,

+ 1 - 1
Examples/UICatalog/Scenarios/DynamicStatusBar.cs

@@ -282,7 +282,7 @@ public class DynamicStatusBar : Scenario
 
             _lstItems = new ListView
             {
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 Y = Pos.Top (btnAddStatusBar) + 2,
                 Width = Dim.Fill () - Dim.Width (btnAdd) - 1,
                 Height = Dim.Fill (),

+ 0 - 51
Examples/UICatalog/Scenarios/Editors/MarginEditor.cs

@@ -1,51 +0,0 @@
-#nullable enable
-using System;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios;
-
-public class MarginEditor : AdornmentEditor
-{
-    public MarginEditor ()
-    {
-        Title = "_Margin";
-        Initialized += MarginEditor_Initialized;
-        AdornmentChanged += MarginEditor_AdornmentChanged;
-    }
-
-    private RadioGroup? _rgShadow;
-
-    private void MarginEditor_AdornmentChanged (object? sender, EventArgs e)
-    {
-        if (AdornmentToEdit is { })
-        {
-            _rgShadow!.SelectedItem = (int)((Margin)AdornmentToEdit).ShadowStyle;
-        }
-    }
-
-    private void MarginEditor_Initialized (object? sender, EventArgs e)
-    {
-        _rgShadow = new RadioGroup
-        {
-            X = 0,
-            Y = Pos.AnchorEnd (),
-
-            SuperViewRendersLineCanvas = true,
-            Title = "_Shadow",
-            BorderStyle = LineStyle.Single,
-            RadioLabels = Enum.GetNames (typeof (ShadowStyle)),
-        };
-
-        if (AdornmentToEdit is { })
-        {
-            _rgShadow.SelectedItem = (int)((Margin)AdornmentToEdit).ShadowStyle;
-        }
-
-        _rgShadow.SelectedItemChanged += (_, args) =>
-                                        {
-                                            ((Margin)AdornmentToEdit!).ShadowStyle = (ShadowStyle)args.SelectedItem!;
-                                        };
-
-        Add (_rgShadow);
-    }
-}

+ 6 - 5
Examples/UICatalog/Scenarios/Editors/AdornmentEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs

@@ -60,9 +60,9 @@ public class AdornmentEditor : EditorBase
 
                 _adornment.Initialized += (sender, args) =>
                                           {
-                                              ColorScheme? cs = _adornment.ColorScheme;
-                                              _foregroundColorPicker.SelectedColor = _adornment.GetNormalColor ().Foreground.GetClosestNamedColor16 ();
-                                              _backgroundColorPicker.SelectedColor = _adornment.GetNormalColor ().Background.GetClosestNamedColor16 ();
+                                              Scheme? cs = _adornment.GetScheme ();
+                                              _foregroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
+                                              _backgroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
                                           };
             }
 
@@ -220,10 +220,11 @@ public class AdornmentEditor : EditorBase
                        return;
                    }
 
-                   AdornmentToEdit.ColorScheme = new (AdornmentToEdit.ColorScheme ?? AdornmentToEdit.Parent?.ColorScheme)
+                   AdornmentToEdit.SetScheme (new (AdornmentToEdit.GetScheme ())
                    {
                        Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
-                   };
+                   })
+                   ;
                };
     }
 

+ 2 - 0
Examples/UICatalog/Scenarios/Editors/AdornmentsEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs

@@ -18,6 +18,8 @@ public class AdornmentsEditor : EditorBase
         ExpanderButton!.Orientation = Orientation.Horizontal;
 
         Initialized += AdornmentsEditor_Initialized;
+
+        SchemeName = "Dialog";
     }
 
     public MarginEditor? MarginEditor { get; set; }

+ 195 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs

@@ -0,0 +1,195 @@
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+public class AllViewsView : View
+{
+    private const int MAX_VIEW_FRAME_HEIGHT = 25;
+    public AllViewsView ()
+    {
+        CanFocus = true;
+        BorderStyle = LineStyle.Heavy;
+        Arrangement = ViewArrangement.Resizable;
+        HorizontalScrollBar.AutoShow = false;
+        VerticalScrollBar.AutoShow = true;
+
+        SubViewsLaidOut += (sender, _) =>
+                           {
+                               if (sender is View sendingView)
+                               {
+                                   sendingView.SetContentSize (new Size (sendingView.Viewport.Width, sendingView.GetHeightRequiredForSubViews ()));
+                               }
+                           };
+
+        AddCommand (Command.Up, () => ScrollVertical (-1));
+        AddCommand (Command.Down, () => ScrollVertical (1));
+        AddCommand (Command.PageUp, () => ScrollVertical (-SubViews.OfType<FrameView> ().First ().Frame.Height));
+        AddCommand (Command.PageDown, () => ScrollVertical (SubViews.OfType<FrameView> ().First ().Frame.Height));
+        AddCommand (
+                    Command.Start,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = 0 };
+
+                        return true;
+                    });
+        AddCommand (
+                    Command.End,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = GetContentSize ().Height };
+
+                        return true;
+                    });
+
+        AddCommand (Command.ScrollDown, () => ScrollVertical (1));
+        AddCommand (Command.ScrollUp, () => ScrollVertical (-1));
+        AddCommand (Command.ScrollRight, () => ScrollHorizontal (1));
+        AddCommand (Command.ScrollLeft, () => ScrollHorizontal (-1));
+
+        KeyBindings.Add (Key.CursorUp, Command.Up);
+        KeyBindings.Add (Key.CursorDown, Command.Down);
+        KeyBindings.Add (Key.CursorLeft, Command.Left);
+        KeyBindings.Add (Key.CursorRight, Command.Right);
+        KeyBindings.Add (Key.PageUp, Command.PageUp);
+        KeyBindings.Add (Key.PageDown, Command.PageDown);
+        KeyBindings.Add (Key.Home, Command.Start);
+        KeyBindings.Add (Key.End, Command.End);
+        KeyBindings.Add (PopoverMenu.DefaultKey, Command.Context);
+
+        MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Accept);
+        MouseBindings.ReplaceCommands (MouseFlags.Button3Clicked, Command.Context);
+        MouseBindings.ReplaceCommands (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Context);
+        MouseBindings.Add (MouseFlags.WheeledDown, Command.ScrollDown);
+        MouseBindings.Add (MouseFlags.WheeledUp, Command.ScrollUp);
+        MouseBindings.Add (MouseFlags.WheeledLeft, Command.ScrollLeft);
+        MouseBindings.Add (MouseFlags.WheeledRight, Command.ScrollRight);
+    }
+
+    /// <inheritdoc />
+    public override void EndInit ()
+    {
+        base.EndInit ();
+
+        var allClasses = GetAllViewClassesCollection ();
+
+        View? previousView = null;
+
+        foreach (Type? type in allClasses)
+        {
+            View? view = CreateView (type);
+
+            if (view is { })
+            {
+                FrameView? frame = new ()
+                {
+                    CanFocus = true,
+                    Title = type.Name,
+                    Y = previousView is { } ? Pos.Bottom (previousView) : 0,
+                    Width = Dim.Fill (),
+                    Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: MAX_VIEW_FRAME_HEIGHT)
+                };
+                frame.Add (view);
+                Add (frame);
+                previousView = frame;
+            }
+        }
+    }
+
+    private static List<Type> GetAllViewClassesCollection ()
+    {
+        List<Type> types = typeof (View).Assembly.GetTypes ()
+                                        .Where (
+                                                myType => myType is { IsClass: true, IsAbstract: false, IsPublic: true }
+                                                          && myType.IsSubclassOf (typeof (View)))
+                                        .ToList ();
+
+        types.Add (typeof (View));
+
+        return types;
+    }
+
+    private View? CreateView (Type type)
+    {
+        // If we are to create a generic Type
+        if (type.IsGenericType)
+        {
+            // For each of the <T> arguments
+            List<Type> typeArguments = new ();
+
+            // use <object> or the original type if applicable
+            foreach (Type arg in type.GetGenericArguments ())
+            {
+                if (arg.IsValueType && Nullable.GetUnderlyingType (arg) == null)
+                {
+                    typeArguments.Add (arg);
+                }
+                else
+                {
+                    typeArguments.Add (typeof (object));
+                }
+            }
+
+            // And change what type we are instantiating from MyClass<T> to MyClass<object> or MyClass<T>
+            type = type.MakeGenericType (typeArguments.ToArray ());
+        }
+
+        // Ensure the type does not contain any generic parameters
+        if (type.ContainsGenericParameters)
+        {
+            Logging.Warning ($"Cannot create an instance of {type} because it contains generic parameters.");
+
+            //throw new ArgumentException ($"Cannot create an instance of {type} because it contains generic parameters.");
+            return null;
+        }
+
+        // Instantiate view
+        var view = (View)Activator.CreateInstance (type)!;
+        var demoText = "This, that, and the other thing.";
+
+        if (view is IDesignable designable)
+        {
+            designable.EnableForDesign (ref demoText);
+        }
+        else
+        {
+            view.Text = demoText;
+            view.Title = "_Test Title";
+        }
+
+        view.X = 0;
+        view.Y = 0;
+
+        view.Initialized += OnViewInitialized;
+
+        return view;
+    }
+
+    private void OnViewInitialized (object? sender, EventArgs e)
+    {
+        if (sender is not View view)
+        {
+            return;
+        }
+
+        if (view.Width == Dim.Absolute (0) || view.Width is null)
+        {
+            view.Width = Dim.Fill ();
+        }
+
+        if (view.Height == Dim.Absolute (0) || view.Height is null)
+        {
+            view.Height = MAX_VIEW_FRAME_HEIGHT - 2;
+        }
+
+        if (!view.Width.Has<DimAuto> (out _))
+        {
+            view.Width = Dim.Fill ();
+        }
+
+        if (!view.Height.Has<DimAuto> (out _))
+        {
+            view.Height = Dim.Auto (minimumContentDim: MAX_VIEW_FRAME_HEIGHT - 2, maximumContentDim: MAX_VIEW_FRAME_HEIGHT - 2);
+        }
+    }
+}

+ 2 - 2
Examples/UICatalog/Scenarios/Editors/ArrangementEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/ArrangementEditor.cs

@@ -107,12 +107,12 @@ public sealed class ArrangementEditor : EditorBase
             if (ViewToEdit.Arrangement.HasFlag (ViewArrangement.Overlapped))
             {
                 ViewToEdit.ShadowStyle = ShadowStyle.Transparent;
-                ViewToEdit.ColorScheme = Colors.ColorSchemes ["Toplevel"];
+                ViewToEdit.SchemeName = "Toplevel";
             }
             else
             {
                 ViewToEdit.ShadowStyle = ShadowStyle.None;
-                ViewToEdit.ColorScheme = ViewToEdit!.SuperView!.ColorScheme;
+                ViewToEdit.SchemeName = ViewToEdit!.SuperView!.SchemeName;
             }
 
             if (ViewToEdit.Arrangement.HasFlag (ViewArrangement.Movable))

+ 0 - 0
Examples/UICatalog/Scenarios/Editors/BorderEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs


+ 3 - 3
Examples/UICatalog/Scenarios/Editors/DimEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs

@@ -27,11 +27,11 @@ public class DimEditor : EditorBase
     {
         if (ViewToEdit is { })
         {
-            ViewToEdit.SubViewsLaidOut += (_, _) => { OnUpdateSettings (); };
+            ViewToEdit.SubViewsLaidOut += (_, _) => { OnUpdateLayoutSettings (); };
         }
     }
 
-    protected override void OnUpdateSettings ()
+    protected override void OnUpdateLayoutSettings ()
     {
         Enabled = ViewToEdit is not Adornment;
 
@@ -130,7 +130,7 @@ public class DimEditor : EditorBase
 
     private void DimChanged ()
     {
-        if (ViewToEdit == null || UpdatingSettings)
+        if (ViewToEdit == null || UpdatingLayoutSettings)
         {
             return;
         }

+ 7 - 5
Examples/UICatalog/Scenarios/Editors/EditorBase.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs

@@ -48,6 +48,8 @@ public abstract class EditorBase : View
 
         AddCommand (Command.Accept, () => true);
 
+        SchemeName = "Dialog";
+
     }
 
     private readonly ExpanderButton? _expanderButton;
@@ -65,15 +67,15 @@ public abstract class EditorBase : View
         }
     }
 
-    public bool UpdatingSettings { get; private set; } = false;
+    public bool UpdatingLayoutSettings { get; private set; } = false;
 
     private void View_LayoutComplete (object? sender, LayoutEventArgs e)
     {
-        UpdatingSettings = true;
+        UpdatingLayoutSettings = true;
 
-        OnUpdateSettings ();
+        OnUpdateLayoutSettings ();
 
-        UpdatingSettings = false;
+        UpdatingLayoutSettings = false;
     }
 
 
@@ -108,7 +110,7 @@ public abstract class EditorBase : View
 
     protected virtual void OnViewToEditChanged () { }
 
-    protected virtual void OnUpdateSettings () { }
+    protected virtual void OnUpdateLayoutSettings () { }
 
     /// <summary>
     ///     Gets or sets whether the DimEditor should automatically select the View to edit

+ 0 - 0
Examples/UICatalog/Scenarios/Editors/EventLog.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs


+ 0 - 0
Examples/UICatalog/Scenarios/Editors/ExpanderButton.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs


+ 0 - 0
Examples/UICatalog/Scenarios/Editors/LayoutEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs


+ 90 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs

@@ -0,0 +1,90 @@
+#nullable enable
+using System;
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+public class MarginEditor : AdornmentEditor
+{
+    public MarginEditor ()
+    {
+        Title = "_Margin";
+        Initialized += MarginEditor_Initialized;
+        AdornmentChanged += MarginEditor_AdornmentChanged;
+    }
+
+    private RadioGroup? _rgShadow;
+
+    private FlagSelector? _flagSelectorTransparent;
+
+    private void MarginEditor_AdornmentChanged (object? sender, EventArgs e)
+    {
+        if (AdornmentToEdit is { })
+        {
+            _rgShadow!.SelectedItem = (int)((Margin)AdornmentToEdit).ShadowStyle;
+        }
+
+        if (AdornmentToEdit is { })
+        {
+            _flagSelectorTransparent!.Value = (uint)((Margin)AdornmentToEdit).ViewportSettings;
+        }
+    }
+
+    private void MarginEditor_Initialized (object? sender, EventArgs e)
+    {
+        _rgShadow = new RadioGroup
+        {
+            X = 0,
+            Y = Pos.Bottom (SubViews.ElementAt(SubViews.Count-1)),
+
+            SuperViewRendersLineCanvas = true,
+            Title = "_Shadow",
+            BorderStyle = LineStyle.Single,
+            RadioLabels = Enum.GetNames (typeof (ShadowStyle)),
+        };
+
+        if (AdornmentToEdit is { })
+        {
+            _rgShadow.SelectedItem = (int)((Margin)AdornmentToEdit).ShadowStyle;
+        }
+
+        _rgShadow.SelectedItemChanged += (_, args) =>
+                                        {
+                                            ((Margin)AdornmentToEdit!).ShadowStyle = (ShadowStyle)args.SelectedItem!;
+                                        };
+
+        Add (_rgShadow);
+
+        var flags = new Dictionary<uint, string> ()
+        {
+            { (uint)Terminal.Gui.ViewportSettings.Transparent, "Transparent" },
+            { (uint)Terminal.Gui.ViewportSettings.TransparentMouse, "TransparentMouse" }
+        };
+
+        _flagSelectorTransparent = new FlagSelector ()
+        {
+            X = 0,
+            Y = Pos.Bottom (_rgShadow),
+
+            SuperViewRendersLineCanvas = true,
+            Title = "_ViewportSettings",
+            BorderStyle = LineStyle.Single,
+        };
+        _flagSelectorTransparent.SetFlags(flags.AsReadOnly ());
+
+
+        Add (_flagSelectorTransparent);
+
+        if (AdornmentToEdit is { })
+        {
+            _flagSelectorTransparent.Value = (uint)((Margin)AdornmentToEdit).ViewportSettings;
+        }
+
+        _flagSelectorTransparent.ValueChanged += (_, args) =>
+                                                 {
+                                                     ((Margin)AdornmentToEdit!).ViewportSettings = (Terminal.Gui.ViewportSettings)args.CurrentValue!;
+                                                 };
+
+
+    }
+}

+ 0 - 0
Examples/UICatalog/Scenarios/Editors/PaddingEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/PaddingEditor.cs


+ 2 - 2
Examples/UICatalog/Scenarios/Editors/PosEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs

@@ -23,7 +23,7 @@ public class PosEditor : EditorBase
     private RadioGroup? _posRadioGroup;
     private TextField? _valueEdit;
 
-    protected override void OnUpdateSettings ()
+    protected override void OnUpdateLayoutSettings ()
     {
         Enabled = ViewToEdit is not Adornment;
 
@@ -130,7 +130,7 @@ public class PosEditor : EditorBase
 
     private void PosChanged ()
     {
-        if (ViewToEdit == null || UpdatingSettings)
+        if (ViewToEdit == null || UpdatingLayoutSettings)
         {
             return;
         }

+ 47 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/SchemeViewer.cs

@@ -0,0 +1,47 @@
+#nullable enable
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+public class SchemeViewer : FrameView
+{
+    public SchemeViewer ()
+    {
+        TabStop = TabBehavior.TabStop;
+        CanFocus = true;
+        Height = Dim.Auto ();
+        Width = Dim.Auto ();
+
+        VisualRoleViewer? prevRoleViewer = null;
+
+        foreach (VisualRole role in Enum.GetValues<VisualRole> ())
+        {
+            var roleViewer = new VisualRoleViewer
+            {
+                Role = role
+            };
+
+            if (prevRoleViewer is { })
+            {
+                roleViewer.Y = Pos.Bottom (prevRoleViewer);
+            }
+
+            base.Add (roleViewer);
+
+            prevRoleViewer = roleViewer;
+        }
+    }
+
+    /// <inheritdoc/>
+    protected override bool OnSettingSchemeName (in string? currentName, ref string? newName)
+    {
+        Title = newName ?? "null";
+
+        foreach (VisualRoleViewer v in SubViews.OfType<VisualRoleViewer> ())
+        {
+            v.SchemeName = newName;
+        }
+
+        return base.OnSettingSchemeName (in currentName, ref newName);
+    }
+}

+ 121 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/ThemeViewer.cs

@@ -0,0 +1,121 @@
+#nullable enable
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+public class ThemeViewer : FrameView
+{
+    public ThemeViewer ()
+    {
+        BorderStyle = LineStyle.Rounded;
+        Border!.Thickness = new (0, 1, 0, 0);
+        Margin!.Thickness = new (0, 0, 1, 0);
+        TabStop = TabBehavior.TabStop;
+        CanFocus = true;
+        Height = Dim.Fill ();
+        Width = Dim.Auto ();
+        Title = $"{ThemeManager.Theme}";
+
+        VerticalScrollBar.AutoShow = true;
+        HorizontalScrollBar.AutoShow = true;
+
+        SubViewsLaidOut += (sender, _) =>
+                           {
+                               if (sender is View sendingView)
+                               {
+                                   sendingView.SetContentSize (new Size (sendingView.GetContentSize ().Width, sendingView.GetHeightRequiredForSubViews ()));
+                               }
+                           };
+
+        AddCommand (Command.Up, () => ScrollVertical (-1));
+        AddCommand (Command.Down, () => ScrollVertical (1));
+
+        AddCommand (Command.PageUp, () => ScrollVertical (-SubViews.OfType<SchemeViewer> ().First ().Frame.Height));
+        AddCommand (Command.PageDown, () => ScrollVertical (SubViews.OfType<SchemeViewer> ().First ().Frame.Height));
+
+        AddCommand (
+                    Command.Start,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = 0 };
+
+                        return true;
+                    });
+
+        AddCommand (
+                    Command.End,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = GetContentSize ().Height };
+
+                        return true;
+                    });
+
+        AddCommand (Command.ScrollDown, () => ScrollVertical (1));
+        AddCommand (Command.ScrollUp, () => ScrollVertical (-1));
+        AddCommand (Command.ScrollRight, () => ScrollHorizontal (1));
+        AddCommand (Command.ScrollLeft, () => ScrollHorizontal (-1));
+
+        KeyBindings.Add (Key.CursorUp, Command.Up);
+        KeyBindings.Add (Key.CursorDown, Command.Down);
+        KeyBindings.Add (Key.CursorLeft, Command.Left);
+        KeyBindings.Add (Key.CursorRight, Command.Right);
+        KeyBindings.Add (Key.PageUp, Command.PageUp);
+        KeyBindings.Add (Key.PageDown, Command.PageDown);
+        KeyBindings.Add (Key.Home, Command.Start);
+        KeyBindings.Add (Key.End, Command.End);
+        KeyBindings.Add (PopoverMenu.DefaultKey, Command.Context);
+
+        MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Accept);
+        MouseBindings.ReplaceCommands (MouseFlags.Button3Clicked, Command.Context);
+        MouseBindings.ReplaceCommands (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Context);
+        MouseBindings.Add (MouseFlags.WheeledDown, Command.ScrollDown);
+        MouseBindings.Add (MouseFlags.WheeledUp, Command.ScrollUp);
+        MouseBindings.Add (MouseFlags.WheeledLeft, Command.ScrollLeft);
+        MouseBindings.Add (MouseFlags.WheeledRight, Command.ScrollRight);
+
+        SchemeViewer? prevSchemeViewer = null;
+
+        foreach (KeyValuePair<string, Scheme?> kvp in SchemeManager.GetSchemesForCurrentTheme ())
+        {
+            var schemeViewer = new SchemeViewer
+            {
+                Id = $"schemeViewer for {kvp.Key}",
+                SchemeName = kvp.Key
+            };
+
+            if (prevSchemeViewer is { })
+            {
+                schemeViewer.Y = Pos.Bottom (prevSchemeViewer);
+            }
+
+            prevSchemeViewer = schemeViewer;
+            base.Add (schemeViewer);
+        }
+
+        ThemeManager.ThemeChanged += OnThemeManagerOnThemeChanged;
+    }
+
+    /// <inheritdoc/>
+    protected override void OnFocusedChanged (View? previousFocused, View? focused)
+    {
+        base.OnFocusedChanged (previousFocused, focused);
+
+        if (focused is { })
+        {
+            SchemeName = focused.Title;
+        }
+    }
+
+    private void OnThemeManagerOnThemeChanged (object? _, StringPropertyEventArgs args) { Title = args.NewString!; }
+
+    protected override void Dispose (bool disposing)
+    {
+        if (disposing)
+        {
+            ThemeManager.ThemeChanged -= OnThemeManagerOnThemeChanged;
+        }
+
+        base.Dispose (disposing);
+    }
+}

+ 127 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewPropertiesEditor.cs

@@ -0,0 +1,127 @@
+#nullable enable
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+public class ViewPropertiesEditor : EditorBase
+{
+    private CheckBox? _canFocusCheckBox;
+    private CheckBox? _enabledCheckBox;
+    private RadioGroup? _orientation;
+    private TextView? _text;
+
+    /// <inheritdoc/>
+    public override void EndInit ()
+    {
+        _canFocusCheckBox = new ()
+        {
+            Title = "CanFocus",
+            X = 0,
+            Y = 0,
+            CheckedState = ViewToEdit is { } ? ViewToEdit.CanFocus ? CheckState.Checked : CheckState.UnChecked : CheckState.UnChecked
+        };
+
+        _canFocusCheckBox.CheckedStateChanged += (s, args) =>
+                                                 {
+                                                     if (ViewToEdit is { })
+                                                     {
+                                                         ViewToEdit.CanFocus = _canFocusCheckBox.CheckedState == CheckState.Checked;
+                                                     }
+                                                 };
+        base.Add (_canFocusCheckBox);
+
+        _enabledCheckBox = new ()
+        {
+            Title = "Enabled",
+            X = Pos.Right (_canFocusCheckBox) + 1,
+            Y = Pos.Top (_canFocusCheckBox),
+            CheckedState = ViewToEdit is { } ? ViewToEdit.Enabled ? CheckState.Checked : CheckState.UnChecked : CheckState.UnChecked
+        };
+
+        _enabledCheckBox.CheckedStateChanged += (s, args) =>
+                                                {
+                                                    if (ViewToEdit is { })
+                                                    {
+                                                        ViewToEdit.Enabled = _enabledCheckBox.CheckedState == CheckState.Checked;
+                                                    }
+                                                };
+        base.Add (_enabledCheckBox);
+
+        Label label = new () { X = Pos.Right (_enabledCheckBox) + 1, Y = Pos.Top (_enabledCheckBox), Text = "Orientation:" };
+
+        _orientation = new ()
+        {
+            X = Pos.Right (label) + 1,
+            Y = Pos.Top (label),
+            RadioLabels = new [] { "Horizontal", "Vertical" },
+            Orientation = Orientation.Horizontal
+        };
+
+        _orientation.SelectedItemChanged += (s, selected) =>
+                                            {
+                                                if (ViewToEdit is IOrientation orientatedView)
+                                                {
+                                                    orientatedView.Orientation = (Orientation)_orientation.SelectedItem!;
+                                                }
+                                            };
+        Add (label, _orientation);
+
+        label = new () { X = 0, Y = Pos.Bottom (_orientation), Text = "Text:" };
+
+        _text = new ()
+        {
+            X = Pos.Right (label) + 1,
+            Y = Pos.Top (label),
+            Width = Dim.Fill (),
+            Height = Dim.Auto (minimumContentDim: 2),
+            Text = "This is demo text"
+        };
+
+        _text.ContentsChanged += (s, e) =>
+                                 {
+                                     if (ViewToEdit is { })
+                                     {
+                                         ViewToEdit.Text = _text.Text;
+                                     }
+                                 };
+
+        Add (label, _text);
+
+        base.EndInit ();
+    }
+
+    public string DemoText
+    {
+        get
+        {
+            if (_text is null)
+            {
+                return string.Empty;
+            }
+
+            return _text!.Text;
+        }
+        set => _text!.Text = value;
+    }
+
+    protected override void OnViewToEditChanged ()
+    {
+        Enabled = ViewToEdit is not Adornment;
+
+        if (ViewToEdit is { } and not Adornment)
+        {
+            _canFocusCheckBox!.CheckedState = ViewToEdit.CanFocus ? CheckState.Checked : CheckState.UnChecked;
+            _enabledCheckBox!.CheckedState = ViewToEdit.Enabled ? CheckState.Checked : CheckState.UnChecked;
+
+            if (ViewToEdit is IOrientation orientatedView)
+            {
+                _orientation!.SelectedItem = (int)orientatedView.Orientation;
+                _orientation.Enabled = true;
+            }
+            else
+            {
+                _orientation!.Enabled = false;
+            }
+        }
+    }
+}

+ 41 - 20
Examples/UICatalog/Scenarios/Editors/ViewportSettingsEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewportSettingsEditor.cs

@@ -17,19 +17,13 @@ public sealed class ViewportSettingsEditor : EditorBase
         Initialized += ViewportSettingsEditor_Initialized;
     }
 
-    protected override void OnUpdateSettings ()
+    protected override void OnViewToEditChanged ()
     {
         foreach (View subview in SubViews)
         {
             subview.Enabled = ViewToEdit is not Adornment;
         }
 
-        if (ViewToEdit is null)
-        { }
-    }
-
-    protected override void OnViewToEditChanged ()
-    {
         if (ViewToEdit is { } and not Adornment)
         {
             //ViewToEdit.VerticalScrollBar.AutoShow = true;
@@ -62,7 +56,11 @@ public sealed class ViewportSettingsEditor : EditorBase
                                                    ? CheckState.Checked
                                                    : CheckState.UnChecked;
 
-            _cbTransparent!.CheckedState = ViewToEdit.ViewportSettings.HasFlag(Terminal.Gui.ViewportSettings.Transparent)
+            _cbTransparent!.CheckedState = ViewToEdit.ViewportSettings.HasFlag (Terminal.Gui.ViewportSettings.Transparent)
+                                               ? CheckState.Checked
+                                               : CheckState.UnChecked;
+
+            _cbTransparentMouse!.CheckedState = ViewToEdit.ViewportSettings.HasFlag (Terminal.Gui.ViewportSettings.TransparentMouse)
                                                ? CheckState.Checked
                                                : CheckState.UnChecked;
 
@@ -82,6 +80,7 @@ public sealed class ViewportSettingsEditor : EditorBase
     private CheckBox? _cbClearContentOnly;
     private CheckBox? _cbClipContentOnly;
     private CheckBox? _cbTransparent;
+    private CheckBox? _cbTransparentMouse;
     private CheckBox? _cbVerticalScrollBar;
     private CheckBox? _cbAutoShowVerticalScrollBar;
     private CheckBox? _cbHorizontalScrollBar;
@@ -89,7 +88,7 @@ public sealed class ViewportSettingsEditor : EditorBase
 
     private void ViewportSettingsEditor_Initialized (object? s, EventArgs e)
     {
-        _cbAllowNegativeX = new()
+        _cbAllowNegativeX = new ()
         {
             Title = "Allow X < 0",
             CanFocus = true
@@ -97,7 +96,7 @@ public sealed class ViewportSettingsEditor : EditorBase
 
         Add (_cbAllowNegativeX);
 
-        _cbAllowNegativeY = new()
+        _cbAllowNegativeY = new ()
         {
             Title = "Allow Y < 0",
             CanFocus = true
@@ -105,7 +104,7 @@ public sealed class ViewportSettingsEditor : EditorBase
 
         Add (_cbAllowNegativeY);
 
-        _cbAllowXGreaterThanContentWidth = new()
+        _cbAllowXGreaterThanContentWidth = new ()
         {
             Title = "Allow X > Content Width",
             Y = Pos.Bottom (_cbAllowNegativeX),
@@ -141,7 +140,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             }
         }
 
-        _cbAllowYGreaterThanContentHeight = new()
+        _cbAllowYGreaterThanContentHeight = new ()
         {
             Title = "Allow Y > Content Height",
             X = Pos.Right (_cbAllowXGreaterThanContentWidth) + 1,
@@ -187,7 +186,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             Y = Pos.Bottom (_cbAllowYGreaterThanContentHeight)
         };
 
-        _contentSizeWidth = new()
+        _contentSizeWidth = new ()
         {
             X = Pos.Right (labelContentSize) + 1,
             Y = Pos.Top (labelContentSize),
@@ -215,7 +214,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             Y = Pos.Top (labelContentSize)
         };
 
-        _contentSizeHeight = new()
+        _contentSizeHeight = new ()
         {
             X = Pos.Right (labelComma) + 1,
             Y = Pos.Top (labelContentSize),
@@ -236,7 +235,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             ViewToEdit?.SetContentSize (ViewToEdit.GetContentSize () with { Height = e.NewValue });
         }
 
-        _cbClearContentOnly = new()
+        _cbClearContentOnly = new ()
         {
             Title = "ClearContentOnly",
             X = 0,
@@ -257,7 +256,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             }
         }
 
-        _cbClipContentOnly = new()
+        _cbClipContentOnly = new ()
         {
             Title = "ClipContentOnly",
             X = Pos.Right (_cbClearContentOnly) + 1,
@@ -299,7 +298,28 @@ public sealed class ViewportSettingsEditor : EditorBase
             }
         }
 
-        _cbVerticalScrollBar = new()
+        _cbTransparentMouse = new ()
+        {
+            Title = "TransparentMouse",
+            X = Pos.Right (_cbTransparent) + 1,
+            Y = Pos.Bottom (labelContentSize),
+            CanFocus = true
+        };
+        _cbTransparentMouse.CheckedStateChanging += TransparentMouseToggle;
+
+        void TransparentMouseToggle (object? sender, CancelEventArgs<CheckState> e)
+        {
+            if (e.NewValue == CheckState.Checked)
+            {
+                ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewportSettings.TransparentMouse;
+            }
+            else
+            {
+                ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewportSettings.TransparentMouse;
+            }
+        }
+
+        _cbVerticalScrollBar = new ()
         {
             Title = "VerticalScrollBar",
             X = 0,
@@ -313,7 +333,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             ViewToEdit!.VerticalScrollBar.Visible = e.NewValue == CheckState.Checked;
         }
 
-        _cbAutoShowVerticalScrollBar = new()
+        _cbAutoShowVerticalScrollBar = new ()
         {
             Title = "AutoShow",
             X = Pos.Right (_cbVerticalScrollBar) + 1,
@@ -327,7 +347,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             ViewToEdit!.VerticalScrollBar.AutoShow = e.NewValue == CheckState.Checked;
         }
 
-        _cbHorizontalScrollBar = new()
+        _cbHorizontalScrollBar = new ()
         {
             Title = "HorizontalScrollBar",
             X = 0,
@@ -341,7 +361,7 @@ public sealed class ViewportSettingsEditor : EditorBase
             ViewToEdit!.HorizontalScrollBar.Visible = e.NewValue == CheckState.Checked;
         }
 
-        _cbAutoShowHorizontalScrollBar = new()
+        _cbAutoShowHorizontalScrollBar = new ()
         {
             Title = "AutoShow ",
             X = Pos.Right (_cbHorizontalScrollBar) + 1,
@@ -363,6 +383,7 @@ public sealed class ViewportSettingsEditor : EditorBase
              _cbClearContentOnly,
              _cbClipContentOnly,
              _cbTransparent,
+             _cbTransparentMouse,
              _cbVerticalScrollBar,
              _cbHorizontalScrollBar,
              _cbAutoShowVerticalScrollBar,

+ 39 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/VisualRoleViewer.cs

@@ -0,0 +1,39 @@
+#nullable enable
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+public class VisualRoleViewer : View
+{
+    public VisualRoleViewer ()
+    {
+        CanFocus = false;
+        Height = Dim.Auto (DimAutoStyle.Text);
+        Width = Dim.Auto (DimAutoStyle.Text);
+    }
+
+    private VisualRole? _role;
+
+    public VisualRole? Role
+    {
+        get => _role;
+        set
+        {
+            _role = value;
+            Text = $"{Role?.ToString ()?.PadRight (10)} {SchemeName}";
+        }
+    }
+
+    /// <inheritdoc/>
+    protected override bool OnGettingAttributeForRole (in VisualRole role, ref Attribute currentAttribute)
+    {
+        if (role != Role)
+        {
+            currentAttribute = GetAttributeForRole (Role!.Value);
+
+            return true;
+        }
+
+        return base.OnGettingAttributeForRole (in role, ref currentAttribute);
+    }
+}

+ 9 - 9
Examples/UICatalog/Scenarios/GraphViewExample.cs

@@ -137,7 +137,7 @@ public class GraphViewExample : Scenario
         };
         app.Add (menu);
 
-        _graphView = new()
+        _graphView = new ()
         {
             X = 0,
             Y = 1,
@@ -161,7 +161,7 @@ public class GraphViewExample : Scenario
         };
 
         frameRight.Add (
-                        _about = new() { Width = Dim.Fill (), Height = Dim.Fill (), ReadOnly = true }
+                        _about = new () { Width = Dim.Fill (), Height = Dim.Fill (), ReadOnly = true }
                        );
 
         app.Add (frameRight);
@@ -239,9 +239,9 @@ public class GraphViewExample : Scenario
 
         _about.Text = "Housing Expenditures by income thirds 1996-2003";
 
-        Color fore = _graphView.ColorScheme.Normal.Foreground == Color.Black
+        Color fore = _graphView.GetAttributeForRole (VisualRole.Normal).Foreground == Color.Black
                          ? Color.White
-                         : _graphView.ColorScheme.Normal.Foreground;
+                         : _graphView.GetAttributeForRole (VisualRole.Normal).Foreground;
         var black = new Attribute (fore, Color.Black);
         var cyan = new Attribute (Color.BrightCyan, Color.Black);
         var magenta = new Attribute (Color.BrightMagenta, Color.Black);
@@ -398,7 +398,7 @@ public class GraphViewExample : Scenario
 
         var barSeries = new BarSeries
         {
-            Bars = new()
+            Bars = new ()
             {
                 new ("Switzerland", softStiple, 83.4f),
                 new (
@@ -533,7 +533,7 @@ public class GraphViewExample : Scenario
 
         _about.Text = "This graph shows random points";
 
-        var black = new Attribute (_graphView.ColorScheme.Normal.Foreground, Color.Black);
+        var black = new Attribute (_graphView.GetAttributeForRole (VisualRole.Normal).Foreground, Color.Black, _graphView.GetAttributeForRole (VisualRole.Normal).Style);
         var cyan = new Attribute (Color.BrightCyan, Color.Black);
         var magenta = new Attribute (Color.BrightMagenta, Color.Black);
         var red = new Attribute (Color.BrightRed, Color.Black);
@@ -621,7 +621,7 @@ public class GraphViewExample : Scenario
         _graphView.Series.Add (
                                new ScatterSeries
                                {
-                                   Points = new()
+                                   Points = new ()
                                    {
                                        new (1, 1.007f),
                                        new (2, 4.002f),
@@ -825,7 +825,7 @@ public class GraphViewExample : Scenario
         var malesSeries = new BarSeries
         {
             Orientation = Orientation.Horizontal,
-            Bars = new()
+            Bars = new ()
             {
                 new ("0-4", stiple, -2009363),
                 new ("5-9", stiple, -2108550),
@@ -856,7 +856,7 @@ public class GraphViewExample : Scenario
         var femalesSeries = new BarSeries
         {
             Orientation = Orientation.Horizontal,
-            Bars = new()
+            Bars = new ()
             {
                 new ("0-4", stiple, 1915127),
                 new ("5-9", stiple, 2011016),

+ 12 - 12
Examples/UICatalog/Scenarios/HexEditor.cs

@@ -15,7 +15,7 @@ public class HexEditor : Scenario
 {
     private string? _fileName;
     private HexView? _hexView;
-    private MenuItemv2? _miAllowEdits;
+    private MenuItemv2? _miReadOnly;
     private bool _saved = true;
     private Shortcut? _scAddress;
     private Shortcut? _scInfo;
@@ -26,9 +26,9 @@ public class HexEditor : Scenario
     {
         Application.Init ();
 
-        var app = new Toplevel
+        var app = new Window ()
         {
-            ColorScheme = Colors.ColorSchemes ["Base"]
+            BorderStyle = LineStyle.None
         };
 
         _fileName = "demo.bin";
@@ -78,10 +78,10 @@ public class HexEditor : Scenario
                      "_Options",
                      new MenuItemv2 []
                      {
-                         _miAllowEdits = new (
-                                              "_AllowEdits",
+                         _miReadOnly = new (
+                                              "_Read Only",
                                               "",
-                                              ToggleAllowEdits
+                                              ToggleReadOnly
                                              )
                          {
 
@@ -93,10 +93,10 @@ public class HexEditor : Scenario
 
         CheckBox cb = new CheckBox ()
         {
-            Title = _miAllowEdits.Title,
-            CheckedState = _hexView.AllowEdits ? CheckState.Checked : CheckState.None,
+            Title = _miReadOnly.Title,
+            CheckedState = _hexView.ReadOnly ? CheckState.Checked : CheckState.None,
         };
-        _miAllowEdits.CommandView = cb;
+        _miReadOnly.CommandView = cb;
         app.Add (menu);
 
         var addressWidthUpDown = new NumericUpDown
@@ -292,13 +292,13 @@ public class HexEditor : Scenario
         }
     }
 
-    private void ToggleAllowEdits ()
+    private void ToggleReadOnly ()
     {
-        if (_miAllowEdits?.CommandView is not CheckBox cb)
+        if (_miReadOnly?.CommandView is not CheckBox cb)
         {
             return;
         }
 
-        _hexView!.AllowEdits = cb.CheckedState == CheckState.Checked;
+        _hexView!.ReadOnly = cb.CheckedState == CheckState.Checked;
     }
 }

+ 0 - 57
Examples/UICatalog/Scenarios/InvertColors.cs

@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios;
-
-[ScenarioMetadata ("Invert Colors", "Invert the foreground and the background colors.")]
-[ScenarioCategory ("Colors")]
-[ScenarioCategory ("Text and Formatting")]
-public class InvertColors : Scenario
-{
-    public override void Main ()
-    {
-        Application.Init ();
-        var win = new Window
-        {
-            Title = GetQuitKeyAndName (),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"]
-        };
-
-        List<Label> labels = new ();
-        ColorName16 [] foreColors = Enum.GetValues (typeof (ColorName16)).Cast<ColorName16> ().ToArray ();
-
-        for (var y = 0; y < foreColors.Length; y++)
-        {
-            ColorName16 fore = foreColors [y];
-            ColorName16 back = foreColors [(y + 1) % foreColors.Length];
-            var color = new Attribute (fore, back);
-
-            var label = new Label { ColorScheme = new ColorScheme (), Y = y, Text = $"{fore} on {back}" };
-            label.ColorScheme = new ColorScheme (label.ColorScheme) { Normal = color };
-            win.Add (label);
-            labels.Add (label);
-        }
-
-        var button = new Button { X = Pos.Center (), Y = foreColors.Length + 1, Text = "Invert color!" };
-
-        button.Accepting += (s, e) =>
-                          {
-                              foreach (Label label in labels)
-                              {
-                                  Attribute color = label.ColorScheme.Normal;
-                                  color = new Attribute (color.Background, color.Foreground);
-
-                                  label.ColorScheme = new ColorScheme (label.ColorScheme) { Normal = color };
-                                  label.Text = $"{color.Foreground} on {color.Background}";
-                                  label.SetNeedsDraw ();
-                              }
-                          };
-        win.Add (button);
-
-        Application.Run (win);
-        win.Dispose ();
-        Application.Shutdown ();
-    }
-}

+ 4 - 4
Examples/UICatalog/Scenarios/Keys.cs

@@ -87,7 +87,7 @@ public class Keys : Scenario
             Height = Dim.Fill (),
             Source = new ListWrapper<string> (keyList)
         };
-        appKeyListView.ColorScheme = Colors.ColorSchemes ["TopLevel"];
+        appKeyListView.SchemeName = "TopLevel";
         win.Add (appKeyListView);
 
         // View key events...
@@ -115,7 +115,7 @@ public class Keys : Scenario
             Height = Dim.Fill (),
             Source = new ListWrapper<string> (keyDownList)
         };
-        onKeyDownListView.ColorScheme = Colors.ColorSchemes ["TopLevel"];
+        appKeyListView.SchemeName = "TopLevel";
         win.Add (onKeyDownListView);
 
         // KeyDownNotHandled
@@ -135,7 +135,7 @@ public class Keys : Scenario
             Height = Dim.Fill (),
             Source = new ListWrapper<string> (keyDownNotHandledList)
         };
-        onKeyDownNotHandledListView.ColorScheme = Colors.ColorSchemes ["TopLevel"];
+        appKeyListView.SchemeName = "TopLevel";
         win.Add (onKeyDownNotHandledListView);
 
 
@@ -156,7 +156,7 @@ public class Keys : Scenario
             Height = Dim.Fill (),
             Source = new ListWrapper<string> (swallowedList)
         };
-        onSwallowedListView.ColorScheme = Colors.ColorSchemes ["TopLevel"];
+        appKeyListView.SchemeName = "TopLevel";
         win.Add (onSwallowedListView);
 
         if (Application.Driver is IConsoleDriverFacade fac)

+ 6 - 6
Examples/UICatalog/Scenarios/LineCanvasExperiment.cs

@@ -25,7 +25,7 @@ public class LineCanvasExperiment : Scenario
             Y = 0,
             Width = Dim.Fill (),
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Base"]
+            SchemeName = "Base"
            ,
             SuperViewRendersLineCanvas = true
         };
@@ -58,7 +58,7 @@ public class LineCanvasExperiment : Scenario
             Width = Dim.Percent (30),
             Height = Dim.Percent (70),
 
-            //ColorScheme = Colors.ColorSchemes ["Error"],
+            //Scheme = Colors.Schemes ["Error"],
             SuperViewRendersLineCanvas = true
         };
 
@@ -72,7 +72,7 @@ public class LineCanvasExperiment : Scenario
             Height = Dim.Fill (),
             SuperViewRendersLineCanvas = true
 
-            //ColorScheme = Colors.ColorSchemes ["Menu"],
+            //Scheme = Colors.Schemes ["Menu"],
         };
 
         win2.Add (subViewOfWin2);
@@ -102,7 +102,7 @@ public class LineCanvasExperiment : Scenario
         //    Width = view4.Width,
         //    Height = 5,
 
-        //    //ColorScheme = Colors.ColorSchemes ["TopLevel"],
+        //    //Scheme = Colors.Schemes ["TopLevel"],
         //    SuperViewRendersLineCanvas = true,
         //    BorderStyle = LineStyle.Double
         //};
@@ -128,10 +128,10 @@ public class LineCanvasExperiment : Scenario
         //    Width = 25,
         //    Height = 10,
 
-        //    //ColorScheme = Colors.ColorSchemes ["Error"],
+        //    //Scheme = Colors.Schemes ["Error"],
         //    SuperViewRendersLineCanvas = true
         //};
-        //marginWindow.Margin.ColorScheme = Colors.ColorSchemes ["Error"];
+        //marginWindow.Margin.Scheme = Colors.Schemes ["Error"];
         //marginWindow.Margin.Thickness = new (1);
         //marginWindow.Border.Thickness = new (1, 2, 1, 1);
 

+ 10 - 10
Examples/UICatalog/Scenarios/LineDrawing.cs

@@ -120,7 +120,7 @@ public class LineDrawing : Scenario
 
         win.Add (canvas);
         win.Add (tools);
-        tools.CurrentColor = canvas.GetNormalColor ();
+        tools.CurrentColor = canvas.GetAttributeForRole (VisualRole.Normal);
         canvas.CurrentAttribute = tools.CurrentColor;
 
         win.KeyDown += (s, e) => { e.Handled = canvas.NewKeyDownEvent (e); };
@@ -235,14 +235,14 @@ public class ToolsView : Window
 
         _colors.ValueChanged += (s, e) => ColorChanged?.Invoke (this, e);
 
-        _stylePicker = new()
+        _stylePicker = new ()
         {
             X = 0, Y = Pos.Bottom (_colors), RadioLabels = Enum.GetNames (typeof (LineStyle)).ToArray ()
         };
         _stylePicker.SelectedItemChanged += (s, a) => { SetStyle?.Invoke ((LineStyle)a.SelectedItem); };
         _stylePicker.SelectedItem = 1;
 
-        _addLayerBtn = new() { Text = "New Layer", X = Pos.Center (), Y = Pos.Bottom (_stylePicker) };
+        _addLayerBtn = new () { Text = "New Layer", X = Pos.Center (), Y = Pos.Bottom (_stylePicker) };
 
         _addLayerBtn.Accepting += (s, a) => AddLayer?.Invoke ();
         Add (_colors, _stylePicker, _addLayerBtn);
@@ -276,7 +276,7 @@ public class DrawingArea : View
             {
                 if (c.Value is { })
                 {
-                    SetCurrentAttribute (c.Value.Value.Attribute ?? ColorScheme.Normal);
+                    SetCurrentAttribute (c.Value.Value.Attribute ?? GetAttributeForRole (VisualRole.Normal));
 
                     // TODO: #2616 - Support combining sequences that don't normalize
                     AddRune (c.Key.X, c.Key.Y, c.Value.Value.Rune);
@@ -286,7 +286,7 @@ public class DrawingArea : View
 
         // TODO: This is a hack to work around overlapped views not drawing correctly.
         // without this the toolbox disappears
-        SuperView?.SetNeedsLayout();
+        SuperView?.SetNeedsLayout ();
 
         return true;
     }
@@ -356,13 +356,13 @@ public class AttributeView : View
         }
     }
 
-    private static readonly HashSet<(int, int)> ForegroundPoints = new()
+    private static readonly HashSet<(int, int)> ForegroundPoints = new ()
     {
         (0, 0), (1, 0), (2, 0),
         (0, 1), (1, 1), (2, 1)
     };
 
-    private static readonly HashSet<(int, int)> BackgroundPoints = new()
+    private static readonly HashSet<(int, int)> BackgroundPoints = new ()
     {
         (3, 1),
         (1, 2), (2, 2), (3, 2)
@@ -380,8 +380,8 @@ public class AttributeView : View
         Color fg = Value.Foreground;
         Color bg = Value.Background;
 
-        bool isTransparentFg = fg == GetNormalColor ().Background;
-        bool isTransparentBg = bg == GetNormalColor ().Background;
+        bool isTransparentFg = fg == GetAttributeForRole (VisualRole.Normal).Background;
+        bool isTransparentBg = bg == GetAttributeForRole (VisualRole.Normal).Background;
 
         SetAttribute (new (fg, isTransparentFg ? Color.Gray : fg));
 
@@ -457,7 +457,7 @@ public class AttributeView : View
     {
         if (LineDrawing.PromptForColor ("Background", Value.Background, out Color newColor))
         {
-            Value = new (Value.Foreground, newColor);
+            Value = new (Value.Foreground, newColor, Value.Style);
             SetNeedsDraw ();
         }
     }

+ 6 - 6
Examples/UICatalog/Scenarios/ListColumns.cs

@@ -14,7 +14,7 @@ namespace UICatalog.Scenarios;
 [ScenarioCategory ("Scrolling")]
 public class ListColumns : Scenario
 {
-    private ColorScheme _alternatingColorScheme;
+    private Scheme _alternatingScheme;
     private DataTable _currentTable;
     private TableView _listColView;
     private MenuItem _miAlternatingColors;
@@ -238,11 +238,11 @@ public class ListColumns : Scenario
 
         //SetupScrollBar ();
 
-        _alternatingColorScheme = new ()
+        _alternatingScheme = new ()
         {
-            Disabled = appWindow.ColorScheme.Disabled,
-            HotFocus = appWindow.ColorScheme.HotFocus,
-            Focus = appWindow.ColorScheme.Focus,
+            Disabled = appWindow.GetAttributeForRole(VisualRole.Disabled),
+            HotFocus = appWindow.GetAttributeForRole (VisualRole.HotFocus),
+            Focus = appWindow.GetAttributeForRole(VisualRole.Focus),
             Normal = new (Color.White, Color.BrightBlue)
         };
 
@@ -382,7 +382,7 @@ public class ListColumns : Scenario
 
         if (_miAlternatingColors.Checked == true)
         {
-            _listColView.Style.RowColorGetter = a => { return a.RowIndex % 2 == 0 ? _alternatingColorScheme : null; };
+            _listColView.Style.RowColorGetter = a => { return a.RowIndex % 2 == 0 ? _alternatingScheme : null; };
         }
         else
         {

+ 1 - 1
Examples/UICatalog/Scenarios/ListViewWithSelection.cs

@@ -99,7 +99,7 @@ public class ListViewWithSelection : Scenario
             Height = Dim.Fill (),
             Source = new ListWrapper<string> (_eventList)
         };
-        _eventListView.ColorScheme = Colors.ColorSchemes ["TopLevel"];
+        _eventListView.SchemeName = "TopLevel";
         _appWindow.Add (_eventListView);
 
         _listView.SelectedItemChanged += (s, a) => LogEvent (s as View, a, "SelectedItemChanged");

+ 3 - 3
Examples/UICatalog/Scenarios/ListsAndCombos.cs

@@ -36,7 +36,7 @@ public class ListsAndCombos : Scenario
         // ListView
         var lbListView = new Label
         {
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             X = 0,
 
             Width = Dim.Percent (40),
@@ -46,7 +46,7 @@ public class ListsAndCombos : Scenario
         var listview = new ListView
         {
             X = 0,
-            Y = Pos.Bottom (lbListView) + 1,
+            Y = Pos.Bottom (lbListView) + 2,
             Height = Dim.Fill (2),
             Width = Dim.Percent (40),
             Source = new ListWrapper<string> (items)
@@ -92,7 +92,7 @@ public class ListsAndCombos : Scenario
         // ComboBox
         var lbComboBox = new Label
         {
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             X = Pos.Right (lbListView) + 1,
 
             Width = Dim.Percent (40),

+ 5 - 5
Examples/UICatalog/Scenarios/Mazing.cs

@@ -67,14 +67,14 @@ public class Mazing : Scenario
                                    top.AddStr ("e");
 
                                    top.Move (_m.Player.X, _m.Player.Y);
-                                   top.SetAttribute (new (Color.Cyan, top.GetNormalColor ().Background));
+                                   top.SetAttribute (new (Color.Cyan, top.GetAttributeForRole (VisualRole.Normal).Background));
                                    top.AddStr (_dead ? "x" : "@");
 
                                    // Draw goblins
                                    foreach (Point goblin in _goblins!)
                                    {
                                        top.Move (goblin.X, goblin.Y);
-                                       top.SetAttribute (new (Color.Red, top.GetNormalColor ().Background));
+                                       top.SetAttribute (new (Color.Red, top.GetAttributeForRole (VisualRole.Normal).Background));
                                        top.AddStr ("G");
                                    }
 
@@ -82,12 +82,12 @@ public class Mazing : Scenario
                                    foreach (Point potion in _potions!)
                                    {
                                        top.Move (potion.X, potion.Y);
-                                       top.SetAttribute (new (Color.Yellow, top.GetNormalColor ().Background));
+                                       top.SetAttribute (new (Color.Yellow, top.GetAttributeForRole (VisualRole.Normal).Background));
                                        top.AddStr ("p");
                                    }
 
                                    // Draw UI
-                                   top.SetAttribute (top.GetNormalColor ());
+                                   top.SetAttribute (top.GetAttributeForRole (VisualRole.Normal));
 
                                    var g = new Gradient ([new (Color.Red), new (Color.BrightGreen)], [10]);
                                    top.Move (_m.MazeWidth + 1, 0);
@@ -102,7 +102,7 @@ public class Mazing : Scenario
                                        top.AddRune ('█');
                                    }
 
-                                   top.SetAttribute (top.GetNormalColor ());
+                                   top.SetAttribute (top.GetAttributeForRole (VisualRole.Normal));
 
                                    if (!string.IsNullOrWhiteSpace (_message))
                                    {

+ 1 - 1
Examples/UICatalog/Scenarios/Menus.cs

@@ -33,7 +33,7 @@ public class Menus : Scenario
             X = Pos.AnchorEnd (),
             Width = Dim.Auto (),
             Height = Dim.Fill (), // Make room for some wide things
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "TopLevel",
             Source = new ListWrapper<string> (eventSource)
         };
         eventLog.Border!.Thickness = new (0, 1, 0, 0);

+ 1 - 1
Examples/UICatalog/Scenarios/MessageBoxes.cs

@@ -221,7 +221,7 @@ public class MessageBoxes : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (label) + 1,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             TextAlignment = Alignment.Center,
             Text = " "
         };

+ 7 - 7
Examples/UICatalog/Scenarios/Mouse.cs

@@ -205,7 +205,7 @@ public class Mouse : Scenario
             Y = Pos.Bottom (label),
             Width = 50,
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Source = new ListWrapper<string> (appLogList)
         };
         win.Add (label, appLog);
@@ -236,7 +236,7 @@ public class Mouse : Scenario
             Y = Pos.Bottom (label),
             Width = Dim.Percent (50),
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Source = new ListWrapper<string> (winLogList)
         };
         win.Add (label, winLog);
@@ -278,7 +278,7 @@ public class Mouse : Scenario
             CanFocus = true;
             Id = "mouseEventDemoView";
 
-            Padding.Thickness = new Thickness (1, 1, 1, 1);
+            Padding!.Thickness = new Thickness (1, 1, 1, 1);
 
             Initialized += OnInitialized;
 
@@ -287,22 +287,22 @@ public class Mouse : Scenario
                 TextAlignment = Alignment.Center;
                 VerticalTextAlignment = Alignment.Center;
 
-                Padding.ColorScheme = new ColorScheme (new Attribute (Color.Black));
+                Padding!.SetScheme (new Scheme (new Attribute (Color.Black)));
 
                 Padding.MouseEnter += PaddingOnMouseEnter;
                 Padding.MouseLeave += PaddingOnMouseLeave;
 
                 void PaddingOnMouseEnter (object o, CancelEventArgs e)
                 {
-                    Padding.ColorScheme = Colors.ColorSchemes ["Error"];
+                    Padding.SchemeName = "Error";
                 }
 
                 void PaddingOnMouseLeave (object o, EventArgs e)
                 {
-                    Padding.ColorScheme = Colors.ColorSchemes ["Dialog"];
+                    Padding.SchemeName = "Dialog";
                 }
 
-                Border.Thickness = new Thickness (1);
+                Border!.Thickness = new Thickness (1);
                 Border.LineStyle = LineStyle.Rounded;
             }
 

+ 5 - 5
Examples/UICatalog/Scenarios/MultiColouredTable.cs

@@ -55,13 +55,13 @@ public class MultiColouredTable : Scenario
         dt.Rows.Add (DBNull.Value, DBNull.Value);
         dt.Rows.Add (DBNull.Value, DBNull.Value);
 
-        _tableView.ColorScheme = new ()
+        _tableView.SetScheme (new ()
         {
-            Disabled = appWindow.ColorScheme.Disabled,
-            HotFocus = appWindow.ColorScheme.HotFocus,
-            Focus = appWindow.ColorScheme.Focus,
+            Disabled = appWindow.GetAttributeForRole (VisualRole.Disabled),
+            HotFocus = appWindow.GetAttributeForRole (VisualRole.HotFocus),
+            Focus = appWindow.GetAttributeForRole (VisualRole.Focus),
             Normal = new (Color.DarkGray, Color.Black)
-        };
+        });
 
         _tableView.Table = new DataTableSource (_table = dt);
 

+ 6 - 6
Examples/UICatalog/Scenarios/Navigation.cs

@@ -32,7 +32,7 @@ public class Navigation : Scenario
         };
         app.Add (adornmentsEditor);
 
-        var arrangementEditor = new ArrangementEditor()
+        var arrangementEditor = new ArrangementEditor ()
         {
             X = Pos.Right (adornmentsEditor),
             Y = 0,
@@ -179,7 +179,7 @@ public class Navigation : Scenario
         };
         colorPicker.ApplyStyleChanges ();
 
-        colorPicker.SelectedColor = testFrame.ColorScheme.Normal.Background;
+        colorPicker.SelectedColor = testFrame.GetAttributeForRole (VisualRole.Normal).Background;
         colorPicker.ColorChanged += ColorPicker_ColorChanged;
         overlappedView2.Add (colorPicker);
         overlappedView2.Width = 50;
@@ -192,7 +192,7 @@ public class Navigation : Scenario
             X = 1,
             Y = 7,
             Id = "datePicker",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "TopLevel",
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,
             CanFocus = true, // Can't drag without this? BUGBUG
@@ -215,7 +215,7 @@ public class Navigation : Scenario
 
         testFrame.SetFocus ();
         Application.Run (app);
-       // timer.Close ();
+        // timer.Close ();
         app.Dispose ();
         Application.Shutdown ();
 
@@ -223,7 +223,7 @@ public class Navigation : Scenario
 
         void ColorPicker_ColorChanged (object sender, ColorEventArgs e)
         {
-            testFrame.ColorScheme = testFrame.ColorScheme with { Normal = new (testFrame.ColorScheme.Normal.Foreground, e.CurrentValue) };
+            testFrame.SetScheme (testFrame.GetScheme () with { Normal = new (testFrame.GetAttributeForRole (VisualRole.Normal).Foreground, e.CurrentValue) });
         }
     }
 
@@ -236,7 +236,7 @@ public class Navigation : Scenario
             Height = Dim.Auto (),
             Width = Dim.Auto (),
             Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "TopLevel",
             Id = $"Overlapped{id}",
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,

+ 9 - 9
Examples/UICatalog/Scenarios/NumericUpDownDemo.cs

@@ -128,16 +128,16 @@ internal class NumericUpDownEditor<T> : View where T : notnull
                         _numericUpDown.Value = (T)Convert.ChangeType (_value.Text, typeof (T));
                     }
 
-                    _value.ColorScheme = SuperView!.ColorScheme;
+                    _value.SetScheme (SuperView!.GetScheme ());
 
                 }
                 catch (System.FormatException)
                 {
-                    _value.ColorScheme = Colors.ColorSchemes ["Error"];
+                    _value.SchemeName = "Error";
                 }
                 catch (InvalidCastException)
                 {
-                    _value.ColorScheme = Colors.ColorSchemes ["Error"];
+                    _value.SchemeName = "Error";
                 }
                 finally
                 {
@@ -176,16 +176,16 @@ internal class NumericUpDownEditor<T> : View where T : notnull
                     _ = string.Format (_format.Text, _value);
                     _numericUpDown.Format = _format.Text;
 
-                    _format.ColorScheme = SuperView!.ColorScheme;
+                    _format.SetScheme (SuperView!.GetScheme ());
 
                 }
                 catch (System.FormatException)
                 {
-                    _format.ColorScheme = Colors.ColorSchemes ["Error"];
+                    _format.SchemeName = "Error";
                 }
                 catch (InvalidCastException)
                 {
-                    _format.ColorScheme = Colors.ColorSchemes ["Error"];
+                    _format.SchemeName = "Error";
                 }
                 finally
                 {
@@ -231,16 +231,16 @@ internal class NumericUpDownEditor<T> : View where T : notnull
                         _numericUpDown.Increment = (T)Convert.ChangeType (_increment.Text, typeof (T));
                     }
 
-                    _increment.ColorScheme = SuperView!.ColorScheme;
+                    _increment.SetScheme (SuperView!.GetScheme ());
 
                 }
                 catch (System.FormatException)
                 {
-                    _increment.ColorScheme = Colors.ColorSchemes ["Error"];
+                    _increment.SchemeName = "Error";
                 }
                 catch (InvalidCastException)
                 {
-                    _increment.ColorScheme = Colors.ColorSchemes ["Error"];
+                    _increment.SchemeName = "Error";
                 }
                 finally
                 {

+ 10 - 10
Examples/UICatalog/Scenarios/PosAlignDemo.cs

@@ -25,9 +25,9 @@ public sealed class PosAlignDemo : Scenario
             Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()} - {GetDescription ()}"
         };
 
-        SetupControls (appWindow, Dimension.Width, Colors.ColorSchemes ["TopLevel"]);
+        SetupControls (appWindow, Dimension.Width, Schemes.Toplevel);
 
-        SetupControls (appWindow, Dimension.Height, Colors.ColorSchemes ["Error"]);
+        SetupControls (appWindow, Dimension.Height, Schemes.Error);
 
         Setup3By3Grid (appWindow);
 
@@ -39,12 +39,12 @@ public sealed class PosAlignDemo : Scenario
         Application.Shutdown ();
     }
 
-    private void SetupControls (Window appWindow, Dimension dimension, ColorScheme colorScheme)
+    private void SetupControls (Window appWindow, Dimension dimension, Schemes scheme)
     {
         RadioGroup alignRadioGroup = new ()
         {
             RadioLabels = Enum.GetNames<Alignment> (),
-            ColorScheme = colorScheme
+            SchemeName = SchemeManager.SchemesToSchemeName (scheme),
         };
 
         if (dimension == Dimension.Width)
@@ -81,7 +81,7 @@ public sealed class PosAlignDemo : Scenario
 
         CheckBox endToStartCheckBox = new ()
         {
-            ColorScheme = colorScheme,
+            SchemeName = SchemeManager.SchemesToSchemeName (scheme),
             Text = "EndToStart"
         };
 
@@ -119,7 +119,7 @@ public sealed class PosAlignDemo : Scenario
 
         CheckBox ignoreFirstOrLast = new ()
         {
-            ColorScheme = colorScheme,
+            SchemeName = SchemeManager.SchemesToSchemeName (scheme),
             Text = "IgnoreFirstOrLast"
         };
 
@@ -157,7 +157,7 @@ public sealed class PosAlignDemo : Scenario
 
         CheckBox addSpacesBetweenItems = new ()
         {
-            ColorScheme = colorScheme,
+            SchemeName = SchemeManager.SchemesToSchemeName (scheme),
             Text = "AddSpaceBetweenItems"
         };
 
@@ -196,7 +196,7 @@ public sealed class PosAlignDemo : Scenario
 
         CheckBox margin = new ()
         {
-            ColorScheme = colorScheme,
+            SchemeName = SchemeManager.SchemesToSchemeName (scheme),
             Text = "Margin"
         };
 
@@ -240,7 +240,7 @@ public sealed class PosAlignDemo : Scenario
         {
             Width = 9,
             Title = "Added",
-            ColorScheme = colorScheme,
+            SchemeName = SchemeManager.SchemesToSchemeName (scheme),
             BorderStyle = LineStyle.None,
             Value = addedViews.Count
         };
@@ -353,7 +353,7 @@ public sealed class PosAlignDemo : Scenario
             Height = Dim.Percent (40)
         };
         container.Padding.Thickness = new (8, 1, 0, 0);
-        container.Padding.ColorScheme = Colors.ColorSchemes ["error"];
+        container.Padding.SchemeName = "Error";
 
         Aligner widthAligner = new () { AlignmentModes = AlignmentModes.StartToEnd };
 

+ 3 - 3
Examples/UICatalog/Scenarios/Progress.cs

@@ -175,7 +175,7 @@ public class Progress : Scenario
 
         internal ProgressDemo ()
         {
-            ColorScheme = Colors.ColorSchemes ["Dialog"];
+            SchemeName = "Dialog";
 
             LeftFrame = new FrameView
             {
@@ -214,7 +214,7 @@ public class Progress : Scenario
                 Width = Dim.Fill () - 1,
                 Height = 1,
                 Fraction = 0.25F,
-                ColorScheme = Colors.ColorSchemes ["Error"]
+                SchemeName = "Error"
             };
             Add (ActivityProgressBar);
 
@@ -233,7 +233,7 @@ public class Progress : Scenario
                 Y = Pos.Bottom (ActivityProgressBar) + 1,
                 Width = Dim.Fill () - Spinner.Width,
                 Height = 1,
-                ColorScheme = Colors.ColorSchemes ["Error"]
+                SchemeName = "Error"
             };
             Add (PulseProgressBar);
 

+ 17 - 15
Examples/UICatalog/Scenarios/ProgressBarStyles.cs

@@ -78,22 +78,23 @@ public class ProgressBarStyles : Scenario
                                     {
                                         if (!LineDrawing.PromptForColor (
                                                                          fgColorPickerBtn.Text,
-                                                                         editor.ViewToEdit.ColorScheme.HotNormal.Foreground,
+                                                                         editor.ViewToEdit!.GetAttributeForRole (VisualRole.Normal).Foreground,
                                                                          out var newColor
                                                                         ))
                                         {
                                             return;
                                         }
 
-                                        var cs = new ColorScheme (editor.ViewToEdit.ColorScheme)
+                                        var cs = new Scheme (editor.ViewToEdit.GetScheme ())
                                         {
-                                            HotNormal = new Attribute (
+                                            Active = new Attribute (
                                                                        newColor,
-                                                                       editor.ViewToEdit.ColorScheme.HotNormal
-                                                                             .Background
+                                                                       editor.ViewToEdit.GetAttributeForRole (VisualRole.Active)
+                                                                             .Background,
+                                                                          editor.ViewToEdit.GetAttributeForRole (VisualRole.Active).Style
                                                                       )
                                         };
-                                        editor.ViewToEdit.ColorScheme = cs;
+                                        editor.ViewToEdit.SetScheme (cs);
                                     };
 
         var bgColorPickerBtn = new Button
@@ -108,22 +109,23 @@ public class ProgressBarStyles : Scenario
                                     {
                                         if (!LineDrawing.PromptForColor (
                                                                          fgColorPickerBtn.Text,
-                                                                         editor.ViewToEdit.ColorScheme.HotNormal.Background
+                                                                         editor.ViewToEdit!.GetAttributeForRole (VisualRole.Active)
+                                                                               .Background
                                                                         , out var newColor))
 
                                         {
                                             return;
                                         }
 
-                                        var cs = new ColorScheme (editor.ViewToEdit.ColorScheme)
+                                        var cs = new Scheme (editor.ViewToEdit.GetScheme ())
                                         {
-                                            HotNormal = new Attribute (
-                                                                       editor.ViewToEdit.ColorScheme.HotNormal
-                                                                             .Foreground,
-                                                                       newColor
-                                                                      )
+                                            Active = new Attribute (
+                                                                    editor.ViewToEdit!.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                    newColor,
+                                                                    editor.ViewToEdit!.GetAttributeForRole (VisualRole.Normal).Style
+                                                                   )
                                         };
-                                        editor.ViewToEdit.ColorScheme = cs;
+                                        editor.ViewToEdit.SetScheme (cs);
                                     };
 
         #endregion
@@ -210,7 +212,7 @@ public class ProgressBarStyles : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (continuousPB),
-            Text = "BidirectionalMarquee", 
+            Text = "BidirectionalMarquee",
             CheckedState = CheckState.Checked
         };
         container.Add (ckbBidirectional);

+ 6 - 6
Examples/UICatalog/Scenarios/RegionScenario.cs

@@ -37,7 +37,7 @@ public class RegionScenario : Scenario
 
         var tools = new ToolsView { Title = "Tools", X = Pos.AnchorEnd (), Y = 2 };
 
-        tools.CurrentAttribute = app.ColorScheme!.HotNormal;
+        tools.CurrentAttribute = app.GetAttributeForRole (VisualRole.HotNormal);
 
         tools.SetStyle += b =>
                           {
@@ -123,7 +123,7 @@ public class RegionScenario : Scenario
                                                                     app.LineCanvas,
                                                                     LineStyle.Dashed,
                                                                     new (
-                                                                         tools.CurrentAttribute!.Value.Foreground.GetHighlightColor (),
+                                                                         tools.CurrentAttribute!.Value.Foreground.GetBrighterColor (),
                                                                          tools.CurrentAttribute!.Value.Background));
                                   }
                               };
@@ -204,7 +204,7 @@ public class ToolsView : Window
         _stylePicker.Border!.Thickness = new (0, 1, 0, 0);
         _stylePicker.Title = "Draw Style";
 
-        _stylePicker.SelectedItemChanged += (s, a) => { SetStyle?.Invoke ((LineStyle)a.SelectedItem); };
+        _stylePicker.SelectedItemChanged += (s, a) => { SetStyle?.Invoke ((LineStyle)a.SelectedItem!); };
         _stylePicker.SelectedItem = (int)RegionDrawStyles.FillOnly;
 
         _regionOpSelector = new ()
@@ -245,7 +245,7 @@ public class RegionOpSelector : View
             Y = 0,
             RadioLabels = Enum.GetNames<RegionOp> ().Select (n => n = "_" + n).ToArray ()
         };
-        _radioGroup.SelectedItemChanged += (s, a) => { SelectedItemChanged?.Invoke (this, (RegionOp)a.SelectedItem); };
+        _radioGroup.SelectedItemChanged += (s, a) => { SelectedItemChanged?.Invoke (this, (RegionOp)a.SelectedItem!); };
         Add (_radioGroup);
     }
 
@@ -301,8 +301,8 @@ public class AttributeView : View
         Color fg = Value?.Foreground ?? Color.Black;
         Color bg = Value?.Background ?? Color.Black;
 
-        bool isTransparentFg = fg == GetNormalColor ().Background;
-        bool isTransparentBg = bg == GetNormalColor ().Background;
+        bool isTransparentFg = fg == GetAttributeForRole (VisualRole.Normal).Background;
+        bool isTransparentBg = bg == GetAttributeForRole (VisualRole.Normal).Background;
 
         SetAttribute (new (fg, isTransparentFg ? Color.Gray : fg));
 

+ 1 - 1
Examples/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs

@@ -75,7 +75,7 @@ public class RuneWidthGreaterThanOne : Scenario
 
         _label = new Label
         {
-            X = Pos.Center (), Y = 1, ColorScheme = new ColorScheme { Normal = Colors.ColorSchemes ["Base"].Focus }
+            X = Pos.Center (), Y = 1,
         };
         _text = new TextField { X = Pos.Center (), Y = 3, Width = 20 };
         _button = new Button { X = Pos.Center (), Y = 5 };

+ 2 - 2
Examples/UICatalog/Scenarios/ScrollBarDemo.cs

@@ -25,7 +25,7 @@ public class ScrollBarDemo : Scenario
             X = 0,
             Width = 75,
             Height = 25 + 4,
-            ColorScheme = Colors.ColorSchemes ["Base"],
+            SchemeName = "Base",
             Arrangement = ViewArrangement.Resizable
         };
         demoFrame!.Padding!.Thickness = new (1);
@@ -46,7 +46,7 @@ public class ScrollBarDemo : Scenario
             X = Pos.AnchorEnd (),
             Width = 5,
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
         };
 
         demoFrame.Add (controlledList);

+ 17 - 161
Examples/UICatalog/Scenarios/Scrolling.cs

@@ -1,4 +1,5 @@
 using System;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
 using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
@@ -21,13 +22,13 @@ public class Scrolling : Scenario
         var label = new Label { X = 0, Y = 0 };
         app.Add (label);
 
-        var demoView = new DemoView
+        var demoView = new AllViewsView
         {
             Id = "demoView",
             X = 2,
             Y = Pos.Bottom (label) + 1,
-            Width = 60,
-            Height = 20
+            Width = Dim.Fill (4),
+            Height = Dim.Fill (4)
         };
 
         label.Text =
@@ -91,35 +92,17 @@ public class Scrolling : Scenario
                                                             hCheckBox.CheckedState = args.NewValue ? CheckState.Checked : CheckState.UnChecked;
                                                         };
 
-        var count = 0;
-
-        var mousePos = new Label
+        // Add a progress bar to cause constant redraws
+        var progress = new ProgressBar
         {
-            X = Pos.Right (demoView) + 1,
-            Y = Pos.AnchorEnd (1),
-
-            Width = 50,
-            Text = "Mouse: "
+            X = Pos.Center (), Y = Pos.AnchorEnd (), Width = Dim.Fill ()
         };
-        app.Add (mousePos);
-        Application.MouseEvent += (sender, a) => { mousePos.Text = $"Mouse: ({a.Position}) - {a.Flags} {count++}"; };
-
-        // Add a progress bar to cause constant redraws
-        var progress = new ProgressBar { X = Pos.Right (demoView) + 1, Y = Pos.AnchorEnd (2), Width = 50 };
 
         app.Add (progress);
 
         var pulsing = true;
 
-        bool TimerFn ()
-        {
-            progress.Pulse ();
-
-            return pulsing;
-        }
-
-        Application.AddTimeout (TimeSpan.FromMilliseconds (300), TimerFn);
-
+        app.Initialized += AppOnInitialized;
         app.Unloaded += AppUnloaded;
 
         Application.Run (app);
@@ -129,144 +112,17 @@ public class Scrolling : Scenario
 
         return;
 
-        void AppUnloaded (object sender, EventArgs args) { pulsing = false; }
-    }
-}
-
-public class DemoView : View
-{
-    public DemoView ()
-    {
-        base.ColorScheme = Colors.ColorSchemes ["TopLevel"];
-        CanFocus = true;
-        BorderStyle = LineStyle.Heavy;
-        Arrangement = ViewArrangement.Resizable;
-        Initialized += OnInitialized;
-        HorizontalScrollBar.AutoShow = true;
-        VerticalScrollBar.AutoShow = true;
-    }
-
-    private void OnInitialized (object sender, EventArgs e)
-    {
-        SetContentSize (new (80, 25));
-
-        var rulerView = new View
+        void AppOnInitialized (object sender, EventArgs e)
         {
-            Height = Dim.Fill (),
-            Width = Dim.Fill ()
-        };
-        rulerView.Border!.Thickness = new (1);
-        rulerView.Border.LineStyle = LineStyle.None;
-        rulerView.Border.Diagnostics = ViewDiagnosticFlags.Ruler;
-        rulerView.Border.ColorScheme = Colors.ColorSchemes ["Error"];
+            bool TimerFn ()
+            {
+                progress.Pulse ();
 
-        Add (rulerView);
-
-        var centeredLabel = new Label ()
-        {
-            X = Pos.Center (),
-            Y = Pos.Center (),
-            TextAlignment = Alignment.Center,
-            VerticalTextAlignment = Alignment.Center,
-            Text = $"This label is centred.\nContentSize is {GetContentSize ()}"
-        };
-        Add (centeredLabel);
-
-        var pressMeButton = new Button
-        {
-            X = 1,
-            Y = 1,
-            Text = "Press me!"
-        };
-        pressMeButton.Accepting += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No");
-        Add (pressMeButton);
+                return pulsing;
+            }
 
-        var aLongButton = new Button
-        {
-            X = Pos.Right (pressMeButton),
-            Y = Pos.Bottom (pressMeButton),
-
-            Text = "A very long button. Should be wide enough to demo clipping!"
-        };
-        aLongButton.Accepting += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No");
-        Add (aLongButton);
-
-        Add (
-             new TextField
-             {
-                 X = Pos.Left (pressMeButton),
-                 Y = Pos.Bottom (aLongButton) + 1,
-                 Width = 50,
-                 ColorScheme = Colors.ColorSchemes ["Dialog"],
-                 Text = "This is a test of..."
-             }
-            );
-
-        Add (
-             new TextField
-             {
-                 X = Pos.Left (pressMeButton),
-                 Y = Pos.Bottom (aLongButton) + 3,
-                 Width = 50,
-                 ColorScheme = Colors.ColorSchemes ["Dialog"],
-                 Text = "... the emergency broadcast system."
-             }
-            );
-
-        Add (
-             new TextField
-             {
-                 X = Pos.Left (pressMeButton),
-                 Y = 40,
-                 Width = 50,
-                 ColorScheme = Colors.ColorSchemes ["Error"],
-                 Text = "Last line - Beyond content area @ Y = 40"
-             }
-            );
-
-        // Demonstrate AnchorEnd - Button is anchored to bottom/right
-        var anchorButton = new Button
-        {
-            X = Pos.AnchorEnd (),
-            Y = Pos.AnchorEnd (),
-            Text = "Bottom Right"
-        };
-
-        anchorButton.Accepting += (s, e) =>
-                                  {
-                                      // This demonstrates how to have a dynamically sized button
-                                      // Each time the button is clicked the button's text gets longer
-                                      anchorButton.Text += "!";
-                                  };
-        Add (anchorButton);
-    }
-
-    protected override bool OnMouseEvent (MouseEventArgs mouseEvent)
-    {
-        if (mouseEvent.Flags == MouseFlags.WheeledDown)
-        {
-            ScrollVertical (1);
-            return mouseEvent.Handled = true;
-        }
-
-        if (mouseEvent.Flags == MouseFlags.WheeledUp)
-        {
-            ScrollVertical (-1);
-            return mouseEvent.Handled = true;
-        }
-
-        if (mouseEvent.Flags == MouseFlags.WheeledRight)
-        {
-            ScrollHorizontal (1);
-            return mouseEvent.Handled = true;
-        }
-
-        if (mouseEvent.Flags == MouseFlags.WheeledLeft)
-        {
-            ScrollHorizontal (-1);
-            return mouseEvent.Handled = true;
+            Application.AddTimeout (TimeSpan.FromMilliseconds (200), TimerFn);
         }
-
-        return false;
+        void AppUnloaded (object sender, EventArgs args) { pulsing = false; }
     }
-}
+}

+ 25 - 4
Examples/UICatalog/Scenarios/ShadowStyles.cs

@@ -18,12 +18,14 @@ public class ShadowStyles : Scenario
 
         Window app = new ()
         {
+            Id = "app",
             Title = GetQuitKeyAndName ()
         };
 
 
         var editor = new AdornmentsEditor ()
         {
+            Id = "editor",
             AutoSelectViewToEdit = true,
             ShowViewIdentifier = true,
         };
@@ -31,8 +33,10 @@ public class ShadowStyles : Scenario
 
         app.Add (editor);
 
-        Window win = new ()
+        Window shadowWindow = new ()
         {
+
+            Id = "shadowWindow",
             X = Pos.Right (editor),
             Y = 0,
             Width = Dim.Percent (30),
@@ -51,20 +55,37 @@ public class ShadowStyles : Scenario
 
         var buttonInWin = new Button
         {
+            Id = "buttonInWin",
             X = Pos.Center (),
             Y = Pos.Center (), Text = "Button in Window",
             ShadowStyle = ShadowStyle.Opaque
         };
-        win.Add (buttonInWin);
-        app.Add (win);
+        shadowWindow.Add (buttonInWin);
+        app.Add (shadowWindow);
 
         var button = new Button
         {
+            Id = "button",
             X = Pos.Right (editor) + 10,
             Y = Pos.Center (), Text = "Button",
             ShadowStyle = ShadowStyle.Opaque
         };
-        app.Add (button);
+
+        ColorPicker colorPicker = new ()
+        {
+            Title = "ColorPicker to illustrate highlight (currently broken)",
+            BorderStyle = LineStyle.Dotted,
+            Id = "colorPicker16",
+            X = Pos.Center (),
+            Y = Pos.AnchorEnd (),
+            Width = Dim.Percent(80),
+        };
+        colorPicker.ColorChanged += (sender, args) =>
+                                    {
+                                        var normal = app.GetScheme ().Normal;
+                                        app.SetScheme (app.GetScheme() with {Normal = new Attribute(normal.Foreground, args.CurrentValue)});
+                                    };
+        app.Add (button, colorPicker);
 
         editor.AutoSelectViewToEdit = true;
         editor.AutoSelectSuperView = app;

+ 180 - 158
Examples/UICatalog/Scenarios/Shortcuts.cs

@@ -1,10 +1,6 @@
 #nullable enable
 
-using System;
-using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using System.Linq;
-using System.Timers;
 using Terminal.Gui;
 using Timer = System.Timers.Timer;
 
@@ -41,13 +37,21 @@ public class Shortcuts : Scenario
             X = Pos.AnchorEnd (),
             Y = 0,
             Height = Dim.Fill (4),
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "TopLevel",
             Source = new ListWrapper<string> (eventSource),
             BorderStyle = LineStyle.Double,
             Title = "E_vents"
         };
-        eventLog.Width = Dim.Func (() => Math.Min (Application.Top.Viewport.Width / 2, eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
-        eventLog.Width = Dim.Func (() => Math.Min (eventLog.SuperView!.Viewport.Width / 2, eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
+
+        eventLog.Width = Dim.Func (
+                                   () => Math.Min (
+                                                   Application.Top.Viewport.Width / 2,
+                                                   eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
+
+        eventLog.Width = Dim.Func (
+                                   () => Math.Min (
+                                                   eventLog.SuperView!.Viewport.Width / 2,
+                                                   eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
         Application.Top.Add (eventLog);
 
         var alignKeysShortcut = new Shortcut
@@ -61,40 +65,47 @@ public class Shortcuts : Scenario
             {
                 Text = "_Align Keys",
                 CanFocus = false,
-                HighlightStyle = HighlightStyle.None,
+                HighlightStyle = HighlightStyle.None
             },
-            Key = Key.F5.WithCtrl.WithAlt.WithShift,
+            Key = Key.F5.WithCtrl.WithAlt.WithShift
         };
 
         // ((CheckBox)vShortcut3.CommandView).CheckedStateChanging += (_, args) =>
         ((CheckBox)alignKeysShortcut.CommandView).CheckedStateChanging += (s, e) =>
-        {
-            if (alignKeysShortcut.CommandView is CheckBox cb)
-            {
-                eventSource.Add ($"{alignKeysShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
-                eventLog.MoveDown ();
-
-                var max = 0;
-                IEnumerable<View> toAlign = Application.Top.SubViews.Where (v => v is Shortcut { Width: not DimAbsolute });
-                IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
-
-                if (e.NewValue == CheckState.Checked)
-                {
-                    max = (from Shortcut? peer in enumerable select peer.Key.ToString ().GetColumns ()).Prepend (max).Max ();
-                    foreach (var view in enumerable)
-                    {
-                        var peer = (Shortcut)view;
-                        max = Math.Max (max, peer.KeyView.Text.GetColumns ());
-                    }
-                }
-
-                foreach (View view in enumerable)
-                {
-                    var peer = (Shortcut)view;
-                    peer.MinimumKeyTextSize = max;
-                }
-            }
-        };
+                                                                          {
+                                                                              if (alignKeysShortcut.CommandView is CheckBox cb)
+                                                                              {
+                                                                                  eventSource.Add (
+                                                                                                   $"{alignKeysShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
+                                                                                  eventLog.MoveDown ();
+
+                                                                                  var max = 0;
+
+                                                                                  IEnumerable<View> toAlign =
+                                                                                      Application.Top.SubViews.Where (
+                                                                                       v => v is Shortcut { Width: not DimAbsolute });
+                                                                                  IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
+
+                                                                                  if (e.NewValue == CheckState.Checked)
+                                                                                  {
+                                                                                      max = (from Shortcut? peer in enumerable
+                                                                                             select peer.Key.ToString ().GetColumns ()).Prepend (max)
+                                                                                          .Max ();
+
+                                                                                      foreach (View view in enumerable)
+                                                                                      {
+                                                                                          var peer = (Shortcut)view;
+                                                                                          max = Math.Max (max, peer.KeyView.Text.GetColumns ());
+                                                                                      }
+                                                                                  }
+
+                                                                                  foreach (View view in enumerable)
+                                                                                  {
+                                                                                      var peer = (Shortcut)view;
+                                                                                      peer.MinimumKeyTextSize = max;
+                                                                                  }
+                                                                              }
+                                                                          };
         Application.Top.Add (alignKeysShortcut);
 
         var commandFirstShortcut = new Shortcut
@@ -108,37 +119,42 @@ public class Shortcuts : Scenario
             {
                 Text = "Command _First",
                 CanFocus = false,
-                HighlightStyle = HighlightStyle.None,
+                HighlightStyle = HighlightStyle.None
             },
-            Key = Key.F.WithCtrl,
+            Key = Key.F.WithCtrl
         };
+
         ((CheckBox)commandFirstShortcut.CommandView).CheckedState =
             commandFirstShortcut.AlignmentModes.HasFlag (AlignmentModes.EndToStart) ? CheckState.UnChecked : CheckState.Checked;
 
         ((CheckBox)commandFirstShortcut.CommandView).CheckedStateChanging += (s, e) =>
-                                                                         {
-                                                                             if (commandFirstShortcut.CommandView is CheckBox cb)
                                                                              {
-                                                                                 eventSource.Add ($"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
-                                                                                 eventLog.MoveDown ();
+                                                                                 if (commandFirstShortcut.CommandView is CheckBox cb)
+                                                                                 {
+                                                                                     eventSource.Add (
+                                                                                                      $"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
+                                                                                     eventLog.MoveDown ();
 
-                                                                                 IEnumerable<View> toAlign = Application.Top.SubViews.Where (v => v is Shortcut { Width: not DimAbsolute });
-                                                                                 IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
+                                                                                     IEnumerable<View> toAlign =
+                                                                                         Application.Top.SubViews.Where (
+                                                                                          v => v is Shortcut { Width: not DimAbsolute });
+                                                                                     IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
 
-                                                                                 foreach (var view in enumerable)
-                                                                                 {
-                                                                                     var peer = (Shortcut)view;
-                                                                                     if (e.NewValue == CheckState.Checked)
-                                                                                     {
-                                                                                         peer.AlignmentModes &= ~AlignmentModes.EndToStart;
-                                                                                     }
-                                                                                     else
+                                                                                     foreach (View view in enumerable)
                                                                                      {
-                                                                                         peer.AlignmentModes |= AlignmentModes.EndToStart;
+                                                                                         var peer = (Shortcut)view;
+
+                                                                                         if (e.NewValue == CheckState.Checked)
+                                                                                         {
+                                                                                             peer.AlignmentModes &= ~AlignmentModes.EndToStart;
+                                                                                         }
+                                                                                         else
+                                                                                         {
+                                                                                             peer.AlignmentModes |= AlignmentModes.EndToStart;
+                                                                                         }
                                                                                      }
                                                                                  }
-                                                                             }
-                                                                         };
+                                                                             };
 
         Application.Top.Add (commandFirstShortcut);
 
@@ -150,26 +166,27 @@ public class Shortcuts : Scenario
             Width = Dim.Fill ()! - Dim.Width (eventLog),
             Key = Key.F4,
             HelpText = "Changes all Command.CanFocus",
-            CommandView = new CheckBox { Text = "_CanFocus" },
+            CommandView = new CheckBox { Text = "_CanFocus" }
         };
 
         ((CheckBox)canFocusShortcut.CommandView).CheckedStateChanging += (s, e) =>
-        {
-            if (canFocusShortcut.CommandView is CheckBox cb)
-            {
-                eventSource.Add ($"Toggle: {cb.Text}");
-                eventLog.MoveDown ();
-                //cb.CanFocus = e.NewValue == CheckState.Checked;
-
-                foreach (Shortcut peer in Application.Top.SubViews.Where (v => v is Shortcut)!)
-                {
-                    if (peer.CanFocus)
-                    {
-                        peer.CommandView.CanFocus = e.NewValue == CheckState.Checked;
-                    }
-                }
-            }
-        };
+                                                                         {
+                                                                             if (canFocusShortcut.CommandView is CheckBox cb)
+                                                                             {
+                                                                                 eventSource.Add ($"Toggle: {cb.Text}");
+                                                                                 eventLog.MoveDown ();
+
+                                                                                 //cb.CanFocus = e.NewValue == CheckState.Checked;
+
+                                                                                 foreach (Shortcut peer in Application.Top.SubViews.Where (v => v is Shortcut)!)
+                                                                                 {
+                                                                                     if (peer.CanFocus)
+                                                                                     {
+                                                                                         peer.CommandView.CanFocus = e.NewValue == CheckState.Checked;
+                                                                                     }
+                                                                                 }
+                                                                             }
+                                                                         };
         Application.Top.Add (canFocusShortcut);
 
         var appShortcut = new Shortcut
@@ -181,12 +198,11 @@ public class Shortcuts : Scenario
             Title = "A_pp Shortcut",
             Key = Key.F1,
             Text = "Width is DimFill",
-            BindKeyToApplication = true,
+            BindKeyToApplication = true
         };
 
         Application.Top.Add (appShortcut);
 
-
         var buttonShortcut = new Shortcut
         {
             Id = "buttonShortcut",
@@ -200,14 +216,13 @@ public class Shortcuts : Scenario
                 ShadowStyle = ShadowStyle.None,
                 HighlightStyle = HighlightStyle.None
             },
-            Key = Key.K,
+            Key = Key.K
         };
         var button = (Button)buttonShortcut.CommandView;
         buttonShortcut.Accepting += Button_Clicked;
 
         Application.Top.Add (buttonShortcut);
 
-
         var radioGroupShortcut = new Shortcut
         {
             Id = "radioGroupShortcut",
@@ -218,8 +233,8 @@ public class Shortcuts : Scenario
             CommandView = new RadioGroup
             {
                 Orientation = Orientation.Vertical,
-                RadioLabels = ["O_ne", "T_wo", "Th_ree", "Fo_ur"],
-            },
+                RadioLabels = ["O_ne", "T_wo", "Th_ree", "Fo_ur"]
+            }
         };
 
         ((RadioGroup)radioGroupShortcut.CommandView).SelectedItemChanged += (o, args) =>
@@ -246,21 +261,21 @@ public class Shortcuts : Scenario
                 Orientation = Orientation.Horizontal,
                 AllowEmpty = true
             },
-            Key = Key.F5,
+            Key = Key.F5
         };
 
         ((Slider<string>)sliderShortcut.CommandView).Options = [new () { Legend = "A" }, new () { Legend = "B" }, new () { Legend = "C" }];
         ((Slider<string>)sliderShortcut.CommandView).SetOption (0);
 
         ((Slider<string>)sliderShortcut.CommandView).OptionsChanged += (o, args) =>
-        {
-            eventSource.Add ($"OptionsChanged: {o?.GetType ().Name} - {string.Join (",", ((Slider<string>)o!)!.GetSetOptions ())}");
-            eventLog.MoveDown ();
-        };
+                                                                       {
+                                                                           eventSource.Add (
+                                                                                            $"OptionsChanged: {o?.GetType ().Name} - {string.Join (",", ((Slider<string>)o!)!.GetSetOptions ())}");
+                                                                           eventLog.MoveDown ();
+                                                                       };
 
         Application.Top.Add (sliderShortcut);
 
-
         var noCommandShortcut = new Shortcut
         {
             Id = "noCommandShortcut",
@@ -281,12 +296,11 @@ public class Shortcuts : Scenario
             Width = Dim.Width (noCommandShortcut),
 
             Title = "No Ke_y",
-            HelpText = "Keyless",
+            HelpText = "Keyless"
         };
 
         Application.Top.Add (noKeyShortcut);
 
-
         var noHelpShortcut = new Shortcut
         {
             Id = "noHelpShortcut",
@@ -295,7 +309,7 @@ public class Shortcuts : Scenario
             Width = Dim.Width (noKeyShortcut),
             Key = Key.F6,
             Title = "Not _very much help",
-            HelpText = "",
+            HelpText = ""
         };
 
         Application.Top.Add (noHelpShortcut);
@@ -310,7 +324,7 @@ public class Shortcuts : Scenario
             Key = Key.K.WithCtrl,
             Text = "Resize frame",
             BorderStyle = LineStyle.Dotted,
-            Arrangement = ViewArrangement.RightResizable | ViewArrangement.BottomResizable,
+            Arrangement = ViewArrangement.RightResizable | ViewArrangement.BottomResizable
         };
         framedShortcut.Orientation = Orientation.Horizontal;
 
@@ -322,12 +336,12 @@ public class Shortcuts : Scenario
 
         if (framedShortcut.CommandView.Margin is { })
         {
-            framedShortcut.CommandView.Margin.ColorScheme = framedShortcut.CommandView.ColorScheme = Colors.ColorSchemes ["Error"];
-            framedShortcut.HelpView.Margin!.ColorScheme = framedShortcut.HelpView.ColorScheme = Colors.ColorSchemes ["Dialog"];
-            framedShortcut.KeyView.Margin!.ColorScheme = framedShortcut.KeyView.ColorScheme = Colors.ColorSchemes ["Menu"];
+            framedShortcut.CommandView.Margin.SchemeName = framedShortcut.CommandView.SchemeName = "Error";
+            framedShortcut.HelpView.Margin!.SchemeName = framedShortcut.HelpView.SchemeName = "Dialog";
+            framedShortcut.KeyView.Margin!.SchemeName = framedShortcut.KeyView.SchemeName = "Menu";
         }
 
-        framedShortcut.ColorScheme = Colors.ColorSchemes ["Toplevel"];
+        framedShortcut.SchemeName = "TopLevel";
         Application.Top.Add (framedShortcut);
 
         // Horizontal
@@ -337,7 +351,7 @@ public class Shortcuts : Scenario
             X = Pos.Align (Alignment.Start, AlignmentModes.IgnoreFirstOrLast, 1),
             Y = Pos.AnchorEnd () - 1,
             Key = Key.F7,
-            HelpText = "Horizontal",
+            HelpText = "Horizontal"
         };
 
         progressShortcut.CommandView = new ProgressBar
@@ -355,32 +369,34 @@ public class Shortcuts : Scenario
 
         Timer timer = new (10)
         {
-            AutoReset = true,
+            AutoReset = true
         };
+
         timer.Elapsed += (o, args) =>
-        {
-            if (progressShortcut.CommandView is ProgressBar pb)
-            {
-                if (pb.Fraction == 1.0)
-                {
-                    pb.Fraction = 0;
-                }
-                pb.Fraction += 0.01f;
+                         {
+                             if (progressShortcut.CommandView is ProgressBar pb)
+                             {
+                                 if (pb.Fraction == 1.0)
+                                 {
+                                     pb.Fraction = 0;
+                                 }
 
-                Application.Wakeup ();
+                                 pb.Fraction += 0.01f;
 
-                pb.SetNeedsDraw ();
-            }
-        };
+                                 Application.Wakeup ();
+
+                                 pb.SetNeedsDraw ();
+                             }
+                         };
         timer.Start ();
 
         Application.Top.Add (progressShortcut);
 
-        var textField = new TextField ()
+        var textField = new TextField
         {
             Text = "Edit me",
             Width = 10,
-            Height = 1,
+            Height = 1
         };
 
         var textFieldShortcut = new Shortcut
@@ -391,7 +407,7 @@ public class Shortcuts : Scenario
             Key = Key.F8,
             HelpText = "TextField",
             CanFocus = true,
-            CommandView = textField,
+            CommandView = textField
         };
         textField.CanFocus = true;
 
@@ -403,13 +419,13 @@ public class Shortcuts : Scenario
             X = Pos.Align (Alignment.Start, AlignmentModes.IgnoreFirstOrLast, 1),
             Y = Pos.AnchorEnd (),
             Key = Key.F9,
-            HelpText = "Cycles BG Color",
+            HelpText = "Cycles BG Color"
         };
 
-        var bgColor = new ColorPicker16 ()
+        var bgColor = new ColorPicker16
         {
             BoxHeight = 1,
-            BoxWidth = 1,
+            BoxWidth = 1
         };
 
         bgColorShortcut.Selecting += (o, args) =>
@@ -425,23 +441,28 @@ public class Shortcuts : Scenario
 
                                              return;
                                          }
+
                                          bgColor.SelectedColor++;
                                          args.Handled = true;
                                      };
 
         bgColor.ColorChanged += (o, args) =>
-        {
-            if (o is { })
-            {
-                eventSource.Add ($"ColorChanged: {o.GetType ().Name} - {args.CurrentValue}");
-                eventLog.MoveDown ();
-
-                Application.Top.ColorScheme = new ColorScheme (Application.Top.ColorScheme)
-                {
-                    Normal = new (Application.Top!.GetNormalColor ().Foreground, args.CurrentValue),
-                };
-            }
-        };
+                                {
+                                    if (o is { })
+                                    {
+                                        eventSource.Add ($"ColorChanged: {o.GetType ().Name} - {args.CurrentValue}");
+                                        eventLog.MoveDown ();
+
+                                        Application.Top.SetScheme (
+                                                                   new (Application.Top.GetScheme ())
+                                                                   {
+                                                                       Normal = new (
+                                                                                     Application.Top!.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                                     args.CurrentValue,
+                                                                                     Application.Top!.GetAttributeForRole (VisualRole.Normal).Style)
+                                                                   });
+                                    }
+                                };
         bgColorShortcut.CommandView = bgColor;
 
         Application.Top.Add (bgColorShortcut);
@@ -454,59 +475,60 @@ public class Shortcuts : Scenario
             Key = Key.Esc,
             BindKeyToApplication = true,
             Title = "Quit",
-            HelpText = "App Scope",
-        };
-        appQuitShortcut.Accepting += (o, args) =>
-        {
-            Application.RequestStop ();
+            HelpText = "App Scope"
         };
+        appQuitShortcut.Accepting += (o, args) => { Application.RequestStop (); };
 
         Application.Top.Add (appQuitShortcut);
 
         foreach (Shortcut shortcut in Application.Top.SubViews.OfType<Shortcut> ())
         {
             shortcut.Selecting += (o, args) =>
-            {
-                if (args.Handled)
-                {
-                    return;
-                }
-                eventSource.Add ($"{shortcut!.Id}.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
-                eventLog.MoveDown ();
-            };
+                                  {
+                                      if (args.Handled)
+                                      {
+                                          return;
+                                      }
+
+                                      eventSource.Add ($"{shortcut!.Id}.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
+                                      eventLog.MoveDown ();
+                                  };
 
             shortcut.CommandView.Selecting += (o, args) =>
-            {
-                if (args.Handled)
-                {
-                    return;
-                }
-                eventSource.Add ($"{shortcut!.Id}.CommandView.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
-                eventLog.MoveDown ();
-                args.Handled = true;
-            };
+                                              {
+                                                  if (args.Handled)
+                                                  {
+                                                      return;
+                                                  }
+
+                                                  eventSource.Add (
+                                                                   $"{shortcut!.Id}.CommandView.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
+                                                  eventLog.MoveDown ();
+                                                  args.Handled = true;
+                                              };
 
             shortcut.Accepting += (o, args) =>
-            {
-                eventSource.Add ($"{shortcut!.Id}.Accepting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
-                eventLog.MoveDown ();
-                // We don't want this to exit the Scenario
-                args.Handled = true;
-            };
+                                  {
+                                      eventSource.Add ($"{shortcut!.Id}.Accepting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
+                                      eventLog.MoveDown ();
 
-            shortcut.CommandView.Accepting += (o, args) =>
-            {
-                eventSource.Add ($"{shortcut!.Id}.CommandView.Accepting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
-                eventLog.MoveDown ();
-            };
+                                      // We don't want this to exit the Scenario
+                                      args.Handled = true;
+                                  };
 
+            shortcut.CommandView.Accepting += (o, args) =>
+                                              {
+                                                  eventSource.Add (
+                                                                   $"{shortcut!.Id}.CommandView.Accepting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
+                                                  eventLog.MoveDown ();
+                                              };
         }
     }
 
     private void Button_Clicked (object? sender, CommandEventArgs e)
     {
         e.Handled = true;
-        View? view = sender as View;
+        var view = sender as View;
         MessageBox.Query ("Hi", $"You clicked {view?.Text}", "_Ok");
     }
 }

+ 0 - 59
Examples/UICatalog/Scenarios/SimpleDialog.cs

@@ -1,59 +0,0 @@
-#nullable enable
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios;
-
-[ScenarioMetadata ("SimpleDialog", "SimpleDialog ")]
-public sealed class SimpleDialog : Scenario
-{
-    public override void Main ()
-    {
-        // Init
-        Application.Init ();
-
-        // Setup - Create a top-level application window and configure it.
-        Window appWindow = new ()
-        {
-            Title = GetQuitKeyAndName (),
-            BorderStyle = LineStyle.None
-        };
-
-
-        appWindow.DrawingText += (s, e) =>
-                                 {
-                                     appWindow!.FillRect (appWindow!.Viewport, Glyphs.Dot);
-                                     e.Cancel = true;
-                                 };
-
-        Dialog dialog = new () { Id = "dialog", Width = 20, Height = 4, Title = "Dialog" };
-        dialog.Arrangement |= ViewArrangement.Resizable;
-
-        var button = new Button
-        {
-            Id = "button", 
-            X = 0,
-            Y = 0, 
-            NoDecorations = true,
-            NoPadding = true,
-            Text = "A",
-            //WantContinuousButtonPressed = false,
-            HighlightStyle = HighlightStyle.None,
-            ShadowStyle = ShadowStyle.Transparent,
-        };
-
-        button.Accepting += (s, e) =>
-                            {
-                                Application.Run (dialog);
-                                e.Handled = true;
-                            };
-        appWindow.Add (button);
-
-        // Run - Start the application.
-        Application.Run (appWindow);
-        dialog.Dispose ();
-        appWindow.Dispose ();
-
-        // Shutdown - Calling Application.Shutdown is required.
-        Application.Shutdown ();
-    }
-}

+ 1 - 1
Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs

@@ -278,7 +278,7 @@ public class SingleBackgroundWorker : Scenario
             Y = 1;
             Height = Dim.Fill (1);
             Title = $"Worker started at {start}.{start:fff}";
-            ColorScheme = Colors.ColorSchemes ["Base"];
+            SchemeName = "Base";
 
             Add (
                  new ListView

+ 216 - 204
Examples/UICatalog/Scenarios/Sliders.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics.Tracing;
-using System.Linq;
+using System.Collections.ObjectModel;
 using System.Text;
 using Terminal.Gui;
 
@@ -28,6 +24,7 @@ public class Sliders : Scenario
                 Type = type,
                 AllowEmpty = true
             };
+
             //view.Padding.Thickness = new (0,1,0,0);
             v.Add (view);
             prev = view;
@@ -90,24 +87,21 @@ public class Sliders : Scenario
                                 {
                                     if (single.Orientation == Orientation.Horizontal)
                                     {
-                                        single.Style.SpaceChar = new Cell { Rune = Glyphs.HLine };
-                                        single.Style.OptionChar = new Cell { Rune = Glyphs.HLine };
+                                        single.Style.SpaceChar = new () { Rune = Glyphs.HLine };
+                                        single.Style.OptionChar = new () { Rune = Glyphs.HLine };
                                     }
                                     else
                                     {
-                                        single.Style.SpaceChar = new Cell { Rune = Glyphs.VLine };
-                                        single.Style.OptionChar = new Cell { Rune = Glyphs.VLine };
+                                        single.Style.SpaceChar = new () { Rune = Glyphs.VLine };
+                                        single.Style.OptionChar = new () { Rune = Glyphs.VLine };
                                     }
                                 };
-        single.Style.SetChar = new Cell { Rune = Glyphs.ContinuousMeterSegment };
-        single.Style.DragChar = new Cell { Rune = Glyphs.ContinuousMeterSegment };
+        single.Style.SetChar = new () { Rune = Glyphs.ContinuousMeterSegment };
+        single.Style.DragChar = new () { Rune = Glyphs.ContinuousMeterSegment };
 
         v.Add (single);
 
-        single.OptionsChanged += (s, e) =>
-                                 {
-                                     single.Title = $"_Continuous {e.Options.FirstOrDefault ().Key}";
-                                 };
+        single.OptionsChanged += (s, e) => { single.Title = $"_Continuous {e.Options.FirstOrDefault ().Key}"; };
 
         List<object> oneOption = new () { "The Only Option" };
 
@@ -134,7 +128,7 @@ public class Sliders : Scenario
 
         MakeSliders (
                      app,
-                     new List<object>
+                     new ()
                      {
                          500,
                          1000,
@@ -156,7 +150,7 @@ public class Sliders : Scenario
             Y = 0,
             Width = Dim.Fill (),
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Dialog"]
+            SchemeName = "Dialog"
         };
 
         app.Add (configView);
@@ -177,7 +171,7 @@ public class Sliders : Scenario
         optionsSlider.Style.SetChar = optionsSlider.Style.SetChar with { Attribute = new Attribute (Color.BrightGreen, Color.Black) };
         optionsSlider.Style.LegendAttributes.SetAttribute = new Attribute (Color.Green, Color.Black);
 
-        optionsSlider.Options = new List<SliderOption<string>>
+        optionsSlider.Options = new ()
         {
             new () { Legend = "Legends" },
             new () { Legend = "RangeAllowSingle" },
@@ -188,38 +182,38 @@ public class Sliders : Scenario
         configView.Add (optionsSlider);
 
         optionsSlider.OptionsChanged += (sender, e) =>
-                                 {
-                                     foreach (Slider s in app.SubViews.OfType<Slider> ())
-                                     {
-                                         s.ShowLegends = e.Options.ContainsKey (0);
-                                         s.RangeAllowSingle = e.Options.ContainsKey (1);
-                                         s.ShowEndSpacing = e.Options.ContainsKey (2);
-
-                                         if (e.Options.ContainsKey (3))
-                                         {
-                                             s.Width = Dim.Auto (DimAutoStyle.Content);
-                                             s.Height = Dim.Auto (DimAutoStyle.Content);
-                                         }
-                                         else
-                                         {
-                                             if (s.Orientation == Orientation.Horizontal)
-                                             {
-                                                 s.Width = Dim.Percent (50);
-
-                                                 int h = s.ShowLegends && s.LegendsOrientation == Orientation.Vertical
-                                                             ? s.Options.Max (o => o.Legend.Length) + 3
-                                                             : 4;
-                                                 s.Height = h;
-                                             }
-                                             else
-                                             {
-                                                 int w = s.ShowLegends ? s.Options.Max (o => o.Legend.Length) + 3 : 3;
-                                                 s.Width = w;
-                                                 s.Height = Dim.Fill ();
-                                             }
-                                         }
-                                     }
-                                 };
+                                        {
+                                            foreach (Slider s in app.SubViews.OfType<Slider> ())
+                                            {
+                                                s.ShowLegends = e.Options.ContainsKey (0);
+                                                s.RangeAllowSingle = e.Options.ContainsKey (1);
+                                                s.ShowEndSpacing = e.Options.ContainsKey (2);
+
+                                                if (e.Options.ContainsKey (3))
+                                                {
+                                                    s.Width = Dim.Auto (DimAutoStyle.Content);
+                                                    s.Height = Dim.Auto (DimAutoStyle.Content);
+                                                }
+                                                else
+                                                {
+                                                    if (s.Orientation == Orientation.Horizontal)
+                                                    {
+                                                        s.Width = Dim.Percent (50);
+
+                                                        int h = s.ShowLegends && s.LegendsOrientation == Orientation.Vertical
+                                                                    ? s.Options.Max (o => o.Legend.Length) + 3
+                                                                    : 4;
+                                                        s.Height = h;
+                                                    }
+                                                    else
+                                                    {
+                                                        int w = s.ShowLegends ? s.Options.Max (o => o.Legend.Length) + 3 : 3;
+                                                        s.Width = w;
+                                                        s.Height = Dim.Fill ();
+                                                    }
+                                                }
+                                            }
+                                        };
         optionsSlider.SetOption (0); // Legends
         optionsSlider.SetOption (1); // RangeAllowSingle
         optionsSlider.SetOption (3); // DimAuto
@@ -232,17 +226,17 @@ public class Sliders : Scenario
         };
 
         dimAutoUsesMin.CheckedStateChanging += (sender, e) =>
-                                  {
-                                      foreach (Slider s in app.SubViews.OfType<Slider> ())
-                                      {
-                                          s.UseMinimumSize = !s.UseMinimumSize;
-                                      }
-                                  };
+                                               {
+                                                   foreach (Slider s in app.SubViews.OfType<Slider> ())
+                                                   {
+                                                       s.UseMinimumSize = !s.UseMinimumSize;
+                                                   }
+                                               };
         configView.Add (dimAutoUsesMin);
 
         #region Slider Orientation Slider
 
-        Slider<string> orientationSlider = new (new List<string> { "Horizontal", "Vertical" })
+        Slider<string> orientationSlider = new (new () { "Horizontal", "Vertical" })
         {
             Title = "Slider Orientation",
             X = 0,
@@ -255,79 +249,79 @@ public class Sliders : Scenario
         configView.Add (orientationSlider);
 
         orientationSlider.OptionsChanged += (sender, e) =>
+                                            {
+                                                View prev = null;
+
+                                                foreach (Slider s in app.SubViews.OfType<Slider> ())
+                                                {
+                                                    if (e.Options.ContainsKey (0))
                                                     {
-                                                        View prev = null;
+                                                        s.Orientation = Orientation.Horizontal;
+
+                                                        s.Style.SpaceChar = new () { Rune = Glyphs.HLine };
 
-                                                        foreach (Slider s in app.SubViews.OfType<Slider> ())
+                                                        if (prev == null)
                                                         {
-                                                            if (e.Options.ContainsKey (0))
-                                                            {
-                                                                s.Orientation = Orientation.Horizontal;
-
-                                                                s.Style.SpaceChar = new Cell { Rune = Glyphs.HLine };
-
-                                                                if (prev == null)
-                                                                {
-                                                                    s.Y = 0;
-                                                                }
-                                                                else
-                                                                {
-                                                                    s.Y = Pos.Bottom (prev) + 1;
-                                                                }
-
-                                                                s.X = 0;
-                                                                prev = s;
-                                                            }
-                                                            else if (e.Options.ContainsKey (1))
-                                                            {
-                                                                s.Orientation = Orientation.Vertical;
-
-                                                                s.Style.SpaceChar = new Cell { Rune = Glyphs.VLine };
-
-                                                                if (prev == null)
-                                                                {
-                                                                    s.X = 0;
-                                                                }
-                                                                else
-                                                                {
-                                                                    s.X = Pos.Right (prev) + 2;
-                                                                }
-
-                                                                s.Y = 0;
-                                                                prev = s;
-                                                            }
-
-                                                            if (optionsSlider.GetSetOptions ().Contains (3))
-                                                            {
-                                                                s.Width = Dim.Auto (DimAutoStyle.Content);
-                                                                s.Height = Dim.Auto (DimAutoStyle.Content);
-                                                            }
-                                                            else
-                                                            {
-                                                                if (s.Orientation == Orientation.Horizontal)
-                                                                {
-                                                                    s.Width = Dim.Percent (50);
-
-                                                                    int h = s.ShowLegends && s.LegendsOrientation == Orientation.Vertical
-                                                                                ? s.Options.Max (o => o.Legend.Length) + 3
-                                                                                : 4;
-                                                                    s.Height = h;
-                                                                }
-                                                                else
-                                                                {
-                                                                    int w = s.ShowLegends ? s.Options.Max (o => o.Legend.Length) + 3 : 3;
-                                                                    s.Width = w;
-                                                                    s.Height = Dim.Fill ();
-                                                                }
-                                                            }
+                                                            s.Y = 0;
                                                         }
-                                                    };
+                                                        else
+                                                        {
+                                                            s.Y = Pos.Bottom (prev) + 1;
+                                                        }
+
+                                                        s.X = 0;
+                                                        prev = s;
+                                                    }
+                                                    else if (e.Options.ContainsKey (1))
+                                                    {
+                                                        s.Orientation = Orientation.Vertical;
+
+                                                        s.Style.SpaceChar = new () { Rune = Glyphs.VLine };
+
+                                                        if (prev == null)
+                                                        {
+                                                            s.X = 0;
+                                                        }
+                                                        else
+                                                        {
+                                                            s.X = Pos.Right (prev) + 2;
+                                                        }
+
+                                                        s.Y = 0;
+                                                        prev = s;
+                                                    }
+
+                                                    if (optionsSlider.GetSetOptions ().Contains (3))
+                                                    {
+                                                        s.Width = Dim.Auto (DimAutoStyle.Content);
+                                                        s.Height = Dim.Auto (DimAutoStyle.Content);
+                                                    }
+                                                    else
+                                                    {
+                                                        if (s.Orientation == Orientation.Horizontal)
+                                                        {
+                                                            s.Width = Dim.Percent (50);
+
+                                                            int h = s.ShowLegends && s.LegendsOrientation == Orientation.Vertical
+                                                                        ? s.Options.Max (o => o.Legend.Length) + 3
+                                                                        : 4;
+                                                            s.Height = h;
+                                                        }
+                                                        else
+                                                        {
+                                                            int w = s.ShowLegends ? s.Options.Max (o => o.Legend.Length) + 3 : 3;
+                                                            s.Width = w;
+                                                            s.Height = Dim.Fill ();
+                                                        }
+                                                    }
+                                                }
+                                            };
 
         #endregion Slider Orientation Slider
 
         #region Legends Orientation Slider
 
-        Slider<string> legendsOrientationSlider = new (new List<string> { "Horizontal", "Vertical" })
+        Slider<string> legendsOrientationSlider = new (new () { "Horizontal", "Vertical" })
         {
             Title = "Legends Orientation",
             X = 0,
@@ -340,48 +334,46 @@ public class Sliders : Scenario
         configView.Add (legendsOrientationSlider);
 
         legendsOrientationSlider.OptionsChanged += (sender, e) =>
-                                                     {
-                                                         foreach (Slider s in app.SubViews.OfType<Slider> ())
-                                                         {
-                                                             if (e.Options.ContainsKey (0))
-                                                             {
-                                                                 s.LegendsOrientation = Orientation.Horizontal;
-                                                             }
-                                                             else if (e.Options.ContainsKey (1))
-                                                             {
-                                                                 s.LegendsOrientation = Orientation.Vertical;
-                                                             }
-
-                                                             if (optionsSlider.GetSetOptions ().Contains (3))
-                                                             {
-                                                                 s.Width = Dim.Auto (DimAutoStyle.Content);
-                                                                 s.Height = Dim.Auto (DimAutoStyle.Content);
-                                                             }
-                                                             else
-                                                             {
-                                                                 if (s.Orientation == Orientation.Horizontal)
-                                                                 {
-                                                                     s.Width = Dim.Percent (50);
-
-                                                                     int h = s.ShowLegends && s.LegendsOrientation == Orientation.Vertical
-                                                                                 ? s.Options.Max (o => o.Legend.Length) + 3
-                                                                                 : 4;
-                                                                     s.Height = h;
-                                                                 }
-                                                                 else
-                                                                 {
-                                                                     int w = s.ShowLegends ? s.Options.Max (o => o.Legend.Length) + 3 : 3;
-                                                                     s.Width = w;
-                                                                     s.Height = Dim.Fill ();
-                                                                 }
-                                                             }
-                                                         }
-
-                                                     };
+                                                   {
+                                                       foreach (Slider s in app.SubViews.OfType<Slider> ())
+                                                       {
+                                                           if (e.Options.ContainsKey (0))
+                                                           {
+                                                               s.LegendsOrientation = Orientation.Horizontal;
+                                                           }
+                                                           else if (e.Options.ContainsKey (1))
+                                                           {
+                                                               s.LegendsOrientation = Orientation.Vertical;
+                                                           }
+
+                                                           if (optionsSlider.GetSetOptions ().Contains (3))
+                                                           {
+                                                               s.Width = Dim.Auto (DimAutoStyle.Content);
+                                                               s.Height = Dim.Auto (DimAutoStyle.Content);
+                                                           }
+                                                           else
+                                                           {
+                                                               if (s.Orientation == Orientation.Horizontal)
+                                                               {
+                                                                   s.Width = Dim.Percent (50);
+
+                                                                   int h = s.ShowLegends && s.LegendsOrientation == Orientation.Vertical
+                                                                               ? s.Options.Max (o => o.Legend.Length) + 3
+                                                                               : 4;
+                                                                   s.Height = h;
+                                                               }
+                                                               else
+                                                               {
+                                                                   int w = s.ShowLegends ? s.Options.Max (o => o.Legend.Length) + 3 : 3;
+                                                                   s.Width = w;
+                                                                   s.Height = Dim.Fill ();
+                                                               }
+                                                           }
+                                                       }
+                                                   };
 
         #endregion Legends Orientation Slider
 
-
         #region Spacing Options
 
         FrameView spacingOptions = new ()
@@ -396,7 +388,7 @@ public class Sliders : Scenario
 
         Label label = new ()
         {
-            Text = "Min _Inner Spacing:",
+            Text = "Min _Inner Spacing:"
         };
 
         NumericUpDown<int> innerSpacingUpDown = new ()
@@ -421,8 +413,6 @@ public class Sliders : Scenario
                                                 }
                                             };
 
-
-
         spacingOptions.Add (label, innerSpacingUpDown);
         configView.Add (spacingOptions);
 
@@ -432,10 +422,10 @@ public class Sliders : Scenario
 
         foreach (Slider s in app.SubViews.OfType<Slider> ())
         {
-            s.Style.OptionChar = s.Style.OptionChar with { Attribute = app.GetNormalColor () };
-            s.Style.SetChar = s.Style.SetChar with { Attribute = app.GetNormalColor () };
-            s.Style.LegendAttributes.SetAttribute = app.GetNormalColor ();
-            s.Style.RangeChar = s.Style.RangeChar with { Attribute = app.GetNormalColor () };
+            s.Style.OptionChar = s.Style.OptionChar with { Attribute = app.GetAttributeForRole (VisualRole.Normal) };
+            s.Style.SetChar = s.Style.SetChar with { Attribute = app.GetAttributeForRole (VisualRole.Normal) };
+            s.Style.LegendAttributes.SetAttribute = app.GetAttributeForRole (VisualRole.Normal);
+            s.Style.RangeChar = s.Style.RangeChar with { Attribute = app.GetAttributeForRole (VisualRole.Normal) };
         }
 
         Slider<(Color, Color)> sliderFGColor = new ()
@@ -465,10 +455,10 @@ public class Sliders : Scenario
             var colorName = colorIndex.ToString ();
 
             colorOptions.Add (
-                              new SliderOption<(Color, Color)>
+                              new ()
                               {
-                                  Data = (new Color (colorIndex),
-                                          new Color (colorIndex)),
+                                  Data = (new (colorIndex),
+                                          new (colorIndex)),
                                   Legend = colorName,
                                   LegendAbbr = (Rune)colorName [0]
                               }
@@ -487,19 +477,23 @@ public class Sliders : Scenario
 
                                                 foreach (Slider s in app.SubViews.OfType<Slider> ())
                                                 {
-                                                    s.ColorScheme = new ColorScheme (s.ColorScheme);
-
-                                                    s.ColorScheme = new ColorScheme (s.ColorScheme)
-                                                    {
-                                                        Normal = new Attribute (
-                                                                                data.Item2,
-                                                                                s.ColorScheme.Normal.Background
-                                                                               )
-                                                    };
+                                                    s.SetScheme (
+                                                                 new (s.GetScheme ())
+                                                                 {
+                                                                     Normal = new (
+                                                                                   data.Item2,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Style
+                                                                                  )
+                                                                 });
 
                                                     s.Style.OptionChar = s.Style.OptionChar with
                                                     {
-                                                        Attribute = new Attribute (data.Item1, s.ColorScheme.Normal.Background)
+                                                        Attribute = new Attribute (
+                                                                                   data.Item1,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Style
+                                                                                  )
                                                     };
 
                                                     s.Style.SetChar = s.Style.SetChar with
@@ -507,23 +501,39 @@ public class Sliders : Scenario
                                                         Attribute = new Attribute (
                                                                                    data.Item1,
                                                                                    s.Style.SetChar.Attribute?.Background
-                                                                                   ?? s.ColorScheme.Normal.Background
+                                                                                   ?? s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                                   s.Style.SetChar.Attribute?.Style
+                                                                                   ?? s.GetAttributeForRole (VisualRole.Normal).Style
                                                                                   )
                                                     };
-                                                    s.Style.LegendAttributes.SetAttribute = new Attribute (data.Item1, s.ColorScheme.Normal.Background);
+
+                                                    s.Style.LegendAttributes.SetAttribute =
+                                                        new Attribute (
+                                                                       data.Item1,
+                                                                       s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                       s.GetAttributeForRole (VisualRole.Normal).Style);
 
                                                     s.Style.RangeChar = s.Style.RangeChar with
                                                     {
-                                                        Attribute = new Attribute (data.Item1, s.ColorScheme.Normal.Background)
+                                                        Attribute = new Attribute (
+                                                                                   data.Item1,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Style)
                                                     };
 
                                                     s.Style.SpaceChar = s.Style.SpaceChar with
                                                     {
-                                                        Attribute = new Attribute (data.Item1, s.ColorScheme.Normal.Background)
+                                                        Attribute = new Attribute (
+                                                                                   data.Item1,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Style)
                                                     };
 
                                                     s.Style.LegendAttributes.NormalAttribute =
-                                                        new Attribute (data.Item1, s.ColorScheme.Normal.Background);
+                                                        new Attribute (
+                                                                       data.Item1,
+                                                                       s.GetAttributeForRole (VisualRole.Normal).Background,
+                                                                       s.GetAttributeForRole (VisualRole.Normal).Style);
                                                 }
                                             }
                                         };
@@ -557,13 +567,14 @@ public class Sliders : Scenario
 
                                                 foreach (Slider s in app.SubViews.OfType<Slider> ())
                                                 {
-                                                    s.ColorScheme = new ColorScheme (s.ColorScheme)
-                                                    {
-                                                        Normal = new Attribute (
-                                                                                s.ColorScheme.Normal.Foreground,
-                                                                                data.Item2
-                                                                               )
-                                                    };
+                                                    s.SetScheme (
+                                                                 new (s.GetScheme ())
+                                                                 {
+                                                                     Normal = new (
+                                                                                   s.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                                   data.Item2
+                                                                                  )
+                                                                 });
                                                 }
                                             }
                                         };
@@ -573,32 +584,33 @@ public class Sliders : Scenario
         #endregion Config Slider
 
         ObservableCollection<string> eventSource = new ();
+
         var eventLog = new ListView
         {
             X = Pos.Right (sliderBGColor),
             Y = Pos.Bottom (spacingOptions),
             Width = Dim.Fill (),
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "TopLevel",
             Source = new ListWrapper<string> (eventSource)
         };
         configView.Add (eventLog);
 
-
         foreach (Slider slider in app.SubViews.Where (v => v is Slider)!)
         {
             slider.Accepting += (o, args) =>
-                             {
-                                 eventSource.Add ($"Accept: {string.Join(",", slider.GetSetOptions ())}");
-                                 eventLog.MoveDown ();
-                                 args.Handled = true;
-                             };
+                                {
+                                    eventSource.Add ($"Accept: {string.Join (",", slider.GetSetOptions ())}");
+                                    eventLog.MoveDown ();
+                                    args.Handled = true;
+                                };
+
             slider.OptionsChanged += (o, args) =>
-                             {
-                                 eventSource.Add ($"OptionsChanged: {string.Join (",", slider.GetSetOptions ())}");
-                                 eventLog.MoveDown ();
-                                 args.Cancel = true;
-                             };
+                                     {
+                                         eventSource.Add ($"OptionsChanged: {string.Join (",", slider.GetSetOptions ())}");
+                                         eventLog.MoveDown ();
+                                         args.Cancel = true;
+                                     };
         }
 
         app.FocusDeepest (NavigationDirection.Forward, null);

+ 2 - 9
Examples/UICatalog/Scenarios/Snake.cs

@@ -291,7 +291,7 @@ public class Snake : Scenario
         {
             _appleRune = Glyphs.Apple;
 
-            if (!Driver.IsRuneSupported (_appleRune))
+            if (!Application.Driver!.IsRuneSupported (_appleRune))
             {
                 _appleRune = Glyphs.AppleBMP;
             }
@@ -299,14 +299,7 @@ public class Snake : Scenario
             State = state;
             CanFocus = true;
 
-            base.ColorScheme = new ()
-            {
-                Normal = white,
-                Focus = white,
-                HotNormal = white,
-                HotFocus = white,
-                Disabled = white
-            };
+            base.SetScheme (new (white));
 
             KeyBindings.Add (Key.CursorLeft, Command.Left);
             KeyBindings.Add (Key.CursorRight, Command.Right);

+ 8 - 8
Examples/UICatalog/Scenarios/SyntaxHighlighting.cs

@@ -100,7 +100,7 @@ public class SyntaxHighlighting : Scenario
     /// <typeparam name="T">The type of object to read from the file.</typeparam>
     /// <param name="filePath">The file path to read the object instance from.</param>
     /// <returns>Returns a new instance of the object read from the Json file.</returns>
-    public static T ReadFromJsonFile<T> (string filePath) where T : new ()
+    public static T ReadFromJsonFile<T> (string filePath) where T : new()
     {
         TextReader reader = null;
 
@@ -170,7 +170,7 @@ public class SyntaxHighlighting : Scenario
         };
         appWindow.Add (menu);
 
-        _textView = new()
+        _textView = new ()
         {
             Y = 1,
             Width = Dim.Fill (),
@@ -212,7 +212,7 @@ public class SyntaxHighlighting : Scenario
     ///     If false the file will be overwritten if it already exists. If true the contents will be appended
     ///     to the file.
     /// </param>
-    public static void WriteToJsonFile<T> (string filePath, T objectToWrite, bool append = false) where T : new ()
+    public static void WriteToJsonFile<T> (string filePath, T objectToWrite, bool append = false) where T : new()
     {
         TextWriter writer = null;
 
@@ -237,16 +237,16 @@ public class SyntaxHighlighting : Scenario
 
         List<Cell> cells = new ();
 
-        foreach (KeyValuePair<string, ColorScheme> color in Colors.ColorSchemes)
+        foreach (KeyValuePair<string, Scheme> color in SchemeManager.GetSchemesForCurrentTheme ())
         {
             string csName = color.Key;
 
             foreach (Rune rune in csName.EnumerateRunes ())
             {
-                cells.Add (new() { Rune = rune, Attribute = color.Value.Normal });
+                cells.Add (new () { Rune = rune, Attribute = color.Value.Normal });
             }
 
-            cells.Add (new() { Rune = (Rune)'\n', Attribute = color.Value.Focus });
+            cells.Add (new () { Rune = (Rune)'\n', Attribute = color.Value.Focus });
         }
 
         if (File.Exists (_path))
@@ -271,7 +271,7 @@ public class SyntaxHighlighting : Scenario
         _blue = new Attribute (Color.Blue, Color.Black);
         _magenta = new Attribute (Color.Magenta, Color.Black);
         _white = new Attribute (Color.White, Color.Black);
-        _textView.ColorScheme = new () { Focus = _white };
+        _textView.SetScheme (new () { Focus = _white });
 
         _textView.Text =
             "/*Query to select:\nLots of data*/\nSELECT TOP 100 * \nfrom\n MyDb.dbo.Biochemistry where TestCode = 'blah';";
@@ -296,7 +296,7 @@ public class SyntaxHighlighting : Scenario
     private void HighlightTextBasedOnKeywords ()
     {
         // Comment blocks, quote blocks etc
-        Dictionary<Rune, ColorScheme> blocks = new ();
+        Dictionary<Rune, Scheme> blocks = new ();
 
         var comments = new Regex (@"/\*.*?\*/", RegexOptions.Singleline);
         MatchCollection commentMatches = comments.Matches (_textView.Text);

+ 19 - 19
Examples/UICatalog/Scenarios/TableEditor.cs

@@ -318,7 +318,7 @@ public class TableEditor : Scenario
         new (0xE0000, 0xE007F, "Tags")
     };
 
-    private ColorScheme _alternatingColorScheme;
+    private Scheme _alternatingScheme;
     private DataTable _currentTable;
     private MenuItem _miAlternatingColors;
     private MenuItem _miAlwaysShowHeaders;
@@ -336,8 +336,8 @@ public class TableEditor : Scenario
     private MenuItem _miShowHeaders;
     private MenuItem _miShowHorizontalScrollIndicators;
     private MenuItem _miSmoothScrolling;
-    private ColorScheme _redColorScheme;
-    private ColorScheme _redColorSchemeAlt;
+    private Scheme _redScheme;
+    private Scheme _redSchemeAlt;
     private TableView _tableView;
 
     /// <summary>
@@ -664,27 +664,27 @@ public class TableEditor : Scenario
 
         //SetupScrollBar ();
 
-        _redColorScheme = new ()
+        _redScheme = new ()
         {
-            Disabled = appWindow.ColorScheme.Disabled,
-            HotFocus = appWindow.ColorScheme.HotFocus,
-            Focus = appWindow.ColorScheme.Focus,
-            Normal = new (Color.Red, appWindow.ColorScheme.Normal.Background)
+            Disabled = appWindow.GetAttributeForRole(VisualRole.Disabled),
+            HotFocus = appWindow.GetAttributeForRole(VisualRole.HotFocus),
+            Focus = appWindow.GetAttributeForRole(VisualRole.Focus),
+            Normal = new (Color.Red, appWindow.GetAttributeForRole(VisualRole.Normal).Background)
         };
 
-        _alternatingColorScheme = new ()
+        _alternatingScheme = new ()
         {
-            Disabled = appWindow.ColorScheme.Disabled,
-            HotFocus = appWindow.ColorScheme.HotFocus,
-            Focus = appWindow.ColorScheme.Focus,
+            Disabled = appWindow.GetAttributeForRole(VisualRole.Disabled),
+            HotFocus = appWindow.GetAttributeForRole(VisualRole.HotFocus),
+            Focus = appWindow.GetAttributeForRole(VisualRole.Focus),
             Normal = new (Color.White, Color.BrightBlue)
         };
 
-        _redColorSchemeAlt = new ()
+        _redSchemeAlt = new ()
         {
-            Disabled = appWindow.ColorScheme.Disabled,
-            HotFocus = appWindow.ColorScheme.HotFocus,
-            Focus = appWindow.ColorScheme.Focus,
+            Disabled = appWindow.GetAttributeForRole(VisualRole.Disabled),
+            HotFocus = appWindow.GetAttributeForRole(VisualRole.HotFocus),
+            Focus = appWindow.GetAttributeForRole(VisualRole.Focus),
             Normal = new (Color.Red, Color.BrightBlue)
         };
 
@@ -1099,8 +1099,8 @@ public class TableEditor : Scenario
                                    d <= 0.0000001
                                        ? a.RowIndex % 2 == 0
                                          && _miAlternatingColors.Checked == true
-                                             ? _redColorSchemeAlt
-                                             : _redColorScheme
+                                             ? _redSchemeAlt
+                                             : _redScheme
                                        :
 
                                        // use normal scheme for positive values
@@ -1334,7 +1334,7 @@ public class TableEditor : Scenario
 
         if (_miAlternatingColors.Checked == true)
         {
-            _tableView.Style.RowColorGetter = a => { return a.RowIndex % 2 == 0 ? _alternatingColorScheme : null; };
+            _tableView.Style.RowColorGetter = a => { return a.RowIndex % 2 == 0 ? _alternatingScheme : null; };
         }
         else
         {

+ 36 - 30
Examples/UICatalog/Scenarios/TextAlignmentAndDirection.cs

@@ -13,7 +13,7 @@ public class TextAlignmentAndDirection : Scenario
 
     internal class AlignmentAndDirectionView : View
     {
-        public AlignmentAndDirectionView()
+        public AlignmentAndDirectionView ()
         {
             ViewportSettings = Terminal.Gui.ViewportSettings.Transparent;
             BorderStyle = LineStyle.Dotted;
@@ -31,8 +31,8 @@ public class TextAlignmentAndDirection : Scenario
 
         var txt = $"Hello World{Environment.NewLine}HELLO WORLD{Environment.NewLine}世界 您好";
 
-        var color1 = new ColorScheme { Normal = new (Color.Black, Color.Gray) };
-        var color2 = new ColorScheme { Normal = new (Color.Black, Color.DarkGray) };
+        SchemeManager.AddScheme ("TextAlignmentAndDirection1", new Scheme { Normal = new (Color.Black, Color.Gray) });
+        SchemeManager.AddScheme ("TextAlignmentAndDirection2", new Scheme { Normal = new (Color.Black, Color.DarkGray) });
 
         List<View> singleLineLabels = new (); // single line
         List<View> multiLineLabels = new (); // multi line
@@ -46,7 +46,7 @@ public class TextAlignmentAndDirection : Scenario
             Width = 6,
             Height = 1,
             TextAlignment = Alignment.End,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
+            SchemeName = "Dialog",
             Text = "Start",
         };
 
@@ -57,7 +57,7 @@ public class TextAlignmentAndDirection : Scenario
             Width = 6,
             Height = 1,
             TextAlignment = Alignment.End,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
+            SchemeName = "Dialog",
             Text = "Center"
         };
 
@@ -68,7 +68,7 @@ public class TextAlignmentAndDirection : Scenario
             Width = 6,
             Height = 1,
             TextAlignment = Alignment.End,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
+            SchemeName = "Dialog",
             Text = "End"
         };
 
@@ -79,7 +79,7 @@ public class TextAlignmentAndDirection : Scenario
             Width = 6,
             Height = 1,
             TextAlignment = Alignment.End,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
+            SchemeName = "Dialog",
             Text = "Fill"
         };
 
@@ -89,7 +89,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Y (labelHL),
             Width = Dim.Fill (9),
             Height = 1,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextAlignment = Alignment.Start,
             Text = txt,
             ViewportSettings = Terminal.Gui.ViewportSettings.Transparent
@@ -101,7 +101,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Y (labelHC),
             Width = Dim.Fill (9),
             Height = 1,
-            ColorScheme = color2,
+            SchemeName = "TextAlignmentAndDirection2",
             TextAlignment = Alignment.Center,
             Text = txt,
             ViewportSettings = Terminal.Gui.ViewportSettings.Transparent
@@ -113,7 +113,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Y (labelHR),
             Width = Dim.Fill (9),
             Height = 1,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextAlignment = Alignment.End,
             Text = txt,
             ViewportSettings = Terminal.Gui.ViewportSettings.Transparent
@@ -125,7 +125,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Y (labelHJ),
             Width = Dim.Fill (9),
             Height = 1,
-            ColorScheme = color2,
+            SchemeName = "TextAlignmentAndDirection2",
             TextAlignment = Alignment.Fill,
             Text = txt,
             ViewportSettings = Terminal.Gui.ViewportSettings.Transparent
@@ -153,7 +153,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = 0,
             Width = 2,
             Height = 6,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.End,
             Text = "Start"
@@ -166,7 +166,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = 0,
             Width = 2,
             Height = 6,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.End,
             Text = "Center"
@@ -179,7 +179,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = 0,
             Width = 2,
             Height = 6,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.End,
             Text = "End"
@@ -192,7 +192,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = 0,
             Width = 2,
             Height = 6,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.End,
             Text = "Fill"
@@ -205,7 +205,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Bottom (labelVT) + 1,
             Width = 2,
             Height = Dim.Fill (),
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.Start,
             Text = txt,
@@ -219,7 +219,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Bottom (labelVM) + 1,
             Width = 2,
             Height = Dim.Fill (),
-            ColorScheme = color2,
+            SchemeName = "TextAlignmentAndDirection2",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.Center,
             Text = txt,
@@ -233,7 +233,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Bottom (labelVB) + 1,
             Width = 2,
             Height = Dim.Fill (),
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.End,
             Text = txt,
@@ -247,7 +247,7 @@ public class TextAlignmentAndDirection : Scenario
             Y = Pos.Bottom (labelVJ) + 1,
             Width = 2,
             Height = Dim.Fill (),
-            ColorScheme = color2,
+            SchemeName = "TextAlignmentAndDirection2",
             TextDirection = TextDirection.TopBottom_LeftRight,
             VerticalTextAlignment = Alignment.Fill,
             Text = txt,
@@ -278,7 +278,7 @@ public class TextAlignmentAndDirection : Scenario
             Width = Dim.Fill (31),
             Height = Dim.Fill (4)
 
-            //ColorScheme = color2
+            //SchemeName = "TextAlignmentAndDirection2"
         };
 
         var txtLabelTL = new AlignmentAndDirectionView
@@ -289,7 +289,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100 / 3),
             TextAlignment = Alignment.Start,
             VerticalTextAlignment = Alignment.Start,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelTL.TextFormatter.MultiLine = true;
@@ -302,7 +302,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100 / 3),
             TextAlignment = Alignment.Center,
             VerticalTextAlignment = Alignment.Start,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelTC.TextFormatter.MultiLine = true;
@@ -315,7 +315,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100 / 3),
             TextAlignment = Alignment.End,
             VerticalTextAlignment = Alignment.Start,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelTR.TextFormatter.MultiLine = true;
@@ -328,7 +328,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100 / 3),
             TextAlignment = Alignment.Start,
             VerticalTextAlignment = Alignment.Center,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelML.TextFormatter.MultiLine = true;
@@ -341,7 +341,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100 / 3),
             TextAlignment = Alignment.Center,
             VerticalTextAlignment = Alignment.Center,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelMC.TextFormatter.MultiLine = true;
@@ -354,7 +354,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100 / 3),
             TextAlignment = Alignment.End,
             VerticalTextAlignment = Alignment.Center,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelMR.TextFormatter.MultiLine = true;
@@ -367,7 +367,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100, DimPercentMode.Position),
             TextAlignment = Alignment.Start,
             VerticalTextAlignment = Alignment.End,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelBL.TextFormatter.MultiLine = true;
@@ -380,7 +380,7 @@ public class TextAlignmentAndDirection : Scenario
             Height = Dim.Percent (100, DimPercentMode.Position),
             TextAlignment = Alignment.Center,
             VerticalTextAlignment = Alignment.End,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelBC.TextFormatter.MultiLine = true;
@@ -388,12 +388,12 @@ public class TextAlignmentAndDirection : Scenario
         var txtLabelBR = new AlignmentAndDirectionView
         {
             X = Pos.X (txtLabelMR),
-            Y = Pos.Bottom(txtLabelMR),
+            Y = Pos.Bottom (txtLabelMR),
             Width = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (100, DimPercentMode.Position),
             TextAlignment = Alignment.End,
             VerticalTextAlignment = Alignment.End,
-            ColorScheme = color1,
+            SchemeName = "TextAlignmentAndDirection1",
             Text = txt,
         };
         txtLabelBR.TextFormatter.MultiLine = true;
@@ -578,6 +578,12 @@ public class TextAlignmentAndDirection : Scenario
         app.Dispose ();
         Application.Shutdown ();
 
+        // Be a good citizen and remove the schemes we added
+        SchemeManager.RemoveScheme ("TextAlignmentAndDirection1");
+        SchemeManager.RemoveScheme ("TextAlignmentAndDirection2");
+
+        return;
+
         void ToggleJustify (bool oldValue, bool wasJustOptions = false)
         {
             if (oldValue)

+ 3 - 3
Examples/UICatalog/Scenarios/TextEffectsScenario.cs

@@ -34,14 +34,14 @@ public class TextEffectsScenario : Scenario
                               }
                           };
 
-        w.ColorScheme = new ()
+        w.SetScheme (new ()
         {
             Normal = new (ColorName16.White, ColorName16.Black),
             Focus = new (ColorName16.Black, ColorName16.White),
             HotNormal = new (ColorName16.White, ColorName16.Black),
             HotFocus = new (ColorName16.White, ColorName16.Black),
             Disabled = new (ColorName16.Gray, ColorName16.Black)
-        };
+        });
 
         var gradientsView = new GradientsView
         {
@@ -159,7 +159,7 @@ internal class GradientsView : View
 
         int width = text.Length;
         int x = xOffset + (GRADIENT_WIDTH - width) / 2; // Center the text within the gradient area width
-        SetAttribute (GetNormalColor ());
+        SetAttribute (GetAttributeForRole (VisualRole.Normal));
         Move (x, yOffset + 1);
         AddStr (text);
     }

+ 3 - 3
Examples/UICatalog/Scenarios/TextFormatterDemo.cs

@@ -31,7 +31,7 @@ public class TextFormatterDemo : Scenario
 
         var blockText = new Label
         {
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             X = 0,
             Y = 0,
 
@@ -78,7 +78,7 @@ public class TextFormatterDemo : Scenario
 
                 Width = Dim.Fill (),
                 Height = 1,
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 Text = text
             };
 
@@ -89,7 +89,7 @@ public class TextFormatterDemo : Scenario
 
                 Width = Dim.Fill (),
                 Height = multiLineHeight,
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 Text = text
             };
         }

+ 56 - 23
Examples/UICatalog/Scenarios/Text.cs → Examples/UICatalog/Scenarios/TextInputControls.cs

@@ -1,11 +1,6 @@
-using System;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
-using System.Text;
+using System.Text;
 using System.Text.RegularExpressions;
 using Terminal.Gui;
-using Terminal.Gui.TextValidateProviders;
 
 namespace UICatalog.Scenarios;
 
@@ -13,7 +8,7 @@ namespace UICatalog.Scenarios;
 [ScenarioCategory ("Controls")]
 [ScenarioCategory ("Mouse and Keyboard")]
 [ScenarioCategory ("Text and Formatting")]
-public class Text : Scenario
+public class TextInputControls : Scenario
 {
     private Label _labelMirroringTimeField;
     private TimeField _timeField;
@@ -22,8 +17,9 @@ public class Text : Scenario
     {
         Application.Init ();
         var win = new Window { Title = GetQuitKeyAndName () };
+
         // TextField is a simple, single-line text input control
-        var label = new Label { Text = "_TextField:" };
+        var label = new Label { Text = " _TextField:" };
         win.Add (label);
 
         var textField = new TextField
@@ -36,9 +32,9 @@ public class Text : Scenario
 
         var singleWordGenerator = new SingleWordSuggestionGenerator ();
         textField.Autocomplete.SuggestionGenerator = singleWordGenerator;
-        textField.TextChanging += TextField_TextChanging;
+        textField.TextChanging += TextFieldTextChanging;
 
-        void TextField_TextChanging (object sender, CancelEventArgs<string> e)
+        void TextFieldTextChanging (object sender, CancelEventArgs<string> e)
         {
             singleWordGenerator.AllSuggestions = Regex.Matches (e.NewValue, "\\w+")
                                                       .Select (s => s.Value)
@@ -60,16 +56,34 @@ public class Text : Scenario
         win.Add (labelMirroringTextField);
         textField.TextChanged += (s, prev) => { labelMirroringTextField.Text = textField.Text; };
 
+        label = new Label
+        {
+            Text = "Te_xtField2:",
+            X = 0,
+            Y = Pos.Bottom (textField)
+        };
+        win.Add (label);
+
+        textField = new TextField
+        {
+            X = Pos.Right (label) + 1,
+            Y = Pos.Bottom (textField),
+            Width = Dim.Percent (50) - 1,
+            Caption = "TextField with caption"
+        };
+
+        win.Add (textField);
+
         // TextView is a rich (as in functionality, not formatting) text editing control
-        label = new() { Text = "T_extView:", Y = Pos.Bottom (label) + 1 };
+        label = new () { Text = "T_extView:", Y = Pos.Bottom (label) + 1 };
         win.Add (label);
 
         var textView = new TextView
         {
-            X = Pos.Right (label) + 1, 
-            Y = Pos.Top (label), 
-            Width = Dim.Percent (50) - 1, 
-            Height = Dim.Percent (20)
+            X = Pos.Right (label) + 1,
+            Y = Pos.Top (label),
+            Width = Dim.Percent (50) - 1,
+            Height = Dim.Percent (10)
         };
         textView.Text = "TextView with some more test text. Unicode shouldn't 𝔹Aℝ𝔽!";
         textView.DrawingContent += TextView_DrawContent;
@@ -104,11 +118,18 @@ public class Text : Scenario
                                         labelMirroringTextView.Text = textView.Text;
                                     };
 
+        CheckBox chxReadOnly = new ()
+        {
+            X = Pos.Left (textView), Y = Pos.Bottom (textView), CheckedState = textView.ReadOnly ? CheckState.Checked : CheckState.UnChecked, Text = "Read_Only"
+        };
+        chxReadOnly.CheckedStateChanging += (sender, args) => textView.ReadOnly = args.NewValue == CheckState.Checked;
+        win.Add (chxReadOnly);
+
         // By default TextView is a multi-line control. It can be forced to 
         // single-line mode.
         var chxMultiline = new CheckBox
         {
-            X = Pos.Left (textView), Y = Pos.Bottom (textView), CheckedState = textView.Multiline ? CheckState.Checked : CheckState.UnChecked, Text = "_Multiline"
+            X = Pos.Right (chxReadOnly) + 2, Y = Pos.Bottom (textView), CheckedState = textView.Multiline ? CheckState.Checked : CheckState.UnChecked, Text = "_Multiline"
         };
         win.Add (chxMultiline);
 
@@ -169,7 +190,7 @@ public class Text : Scenario
         win.Add (chxCaptureTabs);
 
         // Hex editor
-        label = new() { Text = "_HexView:", Y = Pos.Bottom (chxMultiline) + 1 };
+        label = new () { Text = "_HexView:", Y = Pos.Bottom (chxMultiline) + 1 };
         win.Add (label);
 
         var hexEditor =
@@ -201,7 +222,7 @@ public class Text : Scenario
         win.Add (labelMirroringHexEditor);
 
         // DateField
-        label = new() { Text = "_DateField:", Y = Pos.Bottom (hexEditor) + 1 };
+        label = new () { Text = "_DateField:", Y = Pos.Bottom (hexEditor) + 1 };
         win.Add (label);
 
         var dateField = new DateField (DateTime.Now) { X = Pos.Right (label) + 1, Y = Pos.Bottom (hexEditor) + 1, Width = 20 };
@@ -221,10 +242,10 @@ public class Text : Scenario
         dateField.TextChanged += (s, prev) => { labelMirroringDateField.Text = dateField.Text; };
 
         // TimeField
-        label = new() { Text = "T_imeField:", Y = Pos.Top (dateField), X = Pos.Right (labelMirroringDateField) + 5 };
+        label = new () { Text = "T_imeField:", Y = Pos.Top (dateField), X = Pos.Right (labelMirroringDateField) + 5 };
         win.Add (label);
 
-        _timeField = new()
+        _timeField = new ()
         {
             X = Pos.Right (label) + 1,
             Y = Pos.Top (dateField),
@@ -234,7 +255,7 @@ public class Text : Scenario
         };
         win.Add (_timeField);
 
-        _labelMirroringTimeField = new()
+        _labelMirroringTimeField = new ()
         {
             X = Pos.Right (_timeField) + 1,
             Y = Pos.Top (_timeField),
@@ -324,7 +345,7 @@ public class Text : Scenario
 
         appendAutocompleteTextField.Autocomplete.SuggestionGenerator = new SingleWordSuggestionGenerator
         {
-            AllSuggestions = new()
+            AllSuggestions = new ()
             {
                 "fish",
                 "flipper",
@@ -444,8 +465,11 @@ public class Text : Scenario
 
         win.Accepting += WinOnAccept;
 
+        ConfigurationManager.Applied += ConfigurationManagerOnApplied;
+
         Application.Run (win);
         win.Dispose ();
+        win = null;
         Application.Shutdown ();
 
         return;
@@ -454,7 +478,7 @@ public class Text : Scenario
         {
             e.Handled = true; // Don't let it close
 
-            acceptView.Text = $"Accept was Invoked via {win.Focused.GetType().Name}";
+            acceptView.Text = $"Accept was Invoked via {win.Focused.GetType ().Name}";
 
             // Start a task that will set acceptView.Text to an empty string after 1 second
             System.Threading.Tasks.Task.Run (async () =>
@@ -463,8 +487,17 @@ public class Text : Scenario
                 Application.Invoke (() => acceptView.Text = "");
             });
         }
+
+        void ConfigurationManagerOnApplied (object sender, ConfigurationManagerEventArgs e)
+        {
+            if (win is { })
+            {
+                win.SetNeedsDraw ();
+            }
+        }
     }
 
 
+
     private void TimeChanged (object sender, DateTimeEventArgs<TimeSpan> e) { _labelMirroringTimeField.Text = _timeField.Text; }
 }

+ 134 - 35
Examples/UICatalog/Scenarios/TextStyles.cs

@@ -8,6 +8,8 @@ namespace UICatalog.Scenarios;
 [ScenarioCategory ("Colors")]
 public sealed class TestStyles : Scenario
 {
+    private CheckBox? _drawDirectly;
+
     public override void Main ()
     {
         // Init
@@ -16,11 +18,33 @@ public sealed class TestStyles : Scenario
         // Setup - Create a top-level application window and configure it.
         Window appWindow = new ()
         {
-            Title = GetQuitKeyAndName (),
-            BorderStyle = LineStyle.None
+            Id = "appWindow",
+            Title = GetQuitKeyAndName ()
         };
 
+        //appWindow.ContentSizeTracksViewport = false;
+        appWindow.VerticalScrollBar.AutoShow = true;
+        appWindow.HorizontalScrollBar.AutoShow = true;
+
+        appWindow.SubViewsLaidOut += (sender, _) =>
+                                     {
+                                         if (sender is View sendingView)
+                                         {
+                                             sendingView.SetContentSize (new Size(sendingView.GetContentSize().Width, sendingView.GetHeightRequiredForSubViews()));
+                                         }
+                                     };
+
         appWindow.DrawingContent += OnAppWindowOnDrawingContent;
+        appWindow.DrawingSubViews += OnAppWindowOnDrawingSubviews;
+
+        _drawDirectly = new ()
+        {
+            Title = "_Draw styled text directly using DrawingContent vs. Buttons",
+            CheckedState = CheckState.UnChecked
+        };
+
+        appWindow.Add (_drawDirectly);
+        AddButtons (appWindow);
 
         // Run - Start the application.
         Application.Run (appWindow);
@@ -30,47 +54,130 @@ public sealed class TestStyles : Scenario
         Application.Shutdown ();
     }
 
+    private void AddButtons (Window appWindow)
+    {
+        var y = 1;
+
+        TextStyle [] allStyles = Enum.GetValues (typeof (TextStyle))
+                                     .Cast<TextStyle> ()
+                                     .Where (style => style != TextStyle.None)
+                                     .ToArray ();
+
+        // Add individual flags as labels
+        foreach (TextStyle style in allStyles)
+        {
+            y++;
+
+            var button = new Button
+            {
+                X = 0,
+                Y = y,
+                Title = $"{Enum.GetName (typeof (TextStyle), style)}",
+                Visible = _drawDirectly!.CheckedState != CheckState.Checked
+            };
+
+            button.GettingAttributeForRole += (sender, args) =>
+                                              {
+                                                  if (sender is not Button buttonSender)
+                                                  {
+                                                      return;
+                                                  }
+                                                  args.NewValue = args.NewValue with { Style = style };
+                                                  args.Cancel = true;
+                                              };
+
+            appWindow.Add (button);
+        }
+
+        // Add a blank line
+        y += 1;
+
+        // Generate all combinations of TextStyle (excluding individual flags)
+        int totalCombinations = 1 << allStyles.Length; // 2^n combinations
+
+        for (var i = 1; i < totalCombinations; i++) // Start from 1 to skip "None"
+        {
+            var combination = (TextStyle)0;
+            List<string> styleNames = [];
+
+            for (var bit = 0; bit < allStyles.Length; bit++)
+            {
+                if ((i & (1 << bit)) != 0)
+                {
+                    combination |= allStyles [bit];
+                    styleNames.Add (Enum.GetName (typeof (TextStyle), allStyles [bit])!);
+                }
+            }
+
+            // Skip individual flags
+            if (styleNames.Count == 1)
+            {
+                continue;
+            }
+
+            y++;
+
+            var button = new Button
+            {
+                X = 0,
+                Y = y,
+                Text = $"[{string.Join (" | ", styleNames)}]",
+                Visible = _drawDirectly!.CheckedState != CheckState.Checked
+            };
+            button.GettingAttributeForRole += (_, args) =>
+                                              {
+                                                  args.NewValue = args.NewValue with { Style = combination };
+                                                  args.Cancel = true;
+                                              };
+            appWindow.Add (button);
+        }
+    }
+
+    private void OnAppWindowOnDrawingSubviews (object? sender, DrawEventArgs e)
+    {
+        if (sender is not View sendingVioew)
+        {
+            return;
+        }
+
+        foreach (Button view in sendingVioew.SubViews.OfType<Button> ())
+        {
+            view.Visible = _drawDirectly!.CheckedState != CheckState.Checked;
+        }
+
+        e.Cancel = false;
+    }
+
     private void OnAppWindowOnDrawingContent (object? sender, DrawEventArgs args)
     {
-        if (sender is View { } sendingView)
+        if (sender is View { } sendingView && _drawDirectly!.CheckedState == CheckState.Checked)
         {
-            var y = 0;
-            var x = 0;
-            int maxWidth = sendingView.Viewport.Width; // Get the available width of the view
+            int y = 2 - args.NewViewport.Y; // Start drawing below the checkbox
 
             TextStyle [] allStyles = Enum.GetValues (typeof (TextStyle))
                                          .Cast<TextStyle> ()
                                          .Where (style => style != TextStyle.None)
                                          .ToArray ();
 
-            // Draw individual flags on the first line
+            // Draw individual flags, one per line
             foreach (TextStyle style in allStyles)
             {
                 string text = Enum.GetName (typeof (TextStyle), style)!;
-                int textWidth = text.Length;
 
-                // Check if the text fits in the current line
-                if (x + textWidth >= maxWidth)
-                {
-                    x = 0; // Move to the next line
-                    y++;
-                }
-
-                sendingView.Move (x, y);
+                sendingView.Move (0, y);
 
-                var attr = new Attribute (sendingView.GetNormalColor ())
+                var attr = new Attribute (sendingView.GetAttributeForRole (VisualRole.Normal))
                 {
-                    TextStyle = style
+                    Style = style
                 };
                 sendingView.SetAttribute (attr);
                 sendingView.AddStr (text);
 
-                x += textWidth + 2; // Add spacing between entries
+                y++; // Move to the next line
             }
 
             // Add a blank line
-            y += 2;
-            x = 0;
+            y++;
 
             // Generate all combinations of TextStyle (excluding individual flags)
             int totalCombinations = 1 << allStyles.Length; // 2^n combinations
@@ -78,7 +185,7 @@ public sealed class TestStyles : Scenario
             for (var i = 1; i < totalCombinations; i++) // Start from 1 to skip "None"
             {
                 var combination = (TextStyle)0;
-                List<string> styleNames = new ();
+                List<string> styleNames = [];
 
                 for (var bit = 0; bit < allStyles.Length; bit++)
                 {
@@ -95,26 +202,18 @@ public sealed class TestStyles : Scenario
                     continue;
                 }
 
-                string text = $"[{string.Join (" | ", styleNames)}]";
-                int textWidth = text.Length;
-
-                // Check if the text fits in the current line
-                if (x + textWidth >= maxWidth)
-                {
-                    x = 0; // Move to the next line
-                    y++;
-                }
+                var text = $"[{string.Join (" | ", styleNames)}]";
 
-                sendingView.Move (x, y);
+                sendingView.Move (00, y);
 
-                var attr = new Attribute (sendingView.GetNormalColor ())
+                var attr = new Attribute (sendingView.GetAttributeForRole (VisualRole.Normal))
                 {
-                    TextStyle = combination
+                    Style = combination
                 };
                 sendingView.SetAttribute (attr);
                 sendingView.AddStr (text);
 
-                x += textWidth + 2; // Add spacing between entries
+                y++; // Move to the next line
             }
 
             args.Cancel = true;

+ 276 - 0
Examples/UICatalog/Scenarios/Themes.cs

@@ -0,0 +1,276 @@
+#nullable enable
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+[ScenarioMetadata ("Themes", "Shows off Themes, Schemes, and VisualRoles.")]
+[ScenarioCategory ("Colors")]
+[ScenarioCategory ("Drawing")]
+[ScenarioCategory ("Configuration")]
+public sealed class Themes : Scenario
+{
+    private View? _view;
+
+    public override void Main ()
+    {
+        // Init
+        Application.Init ();
+
+        // Setup - Create a top-level application window and configure it.
+        Window appWindow = new ()
+        {
+            Title = GetQuitKeyAndName (),
+            BorderStyle = LineStyle.None
+        };
+
+        string[]  options = ThemeManager.GetThemeNames ().Select (option => option = "_" + option).ToArray ();
+        RadioGroup themeOptionSelector = new ()
+        {
+            Title = "_Themes",
+            BorderStyle = LineStyle.Rounded,
+            Width = Dim.Auto (),
+            Height = Dim.Auto (),
+            RadioLabels= options,
+            SelectedItem = ThemeManager.GetThemeNames ().IndexOf (ThemeManager.Theme)
+        };
+        themeOptionSelector.Border!.Thickness = new (0, 1, 0, 0);
+        themeOptionSelector.Margin!.Thickness = new (0, 0, 1, 0);
+
+        themeOptionSelector.SelectedItemChanged += (sender, args) =>
+                                             {
+                                                 RadioGroup? optionSelector = sender as RadioGroup;
+                                                 if (optionSelector is null)
+                                                 {
+                                                     return;
+                                                 }
+                                                 var newTheme = optionSelector!.RadioLabels! [(int)args.SelectedItem!] as string;
+                                                 // strip off the leading underscore
+                                                 ThemeManager.Theme = newTheme!.Substring (1);
+                                                 ConfigurationManager.Apply ();
+                                             };
+
+        var themeViewer = new ThemeViewer
+        {
+            X = Pos.Right (themeOptionSelector)
+        };
+
+        Dictionary<string, Type> viewClasses = GetAllViewClassesCollection ()
+                                               .OrderBy (t => t.Name)
+                                               .Select (t => new KeyValuePair<string, Type> (t.Name, t))
+                                               .ToDictionary (t => t.Key, t => t.Value);
+
+        CheckBox? allViewsCheckBox = new ()
+        {
+            Title = "_All Views",
+            X = Pos.Right (themeViewer),
+        };
+
+        ListView viewListView = new ()
+        {
+            X = Pos.Right (themeViewer),
+            Y = Pos.Bottom(allViewsCheckBox),
+            Title = "_Views",
+            BorderStyle = LineStyle.Rounded,
+            Width = Dim.Auto (),
+            Height = Dim.Fill (),
+            Source = new ListWrapper<string> (new (viewClasses.Keys))
+        };
+        viewListView.Border!.Thickness = new (0, 1, 0, 0);
+        viewListView.Margin!.Thickness = new (0, 0, 1, 0);
+
+        viewListView.VerticalScrollBar.AutoShow = true;
+
+
+        ViewPropertiesEditor viewPropertiesEditor = new ()
+        {
+            X = Pos.Right (viewListView),
+            Width = Dim.Fill (),
+            Height = Dim.Auto (),
+        };
+
+        FrameView? viewFrame = new ()
+        {
+            X = Pos.Right (viewListView),
+            Y = Pos.Bottom(viewPropertiesEditor),
+            Title = "The View",
+            BorderStyle = LineStyle.Rounded,
+            Width = Dim.Fill (),
+            Height = Dim.Fill (),
+            TabStop = TabBehavior.TabStop
+        };
+        viewFrame.Border!.Thickness = new (0, 1, 0, 0);
+
+        viewListView.SelectedItemChanged += (sender, args) =>
+                                            {
+                                                var listView = sender as ListView;
+
+                                                if (_view is { })
+                                                {
+                                                    viewPropertiesEditor.ViewToEdit = null;
+                                                    viewFrame.Remove (_view);
+                                                    _view.Dispose ();
+                                                    _view = null;
+                                                }
+
+                                                _view = CreateView (viewClasses [(args.Value as string)!]);
+
+                                                if (_view is { })
+                                                {
+                                                    viewFrame.Add (_view);
+                                                    viewPropertiesEditor.ViewToEdit = _view;
+                                                }
+                                            };
+
+
+        appWindow.Add (themeOptionSelector, themeViewer, allViewsCheckBox, viewListView, viewPropertiesEditor, viewFrame);
+
+        viewListView.SelectedItem = 0;
+
+        themeViewer.SettingSchemeName += (sender, args) =>
+                                         {
+                                             if (_view is { })
+                                             {
+                                                 Application.Top!.SchemeName = args.NewString;
+
+                                                 if (_view.HasScheme)
+                                                 {
+                                                     _view.SetScheme (null);
+                                                 }
+
+                                                 _view.SchemeName = args.NewString;
+                                             }
+                                         };
+
+        AllViewsView? allViewsView = null;
+
+        allViewsCheckBox.CheckedStateChanged += (sender, args) =>
+                                                {
+                                                    if (args.CurrentValue == CheckState.Checked)
+                                                    {
+                                                        viewListView.Visible = false;
+                                                        appWindow.Remove (viewFrame);
+
+                                                        allViewsView = new AllViewsView ()
+                                                        {
+                                                            X = Pos.Right (themeViewer),
+                                                            Y = Pos.Bottom (viewPropertiesEditor),
+                                                            Title = "All Views - Focused: {None}",
+                                                            BorderStyle = LineStyle.Rounded,
+                                                            Width = Dim.Fill (),
+                                                            Height = Dim.Fill (),
+                                                            TabStop = TabBehavior.TabStop
+                                                        };
+
+                                                        allViewsView.FocusedChanged += (s, args) =>
+                                                                                       {
+                                                                                           allViewsView.Title =
+                                                                                               $"All Views - Focused: {args.NewFocused.Title}";
+                                                                                           viewPropertiesEditor.ViewToEdit = args.NewFocused.SubViews.ElementAt(0);
+
+                                                                                       };
+                                                        appWindow.Add (allViewsView);
+                                                    }
+                                                    else
+                                                    {
+                                                        appWindow.Remove (allViewsView);
+                                                        allViewsView.Dispose ();
+                                                        allViewsView = null;
+
+                                                        appWindow.Add (viewFrame);
+                                                        viewListView.Visible = true;
+                                                    }
+                                                };
+
+        // Run - Start the application.
+        Application.Run (appWindow);
+        viewFrame.Dispose ();
+        appWindow.Dispose ();
+
+        // Shutdown - Calling Application.Shutdown is required.
+        Application.Shutdown ();
+    }
+
+    private static List<Type> GetAllViewClassesCollection ()
+    {
+        List<Type> types = typeof (View).Assembly.GetTypes ()
+                                        .Where (
+                                                myType => myType is { IsClass: true, IsAbstract: false, IsPublic: true }
+                                                          && myType.IsSubclassOf (typeof (View)))
+                                        .ToList ();
+
+        types.Add (typeof (View));
+
+        return types;
+    }
+
+    private View? CreateView (Type type)
+    {
+        // If we are to create a generic Type
+        if (type.IsGenericType)
+        {
+            // For each of the <T> arguments
+            List<Type> typeArguments = new ();
+
+            // use <object> or the original type if applicable
+            foreach (Type arg in type.GetGenericArguments ())
+            {
+                if (arg.IsValueType && Nullable.GetUnderlyingType (arg) == null)
+                {
+                    typeArguments.Add (arg);
+                }
+                else
+                {
+                    typeArguments.Add (typeof (object));
+                }
+            }
+
+            // And change what type we are instantiating from MyClass<T> to MyClass<object> or MyClass<T>
+            type = type.MakeGenericType (typeArguments.ToArray ());
+        }
+
+        // Ensure the type does not contain any generic parameters
+        if (type.ContainsGenericParameters)
+        {
+            Logging.Warning ($"Cannot create an instance of {type} because it contains generic parameters.");
+
+            //throw new ArgumentException ($"Cannot create an instance of {type} because it contains generic parameters.");
+            return null;
+        }
+
+        // Instantiate view
+        var view = (View)Activator.CreateInstance (type)!;
+        var demoText = "This, that, and the other thing.";
+
+        if (view is IDesignable designable)
+        {
+            designable.EnableForDesign (ref demoText);
+        }
+        else
+        {
+            view.Text = demoText;
+            view.Title = "_Test Title";
+        }
+
+        view.Initialized += OnViewInitialized;
+
+        return view;
+    }
+
+    private void OnViewInitialized (object? sender, EventArgs e)
+    {
+        if (sender is not View view)
+        {
+            return;
+        }
+
+        if (view.Width == Dim.Absolute (0) || view.Width is null)
+        {
+            view.Width = Dim.Fill ();
+        }
+
+        if (view.Height == Dim.Absolute (0) || view.Height is null)
+        {
+            view.Height = Dim.Fill ();
+        }
+    }
+}

+ 2 - 2
Examples/UICatalog/Scenarios/Threading.cs

@@ -66,7 +66,7 @@ public class Threading : Scenario
             Y = Pos.Y (_btnActionCancel) + 6,
             Width = 10,
             Height = 10,
-            ColorScheme = Colors.ColorSchemes ["TopLevel"]
+            SchemeName = "TopLevel"
         };
 
         win.Add (new Label { X = Pos.Right (_itemsList) + 10, Y = Pos.Y (_btnActionCancel) + 4, Text = "Task Logs:" });
@@ -77,7 +77,7 @@ public class Threading : Scenario
             Y = Pos.Y (_itemsList),
             Width = 50,
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Source = new ListWrapper<string> (_log)
         };
 

+ 26 - 12
Examples/UICatalog/Scenarios/Transparent.cs

@@ -17,7 +17,7 @@ public sealed class Transparent : Scenario
             Title = GetQuitKeyAndName (),
         };
         appWindow.BorderStyle = LineStyle.None;
-        appWindow.ColorScheme = Colors.ColorSchemes ["Error"];
+        appWindow.SchemeName = "Error";
 
         appWindow.Text = "App Text - Centered Vertically and Horizontally.\n2nd Line of Text.\n3rd Line of Text.";
         appWindow.TextAlignment = Alignment.Center;
@@ -45,10 +45,13 @@ public sealed class Transparent : Scenario
             Y = 4,
             Title = "_AppButton",
         };
-        appButton.Accepting += (sender, args) => MessageBox.Query ("AppButton", "Transparency is cool!", "_Ok");
+        appButton.Accepting += (sender, args) =>
+                               {
+                                   MessageBox.Query ("AppButton", "Transparency is cool!", "_Ok");
+                                   args.Handled = true;
+                               };
         appWindow.Add (appButton);
 
-
         var tv = new TransparentView ()
         {
             X = 3,
@@ -77,11 +80,11 @@ public sealed class Transparent : Scenario
             Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable | ViewArrangement.Movable;
             ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent | Terminal.Gui.ViewportSettings.TransparentMouse;
             BorderStyle = LineStyle.RoundedDotted;
-            base.ColorScheme = Colors.ColorSchemes ["Base"];
+            //SchemeName = "Base";
 
             var transparentSubView = new View ()
             {
-                Text = "Sizable/Movable View with border. Should be opaque. The shadow should be semi-opaque.",
+                Text = "Sizable/Movable View with border. Should be opaque. No Shadow.",
                 Id = "transparentSubView",
                 X = 4,
                 Y = 8,
@@ -89,31 +92,36 @@ public sealed class Transparent : Scenario
                 Height = 8,
                 BorderStyle = LineStyle.Dashed,
                 Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
-               // ShadowStyle = ShadowStyle.Transparent,
+                // ShadowStyle = ShadowStyle.Transparent,
             };
             transparentSubView.Border!.Thickness = new (1, 1, 1, 1);
-            transparentSubView.ColorScheme = Colors.ColorSchemes ["Dialog"];
-            transparentSubView.Visible = false;
+            transparentSubView.SchemeName = "Dialog";
+            //transparentSubView.Visible = false;
 
             Button button = new Button ()
             {
                 Title = "_Opaque Shadows No Worky",
                 X = Pos.Center (),
                 Y = 2,
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
             };
-            button.Visible = false;
+            button.Accepting += (sender, args) =>
+                                {
+                                    MessageBox.Query ("Clicked!", "Button in Transparent View", "_Ok");
+                                    args.Handled = true;
+                                };
+            //button.Visible = false;
 
 
             var shortcut = new Shortcut ()
             {
                 Id = "shortcut",
                 X = Pos.Center (),
-                Y = Pos.AnchorEnd(),
+                Y = Pos.AnchorEnd (),
                 Title = "A _Shortcut",
                 HelpText = "Help!",
                 Key = Key.F11,
-                ColorScheme = Colors.ColorSchemes ["Base"]
+                SchemeName = "Base"
 
             };
 
@@ -126,6 +134,12 @@ public sealed class Transparent : Scenario
             base.Add (button);
             base.Add (shortcut);
             base.Add (transparentSubView);
+
+            //Padding.Thickness = new (1);
+            //Padding.SchemeName = "Error";
+
+            Margin!.Thickness = new (1);
+           // Margin.ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent;
         }
 
         /// <inheritdoc />

+ 9 - 8
Examples/UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -177,7 +177,7 @@ public class TreeViewFileSystem : Scenario
         };
         top.Add (menu);
 
-        _treeViewFiles = new() { X = 0, Y = 0, Width = Dim.Percent (50), Height = Dim.Fill () };
+        _treeViewFiles = new () { X = 0, Y = 0, Width = Dim.Percent (50), Height = Dim.Fill () };
         _treeViewFiles.DrawLine += TreeViewFiles_DrawLine;
 
         _treeViewFiles.VerticalScrollBar.AutoShow = false;
@@ -247,15 +247,15 @@ public class TreeViewFileSystem : Scenario
                                          {
                                              if (m is IDirectoryInfo && m.Attributes.HasFlag (FileAttributes.Hidden))
                                              {
-                                                 return new()
+                                                 return new ()
                                                  {
                                                      Focus = new (
                                                                   Color.BrightRed,
-                                                                  _treeViewFiles.ColorScheme.Focus.Background
+                                                                  _treeViewFiles.GetAttributeForRole (VisualRole.Focus).Background
                                                                  ),
                                                      Normal = new (
                                                                    Color.BrightYellow,
-                                                                   _treeViewFiles.ColorScheme.Normal.Background
+                                                                   _treeViewFiles.GetAttributeForRole (VisualRole.Normal).Background
                                                                   )
                                                  };
 
@@ -264,15 +264,15 @@ public class TreeViewFileSystem : Scenario
 
                                              if (m is IFileInfo && m.Attributes.HasFlag (FileAttributes.Hidden))
                                              {
-                                                 return new()
+                                                 return new ()
                                                  {
                                                      Focus = new (
                                                                   Color.BrightRed,
-                                                                  _treeViewFiles.ColorScheme.Focus.Background
+                                                                  _treeViewFiles.GetAttributeForRole (VisualRole.Focus).Background
                                                                  ),
                                                      Normal = new (
                                                                    Color.BrightYellow,
-                                                                   _treeViewFiles.ColorScheme.Normal.Background
+                                                                   _treeViewFiles.GetAttributeForRole (VisualRole.Normal).Background
                                                                   )
                                                  };
 
@@ -447,7 +447,8 @@ public class TreeViewFileSystem : Scenario
 
                     cell.Attribute = new Attribute (
                                                     Color.BrightYellow,
-                                                    cell.Attribute!.Value.Background
+                                                    cell.Attribute!.Value.Background,
+                                                    cell.Attribute!.Value.Style
                                                    );
                 }
             }

+ 13 - 14
Examples/UICatalog/Scenarios/TrueColors.cs

@@ -105,19 +105,19 @@ public class TrueColors : Scenario
 
                                       if (e.Flags == MouseFlags.Button1Clicked)
                                       {
-                                          Attribute normal = e.View.GetNormalColor ();
+                                          Attribute normal = e.View.GetAttributeForRole (VisualRole.Normal);
 
-                                          lblLighter.ColorScheme = new (e.View.ColorScheme)
+                                          lblLighter.SetScheme (new (e.View.GetScheme ())
                                           {
                                               Normal = new (
                                                             normal.Foreground,
-                                                            normal.Background.GetHighlightColor ()
+                                                            normal.Background.GetBrighterColor ()
                                                            )
-                                          };
+                                          });
                                       }
                                       else
                                       {
-                                          Attribute normal = e.View.GetNormalColor ();
+                                          Attribute normal = e.View.GetAttributeForRole (VisualRole.Normal);
                                           lblRed.Text = normal.Foreground.R.ToString ();
                                           lblGreen.Text = normal.Foreground.G.ToString ();
                                           lblBlue.Text = normal.Foreground.B.ToString ();
@@ -140,16 +140,15 @@ public class TrueColors : Scenario
                 var l = new Label
                 {
                     X = dx++,
-                    Y = y,
-                    ColorScheme = new()
-                    {
-                        Normal = new (
-                                      colorFunc (Math.Clamp (i, 0, 255)),
-                                      colorFunc (Math.Clamp (i, 0, 255))
-                                     )
-                    },
-                    Text = " "
+                    Y = y
                 };
+                l.SetScheme (new ()
+                {
+                    Normal = new (
+                                  colorFunc (Math.Clamp (i, 0, 255)),
+                                  colorFunc (Math.Clamp (i, 0, 255))
+                                 )
+                });
                 app.Add (l);
             }
 

+ 13 - 12
Examples/UICatalog/Scenarios/ViewportSettings.cs

@@ -19,7 +19,7 @@ public class ViewportSettings : Scenario
             Id = "ViewportSettingsDemoView";
             Width = Dim.Fill ();
             Height = Dim.Fill ();
-            base.ColorScheme = Colors.ColorSchemes ["Base"];
+            SchemeName = "base";
 
             base.Text =
                 "Text (ViewportSettingsDemoView.Text). This is long text.\nThe second line.\n3\n4\n5th line\nLine 6. This is a longer line that should wrap automatically.";
@@ -103,13 +103,13 @@ public class ViewportSettings : Scenario
             Title = GetQuitKeyAndName (),
 
             // Use a different colorscheme so ViewSettings.ClearContentOnly is obvious
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "Toplevel",
             BorderStyle = LineStyle.None
         };
 
         var adornmentsEditor = new AdornmentsEditor
         {
-            X = Pos.AnchorEnd(),
+            X = Pos.AnchorEnd (),
             AutoSelectViewToEdit = true,
             ShowViewIdentifier = true
         };
@@ -117,7 +117,7 @@ public class ViewportSettings : Scenario
 
         ViewportSettingsEditor viewportSettingsEditor = new ViewportSettingsEditor ()
         {
-            Y = Pos.AnchorEnd(),
+            Y = Pos.AnchorEnd (),
             //X = Pos.Right (adornmentsEditor),
         };
         app.Add (viewportSettingsEditor);
@@ -125,7 +125,7 @@ public class ViewportSettings : Scenario
         var view = new ViewportSettingsDemoView
         {
             Title = "ViewportSettings Demo View",
-            Width = Dim.Fill (Dim.Func (() => app.IsInitialized ? adornmentsEditor.Frame.Width+1: 1)),
+            Width = Dim.Fill (Dim.Func (() => app.IsInitialized ? adornmentsEditor.Frame.Width + 1 : 1)),
             Height = Dim.Fill (Dim.Func (() => app.IsInitialized ? viewportSettingsEditor.Frame.Height : 1))
         };
 
@@ -139,13 +139,14 @@ public class ViewportSettings : Scenario
 
         colorPicker.ColorChanged += (s, e) =>
                                     {
-                                        colorPicker.SuperView.ColorScheme = new (colorPicker.SuperView.ColorScheme)
-                                        {
-                                            Normal = new (
-                                                          colorPicker.SuperView.ColorScheme.Normal.Foreground,
-                                                          e.CurrentValue
-                                                         )
-                                        };
+                                        colorPicker.SuperView!.SetScheme (
+                                                                         new (colorPicker.SuperView.GetScheme ())
+                                                                         {
+                                                                             Normal = new (
+                                                                                           colorPicker.SuperView.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                                           e.CurrentValue
+                                                                                          )
+                                                                         });
                                     };
 
         var textView = new TextView

+ 4 - 4
Examples/UICatalog/Scenarios/VkeyPacketSimulator.cs

@@ -31,7 +31,7 @@ public class VkeyPacketSimulator : Scenario
 
         var inputHorizontalRuler = new Label
         {
-            Y = Pos.Bottom (btnInput), Width = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["Error"]
+            Y = Pos.Bottom (btnInput), Width = Dim.Fill (), SchemeName = "Error"
         };
         win.Add (inputHorizontalRuler);
 
@@ -41,7 +41,7 @@ public class VkeyPacketSimulator : Scenario
 
             Width = 1,
             Height = Dim.Percent (50),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             TextDirection = TextDirection.TopBottom_LeftRight
         };
         win.Add (inputVerticalRuler);
@@ -67,7 +67,7 @@ public class VkeyPacketSimulator : Scenario
             Y = Pos.Bottom (btnOutput),
 
             Width = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Error"]
+            SchemeName = "Error"
         };
         win.Add (outputHorizontalRuler);
 
@@ -77,7 +77,7 @@ public class VkeyPacketSimulator : Scenario
 
             Width = 1,
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             TextDirection = TextDirection.TopBottom_LeftRight
         };
         win.Add (outputVerticalRuler);

+ 16 - 16
Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs

@@ -40,7 +40,7 @@ public class WindowsAndFrameViews : Scenario
             Y = 1,
             Width = Dim.Fill (15),
             Height = 10,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
+            SchemeName = "Dialog",
             Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable | ViewArrangement.Resizable
         };
         win.Padding.Thickness = new (padding);
@@ -50,7 +50,7 @@ public class WindowsAndFrameViews : Scenario
         {
             X = Pos.Center (),
             Y = 0,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = $"Padding of container is {padding}"
         };
         paddingButton.Accepting += (s, e) => About ();
@@ -61,7 +61,7 @@ public class WindowsAndFrameViews : Scenario
                  {
                      X = Pos.Center (),
                      Y = Pos.AnchorEnd (),
-                     ColorScheme = Colors.ColorSchemes ["Error"],
+                     SchemeName = "Error",
                      Text = "Press ME! (Y = Pos.AnchorEnd(1))"
                  }
                 );
@@ -81,7 +81,7 @@ public class WindowsAndFrameViews : Scenario
         {
             Window loopWin = null;
 
-            loopWin = new()
+            loopWin = new ()
             {
                 Title = $"{listWin.Count} - Window Loop - padding = {pad}",
                 X = margin,
@@ -92,11 +92,11 @@ public class WindowsAndFrameViews : Scenario
             };
             loopWin.Padding.Thickness = new (pad);
 
-            loopWin.ColorScheme = Colors.ColorSchemes ["Dialog"];
+            loopWin.SchemeName = "Dialog";
 
             var pressMeButton = new Button
             {
-                X = Pos.Center (), Y = 0, ColorScheme = Colors.ColorSchemes ["Error"], Text = "Press me! (Y = 0)",
+                X = Pos.Center (), Y = 0, SchemeName = "Error", Text = "Press me! (Y = 0)",
             };
 
             pressMeButton.Accepting += (s, e) =>
@@ -110,14 +110,14 @@ public class WindowsAndFrameViews : Scenario
                 Y = 1,
                 Width = Dim.Percent (50),
                 Height = 5,
-                ColorScheme = Colors.ColorSchemes ["Base"],
+                SchemeName = "Base",
                 Text = "The Text in the Window",
                 Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable | ViewArrangement.Resizable
 
             };
 
             subWin.Add (
-                        new TextField { Y = 1, ColorScheme = Colors.ColorSchemes ["Error"], Text = "Edit me! " + loopWin.Title }
+                        new TextField { Y = 1, SchemeName = "Error", Text = "Edit me! " + loopWin.Title }
                        );
             loopWin.Add (subWin);
 
@@ -127,7 +127,7 @@ public class WindowsAndFrameViews : Scenario
                 Y = 1,
                 Width = Dim.Percent (100, DimPercentMode.Position), // Or Dim.Percent (50)
                 Height = 5,
-                ColorScheme = Colors.ColorSchemes ["Base"],
+                SchemeName = "Base",
                 Text = "The Text in the FrameView",
                 Title = "This is a Sub-FrameView"
             };
@@ -143,7 +143,7 @@ public class WindowsAndFrameViews : Scenario
 
         FrameView frame = null;
 
-        frame = new()
+        frame = new ()
         {
             X = margin,
             Y = Pos.Bottom (listWin.Last ()) + margin / 2,
@@ -151,12 +151,12 @@ public class WindowsAndFrameViews : Scenario
             Height = contentHeight + 2, // 2 for default padding
             Title = "This is a FrameView"
         };
-        frame.ColorScheme = Colors.ColorSchemes ["Dialog"];
+        frame.SchemeName = "Dialog";
 
         frame.Add (
                    new Label
                    {
-                       X = Pos.Center (), Y = 0, ColorScheme = Colors.ColorSchemes ["Error"], Text = "This is a Label! (Y = 0)"
+                       X = Pos.Center (), Y = 0, SchemeName = "Error", Text = "This is a Label! (Y = 0)"
                    }
                   );
 
@@ -167,14 +167,14 @@ public class WindowsAndFrameViews : Scenario
             Y = 1,
             Width = Dim.Percent (50),
             Height = Dim.Fill () - 1,
-            ColorScheme = Colors.ColorSchemes ["Base"],
+            SchemeName = "Base",
             Text = "The Text in the Window",
             Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable | ViewArrangement.Resizable
 
         };
 
         subWinofFV.Add (
-                        new TextField { ColorScheme = Colors.ColorSchemes ["Error"], Text = "Edit Me" }
+                        new TextField { SchemeName = "Error", Text = "Edit Me" }
                        );
 
         subWinofFV.Add (new CheckBox { Y = 1, Text = "Check me" });
@@ -188,7 +188,7 @@ public class WindowsAndFrameViews : Scenario
             Y = 1,
             Width = Dim.Percent (100),
             Height = Dim.Fill () - 1,
-            ColorScheme = Colors.ColorSchemes ["Base"],
+            SchemeName = "Base",
             Text = "The Text in the FrameView",
             Title = "this is a Sub-FrameView"
         };
@@ -209,7 +209,7 @@ public class WindowsAndFrameViews : Scenario
         app.Add (frame);
         listWin.Add (frame);
 
-        app.ColorScheme = Colors.ColorSchemes ["Base"];
+        app.SchemeName = "Base";
 
         Application.Run (app);
         app.Dispose ();

+ 3 - 3
Examples/UICatalog/Scenarios/Wizards.cs

@@ -21,7 +21,7 @@ public class Wizards : Scenario
             X = Pos.Center (),
             Y = 0,
             Width = Dim.Percent (75),
-            ColorScheme = Colors.ColorSchemes ["Base"],
+            SchemeName = "Base",
             Title = "Wizard Options"
         };
         win.Add (frame);
@@ -99,7 +99,7 @@ public class Wizards : Scenario
 
         var actionLabel = new Label
         {
-            X = Pos.Right (label), Y = Pos.AnchorEnd (1), ColorScheme = Colors.ColorSchemes ["Error"]
+            X = Pos.Right (label), Y = Pos.AnchorEnd (1), SchemeName = "Error"
         };
         win.Add (actionLabel);
 
@@ -278,7 +278,7 @@ public class Wizards : Scenario
                                                Width = Dim.Fill (),
                                                WordWrap = true,
                                                AllowsTab = false,
-                                               ColorScheme = Colors.ColorSchemes ["Base"]
+                                               SchemeName = "Base"
                                            };
 
                                            someText.Height = Dim.Fill (

+ 31 - 25
Examples/UICatalog/UICatalog.cs

@@ -14,7 +14,6 @@ using Serilog;
 using Serilog.Core;
 using Serilog.Events;
 using Terminal.Gui;
-using static Terminal.Gui.ConfigurationManager;
 using Command = Terminal.Gui.Command;
 using ILogger = Microsoft.Extensions.Logging.ILogger;
 
@@ -77,6 +76,13 @@ public class UICatalog
         driverOption.AddAlias ("-d");
         driverOption.AddAlias ("--d");
 
+        // Configuration Management
+        Option<bool> disableConfigManagement = new (
+                                                    "--disable-cm",
+                                                    "Indicates Configuration Management should not be enabled. Only `ConfigLocations.HardCoded` settings will be loaded.");
+        disableConfigManagement.AddAlias ("-dcm");
+        disableConfigManagement.AddAlias ("--dcm");
+
         Option<bool> benchmarkFlag = new ("--benchmark", "Enables benchmarking. If a Scenario is specified, just that Scenario will be benchmarked.");
         benchmarkFlag.AddAlias ("-b");
         benchmarkFlag.AddAlias ("--b");
@@ -109,13 +115,13 @@ public class UICatalog
                                                                   getDefaultValue: () => "none"
                                                                  ).FromAmong (
                                                                               UICatalogTop.CachedScenarios.Select (s => s.GetName ())
-                                                                                               .Append ("none")
-                                                                                               .ToArray ()
+                                                                                          .Append ("none")
+                                                                                          .ToArray ()
                                                                              );
 
         var rootCommand = new RootCommand ("A comprehensive sample library and test app for Terminal.Gui")
         {
-            scenarioArgument, debugLogLevel, benchmarkFlag, benchmarkTimeout, resultsFile, driverOption
+            scenarioArgument, debugLogLevel, benchmarkFlag, benchmarkTimeout, resultsFile, driverOption, disableConfigManagement
         };
 
         rootCommand.SetHandler (
@@ -125,6 +131,7 @@ public class UICatalog
                                     {
                                         Scenario = context.ParseResult.GetValueForArgument (scenarioArgument),
                                         Driver = context.ParseResult.GetValueForOption (driverOption) ?? string.Empty,
+                                        DontEnableConfigurationManagement = context.ParseResult.GetValueForOption (disableConfigManagement),
                                         Benchmark = context.ParseResult.GetValueForOption (benchmarkFlag),
                                         BenchmarkTimeout = context.ParseResult.GetValueForOption (benchmarkTimeout),
                                         ResultsFile = context.ParseResult.GetValueForOption (resultsFile) ?? string.Empty,
@@ -217,16 +224,7 @@ public class UICatalog
 
         Application.Init (driverName: _forceDriver);
 
-        if (string.IsNullOrWhiteSpace (UICatalogTop.CachedTheme))
-        {
-            UICatalogTop.CachedTheme = Themes?.Theme;
-        }
-        else
-        {
-            Themes!.Theme = UICatalogTop.CachedTheme;
-        }
-
-        UICatalogTop top = Application.Run<UICatalogTop> ();
+        var top = Application.Run<UICatalogTop> ();
         top.Dispose ();
         Application.Shutdown ();
         VerifyObjectsWereDisposed ();
@@ -308,14 +306,13 @@ public class UICatalog
             return;
         }
 
-        Load ();
-        Apply ();
+        Logging.Debug ($"{e.FullPath} {e.ChangeType} - Loading and Applying");
+        ConfigurationManager.Load (ConfigLocations.All);
+        ConfigurationManager.Apply ();
     }
 
     private static void UICatalogMain (UICatalogCommandLineOptions options)
     {
-        StartConfigFileWatcher ();
-
         // By setting _forceDriver we ensure that if the user has specified a driver on the command line, it will be used
         // regardless of what's in a config file.
         Application.ForceDriver = _forceDriver = options.Driver;
@@ -324,12 +321,17 @@ public class UICatalog
         // run it and exit when done.
         if (options.Scenario != "none")
         {
+            if (!Options.DontEnableConfigurationManagement)
+            {
+                ConfigurationManager.Enable (ConfigLocations.All);
+            }
+
             int item = UICatalogTop.CachedScenarios!.IndexOf (
-                                                                   UICatalogTop.CachedScenarios!.FirstOrDefault (
-                                                                        s =>
-                                                                            s.GetName ()
-                                                                             .Equals (options.Scenario, StringComparison.OrdinalIgnoreCase)
-                                                                       )!);
+                                                              UICatalogTop.CachedScenarios!.FirstOrDefault (
+                                                                   s =>
+                                                                       s.GetName ()
+                                                                        .Equals (options.Scenario, StringComparison.OrdinalIgnoreCase)
+                                                                  )!);
             UICatalogTop.CachedSelectedScenario = (Scenario)Activator.CreateInstance (UICatalogTop.CachedScenarios [item].GetType ())!;
 
             BenchmarkResults? results = RunScenario (UICatalogTop.CachedSelectedScenario, options.Benchmark);
@@ -358,14 +360,18 @@ public class UICatalog
             return;
         }
 
-
 #if DEBUG_IDISPOSABLE
         View.EnableDebugIDisposableAsserts = true;
 #endif
 
-        while (RunUICatalogTopLevel () is { } scenario)
+        if (!Options.DontEnableConfigurationManagement)
         {
+            ConfigurationManager.Enable (ConfigLocations.All);
+            StartConfigFileWatcher ();
+        }
 
+        while (RunUICatalogTopLevel () is { } scenario)
+        {
 #if DEBUG_IDISPOSABLE
             VerifyObjectsWereDisposed ();
 

+ 4 - 4
Examples/UICatalog/UICatalog.csproj

@@ -27,14 +27,14 @@
         <None Update="Scenarios\AnimationScenario\Spinning_globe_dark_small.gif" CopyToOutputDirectory="PreserveNewest" />
     </ItemGroup>
     <ItemGroup>
-        <PackageReference Include="JetBrains.Annotations"  PrivateAssets="all" />
-        <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets"/>
+        <PackageReference Include="JetBrains.Annotations" PrivateAssets="all" />
+        <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" />
         <PackageReference Include="Serilog" />
         <PackageReference Include="Serilog.Extensions.Logging" />
-        <PackageReference Include="Serilog.Sinks.Debug"  />
+        <PackageReference Include="Serilog.Sinks.Debug" />
         <PackageReference Include="Serilog.Sinks.File" />
         <PackageReference Include="SixLabors.ImageSharp" />
-        <PackageReference Include="CsvHelper"  />
+        <PackageReference Include="CsvHelper" />
         <PackageReference Include="Microsoft.DotNet.PlatformAbstractions" />
         <PackageReference Include="System.CommandLine" V="" />
     </ItemGroup>

+ 2 - 0
Examples/UICatalog/UICatalogCommandLineOptions.cs

@@ -5,6 +5,8 @@ public struct UICatalogCommandLineOptions
 {
     public string Driver { get; set; }
 
+    public bool DontEnableConfigurationManagement { get; set; }
+
     public string Scenario { get; set; }
 
     public uint BenchmarkTimeout { get; set; }

+ 87 - 71
Examples/UICatalog/UICatalogTop.cs

@@ -1,12 +1,10 @@
 using System.Collections.ObjectModel;
 using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.Text.Json.Serialization;
 using Microsoft.Extensions.Logging;
 using Terminal.Gui;
-using static Terminal.Gui.ConfigurationManager;
 using Command = Terminal.Gui.Command;
 using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;
 
@@ -24,13 +22,10 @@ public class UICatalogTop : Toplevel
     // members are cached so that when the scenario exits the
     // main app UI can be restored to previous state
 
-    // Theme Management
-    public static string? CachedTheme { get; set; }
-
     // Note, we used to pass this to scenarios that run, but it just added complexity
     // So that was removed. But we still have this here to demonstrate how changing
     // the scheme works.
-    public static string? CachedTopLevelColorScheme { get; set; }
+    public static string? CachedTopLevelScheme { get; set; }
 
     // Diagnostics
     private static ViewDiagnosticFlags _diagnosticFlags;
@@ -53,7 +48,8 @@ public class UICatalogTop : Toplevel
         _categoryList.SelectedItem = _cachedCategoryIndex;
         _scenarioList.SelectedRow = _cachedScenarioIndex;
 
-        Applied += ConfigAppliedHandler;
+        SchemeName = CachedTopLevelScheme = SchemeManager.SchemesToSchemeName (Schemes.Base);
+        ConfigurationManager.Applied += ConfigAppliedHandler;
     }
 
 
@@ -68,7 +64,7 @@ public class UICatalogTop : Toplevel
 
         if (_shVersion is { })
         {
-            _shVersion.Title = $"{RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion}, {Driver!.GetVersionInfo ()}";
+            _shVersion.Title = $"{RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion}, {Application.Driver!.GetVersionInfo ()}";
         }
 
         if (CachedSelectedScenario != null)
@@ -90,14 +86,11 @@ public class UICatalogTop : Toplevel
         Loaded -= LoadedHandler;
         _categoryList!.EnsureSelectedItemVisible ();
         _scenarioList.EnsureSelectedCellIsVisible ();
-
-        Apply ();
-
     }
 
     private void UnloadedHandler (object? sender, EventArgs? args)
     {
-        Applied -= ConfigAppliedHandler;
+        ConfigurationManager.Applied -= ConfigAppliedHandler;
         Unloaded -= UnloadedHandler;
     }
 
@@ -191,59 +184,73 @@ public class UICatalogTop : Toplevel
 
             menuItems.Add (new Line ());
 
-            _themesRg = new ()
-            {
-                HighlightStyle = HighlightStyle.None,
-                SelectedItem = Themes.Keys.ToList ().IndexOf (CachedTheme!.Replace ("_", string.Empty))
-            };
-
-            _themesRg.SelectedItemChanged += (_, args) =>
-            {
-                Themes!.Theme = Themes!.Keys.ToArray () [args.SelectedItem!.Value];
-                CachedTheme = Themes!.Keys.ToArray () [args.SelectedItem!.Value];
-                Apply ();
-                SetNeedsDraw ();
-            };
-
-            var menuItem = new MenuItemv2
+            if (ConfigurationManager.IsEnabled)
             {
-                CommandView = _themesRg,
-                HelpText = "Cycle Through Themes",
-                Key = Key.T.WithCtrl
-            };
-            menuItems.Add (menuItem);
+                _themesRg = new ()
+                {
+                    HighlightStyle = HighlightStyle.None,
+                };
 
-            menuItems.Add (new Line ());
+                _themesRg.SelectedItemChanged += (_, args) =>
+                                                 {
+                                                     if (args.SelectedItem is null)
+                                                     {
+                                                         return;
+                                                     }
+                                                     ThemeManager.Theme = ThemeManager.GetThemeNames () [args.SelectedItem!.Value];
+                                                 };
 
-            _topSchemeRg = new ()
-            {
-                HighlightStyle = HighlightStyle.None,
-                SelectedItem = Colors.ColorSchemes.Keys.ToList().IndexOf(CachedTopLevelColorScheme!)
-            };
+                var menuItem = new MenuItemv2
+                {
+                    CommandView = _themesRg,
+                    HelpText = "Cycle Through Themes",
+                    Key = Key.T.WithCtrl
+                };
+                menuItems.Add (menuItem);
 
-            _topSchemeRg.SelectedItemChanged += (_, args) =>
-            {
-                CachedTopLevelColorScheme = Colors.ColorSchemes.Keys.ToArray () [args.SelectedItem!.Value];
-                ColorScheme = Colors.ColorSchemes [CachedTopLevelColorScheme];
-                SetNeedsDraw ();
-            };
+                menuItems.Add (new Line ());
 
-            menuItem = new ()
+                _topSchemeRg = new ()
+                {
+                    HighlightStyle = HighlightStyle.None,
+                };
+
+                _topSchemeRg.SelectedItemChanged += (_, args) =>
+                                                    {
+                                                        if (args.SelectedItem is null)
+                                                        {
+                                                            return;
+                                                        }
+                                                        CachedTopLevelScheme = SchemeManager.GetSchemesForCurrentTheme ()!.Keys.ToArray () [args.SelectedItem!.Value];
+                                                        SchemeName = CachedTopLevelScheme;
+                                                        SetNeedsDraw ();
+                                                    };
+
+                menuItem = new ()
+                {
+                    Title = "Scheme for Toplevel",
+                    SubMenu = new (
+                                   [
+                                       new ()
+                                       {
+                                           CommandView = _topSchemeRg,
+                                           HelpText = "Cycle Through schemes",
+                                           Key = Key.S.WithCtrl
+                                       }
+                                   ])
+                };
+                menuItems.Add (menuItem);
+
+                UpdateThemesMenu ();
+            }
+            else
             {
-                Title = "Color Scheme for Application._Top",
-                SubMenu = new (
-                               [
-                                   new ()
-                               {
-                                   CommandView = _topSchemeRg,
-                                   HelpText = "Cycle Through Color Schemes",
-                                   Key = Key.S.WithCtrl
-                               }
-                               ])
-            };
-            menuItems.Add (menuItem);
-
-            UpdateThemesMenu ();
+                menuItems.Add (new MenuItemv2 ()
+                {
+                    Title = "Configuration Manager is not Enabled",
+                    Enabled = false
+                });
+            }
 
             return menuItems.ToArray ();
         }
@@ -346,10 +353,11 @@ public class UICatalogTop : Toplevel
             return;
         }
 
+        _themesRg.SelectedItem = null;
         _themesRg.AssignHotKeysToCheckBoxes = true;
         _themesRg.UsedHotKeys.Clear ();
-        _themesRg.Options = Themes!.Keys.ToArray ();
-        _themesRg.SelectedItem = Themes.Keys.ToList ().IndexOf (CachedTheme!.Replace ("_", string.Empty));
+        _themesRg.Options = ThemeManager.GetThemeNames ();
+        _themesRg.SelectedItem =ThemeManager.GetThemeNames ().IndexOf (ThemeManager.GetCurrentThemeName ());
 
         if (_topSchemeRg is null)
         {
@@ -358,16 +366,21 @@ public class UICatalogTop : Toplevel
 
         _topSchemeRg.AssignHotKeysToCheckBoxes = true;
         _topSchemeRg.UsedHotKeys.Clear ();
-        int? selected = _topSchemeRg.SelectedItem;
-        _topSchemeRg.Options = Colors.ColorSchemes.Keys.ToArray ();
-        _topSchemeRg.SelectedItem = selected;
+        int? selectedScheme = _topSchemeRg.SelectedItem;
+        _topSchemeRg.Options = SchemeManager.GetSchemeNames ();
+        _topSchemeRg.SelectedItem = selectedScheme;
 
-        if (CachedTopLevelColorScheme is null || !Colors.ColorSchemes.ContainsKey (CachedTopLevelColorScheme))
+        if (CachedTopLevelScheme is null || !SchemeManager.GetSchemeNames ().Contains (CachedTopLevelScheme))
         {
-            CachedTopLevelColorScheme = "Base";
+            CachedTopLevelScheme = SchemeManager.SchemesToSchemeName (Schemes.Base);
         }
 
-        _topSchemeRg.SelectedItem = Array.IndexOf (Colors.ColorSchemes.Keys.ToArray (), CachedTopLevelColorScheme);
+        int newSelectedItem = SchemeManager.GetSchemeNames ().IndexOf (CachedTopLevelScheme!);
+        // if the item is in bounds then select it
+        if (newSelectedItem >= 0 && newSelectedItem < SchemeManager.GetSchemeNames ().Count)
+        {
+            _topSchemeRg.SelectedItem = newSelectedItem;
+        }
     }
 
     #endregion MenuBar
@@ -564,7 +577,7 @@ public class UICatalogTop : Toplevel
 
     private readonly StatusBar? _statusBar;
 
-    [SerializableConfigurationProperty (Scope = typeof (AppScope), OmitClassName = true)]
+    [ConfigurationProperty (Scope = typeof (AppSettingsScope), OmitClassName = true)]
     [JsonPropertyName ("UICatalog.StatusBar")]
     public static bool ShowStatusBar { get; set; } = true;
 
@@ -642,6 +655,11 @@ public class UICatalogTop : Toplevel
                        _shVersion
                       );
 
+        if (UICatalog.Options.DontEnableConfigurationManagement)
+        {
+            statusBar.AddShortcutAt (statusBar.SubViews.ToList ().IndexOf (_shVersion), new Shortcut () { Title = "CM is Disabled" });
+        }
+
         return statusBar;
     }
 
@@ -654,11 +672,9 @@ public class UICatalogTop : Toplevel
     /// </summary>
     private void ConfigApplied ()
     {
-        CachedTheme = Themes?.Theme;
-
         UpdateThemesMenu ();
 
-        ColorScheme = Colors.ColorSchemes [CachedTopLevelColorScheme!];
+        SchemeName = CachedTopLevelScheme;
 
         if (_shQuit is { })
         {

+ 2 - 2
Terminal.Gui/Application/Application.Driver.cs

@@ -14,7 +14,7 @@ public static partial class Application // Driver abstractions
     ///     <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
     ///     as long as the selected <see cref="IConsoleDriver"/> supports TrueColor.
     /// </summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
+    [ConfigurationProperty (Scope = typeof (SettingsScope))]
     public static bool Force16Colors { get; set; }
 
     // BUGBUG: ForceDriver should be nullable.
@@ -26,7 +26,7 @@ public static partial class Application // Driver abstractions
     ///     Note, <see cref="Application.Init(IConsoleDriver, string)"/> will override this configuration setting if called
     ///     with either `driver` or `driverName` specified.
     /// </remarks>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
+    [ConfigurationProperty (Scope = typeof (SettingsScope))]
     public static string ForceDriver { get; set; } = string.Empty;
 
     /// <summary>

+ 7 - 27
Terminal.Gui/Application/Application.Initialization.cs

@@ -7,6 +7,7 @@ namespace Terminal.Gui;
 
 public static partial class Application // Initialization (Init/Shutdown)
 {
+
     /// <summary>Initializes a new instance of a Terminal.Gui Application. <see cref="Shutdown"/> must be called when the application is closing.</summary>
     /// <para>Call this method once per instance (or after <see cref="Shutdown"/> has been called).</para>
     /// <para>
@@ -95,19 +96,17 @@ public static partial class Application // Initialization (Init/Shutdown)
 
             if (driver is FakeDriver)
             {
-                // We're running unit tests. Disable loading config files other than default
-                if (Locations == ConfigLocations.All)
-                {
-                    Locations = ConfigLocations.Default;
-                    Reset ();
-                }
+                //// We're running unit tests. Disable loading config files other than default
+                //if (Locations == ConfigLocations.All)
+                //{
+                //    Locations = ConfigLocations.Default;
+                //    ResetAllSettings ();
+                //}
             }
         }
 
         AddKeyBindings ();
 
-        InitializeConfigurationManagement ();
-
         // Ignore Configuration for ForceDriver if driverName is specified
         if (!string.IsNullOrEmpty (driverName))
         {
@@ -177,25 +176,6 @@ public static partial class Application // Initialization (Init/Shutdown)
         InitializedChanged?.Invoke (null, new (init));
     }
 
-    [RequiresUnreferencedCode ("AOT")]
-    [RequiresDynamicCode ("AOT")]
-    internal static void InitializeConfigurationManagement ()
-    {
-        // Start the process of configuration management.
-        // Note that we end up calling LoadConfigurationFromAllSources
-        // multiple times. We need to do this because some settings are only
-        // valid after a Driver is loaded. In this case we need just
-        // `Settings` so we can determine which driver to use.
-        // Don't reset, so we can inherit the theme from the previous run.
-        string previousTheme = Themes?.Theme ?? string.Empty;
-        Load ();
-        if (Themes is { } && !string.IsNullOrEmpty (previousTheme) && previousTheme != "Default")
-        {
-            ThemeManager.SelectedTheme = previousTheme;
-        }
-        Apply ();
-    }
-
     internal static void SubscribeDriverEvents ()
     {
         ArgumentNullException.ThrowIfNull (Driver);

+ 9 - 9
Terminal.Gui/Application/Application.Keyboard.cs

@@ -118,7 +118,7 @@ public static partial class Application // Keyboard handling
     }
 
     /// <summary>
-    ///     Invokes an Application-bound commmand.
+    ///     Invokes an Application-bound command.
     /// </summary>
     /// <param name="command">The Command to invoke</param>
     /// <param name="key">The Application-bound Key that was pressed.</param>
@@ -185,6 +185,9 @@ public static partial class Application // Keyboard handling
             return true;
         }
 
+
+        // TODO: Add Popover support
+
         foreach (Toplevel topLevel in TopLevels.ToList ())
         {
             if (topLevel.NewKeyUpEvent (key))
@@ -203,7 +206,10 @@ public static partial class Application // Keyboard handling
 
     #region Application-scoped KeyBindings
 
-    static Application () { AddKeyBindings (); }
+    static Application ()
+    {
+        AddKeyBindings ();
+    }
 
     /// <summary>Gets the Application-scoped key bindings.</summary>
     public static KeyBindings KeyBindings { get; internal set; } = new (null);
@@ -277,13 +283,7 @@ public static partial class Application // Keyboard handling
                         return false;
                     });
 
-        // Resources/config.json overrides
-        QuitKey = Key.Esc;
-        NextTabKey = Key.Tab;
-        PrevTabKey = Key.Tab.WithShift;
-        NextTabGroupKey = Key.F6;
-        PrevTabGroupKey = Key.F6.WithShift;
-        ArrangeKey = Key.F5.WithCtrl;
+        //SetKeysToHardCodedDefaults ();
 
         // Need to clear after setting the above to ensure actually clear
         // because set_QuitKey etc.. may call Add

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно