Browse Source

Remove _wasSliderLayoutComplete field.

BDisp 11 months ago
parent
commit
71d558fd94
2 changed files with 0 additions and 33 deletions
  1. 0 19
      Terminal.Gui/Views/Scroll/Scroll.cs
  2. 0 14
      Terminal.Gui/Views/Scroll/ScrollSlider.cs

+ 0 - 19
Terminal.Gui/Views/Scroll/Scroll.cs

@@ -38,7 +38,6 @@ public class Scroll : View
     internal readonly ScrollBar? _host;
     internal readonly ScrollBar? _host;
 
 
     internal readonly ScrollSlider _slider;
     internal readonly ScrollSlider _slider;
-    internal bool _wasSliderLayoutComplete = true;
     private Orientation _orientation;
     private Orientation _orientation;
     private int _position;
     private int _position;
     private int _size;
     private int _size;
@@ -134,12 +133,6 @@ public class Scroll : View
     /// <inheritdoc/>
     /// <inheritdoc/>
     protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
     protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
-        if (!_wasSliderLayoutComplete)
-        {
-            // Do not process if slider layout wasn't yet completed
-            return base.OnMouseEvent (mouseEvent);
-        }
-
         int location = Orientation == Orientation.Vertical ? mouseEvent.Position.Y : mouseEvent.Position.X;
         int location = Orientation == Orientation.Vertical ? mouseEvent.Position.Y : mouseEvent.Position.X;
         int barSize = Orientation == Orientation.Vertical ? GetContentSize ().Height : GetContentSize ().Width;
         int barSize = Orientation == Orientation.Vertical ? GetContentSize ().Height : GetContentSize ().Width;
 
 
@@ -173,21 +166,9 @@ public class Scroll : View
             }
             }
         }
         }
 
 
-        // Flag as false until slider layout is completed
-        _wasSliderLayoutComplete = false;
-
         return base.OnMouseEvent (mouseEvent);
         return base.OnMouseEvent (mouseEvent);
     }
     }
 
 
-    /// <inheritdoc/>
-    protected internal override bool OnMouseLeave (MouseEvent mouseEvent)
-    {
-        // If scroll isn't handling mouse then reset the flag
-        _wasSliderLayoutComplete = true;
-
-        return base.OnMouseLeave (mouseEvent);
-    }
-
     // TODO: Move this into "ScrollSlider" and override it there. Scroll can then subscribe to _slider.LayoutComplete and call AdjustSlider.
     // TODO: Move this into "ScrollSlider" and override it there. Scroll can then subscribe to _slider.LayoutComplete and call AdjustSlider.
     // QUESTION: I've been meaning to add a "View.FrameChanged" event (fired from LayoutComplete only if Frame has changed). Should we do that as part of this PR?
     // QUESTION: I've been meaning to add a "View.FrameChanged" event (fired from LayoutComplete only if Frame has changed). Should we do that as part of this PR?
     // QUESTION: Note I *did* add "View.ViewportChanged" in a previous PR.
     // QUESTION: Note I *did* add "View.ViewportChanged" in a previous PR.

+ 0 - 14
Terminal.Gui/Views/Scroll/ScrollSlider.cs

@@ -71,12 +71,6 @@ internal class ScrollSlider : View
     /// <inheritdoc/>
     /// <inheritdoc/>
     protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
     protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
-        if (!_host._wasSliderLayoutComplete)
-        {
-            // Ensure not blocking scroll mouse event
-            _host._wasSliderLayoutComplete = true;
-        }
-
         int location = _host.Orientation == Orientation.Vertical ? mouseEvent.Position.Y : mouseEvent.Position.X;
         int location = _host.Orientation == Orientation.Vertical ? mouseEvent.Position.Y : mouseEvent.Position.X;
         int offset = _lastLocation > -1 ? location - _lastLocation : 0;
         int offset = _lastLocation > -1 ? location - _lastLocation : 0;
         int barSize = _host.Orientation == Orientation.Vertical ? _host.GetContentSize ().Height : _host.GetContentSize ().Width;
         int barSize = _host.Orientation == Orientation.Vertical ? _host.GetContentSize ().Height : _host.GetContentSize ().Width;
@@ -202,14 +196,6 @@ internal class ScrollSlider : View
         return new (location, dimension);
         return new (location, dimension);
     }
     }
 
 
-    /// <inheritdoc/>
-    internal override void OnLayoutComplete (LayoutEventArgs args)
-    {
-        base.OnLayoutComplete (args);
-
-        _host._wasSliderLayoutComplete = true;
-    }
-
     // TODO: I think you should create a new `internal` view named "ScrollSlider" with an `Orientation` property. It should inherit from View and override GetNormalColor and the mouse events
     // TODO: I think you should create a new `internal` view named "ScrollSlider" with an `Orientation` property. It should inherit from View and override GetNormalColor and the mouse events
     // that can be moved within it's Superview, constrained to move only horizontally or vertically depending on Orientation.
     // that can be moved within it's Superview, constrained to move only horizontally or vertically depending on Orientation.
     // This will really simplify a lot of this.
     // This will really simplify a lot of this.