- generic collection support for plot

- traversing gestures don't break editor's inputs
- better editor input eval
This commit is contained in:
jean-emmanuel 2016-03-14 19:36:54 +01:00
parent ef26460b9b
commit 2262bda873
4 changed files with 106 additions and 47 deletions

View file

@ -181,12 +181,12 @@ module.exports = {
},
traversingDisable: function(){
$('body').delegateDrag('disable')
$('#container').delegateDrag('disable')
$('.traversingEnable, .traversingDisable').toggleClass('on')
TRAVERSING = false
},
traversingEnable: function(){
$('body').delegateDrag()
$('#container').delegateDrag()
$('.traversingEnable, .traversingDisable').toggleClass('on')
TRAVERSING = true
}

View file

@ -69,8 +69,16 @@ var editObject = function(container, data, refresh){
input.on('change',function(){
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):v
// var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
var v
try {
eval(`v=${$(this).val()}`)
} catch(err) {
v = $(this).val()
}
console.log(v)
data[$(this).attr('title')] = v
if (v=='') delete data[$(this).attr('title')]
updateDom(container,data)
})

View file

@ -51,10 +51,18 @@ module.exports.create = function(widgetData,container) {
}
}
for (i in widgetData.points) {
for (j in widgetData.points[i]) {
if (typeof widgetData.points[i][j] == 'string') {
widget.linkedWidgets.push(widgetData.points[i][j])
if (typeof widgetData.points=='string') {
widget.linkedWidgets.push(widgetData.points)
} else if (typeof widgetData.points=='object') {
for (i in widgetData.points) {
for (j in widgetData.points[i]) {
if (typeof widgetData.points[i][j] == 'string') {
widget.linkedWidgets.push(widgetData.points[i][j])
}
}
}
}
@ -99,10 +107,19 @@ module.exports.create = function(widgetData,container) {
var point = []
for (i in widget.data) {
var newpoint = [
mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15,widget.width-15],0,widgetData.logScaleX,true),
mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15,15],0,widgetData.logScaleY,true),
]
var newpoint = widget.data[i].length?
[
mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15,widget.width-15],0,widgetData.logScaleX,true),
mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15,15],0,widgetData.logScaleY,true),
]
:
[
mapToScale(i,[0,widget.data.length-1],[15,widget.width-15],0,widgetData.logScaleX,true),
mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15,15],0,widgetData.logScaleY,true),
]
if (first) {
ctx.moveTo(newpoint[0],newpoint[1])
first = false
@ -152,34 +169,31 @@ module.exports.create = function(widgetData,container) {
widget.fetchValues = function(){
var data = []
for (i in widgetData.points) {
data[i] = []
var point = widgetData.points[i]
if (point.length==2) {
for (k in [0,1]) {
if (typeof point[k] == 'string') {
if (WIDGETS[point[k]] && WIDGETS[point[k]].length)
data[i][k] = WIDGETS[point[k]][WIDGETS[point[k]].length-1].getValue()
} else {
data[i][k] = point[k]
}
}
} else if (point.length==1){
if (typeof point[0] == 'string') {
if (WIDGETS[point[0]] && WIDGETS[point[0]].length) {
var v = WIDGETS[point[0]][WIDGETS[point[0]].length-1].getValue()
data[i][0] = v[0]
data[i][1] = v[1]
}
} else {
data[i][0] = point[0]
data[i][1] = point[0]
}
}
}
var data = [],
points = widgetData.points
if (typeof points=='string' && WIDGETS[points]) {
data = WIDGETS[points][WIDGETS[points].length-1].getValue()
} else if (typeof points=='object') {
for (i in points) {
data[i] = []
for (k in [0,1]) {
if (typeof points[i][k] == 'string' && WIDGETS[points[i][k]]) {
data[i][k] = WIDGETS[points[i][k]][WIDGETS[points[i][k]].length-1].getValue()
} else {
data[i][k] = points[i][k]
}
}
}
}
if (!data<widget.data && !data>widget.data) return
widget.data = data
}

View file

@ -11,7 +11,7 @@
"left": "auto",
"top": "auto",
"width": "auto",
"height": "auto",
"height": 254,
"horizontal": false,
"css": "",
"absolute": false,
@ -33,7 +33,7 @@
"left": "auto",
"top": "auto",
"width": "auto",
"height": "auto",
"height": 253,
"horizontal": false,
"css": "",
"absolute": false,
@ -55,7 +55,7 @@
"left": "auto",
"top": "auto",
"width": "auto",
"height": "auto",
"height": 253,
"horizontal": false,
"css": "",
"absolute": false,
@ -77,7 +77,7 @@
"left": "auto",
"top": "auto",
"width": "auto",
"height": "auto",
"height": 256,
"horizontal": false,
"css": "",
"absolute": false,
@ -93,11 +93,11 @@
{
"type": "plot",
"id": "plot_1",
"label": "plot_1",
"label": "plot (faders)",
"left": 406,
"top": 215,
"top": 129,
"width": "auto",
"height": "auto",
"height": 124,
"css": "",
"points": [
[
@ -133,7 +133,7 @@
"left": 406,
"top": 7,
"width": "auto",
"height": "auto",
"height": 122,
"css": "",
"id": "visualizer_(fader_1)",
"curve": "fader_1",
@ -144,6 +144,43 @@
},
"logScale": false,
"label": "visualizer (fader1)"
},
{
"type": "rgb",
"id": "rgb_1",
"linkId": "",
"label": "rgb_1",
"left": 6,
"top": 261,
"width": "auto",
"height": "auto",
"css": "",
"absolute": false,
"precision": 0,
"path": "/rgb_1",
"split": false,
"target": []
},
{
"type": "plot",
"left": 213,
"top": 263,
"width": 191,
"height": 248,
"css": "",
"points": "rgb_1",
"rangeX": {
"min": 0,
"max": 1
},
"rangeY": {
"min": 0,
"max": 255
},
"logScaleX": false,
"logScaleY": false,
"id": "plot_2",
"label": "plot_2 (rgb)"
}
]
}