Fixed a bunch of CM issues

This commit is contained in:
Tig
2025-04-04 09:50:12 -06:00
parent 57fc30804d
commit 9a2a7a4685
10 changed files with 358 additions and 343 deletions

View File

@@ -193,6 +193,10 @@ public static partial class Application // Run (Begin, Run, End, Stop)
toplevel.EndInit (); // Calls Layout
}
// Call ConfigurationManager Apply here to ensure all subscribers to ConfigurationManager.Applied
// can update their state appropriately.
Apply ();
// Try to set initial focus to any TabStop
if (!toplevel.HasFocus)
{

View File

@@ -53,270 +53,272 @@
"MessageBox.DefaultBorderStyle": "Heavy",
"Button.DefaultShadow": "Opaque",
"Menuv2.DefaultBorderStyle": "Single",
"ColorSchemes": [
{
"TopLevel": {
"Normal": {
"Foreground": "BrightGreen",
"Background": "#505050" // DarkerGray
},
"Focus": {
"Foreground": "White",
"Background": "#696969" // DimGray
},
"HotNormal": {
"Foreground": "Yellow",
"Background": "#505050" // DarkerGray
},
"HotFocus": {
"Foreground": "Yellow",
"Background": "#696969" // DimGray
},
"Disabled": {
"Foreground": "DarkGray",
"Background": "#505050" // DarkerGray
}
}
},
{
"Base": {
"Normal": {
"Foreground": "White",
"Background": "Blue"
},
"Focus": {
"Foreground": "DarkBlue",
"Background": "LightGray"
},
"HotNormal": {
"Foreground": "BrightCyan",
"Background": "Blue"
},
"HotFocus": {
"Foreground": "BrightBlue",
"Background": "LightGray"
},
"Disabled": {
"Foreground": "DarkGray",
"Background": "Blue"
}
}
},
{
"Dialog": {
"Normal": {
"Foreground": "Black",
"Background": "LightGray"
},
"Focus": {
"Foreground": "DarkGray",
"Background": "LightGray"
},
"HotNormal": {
"Foreground": "Blue",
"Background": "LightGray"
},
"HotFocus": {
"Foreground": "BrightBlue",
"Background": "LightGray"
},
"Disabled": {
"Foreground": "Gray",
"Background": "DarkGray"
}
}
},
{
"Menu": {
"Normal": {
"Foreground": "White",
"Background": "DarkBlue"
},
"Focus": {
"Foreground": "White",
"Background": "Blue"
},
"HotNormal": {
"Foreground": "Yellow",
"Background": "DarkBlue"
},
"HotFocus": {
"Foreground": "Yellow",
"Background": "Blue"
},
"Disabled": {
"Foreground": "Gray",
"Background": "DarkGray"
}
}
},
{
"Error": {
"Normal": {
"Foreground": "Red",
"Background": "Pink"
},
"Focus": {
"Foreground": "White",
"Background": "BrightRed"
},
"HotNormal": {
"Foreground": "Black",
"Background": "Pink"
},
"HotFocus": {
"Foreground": "Pink",
"Background": "BrightRed"
},
"Disabled": {
"Foreground": "DarkGray",
"Background": "White"
}
"MenuBarv2.DefaultBorderStyle": "None",
"StatusBar.DefaultSeparatorLineStyle": "Single",
"ColorSchemes": [
{
"TopLevel": {
"Normal": {
"Foreground": "BrightGreen",
"Background": "#505050" // DarkerGray
},
"Focus": {
"Foreground": "White",
"Background": "#696969" // DimGray
},
"HotNormal": {
"Foreground": "Yellow",
"Background": "#505050" // DarkerGray
},
"HotFocus": {
"Foreground": "Yellow",
"Background": "#696969" // DimGray
},
"Disabled": {
"Foreground": "DarkGray",
"Background": "#505050" // DarkerGray
}
}
],
"Glyphs.Apple": "\uD83C\uDF4E",
"Glyphs.AppleBMP": "❦",
"Glyphs.BlackCircle": "●",
"Glyphs.BlocksMeterSegment": "",
"Glyphs.BottomSideLineLtHv": "╽",
"Glyphs.BottomTee": "┴",
"Glyphs.BottomTeeDbl": "╩",
"Glyphs.BottomTeeDblH": "╧",
"Glyphs.BottomTeeDblV": "╨",
"Glyphs.BottomTeeHvDblH": "┻",
"Glyphs.BottomTeeHvH": "┷",
"Glyphs.BottomTeeHvV": "┸",
"Glyphs.CheckStateChecked": "☑",
"Glyphs.CheckStateNone": "☒",
"Glyphs.CheckStateUnChecked": "☐",
"Glyphs.Close": "✘",
"Glyphs.Collapse": "-",
"Glyphs.ContinuousMeterSegment": "█",
"Glyphs.Cross": "┼",
"Glyphs.CrossDbl": "╬",
"Glyphs.CrossDblH": "╪",
"Glyphs.CrossDblV": "╫",
"Glyphs.CrossHv": "╋",
"Glyphs.CrossHvH": "┿",
"Glyphs.CrossHvV": "╂",
"Glyphs.Diamond": "◊",
"Glyphs.Dot": "∙",
"Glyphs.DottedSquare": "",
"Glyphs.DownArrow": "▼",
"Glyphs.Expand": "+",
"Glyphs.File": "☰",
"Glyphs.Folder": "꤉",
"Glyphs.HalfBottomLine": "╷",
"Glyphs.HalfBottomLineLt": "╻",
"Glyphs.HalfLeftLine": "╴",
"Glyphs.HalfLeftLineHv": "",
"Glyphs.HalfRightLine": "╶",
"Glyphs.HalfRightLineHv": "╺",
"Glyphs.HalfTopLine": "╵",
"Glyphs.HalfTopLineHv": "╹",
"Glyphs.HLine": "─",
"Glyphs.HLineDa2": "╌",
"Glyphs.HLineDa3": "┄",
"Glyphs.HLineDa4": "",
"Glyphs.HLineDbl": "═",
"Glyphs.HLineHv": "━",
"Glyphs.HLineHvDa2": "╍",
"Glyphs.HLineHvDa3": "┅",
"Glyphs.HLineHvDa4": "┉",
"Glyphs.HorizontalEllipsis": "…",
"Glyphs.IdenticalTo": "≡",
"Glyphs.LeftArrow": "",
"Glyphs.LeftBracket": "⟦",
"Glyphs.LeftDefaultIndicator": "►",
"Glyphs.LeftSideLineHvLt": "╾",
"Glyphs.LeftTee": "",
"Glyphs.LeftTeeDbl": "╠",
"Glyphs.LeftTeeDblH": "╞",
"Glyphs.LeftTeeDblV": "╟",
"Glyphs.LeftTeeHvDblH": "",
"Glyphs.LeftTeeHvH": "┝",
"Glyphs.LeftTeeHvV": "┠",
"Glyphs.LLCorner": "└",
"Glyphs.LLCornerDbl": "",
"Glyphs.LLCornerDblSingle": "╙",
"Glyphs.LLCornerHv": "┗",
"Glyphs.LLCornerHvLt": "┖",
"Glyphs.LLCornerLtHv": "",
"Glyphs.LLCornerR": "╰",
"Glyphs.LLCornerSingleDbl": "╘",
"Glyphs.LRCorner": "┘",
"Glyphs.LRCornerDbl": "╝",
"Glyphs.LRCornerDblSingle": "╜",
"Glyphs.LRCornerHv": "┛",
"Glyphs.LRCornerHvLt": "┚",
"Glyphs.LRCornerLtHv": "",
"Glyphs.LRCornerR": "╯",
"Glyphs.LRCornerSingleDbl": "╛",
"Glyphs.Maximize": "✽",
"Glyphs.Minimize": "",
"Glyphs.Move": "◊",
"Glyphs.RightArrow": "►",
"Glyphs.RightBracket": "⟧",
"Glyphs.RightDefaultIndicator": "",
"Glyphs.RightSideLineLtHv": "╼",
"Glyphs.RightTee": "┤",
"Glyphs.RightTeeDbl": "╣",
"Glyphs.RightTeeDblH": "",
"Glyphs.RightTeeDblV": "╢",
"Glyphs.RightTeeHvDblH": "┫",
"Glyphs.RightTeeHvH": "┥",
"Glyphs.RightTeeHvV": "┨",
"Glyphs.Selected": "◉",
"Glyphs.ShadowHorizontal": "▀",
"Glyphs.ShadowHorizontalEnd": "▘",
"Glyphs.ShadowHorizontalStart": "▝",
"Glyphs.ShadowVertical": "▌",
"Glyphs.ShadowVerticalStart": "▖",
"Glyphs.SizeBottomLeft": "",
"Glyphs.SizeBottomRight": "",
"Glyphs.SizeHorizontal": "",
"Glyphs.SizeTopLeft": "",
"Glyphs.SizeTopRight": "",
"Glyphs.SizeVertical": "",
"Glyphs.Stipple": "",
"Glyphs.TopSideLineHvLt": "",
"Glyphs.TopTee": "",
"Glyphs.TopTeeDbl": "",
"Glyphs.TopTeeDblH": "",
"Glyphs.TopTeeDblV": "",
"Glyphs.TopTeeHvDblH": "",
"Glyphs.TopTeeHvH": "",
"Glyphs.TopTeeHvV": "",
"Glyphs.ULCorner": "",
"Glyphs.ULCornerDbl": "",
"Glyphs.ULCornerDblSingle": "",
"Glyphs.ULCornerHv": "",
"Glyphs.ULCornerHvLt": "",
"Glyphs.ULCornerLtHv": "",
"Glyphs.ULCornerR": "",
"Glyphs.ULCornerSingleDbl": "",
"Glyphs.UnSelected": "",
"Glyphs.UpArrow": "",
"Glyphs.URCorner": "",
"Glyphs.URCornerDbl": "",
"Glyphs.URCornerDblSingle": "",
"Glyphs.URCornerHv": "",
"Glyphs.URCornerHvLt": "",
"Glyphs.URCornerLtHv": "",
"Glyphs.URCornerR": "",
"Glyphs.URCornerSingleDbl": "",
"Glyphs.VerticalFourDots": "",
"Glyphs.VLine": "",
"Glyphs.VLineDa2": "",
"Glyphs.VLineDa3": "",
"Glyphs.VLineDa4": "",
"Glyphs.VLineDbl": "",
"Glyphs.VLineHv": "",
"Glyphs.VLineHvDa2": "",
"Glyphs.VLineHvDa3": "",
"Glyphs.VLineHvDa4": ""
}
},
{
"Base": {
"Normal": {
"Foreground": "White",
"Background": "Blue"
},
"Focus": {
"Foreground": "DarkBlue",
"Background": "LightGray"
},
"HotNormal": {
"Foreground": "BrightCyan",
"Background": "Blue"
},
"HotFocus": {
"Foreground": "BrightBlue",
"Background": "LightGray"
},
"Disabled": {
"Foreground": "DarkGray",
"Background": "Blue"
}
}
},
{
"Dialog": {
"Normal": {
"Foreground": "Black",
"Background": "LightGray"
},
"Focus": {
"Foreground": "DarkGray",
"Background": "LightGray"
},
"HotNormal": {
"Foreground": "Blue",
"Background": "LightGray"
},
"HotFocus": {
"Foreground": "BrightBlue",
"Background": "LightGray"
},
"Disabled": {
"Foreground": "Gray",
"Background": "DarkGray"
}
}
},
{
"Menu": {
"Normal": {
"Foreground": "White",
"Background": "DarkBlue"
},
"Focus": {
"Foreground": "White",
"Background": "Blue"
},
"HotNormal": {
"Foreground": "Yellow",
"Background": "DarkBlue"
},
"HotFocus": {
"Foreground": "Yellow",
"Background": "Blue"
},
"Disabled": {
"Foreground": "Gray",
"Background": "DarkGray"
}
}
},
{
"Error": {
"Normal": {
"Foreground": "Red",
"Background": "Pink"
},
"Focus": {
"Foreground": "White",
"Background": "BrightRed"
},
"HotNormal": {
"Foreground": "Black",
"Background": "Pink"
},
"HotFocus": {
"Foreground": "Pink",
"Background": "BrightRed"
},
"Disabled": {
"Foreground": "DarkGray",
"Background": "White"
}
}
}
],
"Glyphs.Apple": "\uD83C\uDF4E",
"Glyphs.AppleBMP": "",
"Glyphs.BlackCircle": "",
"Glyphs.BlocksMeterSegment": "",
"Glyphs.BottomSideLineLtHv": "",
"Glyphs.BottomTee": "",
"Glyphs.BottomTeeDbl": "",
"Glyphs.BottomTeeDblH": "",
"Glyphs.BottomTeeDblV": "",
"Glyphs.BottomTeeHvDblH": "",
"Glyphs.BottomTeeHvH": "",
"Glyphs.BottomTeeHvV": "",
"Glyphs.CheckStateChecked": "",
"Glyphs.CheckStateNone": "",
"Glyphs.CheckStateUnChecked": "",
"Glyphs.Close": "",
"Glyphs.Collapse": "-",
"Glyphs.ContinuousMeterSegment": "",
"Glyphs.Cross": "",
"Glyphs.CrossDbl": "",
"Glyphs.CrossDblH": "",
"Glyphs.CrossDblV": "",
"Glyphs.CrossHv": "",
"Glyphs.CrossHvH": "",
"Glyphs.CrossHvV": "",
"Glyphs.Diamond": "",
"Glyphs.Dot": "",
"Glyphs.DottedSquare": "",
"Glyphs.DownArrow": "",
"Glyphs.Expand": "+",
"Glyphs.File": "",
"Glyphs.Folder": "",
"Glyphs.HalfBottomLine": "",
"Glyphs.HalfBottomLineLt": "",
"Glyphs.HalfLeftLine": "",
"Glyphs.HalfLeftLineHv": "",
"Glyphs.HalfRightLine": "",
"Glyphs.HalfRightLineHv": "",
"Glyphs.HalfTopLine": "",
"Glyphs.HalfTopLineHv": "",
"Glyphs.HLine": "",
"Glyphs.HLineDa2": "",
"Glyphs.HLineDa3": "",
"Glyphs.HLineDa4": "",
"Glyphs.HLineDbl": "═",
"Glyphs.HLineHv": "━",
"Glyphs.HLineHvDa2": "╍",
"Glyphs.HLineHvDa3": "┅",
"Glyphs.HLineHvDa4": "┉",
"Glyphs.HorizontalEllipsis": "…",
"Glyphs.IdenticalTo": "≡",
"Glyphs.LeftArrow": "◄",
"Glyphs.LeftBracket": "⟦",
"Glyphs.LeftDefaultIndicator": "►",
"Glyphs.LeftSideLineHvLt": "╾",
"Glyphs.LeftTee": "├",
"Glyphs.LeftTeeDbl": "╠",
"Glyphs.LeftTeeDblH": "╞",
"Glyphs.LeftTeeDblV": "╟",
"Glyphs.LeftTeeHvDblH": "┣",
"Glyphs.LeftTeeHvH": "┝",
"Glyphs.LeftTeeHvV": "┠",
"Glyphs.LLCorner": "└",
"Glyphs.LLCornerDbl": "╚",
"Glyphs.LLCornerDblSingle": "╙",
"Glyphs.LLCornerHv": "┗",
"Glyphs.LLCornerHvLt": "┖",
"Glyphs.LLCornerLtHv": "┕",
"Glyphs.LLCornerR": "╰",
"Glyphs.LLCornerSingleDbl": "╘",
"Glyphs.LRCorner": "┘",
"Glyphs.LRCornerDbl": "╝",
"Glyphs.LRCornerDblSingle": "╜",
"Glyphs.LRCornerHv": "┛",
"Glyphs.LRCornerHvLt": "┚",
"Glyphs.LRCornerLtHv": "┙",
"Glyphs.LRCornerR": "╯",
"Glyphs.LRCornerSingleDbl": "╛",
"Glyphs.Maximize": "✽",
"Glyphs.Minimize": "❏",
"Glyphs.Move": "◊",
"Glyphs.RightArrow": "►",
"Glyphs.RightBracket": "⟧",
"Glyphs.RightDefaultIndicator": "◄",
"Glyphs.RightSideLineLtHv": "╼",
"Glyphs.RightTee": "┤",
"Glyphs.RightTeeDbl": "╣",
"Glyphs.RightTeeDblH": "╡",
"Glyphs.RightTeeDblV": "╢",
"Glyphs.RightTeeHvDblH": "┫",
"Glyphs.RightTeeHvH": "┥",
"Glyphs.RightTeeHvV": "┨",
"Glyphs.Selected": "◉",
"Glyphs.ShadowHorizontal": "▀",
"Glyphs.ShadowHorizontalEnd": "▘",
"Glyphs.ShadowHorizontalStart": "▝",
"Glyphs.ShadowVertical": "▌",
"Glyphs.ShadowVerticalStart": "▖",
"Glyphs.SizeBottomLeft": "↙",
"Glyphs.SizeBottomRight": "↘",
"Glyphs.SizeHorizontal": "↔",
"Glyphs.SizeTopLeft": "↖",
"Glyphs.SizeTopRight": "↗",
"Glyphs.SizeVertical": "↕",
"Glyphs.Stipple": "░",
"Glyphs.TopSideLineHvLt": "╿",
"Glyphs.TopTee": "┬",
"Glyphs.TopTeeDbl": "╦",
"Glyphs.TopTeeDblH": "╤",
"Glyphs.TopTeeDblV": "╥",
"Glyphs.TopTeeHvDblH": "┳",
"Glyphs.TopTeeHvH": "┯",
"Glyphs.TopTeeHvV": "┰",
"Glyphs.ULCorner": "┌",
"Glyphs.ULCornerDbl": "╔",
"Glyphs.ULCornerDblSingle": "╓",
"Glyphs.ULCornerHv": "┏",
"Glyphs.ULCornerHvLt": "┎",
"Glyphs.ULCornerLtHv": "┍",
"Glyphs.ULCornerR": "╭",
"Glyphs.ULCornerSingleDbl": "╒",
"Glyphs.UnSelected": "○",
"Glyphs.UpArrow": "▲",
"Glyphs.URCorner": "┐",
"Glyphs.URCornerDbl": "╗",
"Glyphs.URCornerDblSingle": "╖",
"Glyphs.URCornerHv": "┓",
"Glyphs.URCornerHvLt": "┑",
"Glyphs.URCornerLtHv": "┒",
"Glyphs.URCornerR": "╮",
"Glyphs.URCornerSingleDbl": "╕",
"Glyphs.VerticalFourDots": "⁞",
"Glyphs.VLine": "│",
"Glyphs.VLineDa2": "╎",
"Glyphs.VLineDa3": "┆",
"Glyphs.VLineDa4": "┊",
"Glyphs.VLineDbl": "║",
"Glyphs.VLineHv": "┃",
"Glyphs.VLineHvDa2": "╏",
"Glyphs.VLineHvDa3": "┇",
"Glyphs.VLineHvDa4": "┋"
}
},
{
"Dark": {

View File

@@ -148,45 +148,12 @@ public partial class View // Adornments
return;
}
LineStyle old = Border?.LineStyle ?? LineStyle.None;
// It's tempting to try to optimize this by checking that old != value and returning.
// Do not.
CancelEventArgs<LineStyle> e = new (ref old, ref value);
if (OnBorderStyleChanging (e) || e.Cancel)
{
return;
}
BorderStyleChanging?.Invoke (this, e);
if (e.Cancel)
{
return;
}
SetBorderStyle (e.NewValue);
SetBorderStyle (value);
OnBorderStyleChanged ();
BorderStyleChanged?.Invoke(this, EventArgs.Empty);
}
}
/// <summary>
/// Called when the <see cref="BorderStyle"/> is changing.
/// </summary>
/// <remarks>
/// Set e.Cancel to true to prevent the <see cref="BorderStyle"/> from changing.
/// </remarks>
/// <param name="e"></param>
protected virtual bool OnBorderStyleChanging (CancelEventArgs<LineStyle> e) { return false; }
/// <summary>
/// Fired when the <see cref="BorderStyle"/> is changing. Allows the event to be cancelled.
/// </summary>
public event EventHandler<CancelEventArgs<LineStyle>>? BorderStyleChanging;
/// <summary>
/// Called when the <see cref="BorderStyle"/> has changed.
/// </summary>

View File

@@ -74,20 +74,6 @@ public class Bar : View, IOrientation, IDesignable
}
}
/// <inheritdoc/>
protected override bool OnBorderStyleChanging (CancelEventArgs<LineStyle> e)
{
if (Border is { })
{
// The default changes the thickness. We don't want that. We just set the style.
Border.LineStyle = e.NewValue;
return true; // Cancel
}
return base.OnBorderStyleChanging (e);
}
#region IOrientation members
/// <summary>

View File

@@ -23,6 +23,7 @@ public class MenuBarv2 : Menuv2, IDesignable
TabStop = TabBehavior.TabGroup;
Y = 0;
Width = Dim.Fill ();
Height = Dim.Auto ();
Orientation = Orientation.Horizontal;
Key = DefaultKey;
@@ -82,6 +83,10 @@ public class MenuBarv2 : Menuv2, IDesignable
AddCommand (Command.Left, MoveLeft);
KeyBindings.Add (Key.CursorLeft, Command.Left);
BorderStyle = DefaultBorderStyle;
Applied += OnConfigurationManagerApplied;
return;
bool? MoveLeft (ICommandContext? ctx) { return AdvanceFocus (NavigationDirection.Backward, TabBehavior.TabStop); }
@@ -89,6 +94,24 @@ public class MenuBarv2 : Menuv2, IDesignable
bool? MoveRight (ICommandContext? ctx) { return AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop); }
}
private void OnConfigurationManagerApplied (object? sender, ConfigurationManagerEventArgs e)
{
BorderStyle = DefaultBorderStyle;
}
/// <inheritdoc />
protected override bool OnBorderStyleChanged ()
{
HideActiveItem ();
return base.OnBorderStyleChanged ();
}
/// <summary>
/// Gets or sets the default Border Style for the MenuBar. The default is <see cref="LineStyle.None"/>.
/// </summary>
[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
public new static LineStyle DefaultBorderStyle { get; set; } = LineStyle.None;
private Key _key = DefaultKey;
/// <summary>Specifies the key that will activate the context menu.</summary>
@@ -427,4 +450,12 @@ public class MenuBarv2 : Menuv2, IDesignable
}
}
}
/// <inheritdoc />
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
Applied -= OnConfigurationManagerApplied;
}
}

View File

@@ -21,23 +21,21 @@ public class Menuv2 : Bar
base.ColorScheme = Colors.ColorSchemes ["Menu"];
BorderStyle = DefaultBorderStyle;
Applied += OnConfigurationManagerApplied;
}
private void OnConfigurationManagerApplied (object? sender, ConfigurationManagerEventArgs e)
{
BorderStyle = DefaultBorderStyle;
}
// BUGBUG: For some reason this config property is not working!
/// <summary>
/// Gets or sets the default Highlight Style.
/// Gets or sets the default Border Style for Menus. The default is <see cref="LineStyle.Single"/>.
/// </summary>
[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
/// <inheritdoc />
protected override bool OnBorderStyleChanging (CancelEventArgs<LineStyle> e)
{
// Bar (our base) overrides this to prevent automatic changing of thickness.
// We don't want that so we override as well.
return false;
}
/// <summary>
/// Gets or sets the menu item that opened this menu as a sub-menu.
/// </summary>
@@ -182,4 +180,11 @@ public class Menuv2 : Bar
/// </summary>
public event EventHandler<MenuItemv2?>? SelectedMenuItemChanged;
/// <inheritdoc />
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
Applied -= OnConfigurationManagerApplied;
}
}

View File

@@ -23,16 +23,33 @@ public class StatusBar : Bar, IDesignable
Y = Pos.AnchorEnd ();
Width = Dim.Fill ();
Height = Dim.Auto (DimAutoStyle.Content, 1);
BorderStyle = LineStyle.Dashed;
if (Border is { })
{
Border.LineStyle = DefaultSeparatorLineStyle;
}
base.ColorScheme = Colors.ColorSchemes ["Menu"];
SubViewLayout += StatusBar_LayoutStarted;
Applied += OnConfigurationManagerApplied;
}
// StatusBar arranges the items horizontally.
// The first item has no left border, the last item has no right border.
// The Shortcuts are configured with the command, help, and key views aligned in reverse order (EndToStart).
private void StatusBar_LayoutStarted (object sender, LayoutEventArgs e)
private void OnConfigurationManagerApplied (object? sender, ConfigurationManagerEventArgs e)
{
if (Border is { })
{
Border.LineStyle = DefaultSeparatorLineStyle;
}
}
/// <summary>
/// Gets or sets the default Line Style for the separators between the shortcuts of the StatusBar.
/// </summary>
[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
public static LineStyle DefaultSeparatorLineStyle { get; set; } = LineStyle.Dashed;
/// <inheritdoc />
protected override void OnSubViewLayout (LayoutEventArgs args)
{
for (int index = 0; index < SubViews.Count; index++)
{
@@ -40,13 +57,9 @@ public class StatusBar : Bar, IDesignable
barItem.BorderStyle = BorderStyle;
if (index == SubViews.Count - 1)
if (barItem.Border is { })
{
barItem.Border.Thickness = new Thickness (0, 0, 0, 0);
}
else
{
barItem.Border.Thickness = new Thickness (0, 0, 1, 0);
barItem.Border.Thickness = index == SubViews.Count - 1 ? new Thickness (0, 0, 0, 0) : new Thickness (0, 0, 1, 0);
}
if (barItem is Shortcut shortcut)
@@ -54,6 +67,7 @@ public class StatusBar : Bar, IDesignable
shortcut.Orientation = Orientation.Horizontal;
}
}
base.OnSubViewLayout (args);
}
/// <inheritdoc/>
@@ -138,4 +152,11 @@ public class StatusBar : Bar, IDesignable
void Button_Clicked (object sender, EventArgs e) { MessageBox.Query ("Hi", $"You clicked {sender}"); }
}
/// <inheritdoc />
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
Applied -= OnConfigurationManagerApplied;
}
}

View File

@@ -84,8 +84,6 @@ namespace UICatalog;
public class Scenario : IDisposable
{
private static int _maxScenarioNameLen = 30;
public string TopLevelColorScheme { get; set; } = "Base";
public BenchmarkResults BenchmarkResults
{
get { return _benchmarkResults; }

View File

@@ -360,9 +360,6 @@ public class UICatalog
while (RunUICatalogTopLevel () is { } scenario)
{
VerifyObjectsWereDisposed ();
Themes!.Theme = UICatalogTop.CachedTheme!;
Apply ();
scenario.TopLevelColorScheme = UICatalogTop.CachedTopLevelColorScheme!;
#if DEBUG_IDISPOSABLE
View.DebugIDisposable = true;
@@ -412,7 +409,6 @@ public class UICatalog
}
Application.Init (driverName: _forceDriver);
scenario.TopLevelColorScheme = UICatalogTop.CachedTopLevelColorScheme!;
if (benchmark)
{

View File

@@ -27,6 +27,9 @@ public class UICatalogTop : Toplevel
// 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; }
// Diagnostics
@@ -58,8 +61,6 @@ public class UICatalogTop : Toplevel
private void LoadedHandler (object? sender, EventArgs? args)
{
ConfigChanged ();
if (_disableMouseCb is { })
{
_disableMouseCb.CheckedState = Application.IsMouseDisabled ? CheckState.Checked : CheckState.UnChecked;
@@ -648,7 +649,11 @@ public class UICatalogTop : Toplevel
#endregion StatusBar
#region Configuration Manager
public void ConfigChanged ()
/// <summary>
/// Called when CM has applied changes.
/// </summary>
private void ConfigApplied ()
{
CachedTheme = Themes?.Theme;
@@ -672,7 +677,7 @@ public class UICatalogTop : Toplevel
Application.Top?.SetNeedsDraw ();
}
private void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a) { ConfigChanged (); }
private void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a) { ConfigApplied (); }
#endregion Configuration Manager