Browse Source

Ensures accurate calculation if is hosted by a ScrollBar before initialization.

BDisp 11 months ago
parent
commit
cb7bc94c74
1 changed files with 18 additions and 2 deletions
  1. 18 2
      Terminal.Gui/Views/Scroll/Scroll.cs

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

@@ -21,8 +21,18 @@ public class Scroll : View
         WantContinuousButtonPressed = true;
         WantContinuousButtonPressed = true;
         CanFocus = false;
         CanFocus = false;
         Orientation = Orientation.Vertical;
         Orientation = Orientation.Vertical;
-        Width = Dim.Auto (DimAutoStyle.Content, 1);
-        Height = Dim.Auto (DimAutoStyle.Content, 1);
+
+        if (_host is { })
+        {
+            Y = 1;
+            Width = Dim.Fill ();
+            Height = Dim.Fill (1);
+        }
+        else
+        {
+            Width = Dim.Auto (DimAutoStyle.Content, 1);
+            Height = Dim.Auto (DimAutoStyle.Content, 1);
+        }
     }
     }
 
 
 
 
@@ -68,6 +78,12 @@ public class Scroll : View
                 return;
                 return;
             }
             }
 
 
+            if (_host is { IsInitialized: false })
+            {
+                // Ensures a more exactly calculation
+                SetRelativeLayout (_host.Frame.Size);
+            }
+
             int barSize = Orientation == Orientation.Vertical ? GetContentSize ().Height : GetContentSize ().Width;
             int barSize = Orientation == Orientation.Vertical ? GetContentSize ().Height : GetContentSize ().Width;
 
 
             if (value + barSize > Size)
             if (value + barSize > Size)