Implemented scrolling in the terminal widget
This commit is contained in:
parent
4bd28d9155
commit
a4f24af5a8
1 changed files with 30 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue