Jelajahi Sumber

LineCanvas - Exclude

Tig 8 bulan lalu
induk
melakukan
9288de7990

+ 4 - 2
Terminal.Gui/View/Adornment/Border.cs

@@ -720,10 +720,12 @@ public class Border : Adornment
                 focus = GetFocusColor ();
             }
 
-            Parent.TitleTextFormatter.Draw (
-                                            new (borderBounds.X + 2, titleY, maxTitleWidth, 1),
+            Rectangle titleRect = new (borderBounds.X + 2, titleY, maxTitleWidth, 1);
+            Parent.TitleTextFormatter.Draw (titleRect
+                                           ,
                                             Parent.HasFocus ? focus : GetNormalColor (),
                                             Parent.HasFocus ? focus : GetHotNormalColor ());
+            Parent?.LineCanvas.Exclude(new(titleRect));
         }
 
         if (canDrawBorder && LineStyle != LineStyle.None)

+ 12 - 1
Terminal.Gui/View/View.Drawing.cs

@@ -130,7 +130,7 @@ public partial class View // Drawing APIs
     {
         if (Border?.Subviews is { } && Border.Thickness != Thickness.Empty)
         {
-            foreach (View subview in Border.Subviews)
+            foreach (View subview in Border.Subviews.Where (v => v.Visible))
             {
                 subview.SetNeedsDraw ();
                 LineCanvas.Exclude (new (subview.FrameToScreen()));
@@ -479,6 +479,11 @@ public partial class View // Drawing APIs
         // Draw the subviews in reverse order to leverage clipping.
         foreach (View view in _subviews.Where (view => view.Visible).Reverse ())
         {
+            // TODO: HACK - This enables auto line join to work, but is brute force.
+            if (view.SuperViewRendersLineCanvas)
+            {
+                view.SetNeedsDraw ();
+            }
             view.Draw ();
         }
     }
@@ -774,6 +779,12 @@ public partial class View // Drawing APIs
         {
             SuperView.SubViewNeedsDraw = false;
         }
+
+        if (!SuperViewRendersLineCanvas)
+        {
+            LineCanvas.Clear ();
+        }
+
     }
 
     #endregion NeedsDraw

+ 16 - 14
UICatalog/Scenarios/AllViewsTester.cs

@@ -60,7 +60,7 @@ public class AllViewsTester : Scenario
             SelectedItem = 0,
             Source = new ListWrapper<string> (new (_viewClasses.Keys.ToList ())),
             BorderStyle = LineStyle.Rounded,
-            //SuperViewRendersLineCanvas = true
+            SuperViewRendersLineCanvas = true
         };
 
         _classListView.SelectedItemChanged += (s, args) =>
@@ -88,7 +88,7 @@ public class AllViewsTester : Scenario
         _adornmentsEditor = new ()
         {
             Title = "Adornments [_2]",
-            X = Pos.Right (_classListView),
+            X = Pos.Right (_classListView) - 1,
             Y = 0,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
@@ -96,29 +96,29 @@ public class AllViewsTester : Scenario
             BorderStyle = LineStyle.Rounded,
             AutoSelectViewToEdit = false,
             AutoSelectAdornments = false,
-            //SuperViewRendersLineCanvas = true
+            SuperViewRendersLineCanvas = true
         };
         _adornmentsEditor.ExpanderButton.Orientation = Orientation.Vertical;
 
         _arrangementEditor = new ()
         {
             Title = "Arrangement [_3]",
-            X = Pos.Right (_classListView),
-            Y = Pos.Bottom (_adornmentsEditor),
+            X = Pos.Right (_classListView) - 1,
+            Y = Pos.Bottom (_adornmentsEditor) -1,
             Width = Dim.Width (_adornmentsEditor),
             Height = Dim.Fill (),
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             BorderStyle = LineStyle.Rounded,
             AutoSelectViewToEdit = false,
             AutoSelectAdornments = false,
-            //SuperViewRendersLineCanvas = true
+            SuperViewRendersLineCanvas = true
         };
         _arrangementEditor.ExpanderButton.Orientation = Orientation.Vertical;
 
         _layoutEditor = new ()
         {
             Title = "Layout [_4]",
-            X = Pos.Right (_adornmentsEditor),
+            X = Pos.Right (_adornmentsEditor) - 1,
             Y = 0,
 
             //Width = Dim.Fill (), // set below
@@ -134,8 +134,8 @@ public class AllViewsTester : Scenario
         _settingsPane = new ()
         {
             Title = "Settings [_5]",
-            X = Pos.Right (_adornmentsEditor),
-            Y = Pos.Bottom (_layoutEditor),
+            X = Pos.Right (_adornmentsEditor) - 1,
+            Y = Pos.Bottom (_layoutEditor) - 1,
             Width = Dim.Width (_layoutEditor),
             Height = Dim.Auto (),
             CanFocus = true,
@@ -188,9 +188,10 @@ public class AllViewsTester : Scenario
 
         _eventLog = new ()
         {
-            // X = Pos.Right(_layoutEditor)
+            // X = Pos.Right(_layoutEditor),
+            SuperViewRendersLineCanvas = true
         };
-        _eventLog.X = Pos.AnchorEnd ();
+        _eventLog.X = Pos.AnchorEnd () - 1;
         _eventLog.Y = 0;
 
         _eventLog.Height = Dim.Height (_classListView);
@@ -216,15 +217,16 @@ public class AllViewsTester : Scenario
         _hostPane = new ()
         {
             Id = "_hostPane",
-            X = Pos.Right (_adornmentsEditor),
-            Y = Pos.Bottom (_settingsPane),
+            X = Pos.Right (_adornmentsEditor) - 1,
+            Y = Pos.Bottom (_settingsPane) - 1,
             Width = Dim.Width (_layoutEditor),
             Height = Dim.Fill (),
             CanFocus = true,
             TabStop = TabBehavior.TabStop,
             ColorScheme = Colors.ColorSchemes ["Base"],
             Arrangement = ViewArrangement.Resizable,
-            BorderStyle = LineStyle.RoundedDotted
+            BorderStyle = LineStyle.RoundedDotted,
+            SuperViewRendersLineCanvas = true
         };
         _hostPane.Border!.ColorScheme = app.ColorScheme;
         _hostPane.Padding!.Thickness = new (1);

+ 1 - 1
UICatalog/Scenarios/LineCanvasExperiment.cs

@@ -19,7 +19,7 @@ public class LineCanvasExperiment : Scenario
 
         var frame1 = new FrameView
         {
-            Title = "LineCanvas Experiments",
+            Title = "_SuperView",
             X = 0,
             Y = 0,
             Width = Dim.Fill (),