widgets: add keyboard
This commit is contained in:
parent
32988a1f3b
commit
73473c6b98
4 changed files with 117 additions and 2 deletions
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
- bug fixes
|
||||
- error popups raised by the main process can be closed
|
||||
- sliders don't send same value over network when the value change is below the widget's precision
|
||||
- sliders don't send same value over network when the value change is below the widget's precision
|
||||
- widgets
|
||||
- **new** (piano) keyboard widget
|
||||
|
||||
## 0.11.6
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ var widgets = {
|
|||
multitoggle: require('./widgets/matrices/multitoggle'),
|
||||
multipush: require('./widgets/matrices/multipush'),
|
||||
multifader: require('./widgets/matrices/multifader'),
|
||||
keyboard: require('./widgets/matrices/keyboard'),
|
||||
|
||||
// plots
|
||||
led: require('./widgets/plots/led'),
|
||||
|
|
@ -35,7 +36,7 @@ module.exports.categories = {
|
|||
'Sliders':['fader','knob'],
|
||||
'Buttons':['toggle','push','switch'],
|
||||
'Pads':['xy','rgb','multixy'],
|
||||
'Matrices':['multifader','multitoggle','multipush'],
|
||||
'Matrices':['multifader','multitoggle','multipush', 'keyboard'],
|
||||
'Plots':['plot','eq','visualizer','led','meter','text'],
|
||||
'Containers':['panel','strip']
|
||||
}
|
||||
|
|
|
|||
92
src/browser/js/app/widgets/matrices/keyboard.js
Normal file
92
src/browser/js/app/widgets/matrices/keyboard.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
var _matrices_base = require('./_matrices_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'keyboard',
|
||||
id:'auto',
|
||||
|
||||
separator0: 'Matrix',
|
||||
|
||||
keys: 12,
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
traversing:true,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
value:'',
|
||||
norelease:false,
|
||||
precision:2,
|
||||
address:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
|
||||
var Keyboard = module.exports.Keyboard = function(widgetData) {
|
||||
|
||||
_matrices_base.apply(this,arguments)
|
||||
|
||||
|
||||
var strData = JSON.stringify(widgetData),
|
||||
pattern = 'wbwbwwbwbwbw',
|
||||
wCount = 0
|
||||
|
||||
for (var i=0;i<widgetData.keys;i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'push'
|
||||
data.id = widgetData.id + '/' + i
|
||||
data.label = false
|
||||
data.address = widgetData.address + '/' + i
|
||||
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
if (pattern[i % 12] == 'w') {
|
||||
element.addClass('white')
|
||||
wCount++
|
||||
} else {
|
||||
element.addClass('black').data('wCount',wCount)
|
||||
|
||||
}
|
||||
|
||||
this.value[i] = widgetData.off
|
||||
|
||||
}
|
||||
|
||||
this.widget.find('.widget.white').css('width',`${100/wCount}%`)
|
||||
this.widget.find('.widget.black').css('width',`${100/wCount * 6/10}%`)
|
||||
this.widget.find('.widget.black').each(function(){
|
||||
$(this).css('left',`${100/wCount * ($(this).data('wCount') - 3/10)}%`)
|
||||
|
||||
})
|
||||
|
||||
if (widgetData.traversing) this.widget.enableTraversingGestures()
|
||||
|
||||
|
||||
}
|
||||
|
||||
Keyboard.prototype = Object.create(_matrices_base.prototype)
|
||||
|
||||
Keyboard.prototype.constructor = Keyboard
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var keyboard = new Keyboard(widgetData)
|
||||
return keyboard.widget
|
||||
}
|
||||
|
|
@ -67,3 +67,23 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.keyboard-container {
|
||||
.matrix {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
.white {
|
||||
--color-raised:ivory;
|
||||
}
|
||||
.black {
|
||||
// --color-raised:ebony;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top:0;
|
||||
height: 65%;
|
||||
}
|
||||
.light.active {
|
||||
opacity: .25;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue