Implemented scrolling in the terminal widget

This commit is contained in:
Matt Moening 2015-11-16 12:27:31 -08:00
parent 4bd28d9155
commit a4f24af5a8

View file

@ -227,5 +227,34 @@ namespace MatterHackers.MatterControl
base.OnDraw(graphics2D);
}
}
public override void OnMouseWheel(MouseEventArgs mouseEvent)
{
base.OnMouseWheel(mouseEvent);
double scrollDelta = (mouseEvent.WheelDelta / ((visibleLines.Count) * 60.0));
if (scrollDelta < 0)//Rounding seems to favor scrolling up, compinsating scroll down to feel as smooth
{
scrollDelta *= 2;
}
else if (Position0To1 == 0)//IF we scroll up at the bottum get pop out from the "on screen" chunck
{
scrollDelta = (NumVisibleLines/(double)visibleLines.Count);
}
double newPos = Position0To1 + scrollDelta;
if(newPos > 1)
{
newPos = 1;
}
else if(newPos < 0)
{
newPos = 0;
}
Position0To1 = newPos;
}
}
}