ui: fader style big clean + many small enhancements
This commit is contained in:
parent
c8bbd7cd58
commit
1790bf3d79
13 changed files with 274 additions and 231 deletions
|
|
@ -146,7 +146,7 @@ var callbacks = module.exports = {
|
|||
$('canvas').trigger('resize',[0,0,true])
|
||||
},100)
|
||||
window.GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
window.PXSCALE_RESET()
|
||||
// window.PXSCALE_RESET()
|
||||
},
|
||||
readOnly: function(){
|
||||
window.READ_ONLY = true
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
...faderDefaults,
|
||||
id:'s',
|
||||
compact:true,
|
||||
pips:false,
|
||||
horizontal:true,
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:100},
|
||||
|
|
@ -89,6 +90,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
...faderDefaults,
|
||||
id:'b',
|
||||
compact:true,
|
||||
pips:false,
|
||||
horizontal:false,
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:100},
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ module.exports = class Xy extends _pads_base {
|
|||
...faderDefaults,
|
||||
id:0,
|
||||
compact:true,
|
||||
pips:false,
|
||||
horizontal:true,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
|
|
@ -87,6 +88,7 @@ module.exports = class Xy extends _pads_base {
|
|||
...faderDefaults,
|
||||
id:1,
|
||||
compact:true,
|
||||
pips:false,
|
||||
horizontal:false,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ module.exports = class Meter extends Fader {
|
|||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
pips:true,
|
||||
pips:false,
|
||||
dashed:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
|
|
|
|||
|
|
@ -69,12 +69,12 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
}.bind(this))
|
||||
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length)
|
||||
osctouchstate(this, this.canvas)
|
||||
osctouchstate(this, this.wrapper)
|
||||
|
||||
this.widget.on('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
this.canvas.on('draginit',this.draginitHandleProxy.bind(this))
|
||||
this.canvas.on('drag',this.dragHandleProxy.bind(this))
|
||||
this.canvas.on('dragend',this.dragendHandleProxy.bind(this))
|
||||
this.wrapper.on('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
this.wrapper.on('draginit',this.draginitHandleProxy.bind(this))
|
||||
this.wrapper.on('drag',this.dragHandleProxy.bind(this))
|
||||
this.wrapper.on('dragend',this.dragendHandleProxy.bind(this))
|
||||
|
||||
this.input.change(()=>{
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ module.exports = class Fader extends _sliders_base {
|
|||
horizontal:false,
|
||||
pips:true,
|
||||
compact:false,
|
||||
dashed:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
|
|
@ -77,7 +78,27 @@ module.exports = class Fader extends _sliders_base {
|
|||
this.widget.addClass('align-right')
|
||||
}
|
||||
|
||||
if (this.getProp('pips') && !this.getProp('compact')) {
|
||||
if (this.getProp('meter')) {
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
var data = {
|
||||
type:'meter',
|
||||
id: this.getProp('id') + '/meter',
|
||||
label:false,
|
||||
horizontal:this.getProp('horizontal'),
|
||||
range:this.getProp('range'),
|
||||
logScale:this.getProp('logScale'),
|
||||
address:this.getProp('meterAddress') || this.getProp('address') + '/meter',
|
||||
preArgs:this.getProp('preArgs'),
|
||||
color:this.getProp('color'),
|
||||
pips:false,
|
||||
dashed:true
|
||||
}
|
||||
var element = parsewidgets([data],this.wrapper, this.parent)
|
||||
element[0].classList.add('not-editable')
|
||||
this.widget[0].classList.add('has-meter')
|
||||
}
|
||||
|
||||
if (this.getProp('pips')) {
|
||||
|
||||
this.widget.addClass('has-pips')
|
||||
|
||||
|
|
@ -104,25 +125,6 @@ module.exports = class Fader extends _sliders_base {
|
|||
}
|
||||
|
||||
|
||||
if (this.getProp('meter')) {
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
var data = {
|
||||
type:'meter',
|
||||
id: this.getProp('id') + '/meter',
|
||||
label:false,
|
||||
horizontal:this.getProp('horizontal'),
|
||||
range:this.getProp('range'),
|
||||
logScale:this.getProp('logScale'),
|
||||
address:this.getProp('meterAddress') || this.getProp('address') + '/meter',
|
||||
preArgs:this.getProp('preArgs'),
|
||||
color:this.getProp('color'),
|
||||
pips:this.getProp('pips')
|
||||
}
|
||||
var element = parsewidgets([data],this.wrapper, this.parent)
|
||||
element[0].classList.add('not-editable')
|
||||
this.widget[0].classList.add('has-meter')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
draginitHandle(e, data, traversing) {
|
||||
|
|
@ -176,7 +178,8 @@ module.exports = class Fader extends _sliders_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
if (this.getProp('horizontal')){
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
this.ctx.translate(-this.height, 0)
|
||||
}
|
||||
|
|
@ -195,39 +198,21 @@ module.exports = class Fader extends _sliders_base {
|
|||
o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))),
|
||||
m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2)
|
||||
|
||||
var dashed = this.getProp('dashed')
|
||||
|
||||
this.clear()
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
|
||||
this.ctx.globalAlpha = 0.2 + 0.2 * Math.abs(d-o) / (d<o?o:height-o)
|
||||
this.ctx.globalAlpha = 0.4//0.2 + 0.2 * Math.abs(d-o) / (d<o?o:height-o)
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(m, d)
|
||||
this.ctx.lineTo(m, o)
|
||||
this.ctx.moveTo(m, o)
|
||||
this.ctx.lineTo(m, d)
|
||||
this.ctx.lineWidth = width + 2 * PXSCALE
|
||||
if (dashed) this.ctx.setLineDash([PXSCALE, PXSCALE])
|
||||
this.ctx.stroke()
|
||||
|
||||
if (this.getProp('pips') && this.rangeKeys.length > 2) {
|
||||
this.ctx.globalAlpha = 1
|
||||
|
||||
var y,
|
||||
min = Math.min(d,o),
|
||||
max = Math.max(d,o)
|
||||
|
||||
this.ctx.beginPath()
|
||||
for (var i = 1;i < this.rangeKeys.length - 1;i++) {
|
||||
y = this.percentToCoord(this.rangeKeys[i])
|
||||
this.ctx.rect(0, y - PXSCALE, 4.5 * PXSCALE, 2 * PXSCALE)
|
||||
this.ctx.rect(width - 4.5 * PXSCALE, y - PXSCALE, 4.5 * PXSCALE, 2 * PXSCALE)
|
||||
}
|
||||
this.ctx.fillStyle = this.colors.pips
|
||||
this.ctx.fill()
|
||||
this.ctx.fillStyle = this.colors.light
|
||||
this.ctx.fill()
|
||||
this.ctx.lineWidth = 1 * PXSCALE
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.stroke()
|
||||
}
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.beginPath()
|
||||
|
|
@ -268,10 +253,11 @@ module.exports = class Fader extends _sliders_base {
|
|||
this.ctx.beginPath()
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.moveTo(m, d)
|
||||
this.ctx.lineTo(m, o)
|
||||
this.ctx.moveTo(m, o)
|
||||
this.ctx.lineTo(m, d)
|
||||
if (dashed) this.ctx.setLineDash([PXSCALE, PXSCALE])
|
||||
this.ctx.stroke()
|
||||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
height:'auto',
|
||||
color:'auto',
|
||||
pips:true,
|
||||
dashed:false,
|
||||
angle:270,
|
||||
css:'',
|
||||
|
||||
|
|
@ -149,7 +150,9 @@ module.exports = class Knob extends _sliders_base {
|
|||
var o = this.percentToAngle(this.valueToPercent(this.originValue)),
|
||||
d = this.percentToAngle(this.percent),
|
||||
min = this.percentToAngle(0),
|
||||
max = this.percentToAngle(100)
|
||||
max = this.percentToAngle(100),
|
||||
dashed = this.getProp('dashed')
|
||||
|
||||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
|
|
@ -177,7 +180,10 @@ module.exports = class Knob extends _sliders_base {
|
|||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth - this.margin * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
if (dashed) this.ctx.setLineDash([1.5, 1.5])
|
||||
this.ctx.stroke()
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
|
||||
if (this.getProp('pips')) {
|
||||
this.ctx.globalAlpha = 1
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@
|
|||
self.fontSize = parseFloat(getComputedStyle(canvas[0]).getPropertyValue("font-size"))
|
||||
}
|
||||
|
||||
ctx.font = self.fontSize + 'px Droid Sans'
|
||||
ctx.textBaseline = "middle"
|
||||
ctx.fillStyle = self.color
|
||||
ctx.textAlign = settings.align
|
||||
|
||||
self.val(self.value)
|
||||
|
||||
})
|
||||
|
|
@ -51,15 +56,13 @@
|
|||
if (!self.height || !self.width || (self.height==100 && self.width==100)) return
|
||||
|
||||
ctx.clearRect(0,0,self.width,self.height)
|
||||
ctx.font = self.fontSize + 'px Droid Sans'
|
||||
ctx.textBaseline = "middle"
|
||||
ctx.fillStyle = self.color
|
||||
|
||||
if (self.center) {
|
||||
ctx.textAlign = settings.align
|
||||
if (settings.align == 'center') {
|
||||
ctx.fillText(newVal,self.width/2,this.height/2)
|
||||
} else {
|
||||
} else if (settings.align == 'left') {
|
||||
ctx.fillText(newVal,0,this.height/2)
|
||||
} else if (settings.align == 'right') {
|
||||
ctx.fillText(newVal,this.width,this.height/2)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue