Explorar o código

MessageBox works. Dialog broken

Tig hai 1 ano
pai
achega
58e4271588

+ 1 - 0
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -426,6 +426,7 @@ public abstract class ConsoleDriver
     /// <param name="row">Row to move to.</param>
     public virtual void Move (int col, int row)
     {
+        //Debug.Assert (col >= 0 && row >= 0 && col < Contents.GetLength(1) && row < Contents.GetLength(0));
         Col = col;
         Row = row;
     }

+ 2 - 2
Terminal.Gui/Drawing/Glyphs.cs

@@ -442,13 +442,13 @@ public class GlyphDefinitions
 
 
     /// <summary>Shadow - Vertical Start - Left Half Block - ▌ U+0258c</summary>
-    public Rune ShadowVerticalStart { get; set; } =  (Rune)''; // Half: '\u2596'  ▖;
+    public Rune ShadowVerticalStart { get; set; } =  (Rune)''; // Half: '\u2596'  ▖;
 
     /// <summary>Shadow - Vertical - Left Half Block - ▌ U+0258c</summary>
     public Rune ShadowVertical { get; set; } = (Rune)'▌';
 
     /// <summary>Shadow - Horizontal Start - Upper Half Block - ▀ U+02580</summary>
-    public Rune ShadowHorizontalStart { get; set; } = (Rune)''; // Half: ▝ U+0259d;
+    public Rune ShadowHorizontalStart { get; set; } = (Rune)''; // Half: ▝ U+0259d;
 
     /// <summary>Shadow - Horizontal - Upper Half Block - ▀ U+02580</summary>
     public Rune ShadowHorizontal { get; set; } = (Rune)'▀';

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

@@ -149,8 +149,9 @@ public class Border : Adornment
         }
     }
 
-    private Rectangle GetBorderRectangle (Rectangle screenRect)
+    internal Rectangle GetBorderRectangle ()
     {
+        Rectangle screenRect = ViewportToScreen (Viewport);
         return new (
                     screenRect.X + Math.Max (0, Thickness.Left - 1),
                     screenRect.Y + Math.Max (0, Thickness.Top - 1),
@@ -407,7 +408,7 @@ public class Border : Adornment
         // ...thickness extends outward (border/title is always as far in as possible)
         // PERF: How about a call to Rectangle.Offset?
 
-        Rectangle borderBounds = GetBorderRectangle (screenBounds);
+        Rectangle borderBounds = GetBorderRectangle ();
         int topTitleLineY = borderBounds.Y;
         int titleY = borderBounds.Y;
         var titleBarsLength = 0; // the little vertical thingies

+ 22 - 7
Terminal.Gui/View/Adornment/Margin.cs

@@ -44,7 +44,7 @@ public class Margin : Adornment
         ShadowStyle = base.ShadowStyle;
 
         Add (
-             _rightShadow = new()
+             _rightShadow = new ()
              {
                  X = Pos.AnchorEnd (1),
                  Y = 0,
@@ -53,7 +53,7 @@ public class Margin : Adornment
                  ShadowStyle = ShadowStyle,
                  Orientation = Orientation.Vertical
              },
-             _bottomShadow = new()
+             _bottomShadow = new ()
              {
                  X = 0,
                  Y = Pos.AnchorEnd (1),
@@ -220,12 +220,27 @@ public class Margin : Adornment
     private void Margin_LayoutStarted (object? sender, LayoutEventArgs e)
     {
         // Adjust the shadow such that it is drawn aligned with the Border
-        if (ShadowStyle != ShadowStyle.None && _rightShadow is { } && _bottomShadow is { })
+        if (_rightShadow is { } && _bottomShadow is { })
         {
-            _rightShadow.Y = Parent.Border.Thickness.Top > 0
-                                 ? Parent.Border.Thickness.Top - (Parent.Border.Thickness.Top > 2 && Parent.Border.Settings.FastHasFlags (BorderSettings.Title) ? 1 : 0)
-                                 : 1;
-            _bottomShadow.X = Parent.Border.Thickness.Left > 0 ? Parent.Border.Thickness.Left : 1;
+            switch (ShadowStyle)
+            {
+                case ShadowStyle.Transparent:
+                    // BUGBUG: This doesn't work right for all Border.Top sizes - Need an API on Border that gives top-right location of line corner.
+                    _rightShadow.Y = Parent.Border.Thickness.Top > 0 ? ScreenToViewport (Parent.Border.GetBorderRectangle ().Location).Y + 1 : 0;
+                    break;
+
+                case ShadowStyle.Opaque:
+                    // BUGBUG: This doesn't work right for all Border.Top sizes - Need an API on Border that gives top-right location of line corner.
+                    _rightShadow.Y = Parent.Border.Thickness.Top > 0 ? ScreenToViewport (Parent.Border.GetBorderRectangle ().Location).Y + 1 : 0;
+                    _bottomShadow.X = Parent.Border.Thickness.Left > 0 ? ScreenToViewport (Parent.Border.GetBorderRectangle ().Location).X + 1 : 0;
+                    break;
+
+                case ShadowStyle.None:
+                default:
+                    _rightShadow.Y = 0;
+                    _bottomShadow.X = 0;
+                    break;
+            }
         }
     }
 }

+ 13 - 2
Terminal.Gui/View/Adornment/ShadowView.cs

@@ -1,4 +1,7 @@
 #nullable enable
+using Microsoft.VisualBasic;
+using System.Diagnostics;
+
 namespace Terminal.Gui;
 
 /// <summary>
@@ -109,7 +112,11 @@ internal class ShadowView : View
         for (int i = screen.X; i < screen.X + screen.Width - 1; i++)
         {
             Driver.Move (i, screen.Y);
-            Driver.AddRune (Driver.Contents [screen.Y, i].Rune);
+
+            if (i < Driver.Contents.GetLength (1) && screen.Y < Driver.Contents.GetLength (0))
+            {
+                Driver.AddRune (Driver.Contents [screen.Y, i].Rune);
+            }
         }
     }
 
@@ -133,7 +140,11 @@ internal class ShadowView : View
         for (int i = screen.Y; i < screen.Y + viewport.Height; i++)
         {
             Driver.Move (screen.X, i);
-            Driver.AddRune (Driver.Contents [i, screen.X].Rune);
+
+            if (screen.X < Driver.Contents.GetLength (1) && i < Driver.Contents.GetLength (0))
+            {
+                Driver.AddRune (Driver.Contents [i, screen.X].Rune);
+            }
         }
     }
 }

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

@@ -169,7 +169,6 @@ public class Dialog : Window
         // Use a distinct GroupId so users can use Pos.Align for other views in the Dialog
         button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, GetHashCode ());
         button.Y = Pos.AnchorEnd ();
-        button.Margin.Thickness = button.Margin.Thickness with { Top = 1 };
 
         _buttons.Add (button);
         Add (button);

+ 4 - 4
UICatalog/UICatalog.cs

@@ -382,7 +382,7 @@ internal class UICatalogApp
             _themeMenuBarItem = new ("_Themes", _themeMenuItems);
 
             _aboutMessage = new ();
-            _aboutMessage.AppendLine (@"A comprehensive sample library for");
+            _aboutMessage.AppendLine (@"UI Catalog: A comprehensive sample library for");
             _aboutMessage.AppendLine (
                                       """
                                        _______                  _             _   _____       _
@@ -395,7 +395,7 @@ internal class UICatalogApp
             _aboutMessage.AppendLine (@"");
             _aboutMessage.AppendLine (@"v2 - Pre-Alpha");
             _aboutMessage.AppendLine (@"");
-            _aboutMessage.Append (@"https://github.com/gui-cs/Terminal.Gui");
+            _aboutMessage.AppendLine (@"https://github.com/gui-cs/Terminal.Gui");
 
             MenuBar = new ()
             {
@@ -438,8 +438,8 @@ internal class UICatalogApp
                                   "_About...",
                                   "About UI Catalog",
                                   () => MessageBox.Query (
-                                                          "About UI Catalog",
-                                                          _aboutMessage!.ToString (),
+                                                          title: "",
+                                                          message: _aboutMessage!.ToString (),
                                                           wrapMessage: false,
                                                           buttons: "_Ok"
                                                          ),