fader modes, rgb fix
This commit is contained in:
parent
fdc6e1d33d
commit
f41ac14698
5 changed files with 58 additions and 15 deletions
|
|
@ -1018,7 +1018,8 @@ Widget.cssVariables = [
|
|||
{js: 'padding', css: '--widget-padding', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE},
|
||||
{js: 'alphaFillOn', css: '--alpha-fill-on', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
|
||||
{js: 'alphaFillOff', css: '--alpha-fill-off', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
|
||||
{js: 'alphaStroke', css: '--alpha-stroke', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)}
|
||||
{js: 'alphaStroke', css: '--alpha-stroke', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
|
||||
{js: 'colorForegroud', css: '--color-foreground'}
|
||||
]
|
||||
|
||||
Widget.dynamicProps = [
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) {
|
|||
quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
|
||||
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
|
||||
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
|
||||
restrainModals: {type: 'boolean', value: true, help: 'Set to `false` to let modal widgets ignore this container\'s boundaries.'},
|
||||
props: {type: 'object', value: {}, help: [
|
||||
'Defines a set of property to override the widgets\' defaults.',
|
||||
'Formulas in this field are resolved with an extra variable representing each widget\'s index: `$`',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
_fader:'fader',
|
||||
|
||||
mode: {type: 'string', value: 'flat', choices: ['flat', 'line'], help: 'Design style'},
|
||||
mode: {type: 'string', value: 'compact', choices: ['compact', 'classic', 'round'], help: 'Design style'},
|
||||
horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'},
|
||||
alignRight: {type: 'boolean', value: false, help: 'Set to `true` to invert the pip\'s and fader\'s position'},
|
||||
pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
|
||||
|
|
@ -65,7 +65,7 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
this.gaugeGradient = null
|
||||
|
||||
this.container.classList.toggle('alt', this.getProp('mode') !== 'flat')
|
||||
this.container.classList.add('design-' + this.getProp('mode'))
|
||||
|
||||
if (false && this.getProp('pips')) {
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ module.exports = class Fader extends Slider {
|
|||
o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))),
|
||||
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
|
||||
dashed = this.getProp('dashed'),
|
||||
flat = this.getProp('mode') === 'flat'
|
||||
compact = this.getProp('mode') === 'compact'
|
||||
|
||||
// sharp border trick
|
||||
if (width % 2 && parseInt(m) === m) m -= 0.5
|
||||
|
|
@ -211,7 +211,7 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
|
||||
|
||||
if (flat) {
|
||||
if (compact) {
|
||||
this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
|
||||
} else {
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
|
|
@ -242,7 +242,7 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
if (flat) {
|
||||
if (compact) {
|
||||
|
||||
// stroke
|
||||
|
||||
|
|
@ -265,12 +265,45 @@ module.exports = class Fader extends Slider {
|
|||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(this.gaugePadding, Math.min(d, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE)
|
||||
this.ctx.rect(this.gaugePadding, Math.min(d, height - this.gaugePadding - PXSCALE), width - this.gaugePadding * 2, PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
this.clearRect = [0, 0, width, height]
|
||||
|
||||
|
||||
} else if (this.getProp('mode') === 'classic') {
|
||||
|
||||
|
||||
if (this.cssVars.alphaStroke) {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorForegroud
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(m - 6 * PXSCALE, d - 10 * PXSCALE, 12 * PXSCALE, 20 * PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
this.ctx.rect(m - 5.5 * PXSCALE, d - 9.5 * PXSCALE, 11 * PXSCALE, 19 * PXSCALE)
|
||||
this.ctx.stroke()
|
||||
|
||||
}
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorWidget
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(m - 3 * PXSCALE, d, 6 * PXSCALE, PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
this.clearRect = [m - 10 * PXSCALE, this.gaugePadding - 10 * PXSCALE, 20 * PXSCALE, height - 2 * this.gaugePadding + 20 * PXSCALE]
|
||||
|
||||
} else {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
|
|
@ -280,12 +313,15 @@ module.exports = class Fader extends Slider {
|
|||
this.ctx.arc(m, d, 3 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = 0.25
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(m, d, 10 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
if (this.cssVars.alphaStroke) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(m, d, 10 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
}
|
||||
|
||||
this.clearRect = [m - 10 * PXSCALE, this.gaugePadding - 10 * PXSCALE, 20 * PXSCALE, height - 2 * this.gaugePadding + 20 * PXSCALE]
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@
|
|||
left: 2rem;
|
||||
right: 2rem;
|
||||
bottom: 0;
|
||||
background: linear-gradient(to top, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
|
||||
background: linear-gradient(to bottom, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
|
||||
opacity: 0.75;
|
||||
z-index: -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,18 @@
|
|||
|
||||
--widget-padding: 1rem;
|
||||
|
||||
&.alt {
|
||||
&.design-classic {
|
||||
--widget-padding: 10rem;
|
||||
--alpha-stroke: 0.5;
|
||||
--alpha-fill-off: 0.25;
|
||||
--alpha-fill-on: 1;
|
||||
}
|
||||
|
||||
&.design-round {
|
||||
--widget-padding: 10rem;
|
||||
--alpha-stroke: 0.25;
|
||||
--alpha-fill-off: 0.25;
|
||||
--alpha-fill-on: 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue