Browse Source

Messed with some stuff. Probably broke some stuff.

Tig 9 months ago
parent
commit
cf772f80df

+ 4 - 0
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -54,6 +54,8 @@ internal class WindowsConsole
 
 
     public bool WriteToConsole (Size size, ExtendedCharInfo [] charInfoBuffer, Coord bufferSize, SmallRect window, bool force16Colors)
     public bool WriteToConsole (Size size, ExtendedCharInfo [] charInfoBuffer, Coord bufferSize, SmallRect window, bool force16Colors)
     {
     {
+        //Debug.WriteLine ("WriteToConsole");
+
         if (_screenBuffer == nint.Zero)
         if (_screenBuffer == nint.Zero)
         {
         {
             ReadFromConsoleOutput (size, bufferSize, ref window);
             ReadFromConsoleOutput (size, bufferSize, ref window);
@@ -1297,6 +1299,7 @@ internal class WindowsDriver : ConsoleDriver
             Y = (short)Rows, //Clip.Height
             Y = (short)Rows, //Clip.Height
         };
         };
 
 
+        bool _dirty = false;
         for (var row = 0; row < Rows; row++)
         for (var row = 0; row < Rows; row++)
         {
         {
             if (!_dirtyLines [row])
             if (!_dirtyLines [row])
@@ -1320,6 +1323,7 @@ internal class WindowsDriver : ConsoleDriver
                 }
                 }
 
 
                 _outputBuffer [position].Empty = false;
                 _outputBuffer [position].Empty = false;
+                _dirty = true;
 
 
                 if (Contents [row, col].Rune.IsBmp)
                 if (Contents [row, col].Rune.IsBmp)
                 {
                 {

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

@@ -270,7 +270,10 @@ public class Border : Adornment
         }
         }
 
 
         // BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/3312
         // BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/3312
-        if (!_dragPosition.HasValue && mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
+        if (!_dragPosition.HasValue && mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed)
+                                    // HACK: Prevents Window from being draggable if it's Top
+                                    //&& Parent is Toplevel { Modal: true }
+                                    )
         {
         {
             Parent!.SetFocus ();
             Parent!.SetFocus ();
 
 

+ 6 - 1
Terminal.Gui/View/Adornment/Margin.cs

@@ -91,17 +91,22 @@ public class Margin : Adornment
     /// <inheritdoc/>
     /// <inheritdoc/>
     public override void OnDrawContent (Rectangle viewport)
     public override void OnDrawContent (Rectangle viewport)
     {
     {
+        if (!NeedsDisplay)
+        {
+            return;
+        }
+
         Rectangle screen = ViewportToScreen (viewport);
         Rectangle screen = ViewportToScreen (viewport);
         Attribute normalAttr = GetNormalColor ();
         Attribute normalAttr = GetNormalColor ();
 
 
         Driver?.SetAttribute (normalAttr);
         Driver?.SetAttribute (normalAttr);
 
 
-        // This just draws/clears the thickness, not the insides.
         if (ShadowStyle != ShadowStyle.None)
         if (ShadowStyle != ShadowStyle.None)
         {
         {
             screen = Rectangle.Inflate (screen, -1, -1);
             screen = Rectangle.Inflate (screen, -1, -1);
         }
         }
 
 
+        // This just draws/clears the thickness, not the insides.
         Thickness.Draw (screen, ToString ());
         Thickness.Draw (screen, ToString ());
 
 
         if (Subviews.Count > 0)
         if (Subviews.Count > 0)

+ 2 - 2
UICatalog/KeyBindingsDialog.cs

@@ -19,8 +19,8 @@ internal class KeyBindingsDialog : Dialog
     {
     {
         Title = "Keybindings";
         Title = "Keybindings";
 
 
-        Height = Dim.Percent (80);
-        Width = Dim.Percent (80);
+        //Height = Dim.Percent (80);
+        //Width = Dim.Percent (80);
         if (ViewTracker.Instance == null)
         if (ViewTracker.Instance == null)
         {
         {
             ViewTracker.Initialize ();
             ViewTracker.Initialize ();

+ 2 - 0
UICatalog/Scenarios/ASCIICustomButton.cs

@@ -241,6 +241,8 @@ public class ASCIICustomButtonTest : Scenario
             {
             {
                 Add (titleLabel, _scrollView);
                 Add (titleLabel, _scrollView);
             }
             }
+
+            Y = 1;
         }
         }
         private void Button_Initialized (object sender, EventArgs e)
         private void Button_Initialized (object sender, EventArgs e)
         {
         {

+ 16 - 26
UICatalog/Scenarios/AllViewsTester.cs

@@ -149,7 +149,7 @@ public class AllViewsTester : Scenario
         var label = new Label { X = 0, Y = 0, Text = "X:" };
         var label = new Label { X = 0, Y = 0, Text = "X:" };
         _locationFrame.Add (label);
         _locationFrame.Add (label);
         _xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
         _xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _xRadioGroup.SelectedItemChanged += OnXRadioGroupOnSelectedItemChanged;
+        _xRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged;
         _xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
         _xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
 
 
         _xText.Accepting += (s, args) =>
         _xText.Accepting += (s, args) =>
@@ -183,7 +183,7 @@ public class AllViewsTester : Scenario
                          };
                          };
         _locationFrame.Add (_yText);
         _locationFrame.Add (_yText);
         _yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
         _yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _yRadioGroup.SelectedItemChanged += OnYRadioGroupOnSelectedItemChanged;
+        _yRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged;
         _locationFrame.Add (_yRadioGroup);
         _locationFrame.Add (_yRadioGroup);
 
 
         _sizeFrame = new ()
         _sizeFrame = new ()
@@ -200,7 +200,7 @@ public class AllViewsTester : Scenario
         label = new () { X = 0, Y = 0, Text = "Width:" };
         label = new () { X = 0, Y = 0, Text = "Width:" };
         _sizeFrame.Add (label);
         _sizeFrame.Add (label);
         _wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
         _wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _wRadioGroup.SelectedItemChanged += OnWRadioGroupOnSelectedItemChanged;
+        _wRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged;
         _wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
         _wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
 
 
         _wText.Accepting += (s, args) =>
         _wText.Accepting += (s, args) =>
@@ -260,7 +260,7 @@ public class AllViewsTester : Scenario
         _sizeFrame.Add (_hText);
         _sizeFrame.Add (_hText);
 
 
         _hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
         _hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _hRadioGroup.SelectedItemChanged += OnHRadioGroupOnSelectedItemChanged;
+        _hRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged;
         _sizeFrame.Add (_hRadioGroup);
         _sizeFrame.Add (_hRadioGroup);
 
 
         _settingsPane.Add (_sizeFrame);
         _settingsPane.Add (_sizeFrame);
@@ -333,13 +333,7 @@ public class AllViewsTester : Scenario
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }
 
 
-    private void OnHRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); }
-
-    private void OnWRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); }
-
-    private void OnYRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); }
-
-    private void OnXRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); }
+    private void OnRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); }
 
 
     // TODO: Add Command.HotKey handler (pop a message box?)
     // TODO: Add Command.HotKey handler (pop a message box?)
     private void CreateCurrentView (Type type)
     private void CreateCurrentView (Type type)
@@ -407,7 +401,7 @@ public class AllViewsTester : Scenario
 
 
     private void DimPosChanged (View view)
     private void DimPosChanged (View view)
     {
     {
-        if (view == null)
+        if (view == null || _updatingSettings)
         {
         {
             return;
             return;
         }
         }
@@ -504,8 +498,10 @@ public class AllViewsTester : Scenario
         UpdateHostTitle (_curView);
         UpdateHostTitle (_curView);
     }
     }
 
 
+    private bool _updatingSettings = false;
     private void UpdateSettings (View view)
     private void UpdateSettings (View view)
     {
     {
+        _updatingSettings = true;
         var x = view.X.ToString ();
         var x = view.X.ToString ();
         var y = view.Y.ToString ();
         var y = view.Y.ToString ();
 
 
@@ -528,27 +524,29 @@ public class AllViewsTester : Scenario
         _wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => w.Contains (s)));
         _wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => w.Contains (s)));
         _hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => h.Contains (s)));
         _hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => h.Contains (s)));
 
 
-        if (view.Width is DimAuto)
+        if (view.Width.Has<DimAuto> (out _))
         {
         {
             _wText.Text = "Auto";
             _wText.Text = "Auto";
             _wText.Enabled = false;
             _wText.Enabled = false;
         }
         }
         else
         else
         {
         {
-            _wText.Text = "100";
+            _wText.Text = $"{view.Frame.Width}";
             _wText.Enabled = true;
             _wText.Enabled = true;
         }
         }
 
 
-        if (view.Height is DimAuto)
+        if (view.Height.Has<DimAuto> (out _))
         {
         {
             _hText.Text = "Auto";
             _hText.Text = "Auto";
             _hText.Enabled = false;
             _hText.Enabled = false;
         }
         }
         else
         else
         {
         {
-            _hText.Text = "100";
+            _hText.Text = $"{view.Frame.Height}";
             _hText.Enabled = true;
             _hText.Enabled = true;
         }
         }
+
+        _updatingSettings = false;
     }
     }
 
 
     private void UpdateHostTitle (View view) { _hostPane.Title = $"_Demo of {view.GetType ().Name}"; }
     private void UpdateHostTitle (View view) { _hostPane.Title = $"_Demo of {view.GetType ().Name}"; }
@@ -560,25 +558,17 @@ public class AllViewsTester : Scenario
             return;
             return;
         }
         }
 
 
-        if (view.Width is not DimAuto && (view.Width is null || view.Frame.Width == 0))
+        if (!view.Width!.Has<DimAuto> (out _) || (view.Width is null || view.Frame.Width == 0))
         {
         {
             view.Width = Dim.Fill ();
             view.Width = Dim.Fill ();
         }
         }
 
 
-        if (view.Height is not DimAuto && (view.Height is null || view.Frame.Height == 0))
+        if (!view.Height!.Has<DimAuto> (out _) || (view.Height is null || view.Frame.Height == 0))
         {
         {
             view.Height = Dim.Fill ();
             view.Height = Dim.Fill ();
         }
         }
 
 
-        _xRadioGroup.SelectedItemChanged -= OnXRadioGroupOnSelectedItemChanged;
-        _yRadioGroup.SelectedItemChanged -= OnYRadioGroupOnSelectedItemChanged;
-        _hRadioGroup.SelectedItemChanged -= OnHRadioGroupOnSelectedItemChanged;
-        _wRadioGroup.SelectedItemChanged -= OnWRadioGroupOnSelectedItemChanged;
         UpdateSettings (view);
         UpdateSettings (view);
-        _xRadioGroup.SelectedItemChanged += OnXRadioGroupOnSelectedItemChanged;
-        _yRadioGroup.SelectedItemChanged += OnYRadioGroupOnSelectedItemChanged;
-        _hRadioGroup.SelectedItemChanged += OnHRadioGroupOnSelectedItemChanged;
-        _wRadioGroup.SelectedItemChanged += OnWRadioGroupOnSelectedItemChanged;
 
 
         UpdateHostTitle (view);
         UpdateHostTitle (view);
     }
     }