protected final float knobIndent = .4;
protected final int knobSpacing = 6;
protected final int knobLabelHeight = 14;
+ protected final int scrollWidth = 14;
protected final color lightBlue = #666699;
protected final color lightGreen = #669966;
}
protected int drawObjectList(int yPos, String title, Object[] items, Method stateMethod) {
- return drawObjectList(yPos, title, items, classNameArray(items, null), stateMethod);
+ int sz = (items != null) ? items.length : 0;
+ return drawObjectList(yPos, title, items, stateMethod, sz, 0);
}
-
+
+ protected int drawObjectList(int yPos, String title, Object[] items, Method stateMethod, int scrollLength, int scrollPos) {
+ return drawObjectList(yPos, title, items, classNameArray(items, null), stateMethod, scrollLength, scrollPos);
+ }
+
protected int drawObjectList(int yPos, String title, Object[] items, String[] names, Method stateMethod) {
+ int sz = (items != null) ? items.length : 0;
+ return drawObjectList(yPos, title, items, names, stateMethod, sz, 0);
+ }
+
+ protected int drawObjectList(int yPos, String title, Object[] items, String[] names, Method stateMethod, int scrollLength, int scrollPos) {
noStroke();
fill(titleColor);
textFont(titleFont);
textFont(itemFont);
color textColor;
boolean even = true;
- for (int i = 0; i < items.length; ++i) {
+ int yTop = yPos+6;
+ for (int i = scrollPos; i < items.length && i < (scrollPos + scrollLength); ++i) {
Object o = items[i];
int state = STATE_DEFAULT;
try {
fill(even ? #666666 : #777777);
break;
}
- rect(leftPos, yPos+6, width, lineHeight);
+ rect(leftPos, yPos+6, w, lineHeight);
fill(textColor);
text(names[i], leftTextPos, yPos += lineHeight);
even = !even;
}
+ if ((scrollPos > 0) || (scrollLength < items.length)) {
+ int yHere = yPos+6;
+ noStroke();
+ fill(color(0, 0, 0, 50));
+ rect(leftPos + w - scrollWidth, yTop, scrollWidth, yHere - yTop);
+ fill(#666666);
+ rect(leftPos + w - scrollWidth + 2, yTop + (yHere-yTop) * (scrollPos / (float)items.length), scrollWidth - 4, (yHere - yTop) * (scrollLength / (float)items.length));
+
+ }
+
}
return yPos;
}
abstract public void mousePressed();
abstract public void mouseDragged();
abstract public void mouseReleased();
+ abstract public void mouseWheel(int delta);
}
/**
private int firstTransitionKnobY;
private int firstEffectY;
private int firstEffectKnobY;
+
+ private final int PATTERN_LIST_LENGTH = 8;
+ private int patternScrollPos = 0;
private int tempoY;
drawLogoAndBackground();
int yPos = 0;
firstPatternY = yPos + lineHeight + 6;
- yPos = drawObjectList(yPos, "PATTERN", patterns, patternNames, patternStateMethod);
+ yPos = drawObjectList(yPos, "PATTERN", patterns, patternNames, patternStateMethod, PATTERN_LIST_LENGTH, patternScrollPos);
yPos += controlSpacing;
firstPatternKnobY = yPos;
int xPos = leftTextPos;
private int patternKnobIndex = -1;
private int transitionKnobIndex = -1;
private int effectKnobIndex = -1;
+ private boolean patternScrolling = false;
private int lastY;
private int releaseEffect = -1;
lastY = mouseY;
patternKnobIndex = transitionKnobIndex = effectKnobIndex = -1;
releaseEffect = -1;
+ patternScrolling = false;
if (mouseY > tempoY) {
if (mouseY - tempoY < tempoHeight) {
lx.tempo.tap();
patternKnobIndex += glucose.NUM_PATTERN_KNOBS / 2;
}
} else if (mouseY > firstPatternY) {
- int patternIndex = objectClickIndex(firstPatternY);
- if (patternIndex < patterns.length) {
- lx.goIndex(patternIndex);
+ if ((patterns.length > PATTERN_LIST_LENGTH) && (mouseX > width - scrollWidth)) {
+ patternScrolling = true;
+ } else {
+ int patternIndex = objectClickIndex(firstPatternY);
+ if (patternIndex < patterns.length) {
+ lx.goIndex(patternIndex + patternScrollPos);
+ }
}
}
}
+ int scrolldy = 0;
public void mouseDragged() {
int dy = lastY - mouseY;
+ scrolldy += dy;
lastY = mouseY;
if (patternKnobIndex >= 0 && patternKnobIndex < glucose.NUM_PATTERN_KNOBS) {
LXParameter p = glucose.patternKnobs.get(patternKnobIndex);
} else if (transitionKnobIndex >= 0 && transitionKnobIndex < glucose.NUM_TRANSITION_KNOBS) {
LXParameter p = glucose.transitionKnobs.get(transitionKnobIndex);
p.setValue(constrain(p.getValuef() + dy*.01, 0, 1));
+ } else if (patternScrolling) {
+ int scroll = scrolldy / lineHeight;
+ scrolldy = scrolldy % lineHeight;
+ patternScrollPos = constrain(patternScrollPos - scroll, 0, patterns.length - PATTERN_LIST_LENGTH);
}
}
public void mouseReleased() {
+ patternScrolling = false;
tempoDown = false;
if (releaseEffect >= 0) {
effects[releaseEffect].trigger();
}
}
+ public void mouseWheel(int delta) {
+ if (mouseY > firstPatternY) {
+ int patternIndex = objectClickIndex(firstPatternY);
+ if (patternIndex < PATTERN_LIST_LENGTH) {
+ patternScrollPos = constrain(patternScrollPos + delta, 0, patterns.length - PATTERN_LIST_LENGTH);
+ }
+ }
+ }
+
}
/**
}
}
- public void mouseReleased() {
- }
+ public void mouseReleased() {}
+ public void mouseWheel(int delta) {}
public void mouseDragged() {
final int DRAG_THRESHOLD = 5;