Browse Source

Fixed bugs

Tig 9 months ago
parent
commit
6f9816bbb8

+ 4 - 5
Terminal.Gui/Views/Scroll/Scroll.cs

@@ -143,7 +143,8 @@ public class Scroll : View, IOrientation, IDesignable
         }
         }
 
 
         int framePos = Orientation == Orientation.Vertical ? args.CurrentValue.Y : args.CurrentValue.X;
         int framePos = Orientation == Orientation.Vertical ? args.CurrentValue.Y : args.CurrentValue.X;
-        SliderPosition = framePos;
+
+        RaiseSliderPositionChangeEvents (CalculateSliderPosition (_contentPosition), framePos);
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -152,13 +153,11 @@ public class Scroll : View, IOrientation, IDesignable
     public int SliderPosition
     public int SliderPosition
     {
     {
         get => CalculateSliderPosition (_contentPosition);
         get => CalculateSliderPosition (_contentPosition);
-        set => RaiseSliderPositionChangeEvents (value);
+        set => RaiseSliderPositionChangeEvents (_slider.Position, value);
     }
     }
 
 
-    private void RaiseSliderPositionChangeEvents (int newSliderPosition)
+    private void RaiseSliderPositionChangeEvents (int currentSliderPosition, int newSliderPosition)
     {
     {
-        int currentSliderPosition = CalculateSliderPosition (_contentPosition);
-
         if (/*newSliderPosition > Size - ViewportDimension ||*/ currentSliderPosition == newSliderPosition)
         if (/*newSliderPosition > Size - ViewportDimension ||*/ currentSliderPosition == newSliderPosition)
         {
         {
             return;
             return;

+ 12 - 4
Terminal.Gui/Views/Scroll/ScrollBar.cs

@@ -154,11 +154,11 @@ public class ScrollBar : View, IOrientation, IDesignable
 
 
         if (Orientation == Orientation.Vertical)
         if (Orientation == Orientation.Vertical)
         {
         {
-            Visible = Frame.Height - (_decreaseButton.Frame.Height + _increaseButton.Frame.Height) < Size;
+            Visible = Frame.Height < Size;
         }
         }
         else
         else
         {
         {
-            Visible = Frame.Width - (_decreaseButton.Frame.Width + _increaseButton.Frame.Width) < Size;
+            Visible = Frame.Width < Size;
         }
         }
     }
     }
 
 
@@ -208,8 +208,16 @@ public class ScrollBar : View, IOrientation, IDesignable
     /// </summary>
     /// </summary>
     public int Size
     public int Size
     {
     {
-        get => _scroll.Size;
-        set => _scroll.Size = value;
+        get
+        {
+            // Add two for increment/decrement buttons
+            return _scroll.Size + 2;
+        }
+        set
+        {
+            // Remove two for increment/decrement buttons
+            _scroll.Size = value - 2;
+        }
     }
     }
 
 
     /// <summary>
     /// <summary>

+ 2 - 2
UICatalog/Scenarios/CharacterMap.cs

@@ -346,7 +346,7 @@ internal class CharMap : View, IDesignable
 
 
         //ViewportSettings = ViewportSettings.AllowLocationGreaterThanContentSize;
         //ViewportSettings = ViewportSettings.AllowLocationGreaterThanContentSize;
 
 
-        SetContentSize (new (COLUMN_WIDTH * 16 + RowLabelWidth, _maxCodePoint / 16 * _rowHeight)); // +1 for Header
+        SetContentSize (new (COLUMN_WIDTH * 16 + RowLabelWidth, _maxCodePoint / 16 * _rowHeight + 1)); // +1 for Header
 
 
         AddCommand (
         AddCommand (
                     Command.Up,
                     Command.Up,
@@ -483,7 +483,7 @@ internal class CharMap : View, IDesignable
                                                   {
                                                   {
                                                       Viewport = Viewport with
                                                       Viewport = Viewport with
                                                       {
                                                       {
-                                                          Y = Math.Min (args.CurrentValue, GetContentSize ().Height - (Viewport.Height - 2))
+                                                          Y = Math.Min (args.CurrentValue, GetContentSize ().Height - (Viewport.Height - 1))
                                                       };
                                                       };
                                                   }
                                                   }
                                               };
                                               };