diff --git a/Terminal.Gui/Input/KeyBindingScope.cs b/Terminal.Gui/Input/KeyBindingScope.cs index 65331eeca..9799fc831 100644 --- a/Terminal.Gui/Input/KeyBindingScope.cs +++ b/Terminal.Gui/Input/KeyBindingScope.cs @@ -41,9 +41,6 @@ public enum KeyBindingScope /// Application-scoped key bindings are only invoked if the key down event was not handled by the focused view or /// any of its subviews, and if the key was not bound to a . /// - /// - /// makes it easy to add Application-scoped key bindings with a visual indicator. See also . - /// /// Application = 4 } diff --git a/Terminal.Gui/Input/KeyBindings.cs b/Terminal.Gui/Input/KeyBindings.cs index bb487773f..82360a726 100644 --- a/Terminal.Gui/Input/KeyBindings.cs +++ b/Terminal.Gui/Input/KeyBindings.cs @@ -17,7 +17,7 @@ public class KeyBindings /// /// The view that the are bound to. /// - public View BoundView { get; } + public View? BoundView { get; } // TODO: Add a dictionary comparer that ignores Scope // TODO: This should not be public! diff --git a/Terminal.Gui/View/Layout/DimAuto.cs b/Terminal.Gui/View/Layout/DimAuto.cs index 38ec1e086..0538c6f08 100644 --- a/Terminal.Gui/View/Layout/DimAuto.cs +++ b/Terminal.Gui/View/Layout/DimAuto.cs @@ -1,6 +1,4 @@ #nullable enable -using System.Drawing; - namespace Terminal.Gui; /// @@ -22,7 +20,6 @@ public class DimAuto () : Dim /// /// Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED. /// - // ReSharper disable once ConvertToAutoProperty public required Dim? MaximumContentDim { @@ -35,7 +32,6 @@ public class DimAuto () : Dim /// /// Gets the minimum dimension the View's ContentSize will be constrained to. /// - // ReSharper disable once ConvertToAutoProperty public required Dim? MinimumContentDim { @@ -48,7 +44,6 @@ public class DimAuto () : Dim /// /// Gets the style of the DimAuto. /// - // ReSharper disable once ConvertToAutoProperty public required DimAutoStyle Style { @@ -86,11 +81,10 @@ public class DimAuto () : Dim // TODO: This whole body of code is a WIP (for https://github.com/gui-cs/Terminal.Gui/pull/3451). subviewsSize = 0; - List includedSubviews = us.Subviews.ToList (); //.Where (v => !v.ExcludeFromLayout).ToList (); + List includedSubviews = us.Subviews.ToList();//.Where (v => !v.ExcludeFromLayout).ToList (); List subviews; #region Not Anchored and Are Not Dependent - // Start with subviews that are not anchored to the end, aligned, or dependent on content size // [x] PosAnchorEnd // [x] PosAlign @@ -104,25 +98,17 @@ public class DimAuto () : Dim // [ ] DimView if (dimension == Dimension.Width) { - subviews = includedSubviews.Where ( - v => v.X is not PosAnchorEnd - && v.X is not PosAlign - - // && v.X is not PosCenter - && v.Width is not DimAuto - && v.Width is not DimFill) - .ToList (); + subviews = includedSubviews.Where (v => v.X is not PosAnchorEnd + && v.X is not PosAlign + // && v.X is not PosCenter + && v.Width is not DimFill).ToList (); } else { - subviews = includedSubviews.Where ( - v => v.Y is not PosAnchorEnd - && v.Y is not PosAlign - - // && v.Y is not PosCenter - && v.Height is not DimAuto - && v.Height is not DimFill) - .ToList (); + subviews = includedSubviews.Where (v => v.Y is not PosAnchorEnd + && v.Y is not PosAlign + // && v.Y is not PosCenter + && v.Height is not DimFill).ToList (); } for (var i = 0; i < subviews.Count; i++) @@ -137,11 +123,9 @@ public class DimAuto () : Dim subviewsSize = size; } } - #endregion Not Anchored and Are Not Dependent #region Anchored - // Now, handle subviews that are anchored to the end // [x] PosAnchorEnd if (dimension == Dimension.Width) @@ -154,7 +138,6 @@ public class DimAuto () : Dim } int maxAnchorEnd = 0; - for (var i = 0; i < subviews.Count; i++) { View v = subviews [i]; @@ -162,84 +145,47 @@ public class DimAuto () : Dim } subviewsSize += maxAnchorEnd; - #endregion Anchored + //#region Center + //// Now, handle subviews that are Centered + //if (dimension == Dimension.Width) + //{ + // subviews = us.Subviews.Where (v => v.X is PosCenter).ToList (); + //} + //else + //{ + // subviews = us.Subviews.Where (v => v.Y is PosCenter).ToList (); + //} - #region Auto + //int maxCenter = 0; + //for (var i = 0; i < subviews.Count; i++) + //{ + // View v = subviews [i]; + // maxCenter = dimension == Dimension.Width ? v.Frame.Width : v.Frame.Height; + //} - if (dimension == Dimension.Width) - { - subviews = includedSubviews.Where (v => v.Width is DimAuto).ToList (); - } - else - { - subviews = includedSubviews.Where (v => v.Height is DimAuto).ToList (); - } - - int maxAuto = 0; - - for (var i = 0; i < subviews.Count; i++) - { - View v = subviews [i]; - - maxAuto = CalculateMinDimension (us, dimension); - - if (maxAuto > subviewsSize) - { - // BUGBUG: Should we break here? Or choose min/max? - subviewsSize = maxAuto; - } - } - - // subviewsSize += maxAuto; - - #endregion Auto - - #region Center - - // Now, handle subviews that are Centered - if (dimension == Dimension.Width) - { - subviews = us.Subviews.Where (v => v.X is PosCenter).ToList (); - } - else - { - subviews = us.Subviews.Where (v => v.Y is PosCenter).ToList (); - } - - int maxCenter = 0; - - for (var i = 0; i < subviews.Count; i++) - { - View v = subviews [i]; - maxCenter = dimension == Dimension.Width ? v.Frame.Width : v.Frame.Height; - - if (maxCenter > subviewsSize) - { - // BUGBUG: Should we break here? Or choose min/max? - subviewsSize = maxCenter; - } - } - - #endregion Center + //subviewsSize += maxCenter; + //#endregion Center #region Are Dependent - // Now, go back to those that are dependent on content size // [x] DimFill // [ ] DimPercent if (dimension == Dimension.Width) { - subviews = includedSubviews.Where (v => v.Width is DimFill).ToList (); + subviews = includedSubviews.Where (v => v.Width is DimFill + // || v.X is PosCenter + ).ToList (); } else { - subviews = includedSubviews.Where (v => v.Height is DimFill).ToList (); + subviews = includedSubviews.Where (v => v.Height is DimFill + //|| v.Y is PosCenter + ).ToList (); } int maxFill = 0; - for (var i = 0; i < subviews.Count; i++) { View v = subviews [i]; @@ -252,12 +198,10 @@ public class DimAuto () : Dim { v.SetRelativeLayout (new Size (0, autoMax - subviewsSize)); } - maxFill = dimension == Dimension.Width ? v.Frame.Width : v.Frame.Height; } subviewsSize += maxFill; - #endregion Are Dependent } } @@ -283,16 +227,6 @@ public class DimAuto () : Dim return int.Min (max, autoMax); } - internal int CalculateMinDimension (View us, Dimension dimension) - { - - - int min = dimension == Dimension.Width ? us.Frame.Width : us.Frame.Height; - - return min; - } - - internal override bool ReferencesOtherViews () { // BUGBUG: This is not correct. _contentSize may be null. diff --git a/Terminal.Gui/View/Layout/DimAutoStyle.cs b/Terminal.Gui/View/Layout/DimAutoStyle.cs index a0b464d59..f350e8045 100644 --- a/Terminal.Gui/View/Layout/DimAutoStyle.cs +++ b/Terminal.Gui/View/Layout/DimAutoStyle.cs @@ -12,7 +12,7 @@ public enum DimAutoStyle /// /// The dimensions will be computed based on the View's and/or . /// - /// If is , will be used to determine the dimension. + /// If is , will be used to determine the dimension. /// /// /// Otherwise, the Subview in with the largest corresponding position plus dimension diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 11c764b0e..b6400a2b7 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -128,7 +128,7 @@ internal class UICatalogApp { var options = new Options { - Driver = context.ParseResult.GetValueForOption (driverOption), + Driver = context.ParseResult.GetValueForOption (driverOption) ?? string.Empty, Scenario = context.ParseResult.GetValueForArgument (scenarioArgument) /* etc. */ }; @@ -660,7 +660,7 @@ internal class UICatalogApp List schemeMenuItems = new (); - foreach (KeyValuePair sc in Colors.ColorSchemes) + foreach (KeyValuePair sc in Colors.ColorSchemes) { var item = new MenuItem { Title = $"_{sc.Key}", Data = sc.Key }; item.CheckType |= MenuItemCheckStyle.Radio;