From 1f42cce70281d4d70378a2be362f6cb2c6d5f45f Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Thu, 19 Sep 2013 13:05:18 -0700 Subject: [PATCH] Use a scrolllist for output --- _Internals.pde | 2 +- _PandaDriver.pde | 4 ++++ _UIFramework.pde | 5 ++++- _UIImplementation.pde | 36 +++++++++++++++++++++++++++--------- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/_Internals.pde b/_Internals.pde index 5c3f7cd..16a2eb6 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -116,7 +116,7 @@ void setup() { new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 344), new UIEffects(width-144, 352, 140, 144), new UITempo(width-144, 498, 140, 50), - new UIOutput(width-144, 552, 140, 122), + new UIOutput(width-144, 552, 140, 106), uiDebugText = new UIDebugText(4, height-64, width-8, 44), uiMapping = new UIMapping(mappingTool, 4, 4, 140, 344), diff --git a/_PandaDriver.pde b/_PandaDriver.pde index 2d28cd6..0aca6af 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -291,6 +291,10 @@ public static class PandaDriver { } } } + + public boolean isEnabled() { + return this.enabled; + } public void disable() { setEnabled(false); diff --git a/_UIFramework.pde b/_UIFramework.pde index 7ed2585..c2ac505 100644 --- a/_UIFramework.pde +++ b/_UIFramework.pde @@ -655,8 +655,11 @@ public class UIScrollList extends UIObject { itemColor = pendingColor; } else { labelColor = #000000; - itemColor = even ? #666666 : #777777; + itemColor = #707070; } + float factor = even ? .92 : 1.08; + itemColor = color(hue(itemColor), saturation(itemColor), min(100, factor*brightness(itemColor))); + pg.noStroke(); pg.fill(itemColor); pg.rect(0, yp, w, itemHeight); diff --git a/_UIImplementation.pde b/_UIImplementation.pde index cf81f64..03379ce 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -220,21 +220,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 select() { + panda.toggle(); + } + } } class UITempo extends UIWindow { -- 2.34.1