-
Notifications
You must be signed in to change notification settings - Fork 4
/
PatternLengthView.js
65 lines (56 loc) · 1.49 KB
/
PatternLengthView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* @param {Clip} cursorClip
*/
function PatternLengthView(cursorClip) {
var patternLength = 0;
var active = false;
var color = 0;
var exitCallBack = null;
this.canEnter = function() {
return true;
};
this.enter = function() {
active = true;
applicationControl.getApplication().focusPanelBelow();
applicationControl.getApplication().zoomToFit();
update();
};
this.exit = function() {
active = false;
if(exitCallBack) {
exitCallBack();
}
};
this.setColor = function(col) {
color = col;
update();
};
this.setExitCallback = function(callback) {
exitCallBack = callback;
};
function update() {
if(!active) {
return;
}
for(var i=0;i<64;i++){
if(patternLength > 0 && i < patternLength) {
controls.buttonMatrix.sendValue(i, color, true, false);
} else {
controls.buttonMatrix.sendValue(i, 0, true, false);
}
}
}
cursorClip.getLoopLength().addRawValueObserver(function(len) {
patternLength = len/4;
update();
});
this.handleEvent = function(row, col, value) {
if (value === 0) {
return;
}
var len = row*8 + col;
cursorClip.getLoopLength().setRaw((len+1)*4);
applicationControl.getApplication().focusPanelBelow();
applicationControl.getApplication().zoomToFit();
};
}