fader: allow adjusting gauge width

This commit is contained in:
bordun 2019-11-26 21:33:47 +01:00
parent 4037f9c796
commit de4131a58c
3 changed files with 10 additions and 4 deletions

View file

@ -6,6 +6,7 @@
- launcher: limit terminal history size to prevent slowdown/freeze
- widgets
- knob: text pips support
- fader: add css variable `--gauge-width`
## 0.48.3

View file

@ -54,7 +54,8 @@ module.exports = class Fader extends Slider {
'- `--color-gauge: color;`',
'- `--color-knob: color;`',
'- `--color-pips: color;`',
'- `--gauge-opacity: number;`'
'- `--gauge-opacity: number;`',
'- `--gauge-width: number;` (2-16, require a manual resize to take effect)'
]}
})
@ -66,6 +67,7 @@ module.exports = class Fader extends Slider {
this.widget.classList.add('fader')
this.margin = 22
this.gaugeWidth = 2
if (this.getProp('horizontal')) {
@ -187,6 +189,8 @@ module.exports = class Fader extends Slider {
super.resizeHandle(event)
this.gaugeWidth = Math.max(2, Math.min(16, parseInt(event.style.getPropertyValue('--gauge-width')) || 2))
if (this.getProp('horizontal')){
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
this.ctx.rotate(-Math.PI/2)
@ -273,7 +277,7 @@ module.exports = class Fader extends Slider {
} else {
this.ctx.lineWidth = 6 * PXSCALE
this.ctx.lineWidth = (this.gaugeWidth + 4) * PXSCALE
this.ctx.beginPath()
this.ctx.globalAlpha = 1
@ -282,7 +286,7 @@ module.exports = class Fader extends Slider {
this.ctx.lineTo(m, height - this.margin * PXSCALE + 2 * PXSCALE)
this.ctx.stroke()
this.ctx.lineWidth = 4 * PXSCALE
this.ctx.lineWidth = (this.gaugeWidth + 2) * PXSCALE
this.ctx.beginPath()
this.ctx.globalAlpha = 1
@ -291,7 +295,7 @@ module.exports = class Fader extends Slider {
this.ctx.lineTo(m, height - this.margin * PXSCALE + 1 * PXSCALE)
this.ctx.stroke()
this.ctx.lineWidth = 2 * PXSCALE
this.ctx.lineWidth = this.gaugeWidth * PXSCALE
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.track

View file

@ -2,6 +2,7 @@
--color-pips: var(--color-custom);
--color-gauge: var(--color-custom);
--color-knob: var(--color-custom);
--gauge-width: 2;
padding: 1rem;
width:100rem;
height:300rem;