knob: compact mode
This commit is contained in:
parent
ba24263a95
commit
cead37dade
5 changed files with 56 additions and 13 deletions
|
|
@ -6,6 +6,7 @@
|
|||
- bottom horizontal scrollbar not responding on small screens
|
||||
- widgets
|
||||
- `logScale` can be set to a number to use a logarithm base different from the default
|
||||
- knob: `compact` mode is back
|
||||
|
||||
## 0.45.5
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module.exports = class Fader extends Slider {
|
|||
'- the meter\'s `id` will be the same as the widget\'s with `/meter` appended to it',
|
||||
'- the meter\'s `address` will be the same as the widget\'s with `/meter` appended to it'
|
||||
]},
|
||||
compact: {type: 'boolean', value: false, help: 'Set to `true` to display a compact alternative for the widget. Disables default mouse/touch focusing on the value display.'},
|
||||
compact: {type: 'boolean', value: false, help: 'Set to `true` to display a compact alternative for the widget. If `input` is `true`, the input can be focused with a right-click (mouse only). Disables `pips` when enabled.'},
|
||||
dashed: {type: 'boolean', value: false, help: 'Set to `true` to display a dashed gauge'},
|
||||
snap: {type: 'boolean', value: false, help: 'By default, dragging the widget will modify it\'s value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position'},
|
||||
spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'},
|
||||
|
|
@ -73,16 +73,7 @@ module.exports = class Fader extends Slider {
|
|||
}
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.classList.add('compact')
|
||||
this.margin = 0
|
||||
if (this.getProp('input')) {
|
||||
this.widget.addEventListener('fast-right-click', (e)=>{
|
||||
if (e.detail.button == 2 && !EDITING) {
|
||||
// Mouse only
|
||||
this.input.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getProp('alignRight') && !this.getProp('horizontal')) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
_knob:'knob',
|
||||
|
||||
pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
|
||||
pips: {type: 'boolean', value: false, help: 'Set to `true` to show the scale\'s breakpoints'},
|
||||
input: {type: 'boolean', value: true, help: 'Set to `false` to hide the built-in input'},
|
||||
compact: {type: 'boolean', value: false, help: 'Set to `true` to display a compact alternative for the widget. If `input` is `true`, the input can be focused with a right-click (mouse only). Disables `pips` when enabled.'},
|
||||
dashed: {type: 'boolean', value: false, help: 'Set to `true` to display a dashed gauge'},
|
||||
angle: {type: 'number', value: 270, help: 'Defines the angle\'s width of the knob, in degrees'},
|
||||
snap: {type: 'boolean', value: false, help: 'By default, dragging the widget will modify it\'s value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position'},
|
||||
|
|
@ -55,8 +56,6 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
this.widget.classList.add('knob')
|
||||
|
||||
this.widget.classList.add('compact')
|
||||
|
||||
this.lastOffsetX = 0
|
||||
this.lastOffsetY = 0
|
||||
this.minDimension = 0
|
||||
|
|
@ -177,6 +176,13 @@ module.exports = class Knob extends Slider {
|
|||
rad = PXSCALE / gaugeRadius / 2
|
||||
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
pips = false
|
||||
gaugeWidth = this.minDimension / 4
|
||||
gaugeRadius = this.minDimension / 2 - gaugeWidth / 2
|
||||
}
|
||||
|
||||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
|
|
@ -211,6 +217,21 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
this.ctx.globalAlpha = 1
|
||||
let r1 = gaugeRadius - gaugeWidth / 2 + 2 * PXSCALE,
|
||||
r2 = gaugeRadius + gaugeWidth / 2 - 2 * PXSCALE,
|
||||
a = 2 * Math.PI - d
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
|
||||
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
|
||||
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
this.ctx.strokeStyle = this.colors.knob
|
||||
this.ctx.stroke()
|
||||
return
|
||||
}
|
||||
|
||||
if (pips) {
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,18 @@ class Slider extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.classList.add('compact')
|
||||
if (this.getProp('input')) {
|
||||
this.widget.addEventListener('fast-right-click', (e)=>{
|
||||
if (e.detail.button == 2 && !EDITING) {
|
||||
// Mouse only
|
||||
this.input.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.setSteps()
|
||||
|
||||
this.setValue(this.springValue)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,24 @@
|
|||
border: 0!important;
|
||||
}
|
||||
|
||||
&.compact {
|
||||
> .input {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
border:0;
|
||||
background:transparent;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top:50%;
|
||||
left:50%;
|
||||
z-index: 1;
|
||||
width: 100rem;
|
||||
height: 30rem;
|
||||
margin-left:-50rem;
|
||||
margin-top:-15rem;
|
||||
}
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
overflow: hidden;
|
||||
flex: 1 1 100%;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue