widgets: add line pips to compact faders, display them on pads that have multiple breakpoints in their ranges

This commit is contained in:
jean-emmanuel 2016-11-15 23:19:23 +01:00
parent 3a94fdc8e1
commit fc6a49b505
6 changed files with 49 additions and 6 deletions

View file

@ -4,6 +4,8 @@
- widgets
- multixy: minor style update
- fader: display pips to `compact` mode when `range` has multiple breakpoints
- pads: display pips when `range` has multiple breakpoints
## 0.11.1

View file

@ -31,7 +31,7 @@ Sliders are unidimensional widgets that output one value at a time.
#### `compact`
- type: `boolean`
- default: `false`
- usage: set to `true` to display a compact alternative for the widget. Enables `noPips` and disables default mouse/touch focusing on the value display (right-click/long-touch still triggers it).
- usage: set to `true` to display a compact alternative for the widget. Disables default mouse/touch focusing on the value display (right-click/long-touch still triggers it).
#### `range`
@ -107,7 +107,7 @@ range: {
#### `compact`
- type: `boolean`
- default: `false`
- usage: set to `true` to display a compact alternative for the widget. Enables `noPips` and disables mouse/touch focusing on the value display.
- usage: set to `true` to display a compact alternative for the widget. Disables mouse/touch focusing on the value display.
#### `angle`
- type: `number`

View file

@ -2,9 +2,9 @@ var {Fader} = require('../sliders/fader')
var _fake_fader = module.exports = function(widgetData, cancelDraw){
Fader.apply(this, arguments)
this.noDraw = true
if (cancelDraw) this.draw = ()=>{}
Fader.apply(this, arguments)
}
_fake_fader.prototype = Object.create(Fader.prototype)

View file

@ -154,7 +154,7 @@ _sliders_base.prototype.setValue = function(v,options={}) {
if (!options.dragged) this.percent = this.valueToPercent(this.value)
this.draw()
if (!this.noDraw) this.draw()
this.showValue()

View file

@ -159,6 +159,21 @@ Fader.prototype.draw = function(){
if (this.widgetData.compact) {
if (!this.widgetData.noPip) {
this.ctx.lineWidth = PXSCALE
this.ctx.strokeStyle = this.colors.text
this.ctx.globalAlpha = 0.05
var x
for (var i = 1;i < this.rangeKeys.length - 1;i++) {
x = this.percentToCoord(this.rangeKeys[i])
this.ctx.beginPath()
this.ctx.moveTo(x, 0)
this.ctx.lineTo(x, this.height)
this.ctx.stroke()
}
}
this.ctx.globalAlpha = 0.3
this.ctx.strokeStyle = this.colors.gauge
this.ctx.beginPath()
@ -205,6 +220,21 @@ Fader.prototype.draw = function(){
if (this.widgetData.compact) {
if (!this.widgetData.noPip) {
this.ctx.lineWidth = PXSCALE
this.ctx.strokeStyle = this.colors.text
this.ctx.globalAlpha = 0.05
var y
for (var i = 1;i < this.rangeKeys.length - 1;i++) {
y = this.percentToCoord(this.rangeKeys[i])
this.ctx.beginPath()
this.ctx.moveTo(0, y)
this.ctx.lineTo(this.width, y)
this.ctx.stroke()
}
}
this.ctx.globalAlpha = 0.3
this.ctx.strokeStyle = this.colors.gauge

View file

@ -29,13 +29,20 @@
height:100%;
position: absolute;
pointer-events: none;
z-index: 1;
}
.fader {
pointer-events: none;
position: absolute;
width:100%;
height:100%;
opacity: 0;
z-index: 0;
--color-knob:transparent;
--color-gauge:transparent;
* {
background: transparent!important;
}
.input {
display: none;
}
@ -50,6 +57,10 @@
> canvas {
z-index: 1;
}
.fader {
--color-knob:transparent;
--color-gauge:transparent;
}
&:before, &:after {
content:"";
position: absolute;