X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=_Overlay.pde;h=793d313170c577eda7f577babff4cd84e57b434c;hb=cc9fcf4be00a99376a2083ddfbcf589f94ee6785;hp=e21c9cdff0f5f4bd222ace65c4d2b770e7680edd;hpb=3f8be6146c76a48a2e23288555958a26a7c8d643;p=SugarCubes.git diff --git a/_Overlay.pde b/_Overlay.pde index e21c9cd..793d313 100644 --- a/_Overlay.pde +++ b/_Overlay.pde @@ -1,4 +1,13 @@ /** + * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND + * + * //\\ //\\ //\\ //\\ + * ///\\\ ///\\\ ///\\\ ///\\\ + * \\\/// \\\/// \\\/// \\\/// + * \\// \\// \\// \\// + * + * EXPERTS ONLY!! EXPERTS ONLY!! + * * Overlay UI that indicates pattern control, etc. This will be moved * into the Processing library once it is stabilized and need not be * regularly modified. @@ -40,15 +49,6 @@ class OverlayUI { private Method patternStateMethod; private Method transitionStateMethod; private Method effectStateMethod; - - private final int NUM_TRANSITION_KNOBS = 4; - private final int NUM_EFFECT_KNOBS = 4; - - private int activeTransitionIndex = 0; - private int activeEffectIndex = 0; - - private final VirtualTransitionKnob[] transitionKnobs; - private final VirtualEffectKnob[] effectKnobs; OverlayUI() { leftPos = width - w; @@ -59,16 +59,6 @@ class OverlayUI { transitionNames = classNameArray(transitions, "Transition"); effectNames = classNameArray(effects, "Effect"); - transitionKnobs = new VirtualTransitionKnob[NUM_TRANSITION_KNOBS]; - for (int i = 0; i < transitionKnobs.length; ++i) { - transitionKnobs[i] = new VirtualTransitionKnob(i); - } - - effectKnobs = new VirtualEffectKnob[NUM_EFFECT_KNOBS]; - for (int i = 0; i < effectKnobs.length; ++i) { - effectKnobs[i] = new VirtualEffectKnob(i); - } - try { patternStateMethod = getClass().getMethod("getState", LXPattern.class); effectStateMethod = getClass().getMethod("getState", LXEffect.class); @@ -99,8 +89,8 @@ class OverlayUI { firstPatternKnobY = yPos; int xPos = leftTextPos; for (int i = 0; i < glucose.NUM_PATTERN_KNOBS/2; ++i) { - drawKnob(xPos, yPos, knobSize, glucose.patternKnobs[i]); - drawKnob(xPos, yPos + knobSize + knobSpacing + knobLabelHeight, knobSize, glucose.patternKnobs[glucose.NUM_PATTERN_KNOBS/2 + i]); + drawKnob(xPos, yPos, knobSize, glucose.patternKnobs.get(i)); + drawKnob(xPos, yPos + knobSize + knobSpacing + knobLabelHeight, knobSize, glucose.patternKnobs.get(glucose.NUM_PATTERN_KNOBS/2 + i)); xPos += knobSize + knobSpacing; } yPos += 2*(knobSize + knobLabelHeight) + knobSpacing; @@ -111,8 +101,8 @@ class OverlayUI { yPos += controlSpacing; firstTransitionKnobY = yPos; xPos = leftTextPos; - for (int i = 0; i < transitionKnobs.length; ++i) { - drawKnob(xPos, yPos, knobSize, transitionKnobs[i]); + for (VirtualTransitionKnob knob : glucose.transitionKnobs) { + drawKnob(xPos, yPos, knobSize, knob); xPos += knobSize + knobSpacing; } yPos += knobSize + knobLabelHeight; @@ -123,8 +113,8 @@ class OverlayUI { yPos += controlSpacing; firstEffectKnobY = yPos; xPos = leftTextPos; - for (int i = 0; i < effectKnobs.length; ++i) { - drawKnob(xPos, yPos, knobSize, effectKnobs[i]); + for (VirtualEffectKnob knob : glucose.effectKnobs) { + drawKnob(xPos, yPos, knobSize, knob); xPos += knobSize + knobSpacing; } yPos += knobSize + knobLabelHeight; @@ -144,7 +134,7 @@ class OverlayUI { fill(#999999); textFont(itemFont); textAlign(LEFT); - text("Tap 'u' to hide UI (~+3FPS)", leftTextPos, height-6); + text("Tap 'u' to hide UI", leftTextPos, height-6); } public LXParameter getOrNull(List items, int index) { @@ -177,7 +167,7 @@ class OverlayUI { public int getState(LXEffect e) { if (e.isEnabled()) { return STATE_PENDING; - } else if (effects[activeEffectIndex] == e) { + } else if (e == glucose.getSelectedEffect()) { return STATE_ACTIVE; } return STATE_DEFAULT; @@ -186,7 +176,7 @@ class OverlayUI { public int getState(LXTransition t) { if (t == lx.getTransition()) { return STATE_PENDING; - } else if (t == transitions[activeTransitionIndex]) { + } else if (t == glucose.getSelectedTransition()) { return STATE_ACTIVE; } return STATE_DEFAULT; @@ -250,6 +240,7 @@ class OverlayUI { } ellipseMode(CENTER); + noStroke(); fill(#222222); // For some reason this arc call really crushes drawing performance. Presumably // because openGL is drawing it and when we overlap the second set of arcs it @@ -261,18 +252,17 @@ class OverlayUI { fill(lightGreen); arc(xPos + knobSize/2, yPos + knobSize/2, knobSize, knobSize, HALF_PI + knobIndent, endArc); - // Center circle of knob - fill(#333333); - ellipse(xPos + knobSize/2, yPos + knobSize/2, knobSize/2, knobSize/2); - // Mask notch out of knob fill(color(0, 0, 30)); beginShape(); - vertex(xPos + knobSize/2 - 3, yPos + knobSize - 8); - vertex(xPos + knobSize/2 - 5, yPos + knobSize); - vertex(xPos + knobSize/2 + 5, yPos + knobSize); - vertex(xPos + knobSize/2 + 3, yPos + knobSize - 8); + vertex(xPos + knobSize/2, yPos + knobSize/2.); + vertex(xPos + knobSize/2 - 6, yPos + knobSize); + vertex(xPos + knobSize/2 + 6, yPos + knobSize); endShape(); + + // Center circle of knob + fill(#333333); + ellipse(xPos + knobSize/2, yPos + knobSize/2, knobSize/2, knobSize/2); fill(0); rect(xPos, yPos + knobSize + 2, knobSize, knobLabelHeight - 2); @@ -308,38 +298,6 @@ class OverlayUI { } return s; } - - class VirtualTransitionKnob extends LXVirtualParameter { - private final int index; - - VirtualTransitionKnob(int index) { - this.index = index; - } - - public LXParameter getRealParameter() { - List parameters = transitions[activeTransitionIndex].getParameters(); - if (index < parameters.size()) { - return parameters.get(index); - } - return null; - } - } - - class VirtualEffectKnob extends LXVirtualParameter { - private final int index; - - VirtualEffectKnob(int index) { - this.index = index; - } - - public LXParameter getRealParameter() { - List parameters = effects[activeEffectIndex].getParameters(); - if (index < parameters.size()) { - return parameters.get(index); - } - return null; - } - } private int patternKnobIndex = -1; private int transitionKnobIndex = -1; @@ -363,18 +321,18 @@ class OverlayUI { } else if (mouseY > firstEffectY) { int effectIndex = (mouseY - firstEffectY) / lineHeight; if (effectIndex < effects.length) { - if (activeEffectIndex == effectIndex) { + if (effects[effectIndex] == glucose.getSelectedEffect()) { effects[effectIndex].enable(); releaseEffect = effectIndex; } - activeEffectIndex = effectIndex; + glucose.setSelectedEffect(effectIndex); } } else if ((mouseY >= firstTransitionKnobY) && (mouseY < firstTransitionKnobY + knobSize + knobLabelHeight)) { transitionKnobIndex = (mouseX - leftTextPos) / (knobSize + knobSpacing); } else if (mouseY > firstTransitionY) { int transitionIndex = (mouseY - firstTransitionY) / lineHeight; if (transitionIndex < transitions.length) { - activeTransitionIndex = transitionIndex; + glucose.setSelectedTransition(transitionIndex); } } else if ((mouseY >= firstPatternKnobY) && (mouseY < firstPatternKnobY + 2*(knobSize+knobLabelHeight) + knobSpacing)) { patternKnobIndex = (mouseX - leftTextPos) / (knobSize + knobSpacing); @@ -384,7 +342,6 @@ class OverlayUI { } else if (mouseY > firstPatternY) { int patternIndex = (mouseY - firstPatternY) / lineHeight; if (patternIndex < patterns.length) { - patterns[patternIndex].setTransition(transitions[activeTransitionIndex]); lx.goIndex(patternIndex); } } @@ -394,13 +351,13 @@ class OverlayUI { int dy = lastY - mouseY; lastY = mouseY; if (patternKnobIndex >= 0 && patternKnobIndex < glucose.NUM_PATTERN_KNOBS) { - LXParameter p = glucose.patternKnobs[patternKnobIndex]; + LXParameter p = glucose.patternKnobs.get(patternKnobIndex); p.setValue(constrain(p.getValuef() + dy*.01, 0, 1)); - } else if (effectKnobIndex >= 0 && effectKnobIndex < NUM_EFFECT_KNOBS) { - LXParameter p = effectKnobs[effectKnobIndex]; + } else if (effectKnobIndex >= 0 && effectKnobIndex < glucose.NUM_EFFECT_KNOBS) { + LXParameter p = glucose.effectKnobs.get(effectKnobIndex); p.setValue(constrain(p.getValuef() + dy*.01, 0, 1)); - } else if (transitionKnobIndex >= 0 && transitionKnobIndex < NUM_TRANSITION_KNOBS) { - LXParameter p = transitionKnobs[transitionKnobIndex]; + } else if (transitionKnobIndex >= 0 && transitionKnobIndex < glucose.NUM_TRANSITION_KNOBS) { + LXParameter p = glucose.transitionKnobs.get(transitionKnobIndex); p.setValue(constrain(p.getValuef() + dy*.01, 0, 1)); } }