Explorar el Código

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

BDisp hace 11 meses
padre
commit
cb7bc94c74
Se han modificado 1 ficheros con 18 adiciones y 2 borrados
  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;
         CanFocus = false;
         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;
             }
 
+            if (_host is { IsInitialized: false })
+            {
+                // Ensures a more exactly calculation
+                SetRelativeLayout (_host.Frame.Size);
+            }
+
             int barSize = Orientation == Orientation.Vertical ? GetContentSize ().Height : GetContentSize ().Width;
 
             if (value + barSize > Size)