소스 검색

Tweaked Adornments scenario to have editor movable

Tig 1 년 전
부모
커밋
b9c5797726
4개의 변경된 파일19개의 추가작업 그리고 12개의 파일을 삭제
  1. 0 1
      Terminal.Gui/View/View.cs
  2. 9 3
      UICatalog/Scenarios/Adornments.cs
  3. 6 2
      UICatalog/Scenarios/AdornmentsEditor.cs
  4. 4 6
      UICatalog/Scenarios/ExpanderButton.cs

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

@@ -252,7 +252,6 @@ public partial class View : Responder, ISupportInitializeNotification
         }
 
         Initialized?.Invoke (this, EventArgs.Empty);
-        LayoutSubviews();
     }
 
     #endregion Constructors and Initialization

+ 9 - 3
UICatalog/Scenarios/Adornments.cs

@@ -18,15 +18,21 @@ public class Adornments : Scenario
 
         var editor = new AdornmentsEditor
         {
-            AutoSelectViewToEdit = true
+            AutoSelectViewToEdit = true,
+            // This is for giggles, to show that the editor can be moved around.
+            Arrangement = ViewArrangement.Movable,
+            X = Pos.AnchorEnd()
+
         };
+        editor.Border.Thickness = new Thickness (1, 3, 1, 1);
+
         app.Add (editor);
 
         var window = new Window
         {
             Title = "The _Window",
             Arrangement = ViewArrangement.Movable,
-            X = Pos.Right (editor),
+           // X = Pos.Center (),
             Width = Dim.Percent (60),
             Height = Dim.Percent (80)
         };
@@ -98,7 +104,7 @@ public class Adornments : Scenario
                                   window.Padding.Add (labelInPadding);
 
                                   var textFieldInPadding = new TextField
-                                      { X = Pos.Right (labelInPadding) + 1, Y = Pos.Top (labelInPadding), Width = 15, Text = "some text" };
+                                  { X = Pos.Right (labelInPadding) + 1, Y = Pos.Top (labelInPadding), Width = 15, Text = "some text" };
                                   textFieldInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok");
                                   window.Padding.Add (textFieldInPadding);
 

+ 6 - 2
UICatalog/Scenarios/AdornmentsEditor.cs

@@ -24,13 +24,12 @@ public class AdornmentsEditor : View
 
     public AdornmentsEditor ()
     {
-        ColorScheme = Colors.ColorSchemes ["Dialog"];
+        //ColorScheme = Colors.ColorSchemes ["Dialog"];
         Title = $"AdornmentsEditor";
 
         Width = Dim.Auto (DimAutoStyle.Content);
         Height = Dim.Auto (DimAutoStyle.Content);
 
-        BorderStyle = LineStyle.Double;
         //SuperViewRendersLineCanvas = true;
 
         Application.MouseEvent += Application_MouseEvent;
@@ -45,6 +44,8 @@ public class AdornmentsEditor : View
 
     private void AdornmentsEditor_Initialized (object sender, EventArgs e)
     {
+        BorderStyle = LineStyle.Dotted;
+
         ExpanderButton expandButton = new ExpanderButton ()
         {
             Orientation = Orientation.Horizontal
@@ -124,6 +125,9 @@ public class AdornmentsEditor : View
         Add (_diagRulerCheckBox);
         _diagRulerCheckBox.Y = Pos.Bottom (_diagPaddingCheckBox);
 
+        // BUGBUG: This should not be needed. There's some bug in the layout system that doesn't update the layout.
+        SuperView.LayoutSubviews();
+
     }
 
     private void Application_MouseEvent (object sender, MouseEvent e)

+ 4 - 6
UICatalog/Scenarios/ExpanderButton.cs

@@ -15,7 +15,8 @@ namespace UICatalog.Scenarios;
 ///     <para>
 ///         If <see cref="Orientation"/> is set to <see cref="Terminal.Gui.Orientation.Vertical"/>, the button will appear
 ///         at the top/right.
-///         If <see cref="Orientation"/> is set to <see cref="Orientation.Horizontal"/>, the button will appear at the
+///         If <see cref="Orientation"/> is set to <see cref="Terminal.Gui.Orientation.Horizontal"/>, the button will
+///         appear at the
 ///         bottom/left.
 ///     </para>
 /// </remarks>
@@ -118,7 +119,7 @@ public class ExpanderButton : Button
     /// </summary>
     public Rune ExpandedGlyph { get; set; }
 
-    private bool _collapsed = false;
+    private bool _collapsed;
 
     /// <summary>
     ///     Gets or sets a value indicating whether the view is collapsed.
@@ -144,7 +145,6 @@ public class ExpanderButton : Button
             ExpandOrCollapse (_collapsed);
 
             View superView = SuperView;
-
             if (superView is Adornment adornment)
             {
                 superView = adornment.Parent;
@@ -160,7 +160,6 @@ public class ExpanderButton : Button
             superView.SuperView?.LayoutSubviews ();
         }
 
-
         return args.Cancel;
     }
 
@@ -169,7 +168,7 @@ public class ExpanderButton : Button
     ///     <see cref="OrientationEventArgs.Cancel"/> to true.
     /// </summary>
     public event EventHandler<StateEventArgs<bool>> CollapsedChanging;
-    
+
     /// <summary>
     ///     Collapses or Expands the view.
     /// </summary>
@@ -186,7 +185,6 @@ public class ExpanderButton : Button
     private void ExpandOrCollapse (bool collapse)
     {
         View superView = SuperView;
-
         if (superView is Adornment adornment)
         {
             superView = adornment.Parent;