From: Mark Slee Date: Thu, 19 Sep 2013 20:59:41 +0000 (-0700) Subject: Some cleanups and listen to deck for transition changes X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a898d79bac007404bed34365f31ffbc6480c901c;p=SugarCubes.git Some cleanups and listen to deck for transition changes --- diff --git a/_Internals.pde b/_Internals.pde index 16a2eb6..5839359 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -40,22 +40,24 @@ final float TRAILER_DEPTH = 97; final float TRAILER_HEIGHT = 33; int targetFramerate = 60; - int startMillis, lastMillis; + +// Core engine variables GLucose glucose; HeronLX lx; -MappingTool mappingTool; LXPattern[] patterns; -LXTransition[] transitions; -LXEffect[] effects; +MappingTool mappingTool; PandaDriver[] pandaBoards; + +// Display configuration mode boolean mappingMode = false; boolean debugMode = false; DebugUI debugUI; -String displayMode; +// Handles to UI objects UIContext[] overlays; UIPatternDeck uiPatternA; +UICrossfader uiCrossfader; UIMapping uiMapping; UIDebugText uiDebugText; @@ -88,13 +90,12 @@ void setup() { // Set the patterns Engine engine = lx.engine; - glucose.setTransitions(transitions = transitions(glucose)); - logTime("Built transitions"); engine.setPatterns(patterns = _patterns(glucose)); engine.addDeck(_patterns(glucose)); - engine.getDeck(1).setBlendTransition(transitions[0]); logTime("Built patterns"); - glucose.lx.addEffects(effects = effects(glucose)); + glucose.setTransitions(transitions(glucose)); + logTime("Built transitions"); + glucose.lx.addEffects(effects(glucose)); logTime("Built effects"); // Build output driver @@ -111,7 +112,7 @@ void setup() { debugUI = new DebugUI(pandaMappings); overlays = new UIContext[] { uiPatternA = new UIPatternDeck(lx.engine.getDeck(0), "PATTERN A", 4, 4, 140, 344), - new UICrossfader(4, 352, 140, 212), + uiCrossfader = new UICrossfader(4, 352, 140, 212), new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 344), new UIEffects(width-144, 352, 140, 144), @@ -177,7 +178,9 @@ void logTime(String evt) { void draw() { // Draws the simulation and the 2D UI overlay background(40); - color[] colors = glucose.getColors();; + color[] colors = glucose.getColors(); + + String displayMode = uiCrossfader.getDisplayMode(); if (displayMode == "A") { colors = lx.engine.getDeck(0).getColors(); } else if (displayMode == "B") { @@ -414,7 +417,10 @@ void keyPressed() { lx.setPatterns(new LXPattern[] { mappingTool }); } else { lx.setPatterns(patterns); + LXTransition pop = restoreToPattern.getTransition(); + restoreToPattern.setTransition(null); lx.goPattern(restoreToPattern); + restoreToPattern.setTransition(pop); } break; case 'p': diff --git a/_UIImplementation.pde b/_UIImplementation.pde index c2d073c..d25df48 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -34,7 +34,7 @@ class UIPatternDeck extends UIWindow { parameterKnobs[ki].addToContainer(this); } - Engine.Listener lxListener = new Engine.Listener() { + Engine.Listener lxListener = new Engine.AbstractListener() { public void patternWillChange(Engine.Deck deck, LXPattern pattern, LXPattern nextPattern) { patternList.redraw(); } @@ -87,21 +87,30 @@ class UIPatternDeck extends UIWindow { } class UICrossfader extends UIWindow { - + + private final UIToggleSet displayMode; + public UICrossfader(float x, float y, float w, float h) { super("CROSSFADER", 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); + } + final UIScrollList tList; + (tList = 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; + (displayMode = new UIToggleSet(4, 182, w-10, 20)).setOptions(new String[] { "A", "COMP", "B" }).setValue("COMP").addToContainer(this); + + lx.engine.getDeck(1).addListener(new Engine.AbstractListener() { + public void blendTransitionDidChange(Engine.Deck deck, LXTransition transition) { + tList.redraw(); } - }.setOptions(new String[] { "A", "COMP", "B" }).setValue(displayMode = "COMP").addToContainer(this); + }); + } + + public String getDisplayMode() { + return displayMode.getValue(); } } @@ -119,7 +128,7 @@ class TransitionScrollItem extends AbstractScrollItem { } public boolean isSelected() { - return transition == lx.engine.getDeck(1).getBlendTransition(); + return transition == glucose.getSelectedTransition(); } public boolean isPending() { @@ -127,7 +136,7 @@ class TransitionScrollItem extends AbstractScrollItem { } public void onMousePressed() { - lx.engine.getDeck(1).setBlendTransition(transition); + glucose.setSelectedTransition(transition); } } diff --git a/code/GLucose.jar b/code/GLucose.jar index 6d09722..86ea3c4 100755 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ diff --git a/code/HeronLX.jar b/code/HeronLX.jar index 70a8826..a163fc9 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ