X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=_UIImplementation.pde;h=0ea8073ddb57d6701a6a0a1b55df6fc88c89bbe8;hb=2815b69095f53b912200c75cc7a91caf34bd837c;hp=cf81f64fdeb599dbb4322823bacb06c851570420;hpb=fe30b2268bba1105dee4d48eeb9191103fc0e3fb;p=SugarCubes.git diff --git a/_UIImplementation.pde b/_UIImplementation.pde index cf81f64..0ea8073 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -13,9 +13,9 @@ class UIPatternDeck extends UIWindow { - Engine.Deck deck; + LXDeck deck; - public UIPatternDeck(Engine.Deck deck, String label, float x, float y, float w, float h) { + public UIPatternDeck(LXDeck deck, String label, float x, float y, float w, float h) { super(label, x, y, w, h); this.deck = deck; int yp = titleHeight; @@ -24,7 +24,7 @@ class UIPatternDeck extends UIWindow { for (LXPattern p : deck.getPatterns()) { items.add(new PatternScrollItem(p)); } - final UIScrollList patternList = new UIScrollList(1, yp, w-2, 160).setItems(items); + final UIScrollList patternList = new UIScrollList(1, yp, w-2, 140).setItems(items); patternList.addToContainer(this); yp += patternList.h + 10; @@ -34,11 +34,11 @@ class UIPatternDeck extends UIWindow { parameterKnobs[ki].addToContainer(this); } - Engine.Listener lxListener = new Engine.Listener() { - public void patternWillChange(Engine.Deck deck, LXPattern pattern, LXPattern nextPattern) { + LXDeck.Listener lxListener = new LXDeck.AbstractListener() { + public void patternWillChange(LXDeck deck, LXPattern pattern, LXPattern nextPattern) { patternList.redraw(); } - public void patternDidChange(Engine.Deck deck, LXPattern pattern) { + public void patternDidChange(LXDeck deck, LXPattern pattern) { patternList.redraw(); int pi = 0; for (LXParameter parameter : pattern.getParameters()) { @@ -80,54 +80,75 @@ class UIPatternDeck extends UIWindow { return deck.getNextPattern() == pattern; } - public void select() { + public void onMousePressed() { deck.goPattern(pattern); } } } -class UICrossfader extends UIWindow { - - public UICrossfader(float x, float y, float w, float h) { - super("CROSSFADER", x, y, w, h); - +class UIBlendMode extends UIWindow { + public UIBlendMode(float x, float y, float w, float h) { + super("BLEND MODE", x, y, w, h); List items = new ArrayList(); - for (LXTransition t : transitions) { + for (LXTransition t : glucose.getTransitions()) { items.add(new TransitionScrollItem(t)); - } - new UIScrollList(1, titleHeight, w-2, 120).setItems(items).addToContainer(this); - new UIParameterSlider(4, titleHeight + 126, w-10, 24).setParameter(lx.engine.getDeck(1).getCrossfader()).addToContainer(this); - new UIToggleSet(4, 182, w-10, 20) { - protected void onToggle(String value) { - displayMode = value; + } + final UIScrollList tList; + (tList = new UIScrollList(1, titleHeight, w-2, 60)).setItems(items).addToContainer(this); + + lx.engine.getDeck(GLucose.RIGHT_DECK).addListener(new LXDeck.AbstractListener() { + public void faderTransitionDidChange(LXDeck deck, LXTransition transition) { + tList.redraw(); } - }.setOptions(new String[] { "A", "COMP", "B" }).setValue(displayMode = "COMP").addToContainer(this); + }); } -} -class TransitionScrollItem extends AbstractScrollItem { - private final LXTransition transition; - private String label; - - TransitionScrollItem(LXTransition transition) { - this.transition = transition; - label = className(transition, "Transition"); + class TransitionScrollItem extends AbstractScrollItem { + private final LXTransition transition; + private String label; + + TransitionScrollItem(LXTransition transition) { + this.transition = transition; + label = className(transition, "Transition"); + } + + public String getLabel() { + return label; + } + + public boolean isSelected() { + return transition == glucose.getSelectedTransition(); + } + + public boolean isPending() { + return false; + } + + public void onMousePressed() { + glucose.setSelectedTransition(transition); + } } + +} + +class UICrossfader extends UIWindow { - public String getLabel() { - return label; - } + private final UIToggleSet displayMode; - public boolean isSelected() { - return transition == lx.engine.getDeck(1).getBlendTransition(); + public UICrossfader(float x, float y, float w, float h) { + super("CROSSFADER", x, y, w, h); + + new UIParameterSlider(4, titleHeight, w-9, 32).setParameter(lx.engine.getDeck(GLucose.RIGHT_DECK).getFader()).addToContainer(this); + (displayMode = new UIToggleSet(4, titleHeight + 36, w-9, 20)).setOptions(new String[] { "A", "COMP", "B" }).setValue("COMP").addToContainer(this); } - public boolean isPending() { - return false; + public UICrossfader setDisplayMode(String value) { + displayMode.setValue(value); + return this; } - public void select() { - lx.engine.getDeck(1).setBlendTransition(transition); + public String getDisplayMode() { + return displayMode.getValue(); } } @@ -192,10 +213,6 @@ class UIEffects extends UIWindow { return effect.isEnabled(); } - public void select() { - glucose.setSelectedEffect(effect); - } - public void onMousePressed() { if (glucose.getSelectedEffect() == effect) { if (effect.isMomentary()) { @@ -203,6 +220,8 @@ class UIEffects extends UIWindow { } else { effect.toggle(); } + } else { + glucose.setSelectedEffect(effect); } } @@ -220,21 +239,39 @@ class UIOutput extends UIWindow { public UIOutput(float x, float y, float w, float h) { super("OUTPUT", x, y, w, h); float yp = titleHeight; + + final UIScrollList outputs = new UIScrollList(1, titleHeight, w-2, 80); + + List items = new ArrayList(); for (final PandaDriver panda : pandaBoards) { - final UIButton button = new UIButton(4, yp, w-10, 20) { - protected void onToggle(boolean active) { - panda.setEnabled(active); - } - }.setLabel(panda.ip); - button.addToContainer(this); + items.add(new PandaScrollItem(panda)); panda.setListener(new PandaDriver.Listener() { public void onToggle(boolean active) { - button.setActive(active); + outputs.redraw(); } }); - yp += 24; } - } + outputs.setItems(items).addToContainer(this); + } + + class PandaScrollItem extends AbstractScrollItem { + final PandaDriver panda; + PandaScrollItem(PandaDriver panda) { + this.panda = panda; + } + + public String getLabel() { + return panda.ip; + } + + public boolean isSelected() { + return panda.isEnabled(); + } + + public void onMousePressed() { + panda.toggle(); + } + } } class UITempo extends UIWindow { @@ -311,9 +348,8 @@ class UIMapping extends UIWindow { }).setRange(1, glucose.model.cubes.size()).addToContainer(this); yp += 24; - new UILabel(4, yp+8, w-10, 20).setLabel("COLORS").addToContainer(this); - yp += 24; - + yp += 10; + new UIScrollList(1, yp, w-2, 60).setItems(Arrays.asList(new ScrollItem[] { new ColorScrollItem(ColorScrollItem.COLOR_RED), new ColorScrollItem(ColorScrollItem.COLOR_GREEN), @@ -386,7 +422,7 @@ class UIMapping extends UIWindow { return false; } - public void select() { + public void onMousePressed() { switch (colorChannel) { case COLOR_RED: mappingTool.channelModeRed = !mappingTool.channelModeRed; break; case COLOR_GREEN: mappingTool.channelModeGreen = !mappingTool.channelModeGreen; break; @@ -426,6 +462,7 @@ class UIDebugText extends UIContext { pg.fill(#444444); pg.rect(0, 0, w, h); pg.textFont(defaultItemFont); + pg.textSize(10); pg.textAlign(LEFT, TOP); pg.fill(#cccccc); pg.text(line1, 4, 4); @@ -434,6 +471,70 @@ class UIDebugText extends UIContext { } } +class UISpeed extends UIWindow { + + final BasicParameter speed; + + UISpeed(float x, float y, float w, float h) { + super("SPEED", x, y, w, h); + speed = new BasicParameter("SPEED", 0.5); + new UIParameterSlider(4, titleHeight, w-10, 20) + .setParameter(speed.addListener(new LXParameterListener() { + public void onParameterChanged(LXParameter parameter) { + lx.setSpeed(parameter.getValuef() * 2); + } + })).addToContainer(this); + } +} + +class UIMidi extends UIWindow { + + private final UIToggleSet deckMode; + private final UIButton logMode; + + UIMidi(final MidiEngine midiEngine, float x, float y, float w, float h) { + super("MIDI", x, y, w, h); + + // Processing compiler doesn't seem to get that list of class objects also conform to interface + List scrollItems = new ArrayList(); + for (SCMidiInput mc : midiEngine.getControllers()) { + scrollItems.add(mc); + } + final UIScrollList scrollList; + (scrollList = new UIScrollList(1, titleHeight, w-2, 100)).setItems(scrollItems).addToContainer(this); + (deckMode = new UIToggleSet(4, 130, 90, 20) { + protected void onToggle(String value) { + midiEngine.setFocusedDeck(value == "A" ? 0 : 1); + } + }).setOptions(new String[] { "A", "B" }).addToContainer(this); + (logMode = new UIButton(98, 130, w-103, 20)).setLabel("LOG").addToContainer(this); + + SCMidiInputListener listener = new SCMidiInputListener() { + public void onEnabled(SCMidiInput controller, boolean enabled) { + scrollList.redraw(); + } + }; + for (SCMidiInput mc : midiEngine.getControllers()) { + mc.addListener(listener); + } + + midiEngine.addListener(new MidiEngineListener() { + public void onFocusedDeck(int deckIndex) { + deckMode.setValue(deckIndex == 0 ? "A" : "B"); + } + }); + + } + + public boolean logMidi() { + return logMode.isActive(); + } + + public LXDeck getFocusedDeck() { + return lx.engine.getDeck(deckMode.getValue() == "A" ? GLucose.LEFT_DECK : GLucose.RIGHT_DECK); + } +} + String className(Object p, String suffix) { String s = p.getClass().getName(); int li;