mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
Code cleanup.
This commit is contained in:
@@ -35,11 +35,10 @@ public class Scroll : View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal readonly ScrollBar? _host;
|
||||
internal bool _wasSliderLayoutComplete = true;
|
||||
|
||||
internal readonly ScrollSlider _slider;
|
||||
internal bool _wasSliderLayoutComplete = true;
|
||||
private Orientation _orientation;
|
||||
private int _position;
|
||||
private int _size;
|
||||
@@ -173,6 +172,7 @@ public class Scroll : View
|
||||
return _slider.OnMouseEvent (mouseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
// Flag as false until slider layout is completed
|
||||
_wasSliderLayoutComplete = false;
|
||||
|
||||
|
||||
@@ -145,14 +145,6 @@ internal class ScrollSlider : View
|
||||
return base.OnMouseLeave (mouseEvent);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override void OnLayoutComplete (LayoutEventArgs args)
|
||||
{
|
||||
base.OnLayoutComplete (args);
|
||||
|
||||
_host._wasSliderLayoutComplete = true;
|
||||
}
|
||||
|
||||
internal int GetPositionFromSliderLocation (int location)
|
||||
{
|
||||
if (_host.GetContentSize ().Height == 0 || _host.GetContentSize ().Width == 0)
|
||||
@@ -167,7 +159,7 @@ internal class ScrollSlider : View
|
||||
if ((_host.Orientation == Orientation.Vertical && location + Frame.Height >= scrollSize)
|
||||
|| (_host.Orientation == Orientation.Horizontal && location + Frame.Width >= scrollSize))
|
||||
{
|
||||
return _host.Size - scrollSize;
|
||||
return _host.Size - scrollSize;
|
||||
}
|
||||
|
||||
return (int)Math.Min (Math.Round ((double)(location * _host.Size + location) / scrollSize), _host.Size - scrollSize);
|
||||
@@ -210,6 +202,14 @@ internal class ScrollSlider : View
|
||||
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
|
||||
// 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.
|
||||
|
||||
@@ -67,6 +67,7 @@ public class ScrollSliderTests
|
||||
|
||||
host.Width = host.Orientation == Orientation.Vertical ? 1 : randomScrollLength;
|
||||
host.Height = host.Orientation == Orientation.Vertical ? randomScrollLength : 1;
|
||||
|
||||
// Slider may have changed content size
|
||||
host.LayoutSubviews ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user