Pārlūkot izejas kodu

debugging iterations

Tig 9 mēneši atpakaļ
vecāks
revīzija
317d425a93

+ 2 - 1
Terminal.Gui/Application/Application.Run.cs

@@ -510,7 +510,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
 
 
         if (clear || forceRedraw)
         if (clear || forceRedraw)
         {
         {
-            Driver?.ClearContents ();
+            //Driver?.ClearContents ();
         }
         }
 
 
         foreach (Toplevel tl in TopLevels.Reverse ())
         foreach (Toplevel tl in TopLevels.Reverse ())
@@ -519,6 +519,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
             {
             {
                 tl.SetNeedsDisplay ();
                 tl.SetNeedsDisplay ();
             }
             }
+
             tl.Draw ();
             tl.Draw ();
         }
         }
 
 

+ 5 - 5
Terminal.Gui/View/Adornment/Adornment.cs

@@ -155,11 +155,11 @@ public class Adornment : View, IDesignable
         return parentOrSuperView.ScreenToFrame (new (location.X - Frame.X, location.Y - Frame.Y));
         return parentOrSuperView.ScreenToFrame (new (location.X - Frame.X, location.Y - Frame.Y));
     }
     }
 
 
-    /// <summary>Does nothing for Adornment</summary>
-    /// <returns></returns>
-    protected override bool OnDrawingAdornments () { return false; }
-
-    /// <inheritdoc/>
+    /// <summary>
+    ///     Called when the <see cref="Thickness"/> of the Adornment is to be cleared.
+    /// </summary>
+    /// <param name="viewport"></param>
+    /// <returns><see langword="true"/> to stop further clearing.</returns>
     protected override bool OnClearingViewport (Rectangle viewport)
     protected override bool OnClearingViewport (Rectangle viewport)
     {
     {
         if (Thickness == Thickness.Empty)
         if (Thickness == Thickness.Empty)

+ 8 - 19
Terminal.Gui/View/View.Drawing.cs

@@ -5,8 +5,6 @@ namespace Terminal.Gui;
 
 
 public partial class View // Drawing APIs
 public partial class View // Drawing APIs
 {
 {
-    #region Drawing Engine
-
     /// <summary>
     /// <summary>
     ///     Draws the view if it needs to be drawn.
     ///     Draws the view if it needs to be drawn.
     /// </summary>
     /// </summary>
@@ -22,18 +20,14 @@ public partial class View // Drawing APIs
     /// </remarks>
     /// </remarks>
     public void Draw ()
     public void Draw ()
     {
     {
-        if (!CanBeVisible (this))
-        {
-            return;
-        }
-
-        if (!NeedsDisplay && !SubViewNeedsDisplay)
+        if (!CanBeVisible (this) || (!NeedsDisplay && !SubViewNeedsDisplay))
         {
         {
             return;
             return;
         }
         }
 
 
         DoDrawAdornments ();
         DoDrawAdornments ();
 
 
+        // Set the color scheme for the view after adornments have been drawn
         if (ColorScheme is { })
         if (ColorScheme is { })
         {
         {
             Driver?.SetAttribute (GetNormalColor ());
             Driver?.SetAttribute (GetNormalColor ());
@@ -44,27 +38,20 @@ public partial class View // Drawing APIs
         // so via settings. SetClip honors the ViewportSettings.DisableVisibleContentClipping flag.
         // so via settings. SetClip honors the ViewportSettings.DisableVisibleContentClipping flag.
         Rectangle prevClip = SetClip ();
         Rectangle prevClip = SetClip ();
 
 
-        // Clear Viewport
         DoClearViewport (Viewport);
         DoClearViewport (Viewport);
-
-        // Draw Text
         DoDrawText (Viewport);
         DoDrawText (Viewport);
-
-        // Draw Content
         DoDrawContent (Viewport);
         DoDrawContent (Viewport);
-
-        // Draw Subviews
         DoDrawSubviews (Viewport);
         DoDrawSubviews (Viewport);
 
 
+        // Restore the clip before rendering the line canvas and adornment subviews
+        // because they may draw outside the viewport.
         if (Driver is { })
         if (Driver is { })
         {
         {
             Driver.Clip = prevClip;
             Driver.Clip = prevClip;
         }
         }
 
 
         DoRenderLineCanvas ();
         DoRenderLineCanvas ();
-
         DoDrawAdornmentSubViews ();
         DoDrawAdornmentSubViews ();
-
         ClearNeedsDisplay ();
         ClearNeedsDisplay ();
 
 
         // We're done
         // We're done
@@ -75,6 +62,8 @@ public partial class View // Drawing APIs
 
 
     private void DoDrawAdornmentSubViews ()
     private void DoDrawAdornmentSubViews ()
     {
     {
+        // This causes the Adornment's subviews to be REDRAWN
+        // TODO: Figure out how to make this more efficient
         if (Margin?.Subviews is { })
         if (Margin?.Subviews is { })
         {
         {
             foreach (View subview in Margin.Subviews)
             foreach (View subview in Margin.Subviews)
@@ -279,6 +268,8 @@ public partial class View // Drawing APIs
 
 
         // We assume that the text has been drawn over the entire area; ensure that the subviews are redrawn.
         // We assume that the text has been drawn over the entire area; ensure that the subviews are redrawn.
         SetSubViewNeedsDisplay ();
         SetSubViewNeedsDisplay ();
+        
+        Debug.WriteLine($"DrawText: {Id}");
     }
     }
 
 
     #endregion DrawText
     #endregion DrawText
@@ -646,6 +637,4 @@ public partial class View // Drawing APIs
     }
     }
 
 
     #endregion NeedsDisplay
     #endregion NeedsDisplay
-
-    #endregion Drawing Engine
 }
 }

+ 1 - 0
Terminal.Gui/Views/MessageBox.cs

@@ -382,6 +382,7 @@ public static class MessageBox
 
 
         var d = new Dialog
         var d = new Dialog
         {
         {
+            Id = "MessageBox",
             Title = title,
             Title = title,
             ButtonAlignment = MessageBox.DefaultButtonAlignment,
             ButtonAlignment = MessageBox.DefaultButtonAlignment,
             ButtonAlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
             ButtonAlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,

+ 2 - 1
UICatalog/Scenarios/ContentScrolling.cs

@@ -373,8 +373,9 @@ public class ContentScrolling : Scenario
 
 
         var buttonAnchored = new Button
         var buttonAnchored = new Button
         {
         {
-            X = Pos.AnchorEnd (), Y = Pos.AnchorEnd (), Text = "Bottom Right"
+            X = Pos.AnchorEnd (), Y = Pos.AnchorEnd (), Text = "Bottom Rig_ht"
         };
         };
+        buttonAnchored.Accepting += (sender, args) => MessageBox.Query ("Hi", $"You pressed {((Button)sender)?.Text}", "_Ok");
 
 
         view.Margin.Data = "Margin";
         view.Margin.Data = "Margin";
         view.Margin.Thickness = new (0);
         view.Margin.Thickness = new (0);

+ 5 - 1
UICatalog/Scenarios/Generic.cs

@@ -17,7 +17,11 @@ public sealed class Generic : Scenario
             Title = GetQuitKeyAndName (),
             Title = GetQuitKeyAndName (),
         };
         };
 
 
-        var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "_Press me!" };
+        var button = new Button { Id = "button", X = Pos.Center (), Y = 1, Text = "_Press me!" };
+
+        button.ShadowStyle = ShadowStyle.None;
+        button.HighlightStyle = HighlightStyle.None;
+
         button.Accepting += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
         button.Accepting += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
         appWindow.Add (button);
         appWindow.Add (button);