From a4f24af5a8b2ebd43d2e8fb3dd43300e9280dc32 Mon Sep 17 00:00:00 2001 From: Matt Moening Date: Mon, 16 Nov 2015 12:27:31 -0800 Subject: [PATCH] Implemented scrolling in the terminal widget --- .../TerminalWindow/TextScrollWidget.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/PrinterControls/TerminalWindow/TextScrollWidget.cs b/PrinterControls/TerminalWindow/TextScrollWidget.cs index 824095d2b..7fba1113b 100644 --- a/PrinterControls/TerminalWindow/TextScrollWidget.cs +++ b/PrinterControls/TerminalWindow/TextScrollWidget.cs @@ -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; + } + + } } \ No newline at end of file