浏览代码

Refactored and went back and forth. Things are working well. Tests not so much

Tig 9 月之前
父节点
当前提交
c7a254224b

+ 1 - 2
Terminal.Gui/Views/Scroll/Scroll.cs

@@ -405,8 +405,7 @@ public class Scroll : View, IOrientation, IDesignable
 
         Width = 1;
         Height = Dim.Fill ();
-        Size = 1000;
-        ContentPosition = 10;
+        Size = 250;
 
         return true;
     }

+ 0 - 1
Terminal.Gui/Views/Scroll/ScrollBar.cs

@@ -309,7 +309,6 @@ public class ScrollBar : View, IOrientation, IDesignable
         Width = 1;
         Height = Dim.Fill ();
         Size = 200;
-        ContentPosition = 10;
         //ShowPercent = true;
         return true;
     }

+ 18 - 6
Terminal.Gui/Views/Scroll/ScrollSlider.cs

@@ -210,11 +210,11 @@ public class ScrollSlider : View, IOrientation, IDesignable
 
         if (Orientation == Orientation.Vertical)
         {
-            return Math.Clamp (newPosittion, 0, ViewportDimension - Viewport.Height);
+            return Math.Clamp (newPosittion, 0, Math.Max (0, ViewportDimension - Viewport.Height));
         }
         else
         {
-            return Math.Clamp (newPosittion, 0, ViewportDimension - Viewport.Width);
+            return Math.Clamp (newPosittion, 0, Math.Max (0, ViewportDimension - Viewport.Width));
         }
     }
 
@@ -233,7 +233,7 @@ public class ScrollSlider : View, IOrientation, IDesignable
             return;
         }
 
-        int scrollAmount = newPosition -_position;
+        int scrollAmount = newPosition - _position;
         _position = newPosition;
 
         OnPositionChanged (_position);
@@ -361,9 +361,21 @@ public class ScrollSlider : View, IOrientation, IDesignable
     /// <inheritdoc />
     public bool EnableForDesign ()
     {
-        Orientation = Orientation.Vertical;
-        Width = 1;
-        Height = 10;
+        OrientationChanged += (sender, args) =>
+                              {
+                                  if (args.CurrentValue == Orientation.Vertical)
+                                  {
+                                      Width = Dim.Fill ();
+                                      Height = 5;
+                                  }
+                                  else
+                                  {
+                                      Width = 5;
+                                      Height = Dim.Fill();
+                                  }
+                              };
+
+        Orientation = Orientation.Horizontal;
         ShowPercent = true;
 
         return true;

+ 1 - 0
UICatalog/Scenarios/Editor.cs

@@ -262,6 +262,7 @@ public class Editor : Scenario
             AlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast
         };
 
+        _textView.VerticalScrollBar.AutoHide = false;
         _textView.UnwrappedCursorPosition += (s, e) =>
                                              {
                                                  siCursorPosition.Title = $"Ln {e.Point.Y + 1}, Col {e.Point.X + 1}";

+ 2 - 0
UICatalog/Scenarios/HexEditor.cs

@@ -44,6 +44,8 @@ public class HexEditor : Scenario
         _hexView.Arrangement = ViewArrangement.Resizable;
         _hexView.Edited += _hexView_Edited;
         _hexView.PositionChanged += _hexView_PositionChanged;
+        _hexView.VerticalScrollBar.AutoHide = false;
+
         app.Add (_hexView);
 
         var menu = new MenuBar

+ 2 - 0
UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -182,6 +182,8 @@ public class TreeViewFileSystem : Scenario
         _treeViewFiles = new TreeView<IFileSystemInfo> { X = 0, Y = 0, Width = Dim.Percent (50), Height = Dim.Fill () };
         _treeViewFiles.DrawLine += TreeViewFiles_DrawLine;
 
+        _treeViewFiles.VerticalScrollBar.AutoHide = false;
+
         _detailsFrame = new DetailsFrame (_iconProvider)
         {
             X = Pos.Right (_treeViewFiles), Y = 0, Width = Dim.Fill (), Height = Dim.Fill ()

+ 4 - 0
UICatalog/UICatalog.cs

@@ -799,6 +799,8 @@ public class UICatalogApp
             CategoryList.OpenSelectedItem += (s, a) => { ScenarioList!.SetFocus (); };
             CategoryList.SelectedItemChanged += CategoryView_SelectedChanged;
 
+            CategoryList.VerticalScrollBar.AutoHide = true;
+
             // Create the scenario list. The contents of the scenario list changes whenever the
             // Category list selection changes (to show just the scenarios that belong to the selected
             // category).
@@ -821,6 +823,8 @@ public class UICatalogApp
                 BorderStyle = CategoryList.BorderStyle,
                 SuperViewRendersLineCanvas = true
             };
+            //ScenarioList.VerticalScrollBar.AutoHide = false;
+            //ScenarioList.HorizontalScrollBar.AutoHide = false;
 
             // TableView provides many options for table headers. For simplicity we turn all 
             // of these off. By enabling FullRowSelect and turning off headers, TableView looks just