Remove select() from UIScrollList, just mouse events
[SugarCubes.git] / _UIImplementation.pde
index cf81f64fdeb599dbb4322823bacb06c851570420..c2d073cb24d0a4d71e55817a5480504950bae0b3 100644 (file)
@@ -80,7 +80,7 @@ class UIPatternDeck extends UIWindow {
       return deck.getNextPattern() == pattern;
     }
     
-    public void select() {
+    public void onMousePressed() {
       deck.goPattern(pattern);
     }
   }
@@ -126,7 +126,7 @@ class TransitionScrollItem extends AbstractScrollItem {
     return false;
   }
   
-  public void select() {
+  public void onMousePressed() {
     lx.engine.getDeck(1).setBlendTransition(transition);
   }
 }
@@ -192,10 +192,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 +199,8 @@ class UIEffects extends UIWindow {
         } else {
           effect.toggle();
         }
+      } else {
+        glucose.setSelectedEffect(effect);
       }
     }
     
@@ -220,21 +218,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<ScrollItem> items = new ArrayList<ScrollItem>();
     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 {