-
-class UIPatternDeck extends UIWindow {
-
- LXDeck deck;
-
- public UIPatternDeck(LXDeck deck, String label, float x, float y, float w, float h) {
- super(label, x, y, w, h);
- this.deck = deck;
- int yp = titleHeight;
-
- List<ScrollItem> items = new ArrayList<ScrollItem>();
- for (LXPattern p : deck.getPatterns()) {
- items.add(new PatternScrollItem(p));
- }
- final UIScrollList patternList = new UIScrollList(1, yp, w-2, 140).setItems(items);
- patternList.addToContainer(this);
- yp += patternList.h + 10;
-
- final UIParameterKnob[] parameterKnobs = new UIParameterKnob[12];
- for (int ki = 0; ki < parameterKnobs.length; ++ki) {
- parameterKnobs[ki] = new UIParameterKnob(5 + 34*(ki % 4), yp + (ki/4) * 48);
- parameterKnobs[ki].addToContainer(this);
- }
-
- LXDeck.Listener lxListener = new LXDeck.AbstractListener() {
- public void patternWillChange(LXDeck deck, LXPattern pattern, LXPattern nextPattern) {
- patternList.redraw();
- }
- public void patternDidChange(LXDeck deck, LXPattern pattern) {
- patternList.redraw();
- int pi = 0;
- for (LXParameter parameter : pattern.getParameters()) {
- if (pi >= parameterKnobs.length) {
- break;
- }
- parameterKnobs[pi++].setParameter(parameter);
- }
- while (pi < parameterKnobs.length) {
- parameterKnobs[pi++].setParameter(null);
- }
- }
- };
-
- deck.addListener(lxListener);
- lxListener.patternDidChange(deck, deck.getActivePattern());
-
- }
-
- class PatternScrollItem extends AbstractScrollItem {
-
- private LXPattern pattern;
- private String label;
-
- PatternScrollItem(LXPattern pattern) {
- this.pattern = pattern;
- label = className(pattern, "Pattern");
- }
-
- public String getLabel() {
- return label;
- }
-
- public boolean isSelected() {
- return deck.getActivePattern() == pattern;
- }
-
- public boolean isPending() {
- return deck.getNextPattern() == pattern;
- }
-
- public void onMousePressed() {
- deck.goPattern(pattern);
- }
- }
-}