mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 01:38:01 +01:00
Tweaked scroll logic
This commit is contained in:
@@ -109,6 +109,13 @@ public class ScrollBar : View, IOrientation, IDesignable
|
||||
|
||||
_slider.Size = CalculateSliderSize ();
|
||||
_sliderPosition = CalculateSliderPositionFromContentPosition (_position);
|
||||
|
||||
// This keeps the position constant while slider is moving
|
||||
if (_sliderPosition.Value != _slider.Position)
|
||||
{
|
||||
//Position = CalculatePositionFromSliderPosition (_sliderPosition.Value);
|
||||
}
|
||||
|
||||
_slider.Position = _sliderPosition.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public class ScrollSlider : View, IOrientation, IDesignable
|
||||
}
|
||||
_visibleContentSize = int.Max (1, value);
|
||||
|
||||
if (_position > _visibleContentSize - _size)
|
||||
if (_position >= _visibleContentSize - _size)
|
||||
{
|
||||
Position = _position;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class EventLog : ListView
|
||||
public EventLog ()
|
||||
{
|
||||
Title = "Event Log";
|
||||
CanFocus = false;
|
||||
CanFocus = true;
|
||||
|
||||
X = Pos.AnchorEnd ();
|
||||
Y = 0;
|
||||
@@ -38,6 +38,20 @@ public class EventLog : ListView
|
||||
};
|
||||
|
||||
Initialized += EventLog_Initialized;
|
||||
|
||||
HorizontalScrollBar.AutoHide = true;
|
||||
VerticalScrollBar.AutoHide = true;
|
||||
|
||||
AddCommand (Command.DeleteAll,
|
||||
() =>
|
||||
{
|
||||
_eventSource.Clear ();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
KeyBindings.Add (Key.Delete, Command.DeleteAll);
|
||||
|
||||
}
|
||||
public ExpanderButton? ExpandButton { get; }
|
||||
|
||||
@@ -94,10 +108,8 @@ public class EventLog : ListView
|
||||
|
||||
private void EventLog_Initialized (object? _, EventArgs e)
|
||||
{
|
||||
|
||||
Border?.Add (ExpandButton!);
|
||||
Source = new ListWrapper<string> (_eventSource);
|
||||
|
||||
}
|
||||
private string GetIdentifyingString (View? view)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ScrollBarDemo : Scenario
|
||||
X = Pos.AnchorEnd () - 5,
|
||||
AutoHide = false,
|
||||
ScrollableContentSize = 100,
|
||||
//ShowPercent = true
|
||||
Height = Dim.Fill()
|
||||
};
|
||||
demoFrame.Add (scrollBar);
|
||||
|
||||
@@ -394,7 +394,7 @@ public class ScrollBarDemo : Scenario
|
||||
|
||||
controlledList.ViewportChanged += (s, e) =>
|
||||
{
|
||||
eventLog.Log ($"ViewportChanged: {e.NewViewport.Y}");
|
||||
eventLog.Log ($"ViewportChanged: {e.NewViewport}");
|
||||
scrollBar.Position = e.NewViewport.Y;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user