Browse Source

Fixed wizard layout

Tig 11 months ago
parent
commit
942e7fbebe

+ 11 - 9
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -70,16 +70,18 @@ public class Wizard : Dialog
         ButtonAlignmentModes |= AlignmentModes.IgnoreFirstOrLast;
         BorderStyle = LineStyle.Double;
 
+        BackButton = new () { Text = Strings.wzBack };
+        NextFinishButton = new ()
+        {
+            Text = Strings.wzFinish,
+            IsDefault = true
+        };
+
         //// Add a horiz separator
-        var separator = new LineView (Orientation.Horizontal) { Y = Pos.AnchorEnd (2) };
-        Add (separator);
+        var separator = new LineView (Orientation.Horizontal) { Y = Pos.Top (BackButton) - 1 };
 
-        // BUGBUG: Space is to work around https://github.com/gui-cs/Terminal.Gui/issues/1812
-        BackButton = new () { Text = Strings.wzBack };
+        Add (separator);
         AddButton (BackButton);
-
-        NextFinishButton = new () { Text = Strings.wzFinish };
-        NextFinishButton.IsDefault = true;
         AddButton (NextFinishButton);
 
         BackButton.Accept += BackBtn_Clicked;
@@ -495,14 +497,14 @@ public class Wizard : Dialog
             // If we're modal, then we expand the WizardStep so that the top and side 
             // borders and not visible. The bottom border is the separator above the buttons.
             step.X = step.Y = 0;
-            step.Height = Dim.Fill (2); // for button frame
+            step.Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1 : 1)); // for button frame (+1 for lineView)
             step.Width = Dim.Fill ();
         }
         else
         {
             // If we're not a modal, then we show the border around the WizardStep
             step.X = step.Y = 0;
-            step.Height = Dim.Fill (1); // for button frame
+            step.Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1 : 2)); // for button frame (+1 for lineView)
             step.Width = Dim.Fill ();
         }
     }

+ 2 - 1
Terminal.Gui/Views/Wizard/WizardStep.cs

@@ -60,6 +60,7 @@ public class WizardStep : View
         TabStop = TabBehavior.TabStop;
         CanFocus = true;
         BorderStyle = LineStyle.None;
+
         base.Add (_contentView);
 
         base.Add (_helpTextView);
@@ -191,7 +192,7 @@ public class WizardStep : View
     internal void ShowHide ()
     {
         _contentView.Height = Dim.Fill ();
-        _helpTextView.Height = Dim.Fill ();
+        _helpTextView.Height = Dim.Height(_contentView);
         _helpTextView.Width = Dim.Fill ();
 
         if (_contentView.InternalSubviews?.Count > 0)

+ 8 - 1
UICatalog/Scenarios/WizardAsView.cs

@@ -57,7 +57,14 @@ public class WizardAsView : Scenario
         topLevel.Add (menu);
 
         // No need for a Title because the border is disabled
-        var wizard = new Wizard { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
+        var wizard = new Wizard
+        {
+            X = 0,
+            Y = 0,
+            Width = Dim.Fill (),
+            Height = Dim.Fill (),
+            ShadowStyle = ShadowStyle.None
+        };
 
         // Set Mdoal to false to cause the Wizard class to render without a frame and
         // behave like an non-modal View (vs. a modal/pop-up Window).

+ 12 - 2
UICatalog/Scenarios/Wizards.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Linq;
 using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
@@ -276,17 +277,26 @@ public class Wizards : Scenario
                                                X = 0,
                                                Y = 0,
                                                Width = Dim.Fill (),
-                                               Height = Dim.Fill (1),
                                                WordWrap = true,
                                                AllowsTab = false,
                                                ColorScheme = Colors.ColorSchemes ["Base"]
                                            };
+
+                                           someText.Height = Dim.Fill (
+                                                                       Dim.Func (
+                                                                                 () => someText.SuperView is { IsInitialized: true }
+                                                                                           ? someText.SuperView.Subviews
+                                                                                                     .First (view => view.Y.Has<PosAnchorEnd> (out _))
+                                                                                                     .Frame.Height
+                                                                                           : 1));
                                            var help = "This is helpful.";
                                            fourthStep.Add (someText);
 
                                            var hideHelpBtn = new Button
                                            {
-                                               Text = "Press me to show/hide help", X = Pos.Center (), Y = Pos.AnchorEnd (1)
+                                               Text = "Press me to show/hide help",
+                                               X = Pos.Center (),
+                                               Y = Pos.AnchorEnd ()
                                            };
 
                                            hideHelpBtn.Accept += (s, e) =>

+ 2 - 2
UICatalog/UICatalog.cs

@@ -477,7 +477,7 @@ public class UICatalogApp
                 ShVersion = new ()
                 {
                     Title = "Version Info",
-                    CanFocus = false
+                    CanFocus = false,
                 };
 
                 var statusBarShortcut = new Shortcut
@@ -546,7 +546,7 @@ public class UICatalogApp
                 X = 0,
                 Y = 1,
                 Width = Dim.Auto (),
-                Height = Dim.Fill (1),
+                Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height : 1)),
                 AllowsMarking = false,
                 CanFocus = true,
                 Title = "_Categories",