plots: add image widget (#64)

This commit is contained in:
jean-emmanuel 2017-12-18 21:35:39 +01:00
parent e65d287907
commit e1e54c038b
3 changed files with 108 additions and 3 deletions

View file

@ -34,6 +34,7 @@ module.exports.widgets = {
visualizer: require('./plots/visualizer'),
meter: require('./plots/meter'),
text: require('./plots/text'),
image: require('./plots/image'),
// containers
strip: require('./containers/strip'),
@ -58,7 +59,7 @@ module.exports.categories = {
'Buttons':['toggle','push','switch', 'dropdown'],
'Pads':['xy','rgb','multixy'],
'Matrices':['multifader','multitoggle','multipush', 'keyboard'],
'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text'],
'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text', 'image'],
'Containers':['panel','strip','modal', 'clone'],
'Switchers':['switcher','crossfader'],
'Inputs':['input'],

View file

@ -0,0 +1,76 @@
var {mapToScale} = require('../utils'),
_widgets_base = require('../common/_widgets_base')
module.exports = class Led extends _widgets_base {
static defaults() {
return {
type:'image',
id:'auto',
_geometry:'geometry',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
_style:'style',
label:'auto',
// color:'auto',
css:'',
_image:'image',
size: 'cover',
position: 'center',
border: true,
cache: true,
value:'',
_osc:'osc',
preArgs:[],
address:'auto'
}
}
constructor(options) {
var html = `
<div class="image"></div>
`
super({...options, html: html})
if (!this.getProp('border')) this.container.addClass('noborder')
this.widget[0].style.setProperty('background-size', this.getProp('size'))
this.widget[0].style.setProperty('background-position', this.getProp('position'))
}
setValue(v) {
var s = '' + v
this.value = s
if (this.value.length) {
var cache_query = this.getProp('cache') || s.indexOf('base64') != -1 ? '' : (s.indexOf('?') != -1 ? '&' : '?') + Date.now()
this.widget[0].style.setProperty('background-image', `url(${s}${cache_query})`)
} else {
this.widget[0].style.setProperty('background-image', '')
}
}
}

View file

@ -77,15 +77,43 @@
}
}
.image-container {
width:100rem;
height:100rem;
padding:1rem;
.image {
display: flex;
flex-direction: row;
flex: 1 1 100%;
background-size:cover;
border:1rem solid var(--color-bg);
background-repeat: no-repeat;
}
&.noborder {
--color-border:transparent;
--color-light:transparent;
--color-light:transparent;
background: transparent;
padding: 0!important;
.image {
outline:transparent!important;
border:0!important;
box-shadow:none!important;
margin: 0!important;
}
}
}
.panel:not(.tab) > .led-container,
.panel:not(.tab) > .rgbled-container,
.panel:not(.tab) > .text-container,
.panel:not(.tab) > .visualizer-container,
.panel:not(.tab) > .eq-container,
.panel:not(.tab) > .plot-container {
.panel:not(.tab) > .plot-container,
.panel:not(.tab) > .image-container {
--color-border:transparent;
padding: 0rem;
.plot, .text, .led {
.plot, .text, .led, .image {
padding: 0rem;
margin: 1rem;
background-clip: content-box;