From a8da4f0dba6f63c1661c25647801e1174720a80e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 29 Apr 2022 17:55:22 -0500 Subject: [PATCH] GUI: implement sample scroll with mouse wheel --- src/gui/sampleEdit.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 7882e53c..38a737bd 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -1276,7 +1276,26 @@ void FurnaceGUI::drawSampleEdit() { sampleZoom=100.0/zoomPercent; if (sampleZoom<0.01) sampleZoom=0.01; sampleZoomAuto=false; + int bounds=((int)sample->samples-round(rectSize.x*sampleZoom)); + if (bounds<0) bounds=0; + if (samplePos>bounds) samplePos=bounds; updateSampleTex=true; + } else { + if (wheelY!=0) { + if (!sampleZoomAuto) { + double scrollAmount=MAX(fabs((double)wheelY*sampleZoom*60.0),1.0); + if (wheelY>0) { + samplePos+=scrollAmount; + } else { + samplePos-=scrollAmount; + } + if (samplePos<0) samplePos=0; + int bounds=((int)sample->samples-round(rectSize.x*sampleZoom)); + if (bounds<0) bounds=0; + if (samplePos>bounds) samplePos=bounds; + updateSampleTex=true; + } + } } int posX=-1;