Browse Source

timeline behaves more responsively, performance increase

master
Victor Giers 2 years ago
parent
commit
5398c31943
2 changed files with 23 additions and 6 deletions
  1. 22
    5
      Interaction.pde
  2. 1
    1
      data/save.sav

+ 22
- 5
Interaction.pde View File

} }
} }
void mouseReleased() { void mouseReleased() {
timeline.clicked = false;
}
int currentYear;
void mouseDragged() {
if (timeline.clicked) { if (timeline.clicked) {
timeline.clicked = false;
timelinectrl(); timelinectrl();
} }
} }
int currentYear;
void timelinectrl() { void timelinectrl() {
if (interactiveTimeline && displayTimeline) { if (interactiveTimeline && displayTimeline) {
int toYear = (int)constrain(map(mouseX, timeline.x, timeline.x + timeline.l, 1966, 2012), 1966, 2012); int toYear = (int)constrain(map(mouseX, timeline.x, timeline.x + timeline.l, 1966, 2012), 1966, 2012);
if (toYear != currentYear) { if (toYear != currentYear) {
timeline.cursorPos = constrain(mouseX, timeline.x, timeline.x +timeline.l); timeline.cursorPos = constrain(mouseX, timeline.x, timeline.x +timeline.l);
boolean succ = false;
for (int i = 0; i < notebooks.size(); i ++) { for (int i = 0; i < notebooks.size(); i ++) {
if (notebooks.get(i).year == toYear) { if (notebooks.get(i).year == toYear) {
nextSlide(i, 0); nextSlide(i, 0);
succ = true;
break; break;
} }
} }
if (!succ) {
for (int i = 0; i < notebooks.size(); i ++) {
if (notebooks.get(i).year == toYear-1 || notebooks.get(i).year == toYear+1) {
nextSlide(i, 0);
succ = true;
break;
}
}
}
} }
} }
} }
stroke(255, 127); stroke(255, 127);
strokeWeight(4); strokeWeight(4);
line(x, y, l+x, y); line(x, y, l+x, y);
if (clicked) {
cursorPos = (int)constrain(mouseX, x, x+l);
}
ellipse(cursorPos, height-30, 20, 20); ellipse(cursorPos, height-30, 20, 20);
if (displayText) text(notebooks.get(currentNotebookNo).year, cursorPos, y-20);
if (displayText){
String labelText;
if(!clicked) labelText = str(notebooks.get(currentNotebookNo).year);
else labelText = str((int)constrain(map(mouseX, timeline.x, timeline.x + timeline.l, 1966, 2012), 1966, 2012));
text(labelText, cursorPos, y-20);
}
} }
} }

+ 1
- 1
data/save.sav View File

95
0
0 0

Loading…
Cancel
Save