The death of GLucose! Hear ye, hear ye.
[SugarCubes.git] / _UIImplementation.pde
index 1257f6fffd435068e0387f860174dedbbe2eeaf7..1e78beee9e035268f29b1baf3979031597c0804b 100644 (file)
@@ -15,14 +15,13 @@ class UIBlendMode extends UIWindow {
   public UIBlendMode(float x, float y, float w, float h) {
     super(lx.ui, "BLEND MODE", x, y, w, h);
     List<UIScrollList.Item> items = new ArrayList<UIScrollList.Item>();
-    int i = 0;
     for (LXTransition t : transitions) {
-      items.add(new TransitionScrollItem(t, i++));
+      items.add(new TransitionScrollItem(t));
     }
     final UIScrollList tList;
     (tList = new UIScrollList(1, UIWindow.TITLE_LABEL_HEIGHT, w-2, 60)).setItems(items).addToContainer(this);
 
-    lx.engine.getDeck(GLucose.RIGHT_DECK).addListener(new LXDeck.AbstractListener() {
+    lx.engine.getDeck(RIGHT_DECK).addListener(new LXDeck.AbstractListener() {
       public void faderTransitionDidChange(LXDeck deck, LXTransition transition) {
         tList.redraw();
       }
@@ -31,12 +30,10 @@ class UIBlendMode extends UIWindow {
 
   class TransitionScrollItem extends UIScrollList.AbstractItem {
     private final LXTransition transition;
-    private final int index;
     private final String label;
     
-    TransitionScrollItem(LXTransition transition, int index) {
+    TransitionScrollItem(LXTransition transition) {
       this.transition = transition;
-      this.index = index;
       this.label = className(transition, "Transition");
     }
     
@@ -45,7 +42,7 @@ class UIBlendMode extends UIWindow {
     }
     
     public boolean isSelected() {
-      return index == activeTransition.getValuei();
+      return this.transition == lx.engine.getDeck(RIGHT_DECK).getFaderTransition();
     }
     
     public boolean isPending() {
@@ -53,7 +50,7 @@ class UIBlendMode extends UIWindow {
     }
     
     public void onMousePressed() {
-      activeTransition.setValue(this.index);
+      lx.engine.getDeck(RIGHT_DECK).setFaderTransition(this.transition);
     }
   }
 
@@ -66,7 +63,7 @@ class UICrossfader extends UIWindow {
   public UICrossfader(float x, float y, float w, float h) {
     super(lx.ui, "CROSSFADER", x, y, w, h);
 
-    new UISlider(4, UIWindow.TITLE_LABEL_HEIGHT, w-9, 32).setParameter(lx.engine.getDeck(GLucose.RIGHT_DECK).getFader()).addToContainer(this);
+    new UISlider(4, UIWindow.TITLE_LABEL_HEIGHT, w-9, 32).setParameter(lx.engine.getDeck(RIGHT_DECK).getFader()).addToContainer(this);
     (displayMode = new UIToggleSet(4, UIWindow.TITLE_LABEL_HEIGHT + 36, w-9, 20)).setOptions(new String[] { "A", "COMP", "B" }).setValue("COMP").addToContainer(this);
   }
   
@@ -86,8 +83,9 @@ class UIEffects extends UIWindow {
 
     int yp = UIWindow.TITLE_LABEL_HEIGHT;
     List<UIScrollList.Item> items = new ArrayList<UIScrollList.Item>();
-    for (LXEffect fx : glucose.lx.getEffects()) {
-      items.add(new FXScrollItem(fx));
+    int i = 0;
+    for (LXEffect fx : effectsArr) {
+      items.add(new FXScrollItem(fx, i++));
     }    
     final UIScrollList effectsList = new UIScrollList(1, yp, w-2, 60).setItems(items);
     effectsList.addToContainer(this);
@@ -99,10 +97,10 @@ class UIEffects extends UIWindow {
       parameterKnobs[ki].addToContainer(this);
     }
     
-    GLucose.EffectListener fxListener = new GLucose.EffectListener() {
-      public void effectSelected(LXEffect effect) {
+    LXParameterListener fxListener = new LXParameterListener() {
+      public void onParameterChanged(LXParameter parameter) {
         int i = 0;
-        for (LXParameter p : effect.getParameters()) {
+        for (LXParameter p : getSelectedEffect().getParameters()) {
           if (i >= parameterKnobs.length) {
             break;
           }
@@ -116,19 +114,21 @@ class UIEffects extends UIWindow {
       }
     };
     
-    glucose.addEffectListener(fxListener);
-    fxListener.effectSelected(glucose.getSelectedEffect());
+    selectedEffect.addListener(fxListener);
+    fxListener.onParameterChanged(null);
 
   }
   
   class FXScrollItem extends UIScrollList.AbstractItem {
     
-    private LXEffect effect;
-    private String label;
+    private final LXEffect effect;
+    private final int index;
+    private final String label;
     
-    FXScrollItem(LXEffect effect) {
+    FXScrollItem(LXEffect effect, int index) {
       this.effect = effect;
-      label = className(effect, "Effect");
+      this.index = index;
+      this.label = className(effect, "Effect");
     }
     
     public String getLabel() {
@@ -136,7 +136,7 @@ class UIEffects extends UIWindow {
     }
     
     public boolean isSelected() {
-      return !effect.isEnabled() && (glucose.getSelectedEffect() == effect);
+      return !effect.isEnabled() && (effect == getSelectedEffect());
     }
     
     public boolean isPending() {
@@ -144,14 +144,14 @@ class UIEffects extends UIWindow {
     }
     
     public void onMousePressed() {
-      if (glucose.getSelectedEffect() == effect) {
+      if (effect == getSelectedEffect()) {
         if (effect.isMomentary()) {
           effect.enable();
         } else {
           effect.toggle();
         }
       } else {
-        glucose.setSelectedEffect(effect);
+        selectedEffect.setValue(index);
       }
     }
     
@@ -471,7 +471,7 @@ class UIMidi extends UIWindow {
   }
   
   public LXDeck getFocusedDeck() {
-    return lx.engine.getDeck(deckMode.getValue() == "A" ? GLucose.LEFT_DECK : GLucose.RIGHT_DECK);
+    return lx.engine.getDeck(deckMode.getValue() == "A" ? LEFT_DECK : RIGHT_DECK);
   }
 }