void mousePressed() { interactive = true; startInteractionTime = millis(); if (timeline.hovering()) { timeline.clicked = true; timelinectrl(); } else { nextSlide(interactMode); } } void mouseReleased() { timeline.clicked = false; } int currentYear; void mouseDragged() { if (timeline.clicked) { timelinectrl(); } } void timelinectrl() { if (interactiveTimeline && displayTimeline) { int toYear = (int)constrain(map(mouseX, timeline.x, timeline.x + timeline.l, 1966, 2012), 1966, 2012); if (toYear != currentYear) { timeline.cursorPos = constrain(mouseX, timeline.x, timeline.x +timeline.l); for (int i = 0; i < notebooks.size(); i ++) { if (notebooks.get(i).year == toYear) { nextSlide(i, 0); break; } } } } } class Timeline { //currently timeline has to be from left to right to work int x, y, l, cursorPos; boolean clicked; Timeline(int x_, int y_, int l_) { x = x_; y = y_; l = l_; } boolean hovering() { if (mouseX > x - 20 && mouseX < x + l + 20 && mouseY > y - 20 && mouseY < y + 20) { return true; } else { return false; } } void update() { cursorPos = (int)map(notebooks.get(currentNotebookNo).year, 1966, 2012, 50, width-50); } void display() { stroke(255, 127); strokeWeight(4); line(x, y, l+x, y); ellipse(cursorPos, height-30, 20, 20); if (displayText) text(notebooks.get(currentNotebookNo).year, cursorPos, y-20); } }