All widgets can be absolutely positionned, except those within strips & panels.
Widgets can be dragged in editor mode, jquery-ui draggable added) Creating a new session selects the root automatically to show where to start
This commit is contained in:
parent
0a985ff3c6
commit
70124c1880
9 changed files with 76 additions and 38 deletions
File diff suppressed because one or more lines are too long
|
|
@ -53,7 +53,7 @@ ipc.on('sessionList',function(event,data){
|
|||
e.stopPropagation()
|
||||
$('#lobby').remove()
|
||||
setTimeout(function(){
|
||||
init([{}],function(){$('#open-toggle').click()})
|
||||
init([{}],function(){$('#open-toggle, .enable-editor, .editor-root').click()})
|
||||
},25)
|
||||
})
|
||||
})
|
||||
|
|
@ -72,6 +72,6 @@ ipc.on('sessionOpen',function(event,data){
|
|||
|
||||
ipc.on('error',function(event,data){
|
||||
var data = data || event
|
||||
|
||||
|
||||
createPopup(icon('warning')+' '+data.title,data.text)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -59,9 +59,11 @@ enableEditor = function(){
|
|||
}
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
$(this).resizable({
|
||||
handles:'se',
|
||||
helper: "resizable-helper",
|
||||
helper: "ui-helper",
|
||||
stop: function( event, ui ) {
|
||||
data.height = ui.size.height
|
||||
data.width = ui.size.width
|
||||
|
|
@ -69,6 +71,18 @@ enableEditor = function(){
|
|||
}
|
||||
})
|
||||
|
||||
if (!$(this).parents('.strip, .panel').length) {
|
||||
$(this).draggable({
|
||||
helper: "ui-helper",
|
||||
stop: function( event, ui ) {
|
||||
data.top = ui.position.top
|
||||
data.left = ui.offset.left
|
||||
updateWidget()
|
||||
},
|
||||
handle:'.ui-draggable-handle'
|
||||
}).append('<div class="ui-draggable-handle"></div>')
|
||||
}
|
||||
|
||||
for (i in data) {
|
||||
if (i!='widgets' && i!='tabs') {
|
||||
var type = typeof data[i],
|
||||
|
|
@ -396,6 +410,8 @@ enableEditor = function(){
|
|||
}
|
||||
|
||||
disableEditor = function(){
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
$('.widget').off('click.editor')
|
||||
$('a[data-tab]').off('click.editor')
|
||||
$('.editor-root').off('click.editor').addClass('disabled')
|
||||
|
|
|
|||
|
|
@ -95,13 +95,6 @@ parsewidgets = function(widgets,parent) {
|
|||
}
|
||||
|
||||
|
||||
var width = parseInt(widgetData.width)==widgetData.width?parseInt(widgetData.width)+'rem' : widgetData.width,
|
||||
height = parseInt(widgetData.height)==widgetData.height?parseInt(widgetData.height)+'rem' : widgetData.height,
|
||||
styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:${width}`:'',
|
||||
styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:${height}`:'',
|
||||
style = styleW + ';' + styleH
|
||||
|
||||
|
||||
// Sort widgets' properties and turn string-numbers to numbers
|
||||
for (k in widgetOptions[widgetData.type]) {
|
||||
var tmp = widgetData[k]
|
||||
|
|
@ -111,10 +104,23 @@ parsewidgets = function(widgets,parent) {
|
|||
widgetData[k] = tmp
|
||||
}
|
||||
|
||||
if (parent[0].className.match(/strip|panel/)) {
|
||||
delete widgetData.top
|
||||
delete widgetData.left
|
||||
}
|
||||
|
||||
var width = parseInt(widgetData.width)==widgetData.width?parseInt(widgetData.width)+'rem' : widgetData.width,
|
||||
height = parseInt(widgetData.height)==widgetData.height?parseInt(widgetData.height)+'rem' : widgetData.height,
|
||||
left = parseInt(widgetData.left)==widgetData.left?parseInt(widgetData.left)+'rem' : widgetData.left,
|
||||
top = parseInt(widgetData.top)==widgetData.top?parseInt(widgetData.top)+'rem' : widgetData.top,
|
||||
styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:${width};`:'',
|
||||
styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:${height};`:'',
|
||||
styleL = widgetData.left&&widgetData.left!='auto'||widgetData.left==0?`left:${left};`:'',
|
||||
styleT = widgetData.top&&widgetData.top!='auto'||widgetData.top==0?`top:${top};`:''
|
||||
|
||||
|
||||
var widgetContainer = $(`
|
||||
<div class="widget ${widgetData.type}-container" style="${style}">
|
||||
<div class="widget ${widgetData.type}-container ${styleL.length || styleT.length?'absolute-position':''}" style="${styleW + styleH + styleL + styleT}">
|
||||
<div class="label"><span>${widgetData.label}</span></div>
|
||||
</div>
|
||||
`)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ widgetOptions = {
|
|||
id:'auto',
|
||||
label:'auto',
|
||||
horizontal:false,
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
widgets:[]
|
||||
|
|
@ -25,6 +27,8 @@ widgetOptions = {
|
|||
id:'auto',
|
||||
label:'auto',
|
||||
color:'green',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
range:{min:0,max:1},
|
||||
|
|
@ -34,6 +38,8 @@ widgetOptions = {
|
|||
type:'toggle',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
off:0,
|
||||
|
|
@ -45,6 +51,8 @@ widgetOptions = {
|
|||
type:'push',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
off:0,
|
||||
|
|
@ -56,6 +64,8 @@ widgetOptions = {
|
|||
type:'switch',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
|
|
@ -67,6 +77,8 @@ widgetOptions = {
|
|||
type:'xy',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
split:false,
|
||||
|
|
@ -80,6 +92,8 @@ widgetOptions = {
|
|||
type:'rgb',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
split:false,
|
||||
|
|
@ -91,6 +105,8 @@ widgetOptions = {
|
|||
type:'fader',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
|
|
@ -103,6 +119,8 @@ widgetOptions = {
|
|||
type:'knob',
|
||||
id:'auto',
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
range:{min:0,max:1},
|
||||
|
|
@ -135,28 +153,11 @@ createWidget.panel = function(widgetData,container) {
|
|||
var widget = $(`
|
||||
<div class="panel">
|
||||
</div>
|
||||
`),
|
||||
left = parseInt(widgetData.left)==widgetData.left?parseInt(widgetData.left)+'rem' : widgetData.left,
|
||||
top = parseInt(widgetData.top)==widgetData.top?parseInt(widgetData.top)+'rem' : widgetData.top,
|
||||
width = parseInt(widgetData.width)==widgetData.width?parseInt(widgetData.width)+'rem' : widgetData.width,
|
||||
height = parseInt(widgetData.height)==widgetData.height?parseInt(widgetData.height)+'rem' : widgetData.height
|
||||
`)
|
||||
|
||||
if (widgetData.stretch) widget.addClass('stretch')
|
||||
|
||||
container.css({
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto'
|
||||
})
|
||||
|
||||
|
||||
container.css({
|
||||
left:left,
|
||||
top:top,
|
||||
width:width,
|
||||
height:height
|
||||
})
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
widget.getValue = function(){return}
|
||||
widget.setValue = function(){return}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ window.$ = window.jQuery = require('./jquery/jquery.min.js')
|
|||
|
||||
|
||||
// third-party js libraries
|
||||
require('./jquery/jquery.resizable-draggable.js')
|
||||
require('./jquery/jquery.sortable.js')
|
||||
require('./jquery/jquery.drag.js')
|
||||
require('./jquery/jquery.resize.js')
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ window.$ = window.jQuery = require('./jquery/jquery.min.js')
|
|||
|
||||
|
||||
// third-party js libraries
|
||||
require('./jquery/jquery.resizable-draggable.js')
|
||||
require('./jquery/jquery.sortable.js')
|
||||
require('./jquery/jquery.drag.js')
|
||||
require('./jquery/jquery.resize.js')
|
||||
require('./jquery/jquery.resizable.js')
|
||||
|
||||
// main js
|
||||
require('./app/app.js')
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -640,6 +640,11 @@ a {
|
|||
background-clip:padding-box;
|
||||
-webkit-tap-highlight-color:transparent;
|
||||
|
||||
&.absolute-position {
|
||||
position: absolute;
|
||||
z-index: 10
|
||||
}
|
||||
|
||||
&.nolabel {
|
||||
padding-top:0;
|
||||
> .label {
|
||||
|
|
@ -689,8 +694,23 @@ a {
|
|||
z-index: 100000;
|
||||
cursor: se-resize;
|
||||
}
|
||||
.resizable-helper {
|
||||
.ui-helper {
|
||||
border: 1rem dashed $color-accent;
|
||||
}
|
||||
.ui-draggable-handle {
|
||||
position: absolute;
|
||||
position: absolute;
|
||||
top: 5rem;
|
||||
left: 5rem;
|
||||
z-index: 100000;
|
||||
cursor: -webkit-grab;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-radius: 15rem;
|
||||
background: rgba($color-accent,.5);
|
||||
&:active {
|
||||
cursor:-webkit-grabbing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue