processing: preserve scroll position while zooming

This commit makes the Processing program preserve the scroll
position relative to timestamp, when the user is zooming in/out
the graph. Effectively, the left edge of the visible window
always represents the same timestamp, so that the user doesn't
have to search for the interesting region again after zooming.
This commit is contained in:
Junxiao Shi
2018-12-25 11:51:08 -05:00
parent 276435ec11
commit 7470cee5f3

View File

@@ -312,8 +312,10 @@ void mouseWheel(MouseEvent event) {
if (mouseY>buttonY && mouseY <buttonY+buttonH && if (mouseY>buttonY && mouseY <buttonY+buttonH &&
mouseX>button4X && mouseX <button4X+smallButtonW) { mouseX>button4X && mouseX <button4X+smallButtonW) {
//it is over the reducer button //it is over the reducer button
xShift *= reducer;
reducer-= wheel/10; reducer-= wheel/10;
reducer = constrain(reducer, 0.1, 9.9); reducer = constrain(reducer, 0.1, 9.9);
xShift /= reducer; // preserve scroll position
getData(); getData();
} else { //move the graph } else { //move the graph
xShift-=wheel*50; xShift-=wheel*50;