Add midi logging toggle
[SugarCubes.git] / _UIFramework.pde
index aff72fe46a891d93df317c8478ab3976e6598d5d..2b3d0470b5c9420d44199392aeab00b9f3892e80 100644 (file)
@@ -314,15 +314,39 @@ public class UILabel extends UIObject {
   }
 }
 
+public class UICheckbox extends UIButton {
+  
+  private boolean firstDraw = true;
+  
+  public UICheckbox(float x, float y, float w, float h) {
+    super(x, y, w, h);
+    setMomentary(false);
+  }
+  
+  public void onDraw(PGraphics pg) {
+    pg.stroke(borderColor);
+    pg.fill(active ? activeColor : inactiveColor);
+    pg.rect(0, 0, h, h);
+    if (firstDraw) {
+      pg.fill(labelColor);
+      pg.textFont(defaultItemFont);
+      pg.textAlign(LEFT, CENTER);
+      pg.text(label, h + 4, h/2);
+      firstDraw = false;
+    }
+  }
+      
+}
+
 public class UIButton extends UIObject {
 
-  private boolean active = false;
-  private boolean isMomentary = false;
-  private color borderColor = #666666;
-  private color inactiveColor = #222222;
-  private color activeColor = #669966;
-  private color labelColor = #999999;
-  private String label = "";
+  protected boolean active = false;
+  protected boolean isMomentary = false;
+  protected color borderColor = #666666;
+  protected color inactiveColor = #222222;
+  protected color activeColor = #669966;
+  protected color labelColor = #999999;
+  protected String label = "";
    
   public UIButton(float x, float y, float w, float h) {
     super(x, y, w, h);
@@ -359,6 +383,10 @@ public class UIButton extends UIObject {
     }
   }
   
+  public boolean isActive() {
+    return active;
+  }
+  
   public UIButton setActive(boolean active) {
     this.active = active;
     onToggle(active);