improving widget pasting (smart id/path incrementing)
This commit is contained in:
parent
8e6dad3217
commit
b6f7df2b3f
4 changed files with 70 additions and 9 deletions
|
|
@ -5,14 +5,16 @@
|
|||
- engine
|
||||
- electron 0.37.2 (chrome 49)
|
||||
- ui
|
||||
- new style !
|
||||
- new flat ui
|
||||
- tab system rewritten : inactive tabs are detached from the DOM tree, thus improving performances.
|
||||
- widget categories in editor's context menu
|
||||
- features
|
||||
- logarithmic scaling (log10) support added to knob, fader & xy
|
||||
- mousewheel support added to knob and fader (ctrlKey for fine control)
|
||||
- new widgets : plot, visualizer & meter. Fader built-in feedback meter option
|
||||
- new widgets : plot, visualizer & meter. Fader built-in feedback meter option
|
||||
- traversing gestures switch in sidepanel
|
||||
- custom color property for all widgets with inheritance (containers)
|
||||
- editor pasting function now smartly increments widget's id and path while keeping label if different from default
|
||||
- misc
|
||||
- sync/link event handling improved
|
||||
- stylesheets cannot be recompiled on the fly anymore (`--c` switch removed)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,58 @@ var updateDom = function(container,data) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
var incrementWidget = function(data){
|
||||
|
||||
delete data.linkId
|
||||
|
||||
var id = data.id,
|
||||
label = data.label,
|
||||
path = data.path
|
||||
|
||||
if (id && id==label) {
|
||||
data.label = 'auto'
|
||||
}
|
||||
if (id && path == '/'+id) {
|
||||
|
||||
data.path = 'auto'
|
||||
|
||||
} else if (path){
|
||||
|
||||
while (WIDGETS_ID_BY_PATH[path]) {
|
||||
path = path.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
return n
|
||||
})
|
||||
}
|
||||
data.path = path
|
||||
|
||||
}
|
||||
|
||||
if (id) {
|
||||
while (WIDGETS[id]) {
|
||||
id = id.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
return n
|
||||
})
|
||||
}
|
||||
data.id = id
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i in data) {
|
||||
if (typeof data[i] == 'object') data[i] = incrementWidget(data[i])
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateDom:updateDom,
|
||||
getObjectData:getObjectData
|
||||
getObjectData:getObjectData,
|
||||
incrementWidget:incrementWidget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,9 +208,7 @@ var editObject = function(container, data, refresh){
|
|||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)/PXSCALE
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)/PXSCALE
|
||||
updateDom(container,data)
|
||||
},
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
snapTolerance:5
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
var data = require('./data-workers'),
|
||||
getObjectData = data.getObjectData,
|
||||
updateDom = data.updateDom,
|
||||
incrementWidget = data.incrementWidget,
|
||||
edit = require('./edit-objects'),
|
||||
editObject = edit.editObject,
|
||||
editSession = edit.editSession,
|
||||
|
|
@ -76,22 +77,31 @@ var init = function(){
|
|||
|
||||
if (CLIPBOARD!=null) {
|
||||
actions['<i class="fa fa-paste"></i> Paste'] = {
|
||||
'<i class="fa fa-object-ungroup"></i> New ID':function(){
|
||||
'<i class="fa fa-plus-circle"></i> ID + 1':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = JSON.parse(JSON.stringify(CLIPBOARD).replace(/\"(id|label|linkId|path)\"\:\"([^\"]*)\"\,?/g,'').replace(/\,\}/g,'\}'))
|
||||
var newData = incrementWidget(JSON.parse(JSON.stringify(CLIPBOARD)))
|
||||
|
||||
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = e.offsetY
|
||||
newData.left= e.offsetX
|
||||
} else {
|
||||
delete newData.top
|
||||
delete newData.left
|
||||
}
|
||||
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
},
|
||||
'<i class="fa fa-object-group"></i> Same ID':function(){
|
||||
'<i class="fa fa-clone"></i> Clone':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = JSON.parse(JSON.stringify(CLIPBOARD))
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = e.offsetY
|
||||
newData.left= e.offsetX
|
||||
} else {
|
||||
delete newData.top
|
||||
delete newData.left
|
||||
}
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue