Files
zoomable-movie-player/functions.pde
Victor Giers c9075daf5e Initial commit
2017-02-12 01:40:53 +01:00

69 lines
1.3 KiB
Plaintext

int mouseClickX, mouseClickY;
void mousePressed() {
if (mouseButton == CENTER) {
playPause();
}
if (mouseButton == LEFT) {
if (timeline.hover()) {
timeline.clicked();
}
mouseClickX = mouseX;
mouseClickY = mouseY;
}
if (mouseButton == RIGHT){
viewport.renderer.save("screenshots/" + month() + day() + hour() + minute() + second() + millis() + ".png");
}
}
void mouseDragged() {
if (timeline.clicked) {
timeline.jump();
} else {
translateX += (mouseX - mouseClickX);
translateY += (mouseY - mouseClickY);
mouseClickX = mouseX;
mouseClickY = mouseY;
}
}
void mouseReleased() {
timeline.clicked = false;
}
void mouseWheel(MouseEvent e) {
float mwheel = -e.getAmount();
scaleFactor += mwheel / 10;
translateX -= mwheel * mouseX / 10;
translateY -= mwheel * mouseY / 10;
}
boolean b_pause;
void playPause() {
b_pause =! b_pause;
if (b_pause) mov.pause();
else mov.play();
}
void movieEvent(Movie m) {
m.read();
}
void dropEvent(DropEvent theDropEvent) {
if (theDropEvent.isFile()) {
loadMovie(theDropEvent.file().getAbsolutePath());
}
}
void loadMovie(String _path) {
String path = _path;
if (playing)
mov.stop();
mov = new Movie(this, path);
mov.loop();
playing = true;
frame.setTitle(path);
viewport.reload();
}