- logarithmic scaling (log10) support added to knob, fader & xy
- mousewheel support added to knob and fader (ctrlKey for fine control)
This commit is contained in:
parent
05f8a1c567
commit
a924134882
7 changed files with 80 additions and 60 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## next
|
||||
|
||||
- logarithmic scaling (log10) support added to knob, fader & xy
|
||||
- mousewheel support added to knob and fader (shiftKey for fine control)
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- electron updated to 0.36.11
|
||||
|
|
|
|||
|
|
@ -38,33 +38,6 @@ var scrolls = function(){
|
|||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('.tab').on('mousewheel.scroll',function(e) {
|
||||
if (!e.ctrlKey) {
|
||||
if ($(this).height()>$(this).get(0).scrollHeight) {
|
||||
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
|
||||
$(this).scrollLeft($(this).scrollLeft()+scroll)
|
||||
e.preventDefault()
|
||||
} else if (e.pageY>window.innerHeight-scrollbarHeight) {
|
||||
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY)
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$('.panel').on('mousewheel.scroll',function(e) {
|
||||
if (!e.ctrlKey) {
|
||||
|
||||
var h = $(this).parent().innerHeight()-scrollbarHeight-$(this).parents('.tab').length*5
|
||||
if ($(this).get(0).scrollHeight+scrollbarHeight == $(this).parent().height()) {
|
||||
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
|
||||
$(this).scrollLeft($(this).scrollLeft()+scroll)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ module.exports.options = {
|
|||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
target:[]
|
||||
|
|
@ -60,8 +61,6 @@ module.exports.create = function(widgetData,container) {
|
|||
wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
|
||||
|
||||
|
||||
widgetData.range = widgetData.range || {'min':0,'max':1}
|
||||
|
||||
var range = {}
|
||||
for (k in widgetData.range) {
|
||||
if (k=='min') {
|
||||
|
|
@ -73,20 +72,18 @@ module.exports.create = function(widgetData,container) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!widgetData.noPip) {
|
||||
var scale = []
|
||||
for (var i=0;i<=100;i++) {scale.push(i)}
|
||||
for (i in scale) {
|
||||
var pip = $('<div class="pip"></div>')
|
||||
if (range[i]!=undefined) {
|
||||
var piptext = Math.abs(range[i])>=1000?range[i]/1000+'k':range[i]
|
||||
pip.addClass('val').append('<span>'+piptext+'</span>')
|
||||
}
|
||||
pips.append(pip)
|
||||
}
|
||||
if (dimension=='height') {
|
||||
pips.append(pips.find('.pip').get().reverse())
|
||||
var scale = []
|
||||
for (var i=0;i<=100;i++) {scale.push(i)}
|
||||
for (i in scale) {
|
||||
var pip = $('<div class="pip"></div>')
|
||||
if (range[i]!=undefined) {
|
||||
var piptext = Math.abs(range[i])>=1000?range[i]/1000+'k':range[i]
|
||||
pip.addClass('val').append('<span>'+piptext+'</span>')
|
||||
}
|
||||
pips.append(pip)
|
||||
}
|
||||
if (dimension=='height') {
|
||||
pips.append(pips.find('.pip').get().reverse())
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -95,11 +92,29 @@ module.exports.create = function(widgetData,container) {
|
|||
rangeVals = Object.keys(range).map(function (key) {return parseFloat(range[key])})
|
||||
|
||||
|
||||
|
||||
fader.resize(function(){
|
||||
fader.size= dimension=='height'?fader.outerHeight():fader.outerWidth()
|
||||
wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
|
||||
})
|
||||
|
||||
wrapper.on('mousewheel',function(e){
|
||||
if (e.originalEvent.wheelDeltaX) return
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
var divider = e.ctrlKey?4:.25
|
||||
handle.size = clip(handle.size+e.originalEvent.wheelDelta/(fader.size*divider),[0,100])
|
||||
|
||||
widget.updateUi(handle.size)
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync')
|
||||
})
|
||||
|
||||
var off = 0
|
||||
wrapper.on('draginit',function(e,data){
|
||||
|
|
@ -155,7 +170,7 @@ module.exports.create = function(widgetData,container) {
|
|||
var h = clip(handle.size,[0,100])
|
||||
for (var i=0;i<rangeKeys.length-1;i++) {
|
||||
if (h <= rangeKeys[i+1] && h >= rangeKeys[i]) {
|
||||
return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]],widgetData.precision)
|
||||
return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]],widgetData.precision,widgetData.logScale)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +180,7 @@ module.exports.create = function(widgetData,container) {
|
|||
v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
|
||||
for (var i=0;i<rangeVals.length-1;i++) {
|
||||
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
|
||||
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],widgetData.precision)
|
||||
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],widgetData.precision,widgetData.logScale,true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ module.exports.options = {
|
|||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
target:[]
|
||||
|
|
@ -51,13 +52,12 @@ module.exports.create = function(widgetData,container) {
|
|||
knob = widget.find('.knob'),
|
||||
handle = widget.find('.handle'),
|
||||
input = widget.find('.input').fakeInput(),
|
||||
range = widgetData.range || {min:0,max:1},
|
||||
range = widgetData.range,
|
||||
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
|
||||
absolute = widgetData.absolute,
|
||||
pan = widgetData.pan
|
||||
|
||||
|
||||
|
||||
var pipmin = Math.abs(range.min)>=1000?range.min/1000+'k':range.min,
|
||||
pipmax = Math.abs(range.max)>=1000?range.max/1000+'k':range.max
|
||||
|
||||
|
|
@ -73,6 +73,24 @@ module.exports.create = function(widgetData,container) {
|
|||
mask[0].setAttribute('style',`height:${w}px;width:${w}px;padding-bottom:0`)
|
||||
})
|
||||
|
||||
wrapper.on('mousewheel',function(e){
|
||||
if (e.originalEvent.wheelDeltaX) return
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
var divider = e.ctrlKey?48:8
|
||||
knob.rotation = clip(knob.rotation+e.originalEvent.wheelDeltaY/divider,[0,270])
|
||||
|
||||
widget.updateUi(knob.rotation)
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync')
|
||||
})
|
||||
|
||||
|
||||
knob.rotation = 0
|
||||
|
||||
|
|
@ -152,7 +170,7 @@ module.exports.create = function(widgetData,container) {
|
|||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
return mapToScale(knob.rotation,[0,270],[range.min,range.max],widgetData.precision)
|
||||
return mapToScale(knob.rotation,[0,270],[range.min,range.max],widgetData.precision,widgetData.logScale)
|
||||
}
|
||||
widget.showValue = function(v) {
|
||||
input.val(v+unit)
|
||||
|
|
@ -166,7 +184,7 @@ module.exports.create = function(widgetData,container) {
|
|||
})
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
var r = mapToScale(v,[range.min,range.max],[0,270],widgetData.precision)
|
||||
var r = mapToScale(v,[range.min,range.max],[0,270],widgetData.precision,widgetData.logScale,true)
|
||||
knob.rotation = r
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,13 @@ module.exports.options = {
|
|||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'green',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
path:'auto'
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
|
@ -27,12 +28,12 @@ module.exports.create = function(widgetData,container) {
|
|||
</div>
|
||||
`),
|
||||
led = widget.find('span'),
|
||||
range = widgetData.range || {min:0,max:1}
|
||||
range = widgetData.range
|
||||
|
||||
if (widgetData.color) led.css('background-color',widgetData.color)
|
||||
if (widgetData.color!='auto') led.css('background-color',widgetData.color)
|
||||
|
||||
widget.setValue = function(v){
|
||||
led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision))
|
||||
led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision,widgetData.logScale))
|
||||
}
|
||||
widget.getValue = function(){return}
|
||||
return widget
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ module.exports = {
|
|||
sendOsc: function(data){
|
||||
IPC.send('sendOsc', data)
|
||||
},
|
||||
|
||||
|
||||
clip: function(value,range) {
|
||||
var value = parseFloat(value)
|
||||
|
||||
|
|
@ -13,17 +13,23 @@ module.exports = {
|
|||
},
|
||||
|
||||
// map a value from a scale to another input and output must be range arrays
|
||||
mapToScale: function(value,rangeIn,rangeOut,precision) {
|
||||
mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
|
||||
|
||||
var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]]),
|
||||
roundFactor = precision!=undefined?Math.pow(10,precision):100
|
||||
roundFactor = precision!=undefined?Math.pow(10,precision):100,
|
||||
|
||||
value = ((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
|
||||
value = log?
|
||||
revertlog?
|
||||
(Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
|
||||
value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
|
||||
|
||||
value = Math.round(value*roundFactor)/roundFactor
|
||||
|
||||
|
||||
return value
|
||||
|
||||
},
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ module.exports.options = {
|
|||
|
||||
rangeX:{min:0,max:1},
|
||||
rangeY:{min:0,max:1},
|
||||
logScaleX:false,
|
||||
logScaleY:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
split:false,
|
||||
|
|
@ -117,8 +119,8 @@ module.exports.create = function(widgetData,container) {
|
|||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision),
|
||||
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision)
|
||||
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision,widgetData.logScaleX),
|
||||
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision,widgetData.logScaleY)
|
||||
|
||||
return [x,y]
|
||||
}
|
||||
|
|
@ -129,8 +131,8 @@ module.exports.create = function(widgetData,container) {
|
|||
v[i] = clip(v[i],[range[['x','y'][i]].min,range[['x','y'][i]].max])
|
||||
}
|
||||
|
||||
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],widgetData.precision)
|
||||
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],widgetData.precision),
|
||||
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],widgetData.precision,widgetData.logScaleX,true)
|
||||
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],widgetData.precision,widgetData.logScaleX,false),
|
||||
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue