structure: take src out of packaged folder
This commit is contained in:
parent
139eab5fa4
commit
d1cb4194fa
85 changed files with 7 additions and 7 deletions
57
src/browser/js/app.js
Normal file
57
src/browser/js/app.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
///////////////////////
|
||||
|
||||
WIDGETS = {}
|
||||
WIDGETS_LINKED = {}
|
||||
WIDGETS_BY_PATH = {}
|
||||
SESSION = []
|
||||
STATE = []
|
||||
|
||||
CLIPBOARD = null
|
||||
EDITING = false
|
||||
|
||||
TRAVERSING = false
|
||||
|
||||
OSCSYNCONLY = false
|
||||
|
||||
TABS = {}
|
||||
|
||||
|
||||
MISC = {
|
||||
iterators: {
|
||||
widget:{},
|
||||
tab:{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PXSCALE = getComputedStyle(document.documentElement).getPropertyValue("--pixel-scale")
|
||||
INITIALZOOM = PXSCALE
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
$ = jQuery = require('./jquery/jquery.min')
|
||||
require('./jquery/jquery.ui')
|
||||
require('./jquery/jquery.drag')
|
||||
require('./jquery/jquery.resize')
|
||||
require('./jquery/jquery.fake-input')
|
||||
|
||||
///////////////////////
|
||||
|
||||
var callbacks = require('./app/callbacks')
|
||||
|
||||
var bindCallback = function(i) {
|
||||
IPC.on(i,function(event,data){
|
||||
callbacks[i](event,data)
|
||||
})
|
||||
}
|
||||
|
||||
for (i in callbacks) {
|
||||
bindCallback(i)
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
$(document).ready(function(){
|
||||
LOADING = require('./app/utils').loading('Connecting server...')
|
||||
IPC.send('ready')
|
||||
})
|
||||
139
src/browser/js/app/actions.js
Normal file
139
src/browser/js/app/actions.js
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
module.exports = {
|
||||
|
||||
stateQuickSave: function(preset){
|
||||
if (preset) {
|
||||
STATE = preset
|
||||
} else {
|
||||
STATE = module.exports.stateGet()
|
||||
}
|
||||
$('.quickload').removeClass('disabled')
|
||||
},
|
||||
|
||||
stateQuickLoad: function(){
|
||||
module.exports.stateSet(STATE,true)
|
||||
},
|
||||
|
||||
stateSave: function() {
|
||||
state = JSON.stringify(module.exports.stateGet(),null,' ')
|
||||
var down = $('<a download="'+new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16)+'.preset"></a>')
|
||||
var blob = new Blob([state],{type : 'text/plain'});
|
||||
down.attr('href', window.URL.createObjectURL(blob))
|
||||
down[0].click()
|
||||
},
|
||||
|
||||
stateGet: function (){
|
||||
var data = []
|
||||
for (i in WIDGETS) {
|
||||
var widget = WIDGETS[i]
|
||||
for (var j=widget.length-1;j>=0;j--) {
|
||||
if (widget[j].setValue && widget[j].getValue) {
|
||||
var v = widget[j].getValue()
|
||||
if (v!=undefined) data.push([i,v])
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return data
|
||||
},
|
||||
|
||||
stateLoad: function() {
|
||||
var prompt = $('<input type="file" accept=".preset"/>')
|
||||
prompt.click()
|
||||
prompt.on('change',function(e){
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function(e) {
|
||||
var preset = e.target.result
|
||||
module.exports.stateSet(JSON.parse(preset),true)
|
||||
STATE = preset
|
||||
}
|
||||
reader.readAsText(e.target.files[0],'utf-8');
|
||||
})
|
||||
},
|
||||
|
||||
stateSend: function(){
|
||||
var data = module.exports.stateGet()
|
||||
module.exports.stateSet(data,true)
|
||||
|
||||
},
|
||||
|
||||
stateSet: function(preset,send){
|
||||
|
||||
for (i in preset) {
|
||||
var data = preset[i]
|
||||
if (WIDGETS[data[0]]!=undefined) {
|
||||
for (var i=WIDGETS[data[0]].length-1;i>=0;i--) {
|
||||
if (WIDGETS[data[0]][i].setValue) {
|
||||
WIDGETS[data[0]][i].setValue(data[1],{send:send,sync:true})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggleFullscreen: function(){
|
||||
|
||||
var isInFullScreen = document.webkitIsFullScreen
|
||||
|
||||
if (isInFullScreen) {
|
||||
document.webkitExitFullscreen()
|
||||
} else {
|
||||
document.documentElement.webkitRequestFullScreen()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
sessionBrowse: function(){
|
||||
|
||||
var prompt = $('<input type="file" accept=".js"/>')
|
||||
prompt.click()
|
||||
prompt.on('change',function(e){
|
||||
var reader = new FileReader(),
|
||||
file = e.target.files[0]
|
||||
|
||||
reader.onloadend = function(e) {
|
||||
var session = e.target.result
|
||||
IPC.send('sessionOpen',{file:session,path:file.path})
|
||||
}
|
||||
reader.readAsText(file, 'utf-8');
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
sessionSave: function() {
|
||||
var sessionfile = JSON.stringify(SESSION,null,' ')
|
||||
var down = $('<a download="'+new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16)+'.js"></a>')
|
||||
var blob = new Blob([sessionfile],{type : 'text/plain'});
|
||||
down.attr('href', window.URL.createObjectURL(blob))
|
||||
down[0].click()
|
||||
|
||||
},
|
||||
|
||||
editorEnable: function(){
|
||||
$('.editor-root').attr('data-tab','#container').removeClass('disabled')
|
||||
$('.enable-editor').addClass('on')
|
||||
$('.disable-editor').removeClass('on')
|
||||
|
||||
EDITING = true
|
||||
},
|
||||
editorDisable: function(){
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
$('.editing').removeClass('editing')
|
||||
$('.editor-root').addClass('disabled')
|
||||
$('.editor-container').remove()
|
||||
$('.disable-editor').addClass('on')
|
||||
$('.enable-editor').removeClass('on')
|
||||
|
||||
EDITING = false
|
||||
},
|
||||
|
||||
traversingDisable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
$(document).trigger('disableTraversingGestures')
|
||||
},
|
||||
traversingEnable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
$(document).enableTraversingGestures()
|
||||
}
|
||||
|
||||
}
|
||||
132
src/browser/js/app/callbacks.js
Normal file
132
src/browser/js/app/callbacks.js
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
var init = require('./init'),
|
||||
actions = require('./actions'),
|
||||
utils = require('./utils'),
|
||||
icon = utils.icon
|
||||
|
||||
module.exports = {
|
||||
|
||||
receiveOsc: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
// fetch ids corresponding to the osc path
|
||||
var path = data.path,
|
||||
pathref = path,
|
||||
args = data.args,
|
||||
target = data.target
|
||||
|
||||
if (typeof data.args == 'object') {
|
||||
for (var i=data.args.length-1;i>=0;i--) {
|
||||
var ref = path+'||||'+data.args.slice(0,i).join('||||')
|
||||
if (WIDGETS_BY_PATH[ref]) {
|
||||
pathref = ref
|
||||
args = data.args.slice(i,data.args.length)
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args = data.args
|
||||
}
|
||||
|
||||
|
||||
if (args.length==0) args = null
|
||||
else if (args.length==1) args = args[0]
|
||||
|
||||
for (i in WIDGETS_BY_PATH[pathref]) {
|
||||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the same target
|
||||
// compare arrays using > and < operators (both false = equality)
|
||||
if (!target || !(WIDGETS_BY_PATH[pathref][i].target < target || WIDGETS_BY_PATH[pathref][i].target > target)) {
|
||||
// update matching widgets
|
||||
if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,{send:false,sync:true,fromExternal:!target})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
connected:function(){
|
||||
LOADING.close()
|
||||
},
|
||||
|
||||
stateLoad: function(event,data){
|
||||
var data = data || event
|
||||
data = JSON.parse(data)
|
||||
actions.stateSet(data,true)
|
||||
actions.stateQuickSave(data)
|
||||
},
|
||||
|
||||
sessionList: function(event,data){
|
||||
var data = data || event
|
||||
$('#lobby').append(`
|
||||
<div class="main">
|
||||
<div class="header">
|
||||
Open Stage Control
|
||||
</div>
|
||||
<div class="list"></div>
|
||||
<div class="footer"></div>
|
||||
</div>`)
|
||||
|
||||
for (i in data) {
|
||||
$('#lobby .list').append('<a class="btn load" data-session="'+data[i]+'">'+data[i]+'<span>'+icon('remove')+'</span></a>')
|
||||
}
|
||||
$('#lobby .footer').append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
|
||||
$('#lobby .footer').append('<a class="btn new">'+icon('file-o')+' New</a>')
|
||||
$('#lobby .load').click(function(e){
|
||||
e.stopPropagation()
|
||||
IPC.send('sessionOpen',{path:$(this).data('session')})
|
||||
})
|
||||
$('#lobby a span').click(function(e){
|
||||
e.stopPropagation()
|
||||
IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
|
||||
$(this).parents('a').remove()
|
||||
})
|
||||
$('#lobby .browse').click(function(e){
|
||||
e.stopPropagation()
|
||||
actions.sessionBrowse()
|
||||
})
|
||||
$('#lobby .new').click(function(e){
|
||||
e.stopPropagation()
|
||||
init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
|
||||
})
|
||||
},
|
||||
|
||||
sessionOpen: function(event,data){
|
||||
var data = data || event
|
||||
var session = JSON.parse(data)
|
||||
init(session,function(){
|
||||
IPC.send('sessionOpened')
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
stateSend:function(){
|
||||
var p = utils.loading('New client connecting...')
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
OSCSYNCONLY = true
|
||||
actions.stateSend()
|
||||
OSCSYNCONLY = false
|
||||
|
||||
p.close()
|
||||
},150)
|
||||
},
|
||||
|
||||
error: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
utils.createPopup(icon('warning')+' '+data.title,data.text)
|
||||
},
|
||||
|
||||
applyStyle: function(event,data){
|
||||
var data = data || event
|
||||
var style = document.createElement('style');
|
||||
style.innerHTML = data.join('');
|
||||
document.body.appendChild(style);
|
||||
if (data.indexOf('--pixel-scale')!=-1) {
|
||||
PXSCALE = data.match(/--pixel-scale\s*:\s*([^;]*)/)[1]
|
||||
INITIALZOOM = PXSCALE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
59
src/browser/js/app/editor/context-menu.js
Normal file
59
src/browser/js/app/editor/context-menu.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
var correctPosition = function (m, parent){
|
||||
var pos = m.offset(),
|
||||
width = m.outerWidth(),
|
||||
height = m.outerHeight(),
|
||||
totalWidth = $('body').outerWidth(),
|
||||
totalHeight = $('body').outerHeight(),
|
||||
leftAdjust = parent=='body'?0:parent.outerWidth()-2
|
||||
|
||||
if (width + pos.left > totalWidth) {
|
||||
m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
|
||||
}
|
||||
if (height + pos.top > totalHeight) {
|
||||
m.css({'margin-top':totalHeight-(height + pos.top)})
|
||||
}
|
||||
}
|
||||
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
||||
var menu = function(e,actions,parent){
|
||||
|
||||
var m = $('<div class="context-menu"></div>')
|
||||
if (parent=='body') {
|
||||
m.css({top:e.pageY+'px',left:e.pageX+'px'})
|
||||
}
|
||||
|
||||
for (label in actions) {
|
||||
|
||||
if (typeof actions[label] == 'object') {
|
||||
|
||||
var item = $(`<div class="item has-sub" tabIndex="1">${label}</div>`).appendTo(m).on(ev,function(e){e.stopPropagation()})
|
||||
menu(e,actions[label],item)
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$(`<div class="item">${label}</div>`).on(ev + '.editor',function(){
|
||||
var callback = actions[label]
|
||||
return function(e){
|
||||
callback()
|
||||
$('.context-menu').remove()
|
||||
}
|
||||
}()).appendTo(m)
|
||||
}
|
||||
}
|
||||
|
||||
m.appendTo(parent)
|
||||
|
||||
|
||||
|
||||
if (parent=='body') {
|
||||
correctPosition(m,parent)
|
||||
} else {
|
||||
parent.hover(function(){correctPosition(m,parent)})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = menu
|
||||
170
src/browser/js/app/editor/data-workers.js
Normal file
170
src/browser/js/app/editor/data-workers.js
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
var widgets = require('../widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
sync = widgets.sync,
|
||||
parser = require('../parser')
|
||||
parsewidgets = parser.widgets,
|
||||
parsetabs = parser.tabs,
|
||||
ui = require('../ui'),
|
||||
actions = require('../actions'),
|
||||
sidepanelCreateToggle = require('../sidepanel').createToggle,
|
||||
editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
|
||||
editSession = function(a,b){require('./edit-objects').editSession(a,b,true)},
|
||||
purgeStores = require('./purge')
|
||||
|
||||
|
||||
var getObjectData = function(obj){
|
||||
var path = []
|
||||
|
||||
if (obj.hasClass('tab')) {
|
||||
return TABS['#'+obj.attr('id')].data
|
||||
}
|
||||
|
||||
if (obj.is('#container')) {
|
||||
return SESSION
|
||||
}
|
||||
|
||||
while(true) {
|
||||
if (obj.hasClass('widget')) {
|
||||
path.unshift(obj.index())
|
||||
path.unshift('widgets')
|
||||
} else if (obj.hasClass('tab')){
|
||||
path.unshift(obj.data('index'))
|
||||
path.unshift('tabs')
|
||||
} else if (obj.is('#container')) {
|
||||
break
|
||||
}
|
||||
|
||||
obj = obj.parent()
|
||||
}
|
||||
|
||||
path.splice(0,1)
|
||||
|
||||
for (var i=0,data=SESSION, path=path, len=path.length; i<len; i++){
|
||||
data = data[path[i]]
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
}
|
||||
|
||||
var updateDom = function(container,data) {
|
||||
|
||||
// save state
|
||||
var scroll = $('#sidepanel').scrollTop(),
|
||||
state = actions.stateGet(),
|
||||
purgetabs = data.tabs?true:false
|
||||
|
||||
|
||||
|
||||
if (container.hasClass('widget')) {
|
||||
// widget
|
||||
var newContainer = parsewidgets([data],container.parent())
|
||||
container.replaceWith(newContainer)
|
||||
|
||||
editObject(newContainer,data)
|
||||
|
||||
} else if (container.hasClass('tab')) {
|
||||
// tab
|
||||
var newContainer = container.empty()
|
||||
|
||||
if (data.widgets && data.widgets.length) parsewidgets(data.widgets,container)
|
||||
if (data.tabs && data.tabs.length) {
|
||||
parsetabs(data.tabs,container,false,data.label)
|
||||
container.addClass('has-tabs')
|
||||
} else {
|
||||
container.removeClass('has-tabs')
|
||||
}
|
||||
|
||||
$(`[data-tab="#${container.attr('id')}"]`).html(`<a><span>${data.label}</span></a>`)
|
||||
|
||||
editObject(newContainer,data)
|
||||
|
||||
} else if (container.attr('id')=='container') {
|
||||
// session
|
||||
var newContainer = $('#container')
|
||||
container.empty()
|
||||
parsetabs(data,container,true)
|
||||
|
||||
editSession(newContainer,data)
|
||||
sidepanelCreateToggle()
|
||||
|
||||
}
|
||||
|
||||
newContainer.find('[data-tab]:first-child').click()
|
||||
|
||||
$(window).resize()
|
||||
|
||||
purgeStores(purgetabs)
|
||||
|
||||
// restore state
|
||||
actions.stateSet(state,false)
|
||||
sync()
|
||||
ui.scrolls()
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
|
||||
|
||||
// return updated node
|
||||
return newContainer
|
||||
|
||||
}
|
||||
|
||||
|
||||
var incrementWidget = function(data){
|
||||
|
||||
if (!data) return
|
||||
|
||||
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){
|
||||
var pathref
|
||||
while (WIDGETS_BY_PATH[pathref]) {
|
||||
path = path.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
return n
|
||||
})
|
||||
pathref = data.preArgs&&data.preArgs.length?path+'||||'+data.preArgs.join('||||'):path
|
||||
}
|
||||
WIDGETS_BY_PATH[pathref] = []
|
||||
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
|
||||
})
|
||||
}
|
||||
WIDGETS[id] = []
|
||||
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,
|
||||
incrementWidget:incrementWidget
|
||||
}
|
||||
310
src/browser/js/app/editor/edit-objects.js
Normal file
310
src/browser/js/app/editor/edit-objects.js
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
var updateDom = require('./data-workers').updateDom,
|
||||
widgetOptions = require('../widgets').widgetOptions
|
||||
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
||||
var editObject = function(container, data, refresh){
|
||||
|
||||
if (!refresh && (container.hasClass('editing') || $(`a[data-tab="#${container.attr('id')}"]`).hasClass('editing'))) return
|
||||
|
||||
var isWidget = container.hasClass('widget')
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
|
||||
if (isWidget) {
|
||||
$(container).addClass('editing')
|
||||
} else {
|
||||
$(`[data-tab="#${container.attr('id')}"]`).addClass('editing').click()
|
||||
$(container).parent().addClass('editing')
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('.editor-container').remove()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
var form = $('<div class="form"></div>').appendTo('.editor-container')
|
||||
|
||||
|
||||
var params = isWidget?widgetOptions[data.type]:{label:''}
|
||||
|
||||
for (i in params) {
|
||||
|
||||
if (i.indexOf('separator')!=-1) {
|
||||
$(`<div class="separator"><span>${params[i]}</span></div>`).appendTo(form)
|
||||
continue
|
||||
} else if (data[i]===undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Common options edit
|
||||
if (i!='widgets' && i!='tabs') {
|
||||
|
||||
var type = typeof data[i],
|
||||
value = type == 'object'?JSON.stringify(data[i]):data[i],
|
||||
wrapper = $('<div class="input-wrapper"></div>').appendTo(form),
|
||||
label = $(`<label>${i}</label>`).appendTo(wrapper),
|
||||
input
|
||||
|
||||
if (i=='type') {
|
||||
|
||||
input = $(`<select class="input" data-type="${type}" title="${i}"/>`)
|
||||
|
||||
for (t in widgetOptions) {
|
||||
input.append(`<option ${t==value?'selected=':''} value="${t}">${t}</option>`)
|
||||
}
|
||||
select = $('<div class="select-wrapper"></div>').append(input)
|
||||
select.appendTo(wrapper)
|
||||
|
||||
} else if (typeof params[i]=='boolean') {
|
||||
|
||||
input = $(`<input class="checkbox" data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.click(function(){
|
||||
$(this).val(!eval($(this).val())).trigger('change')
|
||||
})
|
||||
input.appendTo(wrapper)
|
||||
|
||||
} else {
|
||||
|
||||
input = $(`<input data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.appendTo(wrapper)
|
||||
|
||||
}
|
||||
|
||||
|
||||
input.on('change',function(){
|
||||
// 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()
|
||||
}
|
||||
|
||||
data[$(this).attr('title')] = v
|
||||
if (v==='') delete data[$(this).attr('title')]
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// widget list edit
|
||||
if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
var list = $('<ul class="input"></ul>'),
|
||||
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.widget').first().siblings().addBack().eq(i).trigger(ev)
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data.widgets) {
|
||||
|
||||
|
||||
var item = $(`<li data-index="${i}" class="sortables" data-id="${data.widgets[i].id}"><a class="btn small">${data.widgets[i].id||data.widgets[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.widgets.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>widgets</label>').appendTo(wrapper)
|
||||
list.appendTo(wrapper)
|
||||
|
||||
}
|
||||
|
||||
// tab list edit
|
||||
if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
|
||||
//tabs
|
||||
var list = $('<ul class="input"></ul>'),
|
||||
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
|
||||
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data.tabs) {
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data.tabs[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.tabs.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>tabs</label>').appendTo(wrapper)
|
||||
list.appendTo(wrapper)
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('width')) {
|
||||
var handleTarget
|
||||
container.resizable({
|
||||
handles:'s, e, se',
|
||||
helper: "ui-helper",
|
||||
start: function(event, ui){
|
||||
handleTarget = $(event.originalEvent.target)
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('top')) {
|
||||
container.draggable({
|
||||
cursor:'-webkit-grabbing',
|
||||
stop: function( event, ui ) {
|
||||
event.preventDefault()
|
||||
data.top = (ui.helper.position().top + container.parent().scrollTop())/PXSCALE
|
||||
data.left = (ui.helper.position().left + container.parent().scrollLeft())/PXSCALE
|
||||
ui.helper.remove()
|
||||
updateDom(container,data)
|
||||
},
|
||||
handle:'.ui-draggable-handle, > .label',
|
||||
snap:'.widget',
|
||||
snapTolerance:5,
|
||||
helper:function(){return $('<div class="ui-helper"></div>').css({height:container.outerHeight(),width:container.outerWidth()})}
|
||||
}).append('<div class="ui-draggable-handle"></div>')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var editSession = function(container,data,refresh){
|
||||
|
||||
if (!refresh && $('.editor-root').hasClass('editing')) return
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$('.editor-root, #container').addClass('editing')
|
||||
|
||||
$('.editor-container').remove()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
|
||||
|
||||
var form = $('<div class="form"></div>').appendTo('.editor-container'),
|
||||
list = $('<ul class="input"></ul>'),
|
||||
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
|
||||
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data) {
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
list.sortable({
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data = data || []
|
||||
data.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>tabs</label>').appendTo(wrapper)
|
||||
list.appendTo(wrapper)
|
||||
|
||||
|
||||
$('.editor-container').append(form)
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
editObject:editObject,
|
||||
editSession:editSession
|
||||
}
|
||||
182
src/browser/js/app/editor/init.js
Normal file
182
src/browser/js/app/editor/init.js
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
var data = require('./data-workers'),
|
||||
getObjectData = data.getObjectData,
|
||||
updateDom = data.updateDom,
|
||||
incrementWidget = data.incrementWidget,
|
||||
edit = require('./edit-objects'),
|
||||
editObject = edit.editObject,
|
||||
editSession = edit.editSession,
|
||||
createPopup = require('../utils').createPopup,
|
||||
widgetOptions = require('../widgets').widgetOptions,
|
||||
widgetCategories = require('../widgets').categories,
|
||||
menu = require('./context-menu')
|
||||
|
||||
|
||||
|
||||
var init = function(){
|
||||
|
||||
$('body').off('.editor').on('fake-click fake-right-click',function(e,d){
|
||||
|
||||
if (!EDITING) return
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.type=='mousedown' && e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
$('.context-menu').remove()
|
||||
|
||||
var target = $(e.target).is('.widget:not(.not-editable), .tab, [data-tab], #container')?
|
||||
$(e.target):
|
||||
$(e.target).closest('.widget:not(.not-editable), .tab, [data-tab], #container')
|
||||
|
||||
if (!target.length) return
|
||||
|
||||
var container = target.attr('data-tab')?TABS[target.attr('data-tab')].tab:target,
|
||||
type = target.hasClass('widget')?'widget':'tab',
|
||||
parent = container.parent(),
|
||||
index = container.index(),
|
||||
data = getObjectData(container)
|
||||
|
||||
if (container.attr('id')=='container') {
|
||||
editSession(container,SESSION)
|
||||
} else {
|
||||
editObject(container,data)
|
||||
}
|
||||
|
||||
|
||||
if (e.type!='fake-right-click') return
|
||||
|
||||
if (container.attr('id')=='container') {
|
||||
menu(d,{
|
||||
'<i class="fa fa-plus"></i> Add tab': function(){
|
||||
data.push({})
|
||||
updateDom(container,data)
|
||||
}
|
||||
},'body')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var actions = {}
|
||||
|
||||
// actions['<i class="fa fa-edit"></i> Edit'] = function(){editObject(container,data)}
|
||||
|
||||
if (type=='widget') actions['<i class="fa fa-copy"></i> Copy'] = function(){CLIPBOARD=data}
|
||||
|
||||
if (type=='widget') actions['<i class="fa fa-cut"></i> Cut'] = function(){
|
||||
CLIPBOARD=JSON.parse(JSON.stringify(data))
|
||||
var parentContainer = container.parents('.widget, .tab, #container').first()
|
||||
parentData = getObjectData(parentContainer)
|
||||
|
||||
parentData.widgets.splice(container.index(),1)
|
||||
updateDom(parentContainer,parentData)
|
||||
}
|
||||
|
||||
if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
if (CLIPBOARD!=null) {
|
||||
actions['<i class="fa fa-paste"></i> Paste'] = {
|
||||
'<i class="fa fa-plus-circle"></i> ID + 1':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = incrementWidget(JSON.parse(JSON.stringify(CLIPBOARD)))
|
||||
|
||||
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = d.offsetY
|
||||
newData.left= d.offsetX
|
||||
} else {
|
||||
delete newData.top
|
||||
delete newData.left
|
||||
}
|
||||
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
},
|
||||
'<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 = d.offsetY
|
||||
newData.left= d.offsetX
|
||||
} else {
|
||||
delete newData.top
|
||||
delete newData.left
|
||||
}
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add widget'] = {}
|
||||
var createFunction = function(widgetType,container,data){
|
||||
return function() {
|
||||
data.widgets = data.widgets || []
|
||||
var newData = {type:widgetType}
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = d.offsetY
|
||||
newData.left= d.offsetX
|
||||
}
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
}
|
||||
}
|
||||
for (category in widgetCategories) {
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][category] = {}
|
||||
for (t in widgetCategories[category]) {
|
||||
var wtype = widgetCategories[category][t]
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][category][wtype] = createFunction(wtype,container,data)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add tab'] = function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
updateDom(container,data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-trash"></i> Delete'] = function(){
|
||||
var popup = createPopup('Are you sure ?',`
|
||||
<div class="actions">
|
||||
<a class="btn warning confirm-delete">DELETE</a>
|
||||
<a class="btn cancel-delete">CANCEL</a>
|
||||
</div>
|
||||
`)
|
||||
$('.confirm-delete').click(function(){
|
||||
popup.close()
|
||||
var parentContainer = container.parents('.widget, .tab, #container').first()
|
||||
parentData = getObjectData(parentContainer)
|
||||
|
||||
|
||||
if (type=='widget') {
|
||||
parentData.widgets.splice(container.index(),1)
|
||||
} else if (type=='tab' && parentContainer.attr('id')!='container') {
|
||||
parentData.tabs.splice(container.data('index'),1)
|
||||
} else {
|
||||
parentData.splice(container.data('index'),1)
|
||||
}
|
||||
|
||||
updateDom(parentContainer,parentData)
|
||||
})
|
||||
$('.cancel-delete').click(function(){
|
||||
popup.close()
|
||||
})
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==13) $('.confirm-delete').click()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
menu(d,actions,'body')
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
module.exports = init
|
||||
70
src/browser/js/app/editor/purge.js
Normal file
70
src/browser/js/app/editor/purge.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
module.exports = function(purgetabs) {
|
||||
|
||||
// prune tabs store
|
||||
var count, newcount, formerBuffuredTabs, bufferedTabs
|
||||
|
||||
if (purgetabs) {
|
||||
while (true) {
|
||||
// we need to do that several times since tabs are referenced in each of their parents
|
||||
|
||||
// get all buffered tabs
|
||||
formerBuffuredTabs = []
|
||||
for (i in TABS) {
|
||||
formerBuffuredTabs.push(TABS[i].tab[0])
|
||||
}
|
||||
|
||||
// remove deleted tabs that are not referenced (have no navigation link pointing to them)
|
||||
var $f = $(formerBuffuredTabs)
|
||||
for (i in TABS) {
|
||||
if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
|
||||
delete TABS[i]
|
||||
}
|
||||
}
|
||||
|
||||
newcount = Object.keys(TABS).length
|
||||
if (count == newcount) break
|
||||
count = newcount
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bufferedTabs = []
|
||||
for (i in TABS) {
|
||||
bufferedTabs.push(TABS[i].tab[0])
|
||||
}
|
||||
|
||||
// prune widget stores
|
||||
// if widgets cannot be found in buffered tabs, it must be unreferenced
|
||||
var $b = $(bufferedTabs)
|
||||
for (i in WIDGETS) {
|
||||
for (var j=WIDGETS[i].length-1;j>=0;j--) {
|
||||
if (!$b.find(WIDGETS[i][j]).length) {
|
||||
WIDGETS[i].splice(j,1)
|
||||
}
|
||||
}
|
||||
if (!WIDGETS[i].length) {
|
||||
delete WIDGETS[i]
|
||||
}
|
||||
}
|
||||
for (i in WIDGETS_LINKED) {
|
||||
for (var j=WIDGETS_LINKED[i].length-1;j>=0;j--) {
|
||||
if (!$b.find(WIDGETS_LINKED[i][j]).length) {
|
||||
WIDGETS_LINKED[i].splice(j,1)
|
||||
}
|
||||
}
|
||||
if (!WIDGETS_LINKED[i].length) {
|
||||
delete WIDGETS_LINKED[i]
|
||||
}
|
||||
}
|
||||
for (i in WIDGETS_BY_PATH) {
|
||||
for (var j=WIDGETS_BY_PATH[i].length-1;j>=0;j--) {
|
||||
if (!$b.find(WIDGETS_BY_PATH[i][j]).length) {
|
||||
WIDGETS_BY_PATH[i].splice(j,1)
|
||||
}
|
||||
}
|
||||
if (!WIDGETS_BY_PATH[i].length) {
|
||||
delete WIDGETS_BY_PATH[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/browser/js/app/init.js
Normal file
43
src/browser/js/app/init.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
var parsetabs = require('./parser').tabs,
|
||||
ui = require('./ui'),
|
||||
sync = require('./widgets').sync,
|
||||
editorDisable = require('./actions').editorDisable,
|
||||
editorInit = require('./editor/init'),
|
||||
{loading} = require('./utils')
|
||||
|
||||
module.exports = function(session,callback) {
|
||||
|
||||
$('#lobby').remove()
|
||||
$('#container').empty()
|
||||
var p = loading('Loading session file...')
|
||||
|
||||
setTimeout(function(){
|
||||
parsetabs(session,$('#container'),true)
|
||||
|
||||
// var t = $('<div></div>').appendTo('body')
|
||||
// for (id in TABS) {
|
||||
// if (id!='#container') {
|
||||
// t[0].appendChild(TABS[id].tab[0])
|
||||
// }
|
||||
// }
|
||||
// setTimeout(function(){
|
||||
// t.detach()
|
||||
// },250)
|
||||
|
||||
|
||||
ui.init()
|
||||
editorDisable()
|
||||
editorInit()
|
||||
sync()
|
||||
|
||||
|
||||
setTimeout(function(){
|
||||
p.close()
|
||||
if (!callback) return
|
||||
setTimeout(function(){
|
||||
callback()
|
||||
},25)
|
||||
},25)
|
||||
},25)
|
||||
|
||||
}
|
||||
186
src/browser/js/app/parser.js
Normal file
186
src/browser/js/app/parser.js
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
var widgets = require('./widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
createWidget = widgets.createWidget,
|
||||
icon = require('./utils').icon
|
||||
|
||||
var getIterator = function(id,type){
|
||||
var iterator = MISC.iterators[type]
|
||||
if (iterator[id]==undefined) iterator[id] = 0
|
||||
iterator[id] += 1
|
||||
return iterator[id]
|
||||
}
|
||||
|
||||
var hashCode = function(s){
|
||||
return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
|
||||
}
|
||||
|
||||
module.exports.tabs = function(data,parent,main,parentLabel){
|
||||
|
||||
if (main) {
|
||||
// Reset Globals
|
||||
WIDGETS = {}
|
||||
WIDGETS_LINKED = {}
|
||||
WIDGETS_BY_PATH = {}
|
||||
SESSION = data
|
||||
for (i in TABS) {
|
||||
if (i!='#container') {
|
||||
TABS[i].parent.remove()
|
||||
TABS[i].tab.remove()
|
||||
}
|
||||
}
|
||||
TABS['#container'] = {
|
||||
tab:$('#container')
|
||||
}
|
||||
|
||||
MISC.iterators.tab = {}
|
||||
}
|
||||
|
||||
var main = main?'main ':'',
|
||||
nav = $(document.createElement('div')).addClass(main + 'navigation'),
|
||||
navtabs = $(document.createElement('ul')).addClass('tablist'),
|
||||
content = $(document.createElement('div')).addClass('content')
|
||||
|
||||
|
||||
for (i in data) {
|
||||
var tabData = data[i]
|
||||
|
||||
|
||||
var label = tabData.label||tabData.id||'Unnamed',
|
||||
hash = hashCode(label),
|
||||
id = 'tab_'+hash+'_'+getIterator('tab'+hash,'tab')
|
||||
|
||||
tabData.label = label
|
||||
delete tabData.id
|
||||
|
||||
navtabs.append(`<li data-tab="#${id}"><a><span>${label}</span></a></li>`)
|
||||
|
||||
var tabContent = $(`<div class="tab ${tabData.tabs&&tabData.tabs.length?'has-tabs':''}" id="${id}" data-index="${i}"></div>`)
|
||||
tabContent.data(tabData)
|
||||
|
||||
|
||||
if (tabData.tabs && tabData.tabs.length) {
|
||||
module.exports.tabs(tabData.tabs,tabContent,false,label)
|
||||
} else if (tabData.widgets && tabData.widgets.length) {
|
||||
module.exports.widgets(tabData.widgets,tabContent)
|
||||
}
|
||||
|
||||
// content.append(tabContent)
|
||||
TABS['#'+id]= {
|
||||
parent:content,
|
||||
tab:tabContent,
|
||||
data:tabData
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nav[0].appendChild(navtabs[0])
|
||||
parent[0].appendChild(nav[0])
|
||||
parent[0].appendChild(content[0])
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports.widgets = function(data,parent) {
|
||||
|
||||
for (i in data) {
|
||||
var widgetData = data[i]
|
||||
|
||||
widgetData.type = widgetData.type || 'fader'
|
||||
|
||||
var tmpWidgetOptions = JSON.parse(JSON.stringify(widgetOptions))
|
||||
|
||||
for (i in tmpWidgetOptions[widgetData.type]) {
|
||||
if (i.indexOf('separator')==-1 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
|
||||
}
|
||||
|
||||
if (widgetData.id=='auto') {
|
||||
var id
|
||||
while (!id || WIDGETS[id]) {
|
||||
id=widgetData.type+'_'+getIterator(widgetData.type,'widget')
|
||||
}
|
||||
widgetData.id = id
|
||||
}
|
||||
|
||||
widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path
|
||||
widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false
|
||||
|
||||
for (i in widgetData) {
|
||||
if (widgetOptions[widgetData.type][i]===undefined && i!='type') {delete widgetData[i]}
|
||||
}
|
||||
|
||||
|
||||
for (t in {width:'',height:'',top:'',left:''}) {
|
||||
widgetData[t] = `${widgetData[t]}`.indexOf('-')!=-1?0:widgetData[t]
|
||||
}
|
||||
|
||||
if (parent.hasClass('strip')) {
|
||||
delete widgetData.top
|
||||
delete widgetData.left
|
||||
}
|
||||
|
||||
if (widgetData.preArgs!=undefined) {
|
||||
widgetData.preArgs = Array.isArray(widgetData.preArgs)?widgetData.preArgs:[widgetData.preArgs]
|
||||
}
|
||||
if (widgetData.target!=undefined) {
|
||||
widgetData.target = Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]
|
||||
}
|
||||
|
||||
var width = parseFloat(widgetData.width)==widgetData.width?parseFloat(widgetData.width)+'rem' : widgetData.width,
|
||||
height = parseFloat(widgetData.height)==widgetData.height?parseFloat(widgetData.height)+'rem' : widgetData.height,
|
||||
left = parseFloat(widgetData.left)==widgetData.left?parseFloat(widgetData.left)+'rem' : widgetData.left,
|
||||
top = parseFloat(widgetData.top)==widgetData.top?parseFloat(widgetData.top)+'rem' : widgetData.top
|
||||
|
||||
|
||||
var styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:auto;`:'',
|
||||
styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:auto;`:'',
|
||||
styleL = widgetData.left&&widgetData.left!='auto'||widgetData.left==0?`left:${left};`:'',
|
||||
styleT = widgetData.top&&widgetData.top!='auto'||widgetData.top==0?`top:${top};`:''
|
||||
|
||||
var label = widgetData.label == 'auto'?
|
||||
widgetData.id:
|
||||
typeof widgetData.label == 'string' && widgetData.label.indexOf('icon:')!=-1?
|
||||
icon(widgetData.label.split(':')[1].trim().replace('fa-','')):
|
||||
widgetData.label
|
||||
|
||||
var widgetContainer = $(`
|
||||
<div class="widget ${widgetData.type}-container ${styleL.length || styleT.length?'absolute-position':''}" style="${styleW + styleH + styleL + styleT + widgetData.css}">
|
||||
<div class="label"><span>${label}</span></div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (widgetData.color && widgetData.color!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetData.color)
|
||||
|
||||
if (widgetData.label===false) widgetContainer.addClass('nolabel')
|
||||
|
||||
// create widget
|
||||
var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
|
||||
|
||||
// store widgets target
|
||||
widgetInner.target = widgetData.target
|
||||
|
||||
widgetContainer[0].appendChild(widgetInner[0])
|
||||
|
||||
// store widget reference for cross widget sync
|
||||
if (WIDGETS[widgetData.id]==undefined) WIDGETS[widgetData.id] = []
|
||||
WIDGETS[widgetData.id].push(widgetInner)
|
||||
|
||||
// store widget with linkId for widgte linking
|
||||
if (widgetData.linkId && widgetData.linkId.length) {
|
||||
if (WIDGETS_LINKED[widgetData.linkId]==undefined) WIDGETS_LINKED[widgetData.linkId] = []
|
||||
WIDGETS_LINKED[widgetData.linkId].push(widgetInner)
|
||||
}
|
||||
|
||||
// store widget by path and encode preArgs for perfect cross-app sync
|
||||
if (widgetData.path) {
|
||||
var pathref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.path+'||||'+widgetData.preArgs.join('||||'):widgetData.path
|
||||
if (WIDGETS_BY_PATH[pathref]==undefined) WIDGETS_BY_PATH[pathref] = []
|
||||
WIDGETS_BY_PATH[pathref].push(widgetInner)
|
||||
}
|
||||
|
||||
parent[0].appendChild(widgetContainer[0])
|
||||
}
|
||||
|
||||
// Editor needs to get the container object
|
||||
if (data && data.length==1) return widgetContainer
|
||||
|
||||
}
|
||||
143
src/browser/js/app/sidepanel.js
Normal file
143
src/browser/js/app/sidepanel.js
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
var actions = require('./actions'),
|
||||
icon = require('./utils').icon
|
||||
|
||||
var data = [
|
||||
{
|
||||
actions: [
|
||||
{
|
||||
title:'Fullscreen (F11)',
|
||||
action:actions.toggleFullscreen
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
title: icon('sliders') + ' State',
|
||||
actions: [
|
||||
{
|
||||
title:'Store',
|
||||
action:actions.stateQuickSave
|
||||
},
|
||||
{
|
||||
title:'Recall',
|
||||
action:actions.stateQuickLoad,
|
||||
class:'disabled quickload'
|
||||
},
|
||||
{
|
||||
title:'Send All',
|
||||
action:actions.stateSend
|
||||
},
|
||||
{
|
||||
title:'Import',
|
||||
action:actions.stateLoad
|
||||
},
|
||||
{
|
||||
title:'Export',
|
||||
action:actions.stateSave
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: icon('magic') + ' Traversing gestures',
|
||||
actions: [
|
||||
{
|
||||
title:'On',
|
||||
action:actions.traversingEnable,
|
||||
class:'traversingEnable'
|
||||
},
|
||||
{
|
||||
title:'Off',
|
||||
action:actions.traversingDisable,
|
||||
class:'traversingDisable on'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: icon('edit') + ' Editor',
|
||||
class:'editor',
|
||||
actions: [
|
||||
{
|
||||
title:'On',
|
||||
action:actions.editorEnable,
|
||||
class:'enable-editor'
|
||||
},
|
||||
{
|
||||
title:'Off',
|
||||
action:actions.editorDisable,
|
||||
class:'on disable-editor'
|
||||
},
|
||||
{
|
||||
title:'Root',
|
||||
class:'editor-root disabled'
|
||||
},
|
||||
{
|
||||
title:'Load',
|
||||
action:actions.sessionBrowse
|
||||
},
|
||||
{
|
||||
title:'Save',
|
||||
action:actions.sessionSave
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
var sidepanel = function(data){
|
||||
|
||||
var bindAction = function(el,callback) {
|
||||
el.click(function(){callback()})
|
||||
}
|
||||
|
||||
var html = $('<ul id="options"></ul>')
|
||||
|
||||
for (i in data) {
|
||||
var itemData = data[i]
|
||||
|
||||
var item = $('<li></li>'),
|
||||
inner = $('<div></div>').appendTo(item)
|
||||
wrapper = $('<div class="actions"></div>').appendTo(inner)
|
||||
|
||||
if (itemData.title) $('<div class="title">'+itemData.title+'</div>').prependTo(wrapper)
|
||||
if (itemData.class) inner.attr('class',itemData.class)
|
||||
|
||||
for (j in itemData.actions) {
|
||||
var actionData = itemData.actions[j]
|
||||
var el = $('<a class="btn">'+actionData.title+'</a>').appendTo(wrapper)
|
||||
if (actionData.action) bindAction(el, actionData.action)
|
||||
|
||||
if (actionData.class) el.addClass(actionData.class)
|
||||
|
||||
}
|
||||
item.appendTo(html)
|
||||
|
||||
}
|
||||
|
||||
return html
|
||||
|
||||
}(data)
|
||||
|
||||
var toggle = function(){
|
||||
$(`<li><a id="open-toggle">${icon('navicon')}</a></li>`).appendTo('.navigation.main ul').click(function(e){
|
||||
var t = 0
|
||||
if (!$('#sidepanel').hasClass('sidepanel-open')) t = 250
|
||||
|
||||
$('#open-toggle, #sidepanel').toggleClass('sidepanel-open')
|
||||
setTimeout(function(){
|
||||
$('#container').toggleClass('sidepanel-open')
|
||||
$(window).resize()
|
||||
},t)
|
||||
}).on('mousedown touchstart',function(e){e.stopPropagation()})
|
||||
|
||||
// in case where are hot loading a session
|
||||
if ($('#sidepanel').hasClass('sidepanel-open')) {
|
||||
$('#open-toggle, #container').addClass('sidepanel-open')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init:function(){
|
||||
$('#sidepanel').append(sidepanel)
|
||||
toggle()
|
||||
},
|
||||
createToggle:toggle
|
||||
}
|
||||
71
src/browser/js/app/ui.js
Normal file
71
src/browser/js/app/ui.js
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
var actions = require('./actions'),
|
||||
icon = require('./utils').icon
|
||||
|
||||
var sidepanel = require('./sidepanel').init
|
||||
|
||||
// Tabs...
|
||||
var tabs = function() {
|
||||
$('#container').click(function(e){
|
||||
var link = e.target
|
||||
|
||||
if (!link.hasAttribute('data-tab') || link.classList.contains('on')) return
|
||||
|
||||
var id = link.getAttribute('data-tab')
|
||||
|
||||
link.classList.add('on')
|
||||
|
||||
var previous = $(link).siblings('.on').removeClass('on').data('tab')
|
||||
|
||||
// TABS[id].tab.appendTo(TABS[id].parent)
|
||||
TABS[id].parent[0].appendChild(TABS[id].tab[0])
|
||||
$(previous).detach()
|
||||
|
||||
|
||||
$(id).find('li[data-tab]:first-child, li.parent + li[data-tab]').each(function(){
|
||||
if (!$(this).siblings('.on').length) $(this).click()
|
||||
})
|
||||
|
||||
$(window).resize()
|
||||
|
||||
})
|
||||
$('li[data-tab]').first().click()
|
||||
}
|
||||
|
||||
// horizontal scrolling & zoom with mousewheel
|
||||
// if shift is pressed (native), or if there is no vertical scrollbar,
|
||||
// or if mouse is on h-scrollbar
|
||||
var scrollbarHeight = 20
|
||||
var scrolls = function(){
|
||||
$('html').on('mousewheel.zoom',function(e) {
|
||||
// console.log(e)
|
||||
if (e.ctrlKey) {
|
||||
e.preventDefault()
|
||||
if (e.originalEvent.deltaY==0) return
|
||||
var d = -e.originalEvent.deltaY/(10*Math.abs(e.originalEvent.deltaY))
|
||||
|
||||
PXSCALE = parseFloat(d)+parseFloat(PXSCALE)
|
||||
document.documentElement.style.setProperty("--pixel-scale",'')
|
||||
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
|
||||
|
||||
}
|
||||
})
|
||||
$(document).on('keydown.resetzoom', function(e){
|
||||
if (e.keyCode==96||e.keyCode==48) {
|
||||
PXSCALE = INITIALZOOM
|
||||
document.documentElement.style.setProperty("--pixel-scale",'')
|
||||
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
init: function(){
|
||||
sidepanel()
|
||||
tabs()
|
||||
scrolls()
|
||||
},
|
||||
tabs:tabs,
|
||||
scrolls:scrolls
|
||||
}
|
||||
46
src/browser/js/app/utils.js
Normal file
46
src/browser/js/app/utils.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
module.exports = {
|
||||
|
||||
createPopup: function(title,content,closable) {
|
||||
|
||||
var popup = $(`
|
||||
<div class="popup">
|
||||
<div class="popup-wrapper">
|
||||
<div class="popup-title">${title}<span class="closer">${module.exports.icon('remove')}</span></div>
|
||||
<div class="popup-content"></div>
|
||||
</div>
|
||||
</div>`),
|
||||
closer = popup.find('.popup-title .closer')
|
||||
|
||||
if (closable) {
|
||||
closer.click(function(){
|
||||
popup.close()
|
||||
})
|
||||
} else {
|
||||
closer.remove()
|
||||
}
|
||||
|
||||
|
||||
popup.close = function(){
|
||||
$(document).off('.popup')
|
||||
popup.remove()
|
||||
}
|
||||
|
||||
popup.find('.popup-content').append(content)
|
||||
$('body').append(popup)
|
||||
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==27) popup.close()
|
||||
})
|
||||
|
||||
|
||||
|
||||
return popup
|
||||
},
|
||||
loading: function(title){
|
||||
return module.exports.createPopup(title,'<p><div class="spinner"></div></p>', false)
|
||||
},
|
||||
icon: function(i) {
|
||||
return `<i class="fa fa-fw fa-${i}"></i>`
|
||||
}
|
||||
|
||||
}
|
||||
82
src/browser/js/app/widgets.js
Normal file
82
src/browser/js/app/widgets.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
var widgets = {
|
||||
// sliders
|
||||
fader: require('./widgets/sliders/fader'),
|
||||
knob: require('./widgets/sliders/knob'),
|
||||
|
||||
// buttons
|
||||
toggle: require('./widgets/toggle'),
|
||||
switch: require('./widgets/switch'),
|
||||
push: require('./widgets/push'),
|
||||
|
||||
// pads
|
||||
xy: require('./widgets/xy'),
|
||||
rgb: require('./widgets/rgb'),
|
||||
|
||||
// matrices
|
||||
multitoggle: require('./widgets/matrices/multitoggle'),
|
||||
multipush: require('./widgets/matrices/multipush'),
|
||||
multifader: require('./widgets/matrices/multifader'),
|
||||
|
||||
// plots
|
||||
led: require('./widgets/plots/led'),
|
||||
plot: require('./widgets/plots/plot'),
|
||||
eq: require('./widgets/plots/eq'),
|
||||
visualizer: require('./widgets/plots/visualizer'),
|
||||
meter: require('./widgets/plots/meter'),
|
||||
text: require('./widgets/plots/text'),
|
||||
|
||||
// containers
|
||||
strip: require('./widgets/strip'),
|
||||
panel: require('./widgets/panel'),
|
||||
}
|
||||
|
||||
module.exports.categories = {
|
||||
'Sliders':['fader','knob'],
|
||||
'Buttons':['toggle','push','switch'],
|
||||
'Pads':['xy','rgb'],
|
||||
'Matrices':['multifader','multitoggle','multipush'],
|
||||
'Plots':['plot','eq','visualizer','led','meter','text'],
|
||||
'Containers':['panel','strip']
|
||||
}
|
||||
|
||||
module.exports.widgetOptions = function(){
|
||||
var r = {}
|
||||
for (i in widgets) {
|
||||
r[i] = widgets[i].options
|
||||
}
|
||||
return r
|
||||
}()
|
||||
|
||||
module.exports.createWidget = function(){
|
||||
var r = {}
|
||||
for (i in widgets) {
|
||||
r[i] = widgets[i].create
|
||||
}
|
||||
return r
|
||||
}()
|
||||
|
||||
module.exports.sync = function() {
|
||||
$('body').off('sync.global').on('sync.global',function(e){
|
||||
var {id, widget, linkId, fromExternal, options} = e
|
||||
// Widget that share the same id will update each other
|
||||
// without sending any extra osc message
|
||||
if (WIDGETS[id] && WIDGETS[id].length>1) {
|
||||
var v = widget.getValue()
|
||||
for (i in WIDGETS[id]) {
|
||||
if (!WIDGETS[id][i].is(widget) && WIDGETS[id][i].setValue) {
|
||||
WIDGETS[id][i].setValue(v,{send:false,sync:false})
|
||||
}
|
||||
}
|
||||
}
|
||||
// widgets that share the same linkId will update each other.
|
||||
// Updated widgets will send osc messages normally
|
||||
if (WIDGETS_LINKED[linkId] && WIDGETS_LINKED[linkId].length>1) {
|
||||
var v = widget.getValue()
|
||||
for (i in WIDGETS_LINKED[linkId]) {
|
||||
if (!WIDGETS_LINKED[linkId][i].is(widget) && WIDGETS_LINKED[linkId][i].setValue) {
|
||||
WIDGETS_LINKED[linkId][i].setValue(v,{send:options.send,sync:false})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
63
src/browser/js/app/widgets/common/_canvas_base.js
Normal file
63
src/browser/js/app/widgets/common/_canvas_base.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
var _widgets_base = require('./_widgets_base')
|
||||
|
||||
var _canvas_base = module.exports = function() {
|
||||
|
||||
_widgets_base.apply(this,arguments)
|
||||
|
||||
this.canvas = this.widget.find('canvas')
|
||||
this.ctx = this.canvas[0].getContext('2d')
|
||||
|
||||
this.height = undefined
|
||||
this.width = undefined
|
||||
|
||||
this.visible = false
|
||||
|
||||
this.colors = {}
|
||||
this.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
|
||||
|
||||
|
||||
this.canvas.resize(this.resizeHandleProxy.bind(this))
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
_canvas_base.prototype = Object.create(_widgets_base.prototype)
|
||||
|
||||
_canvas_base.prototype.constructor = _canvas_base
|
||||
|
||||
_canvas_base.prototype.resizeHandleProxy = function() {
|
||||
this.resizeHandle.apply(this,arguments)
|
||||
}
|
||||
|
||||
_canvas_base.prototype.resizeHandle = function(){
|
||||
|
||||
var width = this.canvas.width(),
|
||||
height = this.canvas.height()
|
||||
|
||||
if (height==100 && width==100) return
|
||||
|
||||
|
||||
this.height=height
|
||||
this.width=width
|
||||
|
||||
this.canvas[0].setAttribute('width',width)
|
||||
this.canvas[0].setAttribute('height',height)
|
||||
|
||||
if (!self.visible) {
|
||||
this.visible = true
|
||||
this.colors.custom = getComputedStyle(this.widget[0]).getPropertyValue('--color-custom')
|
||||
this.colors.text = getComputedStyle(this.widget[0]).getPropertyValue('--color-text')
|
||||
this.colors.raised = getComputedStyle(this.widget[0]).getPropertyValue('--color-raised')
|
||||
this.colors.bg = getComputedStyle(this.widget[0]).getPropertyValue('--color-bg')
|
||||
this.colors.fg = getComputedStyle(this.widget[0]).getPropertyValue('--color-fg')
|
||||
this.colors.faded = getComputedStyle(this.widget[0]).getPropertyValue('--color-faded')
|
||||
}
|
||||
|
||||
requestAnimationFrame(this.draw.bind(this))
|
||||
|
||||
}
|
||||
|
||||
_canvas_base.prototype.draw = function(){
|
||||
//
|
||||
}
|
||||
3
src/browser/js/app/widgets/common/_widgets_base.js
Normal file
3
src/browser/js/app/widgets/common/_widgets_base.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var _widget_base = module.exports = function(widgetData) {
|
||||
this.widgetData = widgetData
|
||||
}
|
||||
36
src/browser/js/app/widgets/matrices/_matrices_base.js
Normal file
36
src/browser/js/app/widgets/matrices/_matrices_base.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
var _widgets_base = require('../common/_widgets_base')
|
||||
|
||||
var _matrices_base = module.exports = function(widgetData){
|
||||
|
||||
_widgets_base.apply(this,arguments)
|
||||
|
||||
this.widget = $(`
|
||||
<div class="matrix">
|
||||
</div>\
|
||||
`)
|
||||
this.value = []
|
||||
|
||||
this.widget.getValue = function(){
|
||||
console.log(this.value)
|
||||
return this.value
|
||||
}.bind(this)
|
||||
|
||||
this.widget.on('sync',function(e){
|
||||
if (e.id==this.widgetData.id) return
|
||||
this.value[e.widget.parent().index()] = e.widget.getValue()
|
||||
this.widget.trigger({type:'sync',id:this.widgetData.id,widget:this.widget})
|
||||
}.bind(this))
|
||||
|
||||
this.widget.enableTraversingGestures()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
_matrices_base.prototype = Object.create(_widgets_base.prototype)
|
||||
|
||||
_matrices_base.prototype.constructor = _matrices_base
|
||||
|
||||
_matrices_base.prototype.getValue = function(){
|
||||
return this.value
|
||||
}
|
||||
72
src/browser/js/app/widgets/matrices/multifader.js
Normal file
72
src/browser/js/app/widgets/matrices/multifader.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
var _matrices_base = require('./_matrices_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'multifader',
|
||||
id:'auto',
|
||||
|
||||
separator0:'Matrix',
|
||||
|
||||
strips:2,
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
compact:false,
|
||||
css:'',
|
||||
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
|
||||
var Multifader = function(widgetData) {
|
||||
|
||||
_matrices_base.apply(this,arguments)
|
||||
|
||||
for (var i=0;i<widgetData.strips;i++) {
|
||||
var data = {
|
||||
type:'fader',
|
||||
id: widgetData.id + '/' + i,
|
||||
label:i,
|
||||
horizontal:false,
|
||||
snap:true,
|
||||
range:widgetData.range,
|
||||
logScale:widgetData.logScale,
|
||||
precision:widgetData.precision,
|
||||
path:widgetData.path + '/' + i,
|
||||
preArgs:widgetData.preArgs,
|
||||
target:widgetData.target,
|
||||
noPip:true,
|
||||
compact:widgetData.compact
|
||||
}
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].setAttribute('style',`width:${100/widgetData.strips}%`)
|
||||
element[0].classList.add('not-editable')
|
||||
element.find('.fader-wrapper').off('drag')
|
||||
|
||||
this.value[i] = widgetData.range.min
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Multifader.prototype = Object.create(_matrices_base.prototype)
|
||||
|
||||
Multifader.prototype.constructor = Multifader
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var multifader = new Multifader(widgetData)
|
||||
return multifader.widget
|
||||
}
|
||||
65
src/browser/js/app/widgets/matrices/multipush.js
Normal file
65
src/browser/js/app/widgets/matrices/multipush.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
var _matrices_base = require('./_matrices_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'multipush',
|
||||
id:'auto',
|
||||
|
||||
separator0: 'Matrix',
|
||||
|
||||
matrix: [2,2],
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
|
||||
var Multipush = function(widgetData) {
|
||||
|
||||
_matrices_base.apply(this,arguments)
|
||||
|
||||
for (var i=0;i<widgetData.matrix[0]*widgetData.matrix[1];i++) {
|
||||
var data = {
|
||||
type:'push',
|
||||
id: widgetData.id + '/' + i,
|
||||
label:i,
|
||||
on:widgetData.on,
|
||||
off:widgetData.off,
|
||||
precision:widgetData.precision,
|
||||
path:widgetData.path + '/' + i,
|
||||
preArgs:widgetData.preArgs,
|
||||
target:widgetData.target
|
||||
}
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`)
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
this.value[i] = widgetData.off
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Multipush.prototype = Object.create(_matrices_base.prototype)
|
||||
|
||||
Multipush.prototype.constructor = Multipush
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var multipush = new Multipush(widgetData)
|
||||
return multipush.widget
|
||||
}
|
||||
64
src/browser/js/app/widgets/matrices/multitoggle.js
Normal file
64
src/browser/js/app/widgets/matrices/multitoggle.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
var _matrices_base = require('./_matrices_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'multitoggle',
|
||||
id:'auto',
|
||||
|
||||
separator0: 'Matrix',
|
||||
|
||||
matrix: [2,2],
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
var Multitoggle = function(widgetData) {
|
||||
|
||||
_matrices_base.apply(this,arguments)
|
||||
|
||||
for (var i=0;i<widgetData.matrix[0]*widgetData.matrix[1];i++) {
|
||||
var data = {
|
||||
type:'toggle',
|
||||
id: widgetData.id + '/' + i,
|
||||
label:i,
|
||||
on:widgetData.on,
|
||||
off:widgetData.off,
|
||||
precision:widgetData.precision,
|
||||
path:widgetData.path + '/' + i,
|
||||
preArgs:widgetData.preArgs,
|
||||
target:widgetData.target
|
||||
}
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`)
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
this.value[i] = widgetData.off
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Multitoggle.prototype = Object.create(_matrices_base.prototype)
|
||||
|
||||
Multitoggle.prototype.constructor = Multitoggle
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var multitoggle = new Multitoggle(widgetData)
|
||||
return multitoggle.widget
|
||||
}
|
||||
41
src/browser/js/app/widgets/panel.js
Normal file
41
src/browser/js/app/widgets/panel.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
module.exports.options = {
|
||||
type:'panel',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
scroll:true,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'chilren',
|
||||
|
||||
widgets:[],
|
||||
tabs:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parser = require('../parser'),
|
||||
parsewidgets = parser.widgets,
|
||||
parsetabs = parser.tabs
|
||||
|
||||
var widget = $(`
|
||||
<div class="panel">
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (!widgetData.scroll) widget.addClass('noscroll')
|
||||
|
||||
if (widgetData.tabs.length) {
|
||||
parsetabs(widgetData.tabs,widget)
|
||||
widget.addClass('has-tabs')
|
||||
} else {
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
}
|
||||
return widget
|
||||
}
|
||||
137
src/browser/js/app/widgets/plots/_biquad_response.js
Normal file
137
src/browser/js/app/widgets/plots/_biquad_response.js
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
//
|
||||
// calcBiquad
|
||||
//
|
||||
// Dec 14, 2010 njr
|
||||
// original @ Nigel Redmon
|
||||
|
||||
module.exports = function(options,linear,resolution) {
|
||||
var {type, freq, q, gain} = options,
|
||||
Fs = 44100,
|
||||
a0,a1,a2,b1,b2,norm,
|
||||
ymin, ymax, minVal, maxVal,
|
||||
len = resolution
|
||||
|
||||
var V = Math.pow(10, Math.abs(gain) / 20)
|
||||
var K = Math.tan(Math.PI * freq / Fs)
|
||||
switch (type) {
|
||||
case "lowpass":
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = K * K * norm
|
||||
a1 = 2 * a0
|
||||
a2 = a0
|
||||
b1 = 2 * (K * K - 1) * norm
|
||||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "highpass":
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = 1 * norm
|
||||
a1 = -2 * a0
|
||||
a2 = a0
|
||||
b1 = 2 * (K * K - 1) * norm
|
||||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "bandpass":
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = K / q * norm
|
||||
a1 = 0
|
||||
a2 = -a0
|
||||
b1 = 2 * (K * K - 1) * norm
|
||||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "notch":
|
||||
norm = 1 / (1 + K / q + K * K)
|
||||
a0 = (1 + K * K) * norm
|
||||
a1 = 2 * (K * K - 1) * norm
|
||||
a2 = a0
|
||||
b1 = a1
|
||||
b2 = (1 - K / q + K * K) * norm
|
||||
break
|
||||
|
||||
case "peak":
|
||||
if (gain >= 0) {
|
||||
norm = 1 / (1 + 1/q * K + K * K)
|
||||
a0 = (1 + V/q * K + K * K) * norm
|
||||
a1 = 2 * (K * K - 1) * norm
|
||||
a2 = (1 - V/q * K + K * K) * norm
|
||||
b1 = a1
|
||||
b2 = (1 - 1/q * K + K * K) * norm
|
||||
}
|
||||
else {
|
||||
norm = 1 / (1 + V/q * K + K * K)
|
||||
a0 = (1 + 1/q * K + K * K) * norm
|
||||
a1 = 2 * (K * K - 1) * norm
|
||||
a2 = (1 - 1/q * K + K * K) * norm
|
||||
b1 = a1
|
||||
b2 = (1 - V/q * K + K * K) * norm
|
||||
}
|
||||
break
|
||||
case "lowshelf":
|
||||
if (gain >= 0) {
|
||||
norm = 1 / (1 + Math.SQRT2 * K + K * K)
|
||||
a0 = (1 + Math.sqrt(2*V) * K + V * K * K) * norm
|
||||
a1 = 2 * (V * K * K - 1) * norm
|
||||
a2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
|
||||
b1 = 2 * (K * K - 1) * norm
|
||||
b2 = (1 - Math.SQRT2 * K + K * K) * norm
|
||||
}
|
||||
else {
|
||||
norm = 1 / (1 + Math.sqrt(2*V) * K + V * K * K)
|
||||
a0 = (1 + Math.SQRT2 * K + K * K) * norm
|
||||
a1 = 2 * (K * K - 1) * norm
|
||||
a2 = (1 - Math.SQRT2 * K + K * K) * norm
|
||||
b1 = 2 * (V * K * K - 1) * norm
|
||||
b2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
|
||||
}
|
||||
break
|
||||
case "highshelf":
|
||||
if (gain >= 0) {
|
||||
norm = 1 / (1 + Math.SQRT2 * K + K * K)
|
||||
a0 = (V + Math.sqrt(2*V) * K + K * K) * norm
|
||||
a1 = 2 * (K * K - V) * norm
|
||||
a2 = (V - Math.sqrt(2*V) * K + K * K) * norm
|
||||
b1 = 2 * (K * K - 1) * norm
|
||||
b2 = (1 - Math.SQRT2 * K + K * K) * norm
|
||||
}
|
||||
else {
|
||||
norm = 1 / (V + Math.sqrt(2*V) * K + K * K)
|
||||
a0 = (1 + Math.SQRT2 * K + K * K) * norm
|
||||
a1 = 2 * (K * K - 1) * norm
|
||||
a2 = (1 - Math.SQRT2 * K + K * K) * norm
|
||||
b1 = 2 * (K * K - V) * norm
|
||||
b2 = (V - Math.sqrt(2*V) * K + K * K) * norm
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
var magPlot = []
|
||||
for (var i = 0; i < len; i++) {
|
||||
var w, phi, y
|
||||
if (linear)
|
||||
w = i / (len - 1) * Math.PI; // 0 to pi, linear scale
|
||||
else
|
||||
w = Math.exp(Math.log(1 / 0.001) * i / (len - 1)) * 0.001 * Math.PI; // 0.001 to 1, times pi, log scale
|
||||
|
||||
phi = Math.pow(Math.sin(w/2), 2)
|
||||
|
||||
y = Math.log(Math.pow(a0+a1+a2, 2) - 4*(a0*a1 + 4*a0*a2 + a1*a2)*phi + 16*a0*a2*phi*phi) - Math.log(Math.pow(1+b1+b2, 2) - 4*(b1 + 4*b2 + b1*b2)*phi + 16*b2*phi*phi)
|
||||
y = y * 10 / Math.LN10
|
||||
if (y == -Infinity) y = -200
|
||||
|
||||
if (linear)
|
||||
magPlot.push([i / (len - 1) * Fs / 2, y])
|
||||
else
|
||||
magPlot.push([i / (len - 1) * Fs / 2, y])
|
||||
|
||||
if (i == 0)
|
||||
minVal = maxVal = y
|
||||
else if (y < minVal)
|
||||
minVal = y
|
||||
else if (y > maxVal)
|
||||
maxVal = y
|
||||
}
|
||||
|
||||
return magPlot
|
||||
}
|
||||
126
src/browser/js/app/widgets/plots/_plots_base.js
Normal file
126
src/browser/js/app/widgets/plots/_plots_base.js
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
_canvas_base = require('../common/_canvas_base')
|
||||
|
||||
var _plots_base = module.exports = function(){
|
||||
|
||||
this.widget = $(`
|
||||
<div class="plot">
|
||||
<canvas></canvas>
|
||||
</div>
|
||||
`)
|
||||
|
||||
_canvas_base.apply(this,arguments)
|
||||
|
||||
this.data = []
|
||||
this.linkedWidgets = []
|
||||
this.rangeX = this.widgetData.rangeX || {min:0,max:1}
|
||||
this.rangeY = this.widgetData.rangeY || {min:0,max:1}
|
||||
this.pips = {
|
||||
x : {
|
||||
min: Math.abs(this.rangeX.min)>=1000?this.rangeY.min/1000+'k':this.rangeX.min,
|
||||
max: Math.abs(this.rangeX.max)>=1000?this.rangeY.max/1000+'k':this.rangeX.max
|
||||
},
|
||||
y : {
|
||||
min: Math.abs(this.rangeY.min)>=1000?this.rangeY.min/1000+'k':this.rangeY.min,
|
||||
max: Math.abs(this.rangeY.max)>=1000?this.rangeY.max/1000+'k':this.rangeY.max
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('body').on('sync',this.syncHandleProxy.bind(this))
|
||||
|
||||
}
|
||||
|
||||
_plots_base.prototype = Object.create(_canvas_base.prototype)
|
||||
|
||||
_plots_base.prototype.constructor = _plots_base
|
||||
|
||||
_plots_base.prototype.syncHandleProxy = function() {
|
||||
this.syncHandle.apply(this,arguments)
|
||||
}
|
||||
|
||||
_plots_base.prototype.syncHandle = function(e) {
|
||||
if (this.linkedWidgets.indexOf(e.id)==-1 || !WIDGETS[e.id]) return
|
||||
this.updateData()
|
||||
requestAnimationFrame(this.draw.bind(this))
|
||||
}
|
||||
|
||||
_plots_base.prototype.resizeHandle = function(){
|
||||
this.updateData()
|
||||
_canvas_base.prototype.resizeHandle.call(this)
|
||||
}
|
||||
|
||||
_plots_base.prototype.draw = function() {
|
||||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
this.ctx.beginPath()
|
||||
|
||||
this.draw_data()
|
||||
|
||||
this.ctx.lineWidth = 1*PXSCALE
|
||||
this.ctx.strokeStyle = this.colors.custom
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.font = PXSCALE * 10 + 'px sans-serif'
|
||||
this.ctx.fillStyle = this.colors.text
|
||||
|
||||
|
||||
this.ctx.textBaseline = "bottom"
|
||||
this.ctx.textAlign = 'left'
|
||||
this.ctx.fillText(this.pips.x.min,12*PXSCALE,this.height)
|
||||
this.ctx.textAlign = 'right'
|
||||
this.ctx.fillText(this.pips.x.max,this.width-10,this.height)
|
||||
|
||||
this.ctx.save()
|
||||
this.ctx.translate(0, this.height)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
|
||||
this.ctx.textBaseline = "top"
|
||||
this.ctx.textAlign = 'left'
|
||||
this.ctx.fillText(this.pips.y.min,12*PXSCALE,2*PXSCALE)
|
||||
this.ctx.textAlign = 'right'
|
||||
this.ctx.fillText(this.pips.y.max,this.height-10*PXSCALE,2*PXSCALE)
|
||||
this.ctx.rotate(Math.PI/2)
|
||||
this.ctx.restore()
|
||||
|
||||
}
|
||||
|
||||
_plots_base.prototype.draw_data = function() {
|
||||
var first = true
|
||||
var point = []
|
||||
for (i in this.data) {
|
||||
|
||||
if (this.data[i][1]>this.rangeY.max || this.data[i][1]<this.rangeY.min ||
|
||||
this.data[i][0]>this.rangeX.max || this.data[i][0]<this.rangeX.min) continue
|
||||
|
||||
var newpoint = this.data[i].length?
|
||||
[
|
||||
mapToScale(this.data[i][0],[this.rangeX.min,this.rangeX.max],[15*PXSCALE,this.width-15*PXSCALE],0,this.widgetData.logScaleX,true),
|
||||
mapToScale(this.data[i][1],[this.rangeY.min,this.rangeY.max],[this.height-15*PXSCALE,15*PXSCALE],0,this.widgetData.logScaleY,true),
|
||||
]
|
||||
:
|
||||
[
|
||||
mapToScale(i,[0,this.data.length-1],[15*PXSCALE,this.width-15*PXSCALE],0,this.widgetData.logScaleX,true),
|
||||
mapToScale(this.data[i],[this.rangeY.min,this.rangeY.max],[this.height-15*PXSCALE,15*PXSCALE],0,this.widgetData.logScaleY,true),
|
||||
]
|
||||
|
||||
|
||||
if (first) {
|
||||
this.ctx.moveTo(newpoint[0],newpoint[1])
|
||||
first = false
|
||||
} else {
|
||||
this.ctx.moveTo(point[0],point[1])
|
||||
this.ctx.lineTo(newpoint[0],newpoint[1])
|
||||
}
|
||||
point = newpoint
|
||||
}
|
||||
}
|
||||
|
||||
_plots_base.prototype.setValue = function(v) {
|
||||
this.data = v
|
||||
requestAnimationFrame(this.draw.bind(this))
|
||||
}
|
||||
|
||||
_plots_base.prototype.updateData = function(){
|
||||
// update the coordinates to draw
|
||||
}
|
||||
112
src/browser/js/app/widgets/plots/eq.js
Normal file
112
src/browser/js/app/widgets/plots/eq.js
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
var {mapToScale, clip} = require('../utils'),
|
||||
_biquad_response = require('./_biquad_response'),
|
||||
_plots_base = require('./_plots_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'eq',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'plot',
|
||||
|
||||
filters:[],
|
||||
resolution:128,
|
||||
rangeY: {min:-20,max:20},
|
||||
logScaleX: false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
|
||||
}
|
||||
|
||||
var Eq = function(widgetData) {
|
||||
|
||||
_plots_base.call(this,widgetData)
|
||||
|
||||
this.rangeX = {min:20,max:22050}
|
||||
this.pips.x.min = '20'
|
||||
this.pips.x.max = '22k'
|
||||
|
||||
widgetData.resolution = clip(widgetData.resolution,[64,1024])
|
||||
|
||||
for (i in widgetData.filters) {
|
||||
|
||||
for (j in widgetData.filters[i]) {
|
||||
if (typeof widgetData.filters[i][j]=='string' && !(j=='type' && widgetData.filters[i][j].match(/peak|notch|highpass|highshelf|lowpass|lowshelf/))) {
|
||||
this.linkedWidgets.push(widgetData.filters[i][j])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Eq.prototype = Object.create(_plots_base.prototype)
|
||||
|
||||
Eq.prototype.constructor = Eq
|
||||
|
||||
|
||||
Eq.prototype.updateData = function(){
|
||||
var filters = [],
|
||||
eqResponse = []
|
||||
|
||||
|
||||
for (i in this.widgetData.filters) {
|
||||
var filter = this.widgetData.filters[i]
|
||||
|
||||
filters[i] = {}
|
||||
|
||||
for (j in filter) {
|
||||
|
||||
if (typeof filter[j]=='string' && WIDGETS[filter[j]]) {
|
||||
|
||||
filters[i][j] = WIDGETS[filter[j]][WIDGETS[filter[j]].length-1].getValue()
|
||||
|
||||
} else {
|
||||
|
||||
filters[i][j] = filter[j]
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (i in filters) {
|
||||
|
||||
var filterResponse
|
||||
|
||||
if (!filters[i].type) filters[i].type = "peak"
|
||||
|
||||
if (!filters[i].on) {
|
||||
filterResponse = _biquad_response({type:"peak",freq:1,gain:0,q:1},!this.widgetData.logScaleX,this.widgetData.resolution)
|
||||
} else {
|
||||
filterResponse = _biquad_response(filters[i],!this.widgetData.logScaleX,this.widgetData.resolution)
|
||||
}
|
||||
for (k in filterResponse) {
|
||||
if (eqResponse[k]===undefined) {
|
||||
eqResponse[k]=[0,0]
|
||||
}
|
||||
|
||||
eqResponse[k] = [filterResponse[k][0], eqResponse[k][1]+filterResponse[k][1]]
|
||||
}
|
||||
}
|
||||
if (eqResponse.length) this.data = eqResponse
|
||||
|
||||
}
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var eq = new Eq(widgetData)
|
||||
return eq.widget
|
||||
}
|
||||
41
src/browser/js/app/widgets/plots/led.js
Normal file
41
src/browser/js/app/widgets/plots/led.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
var {mapToScale} = require('../utils')
|
||||
|
||||
module.exports.options = {
|
||||
type:'led',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
preArgs:[],
|
||||
path:'auto'
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="led">
|
||||
<div><span></span></div>
|
||||
</div>
|
||||
`),
|
||||
led = widget.find('span'),
|
||||
range = widgetData.range
|
||||
|
||||
widget.setValue = function(v){
|
||||
if (typeof v != 'number') return
|
||||
led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision,widgetData.logScale,true))
|
||||
}
|
||||
|
||||
widget.setValue(range.min)
|
||||
|
||||
return widget
|
||||
}
|
||||
85
src/browser/js/app/widgets/plots/meter.js
Normal file
85
src/browser/js/app/widgets/plots/meter.js
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
var {mapToScale, clip} = require('../utils')
|
||||
|
||||
module.exports.options = {
|
||||
type:'fader',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
path:'auto',
|
||||
preArgs:[]
|
||||
}
|
||||
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="meter">
|
||||
<div class="level"></div>
|
||||
</div>
|
||||
`),
|
||||
level = widget.find('.level'),
|
||||
logScale = widgetData.logScale,
|
||||
dimension = widgetData.horizontal?'width':'height',
|
||||
axe = dimension=='height'?'X':'Y'
|
||||
|
||||
|
||||
if (widgetData.horizontal) widget.addClass('horizontal')
|
||||
|
||||
|
||||
var rangeKeys = [],
|
||||
rangeVals = []
|
||||
|
||||
for (k in widgetData.range) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof widgetData.range[k] == 'object'?
|
||||
widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
|
||||
widgetData.range[k]
|
||||
|
||||
rangeKeys.push(key)
|
||||
rangeVals.push(val)
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.updateUi = function(v){
|
||||
var s = v/100,
|
||||
t = dimension=='height'?
|
||||
'1,'+s+',1'
|
||||
:s+',1,1'
|
||||
level[0].setAttribute('style','transform:scale3d('+t+')')
|
||||
}
|
||||
|
||||
|
||||
widget.setValue = function(v) {
|
||||
if (typeof v != 'number') return
|
||||
|
||||
var h,
|
||||
v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
|
||||
for (var i=0;i<rangeVals.length-1;i++) {
|
||||
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
|
||||
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],2,logScale,true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
widget.updateUi(h)
|
||||
|
||||
}
|
||||
|
||||
widget.setValue(rangeVals[0])
|
||||
|
||||
return widget
|
||||
}
|
||||
88
src/browser/js/app/widgets/plots/plot.js
Normal file
88
src/browser/js/app/widgets/plots/plot.js
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
_plots_base = require('./_plots_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'plot',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'plot',
|
||||
|
||||
points:[],
|
||||
rangeX: {min:0,max:1},
|
||||
rangeY: {min:0,max:1},
|
||||
logScaleX: false,
|
||||
logScaleY: false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
|
||||
}
|
||||
|
||||
var Plot = function(widgetData) {
|
||||
|
||||
_plots_base.call(this,widgetData)
|
||||
|
||||
if (typeof widgetData.points=='string') {
|
||||
|
||||
this.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') {
|
||||
this.linkedWidgets.push(widgetData.points[i][j])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.updateData = function(){
|
||||
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.length) this.data = data
|
||||
}
|
||||
}
|
||||
|
||||
Plot.prototype = Object.create(_plots_base.prototype)
|
||||
|
||||
Plot.prototype.constructor = Plot
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var plot = new Plot(widgetData)
|
||||
return plot.widget
|
||||
}
|
||||
51
src/browser/js/app/widgets/plots/text.js
Normal file
51
src/browser/js/app/widgets/plots/text.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
module.exports.options = {
|
||||
type:'text',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
vertical:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
preArgs:[],
|
||||
path:'auto',
|
||||
defaultText:''
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="text">
|
||||
</div>
|
||||
`),
|
||||
label = widgetData.defaultText!==''?
|
||||
widgetData.defaultText:
|
||||
widgetData.label===false?
|
||||
widgetData.id:
|
||||
widgetData.label=='auto'?
|
||||
widgetData.id:
|
||||
widgetData.label,
|
||||
text = label
|
||||
|
||||
|
||||
if (widgetData.vertical) widget.addClass('vertical')
|
||||
|
||||
widget.setValue = function(v){
|
||||
text = typeof v=='object' && !v.length?label:v
|
||||
widget.text(text)
|
||||
}
|
||||
|
||||
widget.getValue = function(){
|
||||
return text
|
||||
}
|
||||
|
||||
widget.setValue(label)
|
||||
|
||||
return widget
|
||||
}
|
||||
126
src/browser/js/app/widgets/plots/visualizer.js
Normal file
126
src/browser/js/app/widgets/plots/visualizer.js
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
var {mapToScale, clip} = require('../utils'),
|
||||
_plots_base = require('./_plots_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'visualizer',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'plot',
|
||||
|
||||
widgetId:'',
|
||||
duration:1,
|
||||
range: {min:0,max:1},
|
||||
logScale: false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
}
|
||||
|
||||
var Visualizer = function(widgetData) {
|
||||
|
||||
_plots_base.call(this,widgetData)
|
||||
|
||||
this.pips.y.min = Math.abs(widgetData.range.min)>=1000?widgetData.range.min/1000+'k':widgetData.range.min
|
||||
this.pips.y.max = Math.abs(widgetData.range.max)>=1000?widgetData.range.max/1000+'k':widgetData.range.max
|
||||
this.pips.x.min = ''
|
||||
this.pips.x.max = ''
|
||||
this.length = Math.round(clip(60*widgetData.duration,[8,4096]))
|
||||
this.data = new Array(this.length)
|
||||
this.value = widgetData.range.min
|
||||
this.cancel = false
|
||||
this.loop = false
|
||||
|
||||
}
|
||||
|
||||
Visualizer.prototype = Object.create(_plots_base.prototype)
|
||||
|
||||
Visualizer.prototype.constructor = Visualizer
|
||||
|
||||
Visualizer.prototype.syncHandle = function(e) {
|
||||
if (this.widgetData.widgetId!=e.id || !WIDGETS[e.id]) return
|
||||
this.startLoop()
|
||||
}
|
||||
|
||||
Visualizer.prototype.startLoop = function(){
|
||||
|
||||
if (this.cancel) clearTimeout(this.cancel)
|
||||
|
||||
this.cancel = setTimeout(function(){
|
||||
clearInterval(this.loop)
|
||||
this.loop = false
|
||||
this.cancel = false
|
||||
},1000*this.widgetData.duration)
|
||||
|
||||
if (this.loop) return
|
||||
|
||||
this.loop = setInterval(function(){
|
||||
this.updateData()
|
||||
this.draw()
|
||||
}.bind(this),1000*this.widgetData.duration/this.length)
|
||||
}
|
||||
|
||||
|
||||
Visualizer.prototype.draw_data = function(){
|
||||
|
||||
var first = true
|
||||
var point = []
|
||||
|
||||
for (var i=this.length-1;i>=0;i=i-1) {
|
||||
var newpoint = [
|
||||
mapToScale(i,[0,this.length-1],[15*PXSCALE,this.width-15*PXSCALE],1),
|
||||
mapToScale(this.data[i],[this.widgetData.range.min,this.widgetData.range.max],[this.height-15*PXSCALE,15*PXSCALE],1,this.widgetData.logScale,true),
|
||||
]
|
||||
if (first) {
|
||||
this.ctx.moveTo(newpoint[0],newpoint[1])
|
||||
first = false
|
||||
} else {
|
||||
if (this.widgetData.logScale) {
|
||||
this.ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
|
||||
} else {
|
||||
this.ctx.lineTo(newpoint[0],newpoint[1])
|
||||
}
|
||||
|
||||
}
|
||||
point = newpoint
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Visualizer.prototype.updateData = function(){
|
||||
var id = this.widgetData.widgetId
|
||||
|
||||
if (typeof id == 'string' && WIDGETS[id]) {
|
||||
var v = WIDGETS[id][WIDGETS[id].length-1].getValue()
|
||||
this.data.push(v)
|
||||
this.value = v
|
||||
} else {
|
||||
this.data.push(this.value)
|
||||
}
|
||||
|
||||
this.data.splice(0,1)
|
||||
|
||||
}
|
||||
|
||||
Visualizer.prototype.setValue = function(v) {
|
||||
this.value = v
|
||||
this.startLoop()
|
||||
}
|
||||
|
||||
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var visualizer = new Visualizer(widgetData)
|
||||
return visualizer.widget
|
||||
}
|
||||
115
src/browser/js/app/widgets/push.js
Normal file
115
src/browser/js/app/widgets/push.js
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
var sendOsc = require('./utils').sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'push',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
norelease:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
|
||||
var widget = $(`
|
||||
<div class="light">
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = widget.find('span')
|
||||
widget.state = 0
|
||||
widget.active = 0
|
||||
widget.lastChanged = 'state'
|
||||
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
if (!widget.active) widget.setValuePrivate(widgetData.on,{send:true,sync:true})
|
||||
$document.on('dragend.push',function(){
|
||||
widget.setValuePrivate(widgetData.off,{send:true,sync:true})
|
||||
$document.off('dragend.push')
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget[widget.lastChanged] ?
|
||||
widgetData.on.value !== undefined ? widgetData.on.value : widgetData.on
|
||||
:
|
||||
widgetData.off.value !== undefined ? widgetData.off.value : widgetData.off
|
||||
}
|
||||
|
||||
widget.setValuePrivate = function(v,options={}) {
|
||||
if (v===widgetData.on || (v.value === widgetData.on.value && v.value !== undefined)) {
|
||||
widget.addClass('active')
|
||||
widget.active = 1
|
||||
if (options.send) widget.sendValue(v)
|
||||
widget.lastChanged = 'active'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options:options})
|
||||
} else if (v===widgetData.off || (v.value === widgetData.off.value && v.value !== undefined)) {
|
||||
widget.removeClass('active')
|
||||
widget.active = 0
|
||||
if (options.send) widget.sendValue(v, widgetData.norelease)
|
||||
widget.lastChanged = 'active'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options:options})
|
||||
}
|
||||
}
|
||||
|
||||
widget.setValue = function(v,options={}) {
|
||||
if (!options.fromExternal) {
|
||||
if (options.send || options.sync) widget.setValuePrivate(v,options)
|
||||
return
|
||||
}
|
||||
if (v===widgetData.on || (v.value === widgetData.on.value && v.value !== undefined)) {
|
||||
widget.addClass('on')
|
||||
widget.state = 1
|
||||
if (options.send) widget.sendValue(v)
|
||||
widget.lastChanged = 'state'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId,options:options})
|
||||
} else if (v===widgetData.off || (v.value === widgetData.off.value && v.value !== undefined)) {
|
||||
widget.removeClass('on')
|
||||
widget.state = 0
|
||||
if (options.send) widget.sendValue(v)
|
||||
widget.lastChanged = 'state'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId,options:options})
|
||||
}
|
||||
}
|
||||
|
||||
widget.sendValue = function(v, norelease) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args,
|
||||
syncOnly:norelease
|
||||
})
|
||||
}
|
||||
return widget
|
||||
}
|
||||
292
src/browser/js/app/widgets/rgb.js
Normal file
292
src/browser/js/app/widgets/rgb.js
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale,
|
||||
hsbToRgb = utils.hsbToRgb,
|
||||
rgbToHsb = utils.rgbToHsb,
|
||||
sendOsc = utils.sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'rgb',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
precision:0,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
split:false,
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="xy-wrapper rgb-wrapper">
|
||||
<div class="xy rgb">
|
||||
<div class="bg"></div>
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="hue">
|
||||
<div class="bg"></div>
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="value">
|
||||
<div class="input disabled">R</div><div class="input disabled">G</div><div class="input disabled">B</div>
|
||||
<div class="input r"></div><div class="input g"></div><div class="input b"></div>
|
||||
</div>
|
||||
</div>`),
|
||||
rgbHandle = widget.find('.rgb .handle'),
|
||||
hueHandle = widget.find('.hue .handle'),
|
||||
pad = widget.find('.xy'),
|
||||
huePad = widget.find('.hue'),
|
||||
rgbBg = pad.find('.bg')[0],
|
||||
value = {r:widget.find('.r').fakeInput({align:'center'}),g:widget.find('.g').fakeInput({align:'center'}),b:widget.find('.b').fakeInput({align:'center'})},
|
||||
snap = widgetData.snap,
|
||||
split = widgetData.split?
|
||||
typeof widgetData.split == 'object'?
|
||||
widgetData.split:{r:widgetData.path+'/r',g:widgetData.path+'/g',b:widgetData.path+'/b'}
|
||||
:false
|
||||
|
||||
|
||||
pad.width = 0
|
||||
pad.height = 0
|
||||
rgbHandle.height = 0
|
||||
rgbHandle.width = 0
|
||||
hueHandle.width = 0
|
||||
widget.value = undefined
|
||||
|
||||
pad.resize(function(){
|
||||
var width = pad.innerWidth(),
|
||||
height = pad.innerHeight()
|
||||
if (!width || (pad.height==height && pad.width==width)) return
|
||||
pad.width = width
|
||||
pad.height = height
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*rgbHandle.width/100}px, -${pad.height*rgbHandle.height/100}px,0)`)
|
||||
|
||||
})
|
||||
|
||||
|
||||
var rgbOff = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
rgbHandle.height = h
|
||||
rgbHandle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
|
||||
w = clip(data.deltaX*100/pad.width+rgbOff.x,[0,100])
|
||||
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
rgbHandle.height = h
|
||||
rgbHandle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
var hueOff = 0
|
||||
huePad.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var d = (data.offsetX * 100 / pad.width)
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*d/100}px,0,0)`)
|
||||
hueHandle.width = d
|
||||
|
||||
|
||||
var h = clip(hueHandle.width*3.6,[0,360]),
|
||||
rgb = hsbToRgb({h:h,s:100,b:100})
|
||||
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hueOff = hueHandle.width
|
||||
|
||||
})
|
||||
|
||||
|
||||
huePad.on('drag',function(e,data){
|
||||
|
||||
var w = clip(data.deltaX*100/pad.width+hueOff,[0,100])
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px,0,0)`)
|
||||
hueHandle.width = w
|
||||
|
||||
var h = clip(hueHandle.width*3.6,[0,360]),
|
||||
rgb = hsbToRgb({h:h,s:100,b:100})
|
||||
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
var s = clip(rgbHandle.width,[0,100]),
|
||||
l = clip(rgbHandle.height,[0,100]),
|
||||
h = mapToScale(hueHandle.width,[0,100],[0,360],widgetData.precision),
|
||||
rgb = hsbToRgb({h:h,s:s,b:l})
|
||||
return [rgb.r,rgb.g,rgb.b]
|
||||
}
|
||||
widget.setValue = function(v,options={}) {
|
||||
if (!v || v.length!=3) return
|
||||
|
||||
for (i in [0,1,2]) {
|
||||
v[i] = clip(v[i],[0,255])
|
||||
}
|
||||
|
||||
|
||||
var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
|
||||
|
||||
var w = mapToScale(hsb.s,[0,100],[0,100],false),
|
||||
h = mapToScale(hsb.b,[0,100],[0,100],false),
|
||||
hueW = mapToScale(hsb.h,[0,360],[0,100],false)
|
||||
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*hueW/100}px,0,0)`)
|
||||
|
||||
rgbHandle.height = h
|
||||
rgbHandle.width = w
|
||||
hueHandle.width = hueW
|
||||
widget.value = v
|
||||
|
||||
|
||||
var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
widget.showValue(v)
|
||||
|
||||
|
||||
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
if (options.send) widget.sendValue(v)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:split?false:widgetData.target,
|
||||
path:widgetData.path,
|
||||
args:args,
|
||||
precision:widgetData.precision,
|
||||
})
|
||||
if (split) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.r,
|
||||
args:widgetData.preArgs.concat(v[0]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.g,
|
||||
args:widgetData.preArgs.concat(v[1]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.b,
|
||||
args:widgetData.preArgs.concat(v[2]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.showValue = function(v) {
|
||||
value.r.val(v[0])
|
||||
value.g.val(v[1])
|
||||
value.b.val(v[2])
|
||||
}
|
||||
value.r.change(function(){
|
||||
var r = clip(value.r.val(),[0,255])
|
||||
var v = widget.getValue()
|
||||
widget.setValue([r,v[1],v[2]],{sync:true,send:true})
|
||||
})
|
||||
value.g.change(function(){
|
||||
var g = clip(value.g.val(),[0,255])
|
||||
var v = widget.getValue()
|
||||
widget.setValue([v[0],g,v[2]],{sync:true,send:true})
|
||||
})
|
||||
value.b.change(function(){
|
||||
var b = clip(value.b.val(),[0,255])
|
||||
var v = widget.getValue()
|
||||
widget.setValue([v[0],v[1],b],{sync:true,send:true})
|
||||
})
|
||||
|
||||
widget.setValue([0,0,0])
|
||||
|
||||
return widget
|
||||
}
|
||||
180
src/browser/js/app/widgets/sliders/_sliders_base.js
Normal file
180
src/browser/js/app/widgets/sliders/_sliders_base.js
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
var {clip, roundTo, mapToScale, sendOsc} = require('../utils')
|
||||
var _canvas_base = require('../common/_canvas_base')
|
||||
|
||||
var _sliders_base = module.exports = function(){
|
||||
|
||||
this.widget = $(`
|
||||
<div class="slider">
|
||||
<div class="wrapper">
|
||||
<canvas></canvas>
|
||||
</div>
|
||||
<div class="input"></div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
_canvas_base.apply(this, arguments)
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.input = this.widget.find('.input').fakeInput({align:'center'})
|
||||
this.roundFactor = Math.pow(10,this.widgetData.precision)
|
||||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
||||
this.unit = this.widgetData.unit ? ' ' + this.widgetData.unit : ''
|
||||
|
||||
|
||||
this.rangeKeys = []
|
||||
this.rangeVals = []
|
||||
this.rangeLabels = []
|
||||
|
||||
for (k in this.widgetData.range) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof this.widgetData.range[k] == 'object'?
|
||||
this.widgetData.range[k][Object.keys(this.widgetData.range[k])[0]]:
|
||||
this.widgetData.range[k],
|
||||
label = typeof this.widgetData.range[k] == 'object'?
|
||||
Object.keys(this.widgetData.range[k])[0]:
|
||||
val
|
||||
|
||||
this.rangeKeys.push(key)
|
||||
this.rangeVals.push(val)
|
||||
this.rangeLabels.push(label)
|
||||
}
|
||||
this.rangeValsMax = Math.max.apply(Math, this.rangeVals),
|
||||
this.rangeValsMin = Math.min.apply(Math, this.rangeVals)
|
||||
|
||||
this.originValue = this.widgetData.origin=='auto'?
|
||||
this.rangeValsMin:
|
||||
clip(this.widgetData.origin,[this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
|
||||
|
||||
this.widget.on('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
this.input.focus()
|
||||
}
|
||||
}.bind(this))
|
||||
|
||||
this.widget.on('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
this.canvas.on('draginit',this.draginitHandleProxy.bind(this))
|
||||
this.canvas.on('drag',this.dragHandleProxy.bind(this))
|
||||
|
||||
this.input.change(function(){
|
||||
this.widget.setValue(parseFloat(this.input.val()),{sync:true,send:true})
|
||||
}.bind(this))
|
||||
|
||||
this.widget.getValue = function(){
|
||||
return this.value
|
||||
}.bind(this)
|
||||
|
||||
this.widget.setValue = this.setValue.bind(this)
|
||||
|
||||
this.setValue(this.originValue)
|
||||
|
||||
}
|
||||
|
||||
_sliders_base.prototype = Object.create(_canvas_base.prototype)
|
||||
|
||||
_sliders_base.prototype.constructor = _sliders_base
|
||||
|
||||
|
||||
_sliders_base.prototype.mousewheelHandleProxy = function() {
|
||||
this.mousewheelHandle.apply(this,arguments)
|
||||
}
|
||||
|
||||
_sliders_base.prototype.draginitHandleProxy = function() {
|
||||
this.draginitHandle.apply(this,arguments)
|
||||
}
|
||||
|
||||
_sliders_base.prototype.dragHandleProxy = function() {
|
||||
this.dragHandle.apply(this,arguments)
|
||||
}
|
||||
|
||||
|
||||
_sliders_base.prototype.mousewheelHandle = function(e, data, traversing) {
|
||||
if (e.originalEvent.wheelDeltaX) return
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
var direction = e.originalEvent.wheelDelta / Math.abs(e.originalEvent.wheelDelta),
|
||||
increment = e.ctrlKey?0.25:1
|
||||
|
||||
this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.widgetData.precision)) * direction ,[0,100])
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {sync:true,send:true})
|
||||
|
||||
|
||||
}
|
||||
|
||||
_sliders_base.prototype.draginitHandle = function(e, data, traversing) {
|
||||
|
||||
}
|
||||
|
||||
_sliders_base.prototype.dragHandle = function(e, data, traversing) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
_sliders_base.prototype.resizeHandle = function() {
|
||||
if (!self.visible) {
|
||||
this.colors.track = getComputedStyle(this.widget[0]).getPropertyValue('--color-track')
|
||||
this.colors.gauge = getComputedStyle(this.widget[0]).getPropertyValue('--color-gauge')
|
||||
this.colors.knob = getComputedStyle(this.widget[0]).getPropertyValue('--color-knob')
|
||||
}
|
||||
_canvas_base.prototype.resizeHandle.call(this)
|
||||
}
|
||||
|
||||
|
||||
_sliders_base.prototype.percentToValue = function(percent) {
|
||||
var h = clip(percent,[0,100])
|
||||
for (var i=0;i<this.rangeKeys.length-1;i++) {
|
||||
if (h <= this.rangeKeys[i+1] && h >= this.rangeKeys[i]) {
|
||||
return mapToScale(h,[this.rangeKeys[i],this.rangeKeys[i+1]],[this.rangeVals[i],this.rangeVals[i+1]],false,this.widgetData.logScale)
|
||||
}
|
||||
}
|
||||
}
|
||||
_sliders_base.prototype.valueToPercent = function(value) {
|
||||
for (var i=0;i<this.rangeVals.length-1;i++) {
|
||||
if (value <= this.rangeVals[i+1] && value >= this.rangeVals[i]) {
|
||||
return mapToScale(value,[this.rangeVals[i],this.rangeVals[i+1]],[this.rangeKeys[i],this.rangeKeys[i+1]],false,this.widgetData.logScale,true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_sliders_base.prototype.setValue = function(v,options={}) {
|
||||
if (typeof v != 'number') return
|
||||
|
||||
var value = roundTo(clip(Math.round(v*this.roundFactor)/this.roundFactor,[this.rangeValsMin,this.rangeValsMax]),this.widgetData.precision)
|
||||
|
||||
if ((options.dragged || options.fromLocal) && this.value == value) options.send = false
|
||||
|
||||
this.value = value
|
||||
|
||||
if (!options.dragged) this.percent = this.valueToPercent(this.value)
|
||||
|
||||
this.draw()
|
||||
|
||||
this.showValue()
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.widgetData.id,widget:this.widget, linkId:this.widgetData.linkId, options:options})
|
||||
if (options.send) this.sendValue(v)
|
||||
}
|
||||
|
||||
_sliders_base.prototype.sendValue = function(value) {
|
||||
var args = this.widgetData.preArgs.concat(value)
|
||||
|
||||
sendOsc({
|
||||
target:this.widgetData.target,
|
||||
path:this.widgetData.path,
|
||||
precision:this.widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
_sliders_base.prototype.showValue = function() {
|
||||
this.input.val(this.value + this.unit)
|
||||
}
|
||||
260
src/browser/js/app/widgets/sliders/fader.js
Normal file
260
src/browser/js/app/widgets/sliders/fader.js
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
var {clip, mapToScale, sendOsc} = require('../utils'),
|
||||
_sliders_base = require('./_sliders_base')
|
||||
|
||||
|
||||
module.exports.options = {
|
||||
type:'fader',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
alignRight:false,
|
||||
horizontal:false,
|
||||
noPip:false,
|
||||
compact:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
origin: 'auto',
|
||||
logScale:false,
|
||||
precision:2,
|
||||
meter:false,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
var Fader = function(widgetData){
|
||||
|
||||
_sliders_base.apply(this,arguments)
|
||||
this.widget.addClass('fader')
|
||||
this.margin = 20
|
||||
|
||||
|
||||
if (widgetData.horizontal) {
|
||||
this.widget.addClass('horizontal')
|
||||
}
|
||||
|
||||
if (widgetData.compact) {
|
||||
this.widget.addClass('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
if (widgetData.alignRight && !widgetData.horizontal) {
|
||||
this.widget.addClass('align-right')
|
||||
}
|
||||
|
||||
if (!widgetData.noPip&&!widgetData.compact) {
|
||||
|
||||
this.widget.addClass('has-pips')
|
||||
|
||||
var pips = $('<div class="pips"></div>').appendTo(this.widget.find('.wrapper'))
|
||||
var pipTexts = {}
|
||||
for (k in this.rangeKeys) {
|
||||
pipTexts[this.rangeKeys[k]]=this.rangeLabels[k]
|
||||
}
|
||||
|
||||
var pipsInner = ''
|
||||
for (var i=0;i<=100;i++) {
|
||||
if (pipTexts[i]==undefined) continue
|
||||
|
||||
var pos = widgetData.horizontal?'left':'bottom';
|
||||
|
||||
var piptext = `<span>${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]}</span>`
|
||||
|
||||
var add = `
|
||||
<div class="pip val" style="${pos}:${i}%">${piptext}</div>
|
||||
`
|
||||
pipsInner = pipsInner + add
|
||||
}
|
||||
pips[0].innerHTML = pipsInner
|
||||
}
|
||||
|
||||
|
||||
if (widgetData.meter) {
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
var data = {
|
||||
type:'meter',
|
||||
id: widgetData.id + '/meter',
|
||||
label:false,
|
||||
horizontal:widgetData.horizontal,
|
||||
range:widgetData.range,
|
||||
logScale:widgetData.logScale,
|
||||
path:widgetData.path + '/meter',
|
||||
preArgs:widgetData.preArgs,
|
||||
color:widgetData.color
|
||||
}
|
||||
var element = parsewidgets([data],this.widget.find('.wrapper'))
|
||||
element[0].classList.add('not-editable')
|
||||
this.widget[0].classList.add('has-meter')
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Fader.prototype = Object.create(_sliders_base.prototype)
|
||||
|
||||
Fader.prototype.constructor = Fader
|
||||
|
||||
Fader.prototype.draginitHandle = function(e, data, traversing){
|
||||
|
||||
this.percent = clip(this.percent,[0,100])
|
||||
|
||||
if (!(traversing || this.widgetData.snap)) return
|
||||
|
||||
this.percent = this.widgetData.horizontal?
|
||||
(data.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100:
|
||||
(this.height - data.offsetY - this.margin * PXSCALE) / (this.height - (this.margin * PXSCALE * 2)) * 100
|
||||
|
||||
// this.percent = clip(this.percent,[0,100])
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
|
||||
|
||||
}
|
||||
|
||||
Fader.prototype.dragHandle = function(e, data) {
|
||||
|
||||
this.percent = this.widgetData.horizontal?
|
||||
this.percent + ( data.speedX/(this.width - this.margin * PXSCALE * 2)) * 100:
|
||||
this.percent + (-data.speedY/(this.height - this.margin * PXSCALE * 2)) * 100
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
|
||||
|
||||
}
|
||||
|
||||
Fader.prototype.percentToCoord = function(percent) {
|
||||
if (this.widgetData.horizontal) {
|
||||
return clip(percent / 100,[0,1]) * (this.width - 2 * PXSCALE * this.margin)
|
||||
} else {
|
||||
return (this.height - this.margin * PXSCALE) - clip(percent / 100, [0,1]) * (this.height - 2 * PXSCALE * this.margin)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Fader.prototype.draw = function(){
|
||||
|
||||
var d = this.percentToCoord(this.percent),
|
||||
o = this.percentToCoord(this.valueToPercent(this.originValue))
|
||||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
if (this.widgetData.horizontal) {
|
||||
if (this.widgetData.compact) {
|
||||
|
||||
|
||||
this.ctx.save()
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(d, this.height / 2)
|
||||
this.ctx.lineTo(o, this.height / 2)
|
||||
this.ctx.lineWidth = this.height
|
||||
this.ctx.stroke()
|
||||
this.ctx.restore()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.rect(Math.min(d,this.width-PXSCALE), 0, PXSCALE, this.height)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.track
|
||||
this.ctx.rect(this.margin * PXSCALE, this.height / 2 - 1 * PXSCALE, this.width - this.margin * 2 * PXSCALE, 2 * PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.moveTo(d + this.margin * PXSCALE, this.height / 2)
|
||||
this.ctx.lineTo(o + this.margin * PXSCALE, this.height / 2)
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
|
||||
this.ctx.save()
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.arc(d + this.margin * PXSCALE, this.height / 2, 10 * PXSCALE, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
this.ctx.restore()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(d + this.margin * PXSCALE, this.height / 2, 4 * PXSCALE, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (this.widgetData.compact) {
|
||||
|
||||
|
||||
this.ctx.save()
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(this.width / 2, d)
|
||||
this.ctx.lineTo(this.width / 2, o)
|
||||
this.ctx.lineWidth = this.width
|
||||
this.ctx.stroke()
|
||||
this.ctx.restore()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.rect(0, Math.min(d, this.height - PXSCALE), this.width, PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.track
|
||||
this.ctx.rect(this.width / 2 - 1 * PXSCALE, this.margin * PXSCALE, 2 * PXSCALE, this.height - this.margin *2 * PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.moveTo(this.width / 2, d)
|
||||
this.ctx.lineTo(this.width / 2, o)
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.stroke()
|
||||
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.save()
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.arc(this.width / 2, d, 10 * PXSCALE, Math.PI * 2,false)
|
||||
this.ctx.fill()
|
||||
this.ctx.restore()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, d, 4 * PXSCALE, Math.PI * 2,false)
|
||||
this.ctx.fill()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var fader = new Fader(widgetData, container)
|
||||
return fader.widget
|
||||
}
|
||||
236
src/browser/js/app/widgets/sliders/knob.js
Normal file
236
src/browser/js/app/widgets/sliders/knob.js
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
var {clip, mapToScale, sendOsc} = require('../utils'),
|
||||
_sliders_base = require('./_sliders_base')
|
||||
|
||||
|
||||
module.exports.options = {
|
||||
type:'knob',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
noPip:true,
|
||||
compact:false,
|
||||
angle:270,
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
origin: 'auto',
|
||||
logScale:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
Knob = function(widgetData) {
|
||||
|
||||
_sliders_base.apply(this,arguments)
|
||||
|
||||
this.widget.addClass('knob')
|
||||
|
||||
this.margin = 5
|
||||
|
||||
if (widgetData.compact) {
|
||||
this.widget.addClass('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
if (!widgetData.noPip) {
|
||||
this.wrapper.append(`
|
||||
<div class="pips">
|
||||
<div>${this.rangeLabels[0]}</div><div>${this.rangeLabels[this.rangeLabels.length-1]}</div>
|
||||
</div>
|
||||
`)
|
||||
}
|
||||
|
||||
this.lastOffsetX = 0
|
||||
this.lastOffsetY = 0
|
||||
this.minDimension = 0
|
||||
|
||||
this.maxAngle = widgetData.angle
|
||||
|
||||
// calculate lost height factor
|
||||
var a = Math.sin((360 - this.maxAngle)),
|
||||
h = a < 0 ? 1 - a : a
|
||||
|
||||
this.lostHeightFactor = h / 4
|
||||
|
||||
}
|
||||
|
||||
|
||||
Knob.prototype = Object.create(_sliders_base.prototype)
|
||||
|
||||
Knob.prototype.constructor = Knob
|
||||
|
||||
Knob.prototype.draginitHandle = function(e, data, traversing){
|
||||
|
||||
this.percent = clip(this.percent,[0,100])
|
||||
|
||||
this.lastOffsetX = data.offsetX
|
||||
this.lastOffsetY = data.offsetY
|
||||
|
||||
if (!(traversing || this.widgetData.snap)) return
|
||||
|
||||
this.percent = this.angleToPercent(this.coordsToAngle(data.offsetX, data.offsetY))
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
|
||||
|
||||
}
|
||||
|
||||
Knob.prototype.dragHandle = function(e, data, traversing) {
|
||||
|
||||
|
||||
if (!(traversing || this.widgetData.snap)) {
|
||||
|
||||
this.percent = -data.speedY + this.percent
|
||||
|
||||
} else {
|
||||
|
||||
this.lastOffsetX = this.lastOffsetX + data.speedX
|
||||
this.lastOffsetY = this.lastOffsetY + data.speedY
|
||||
this.percent = this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY))
|
||||
}
|
||||
|
||||
this.percent = this.percent,[0,100]
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
|
||||
|
||||
}
|
||||
|
||||
Knob.prototype.coordsToAngle = function(x,y) {
|
||||
var xToCenter = x - this.width /2,
|
||||
yToCenter = y - this.height / 2,
|
||||
angle = Math.atan2(-yToCenter, -xToCenter) * 180 / Math.PI + 90
|
||||
|
||||
return angle<0?360+angle:angle
|
||||
}
|
||||
|
||||
Knob.prototype.angleToPercent = function(angle) {
|
||||
return clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
|
||||
}
|
||||
|
||||
Knob.prototype.percentToAngle = function(percent) {
|
||||
var percent = clip(percent, [0, 100])
|
||||
return 2 * Math.PI * percent / 100 * (this.maxAngle / 360) // angle relative to maxAngle
|
||||
+ Math.PI / 2 // quarter circle offset
|
||||
+ Math.PI * (1 - this.maxAngle / 360) // centering offset depending on maxAngle
|
||||
}
|
||||
|
||||
Knob.prototype.resizeHandle = function() {
|
||||
_sliders_base.prototype.resizeHandle.call(this)
|
||||
this.minDimension = Math.min(this.width, this.height)
|
||||
this.canvas[0].style.top = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px'
|
||||
if (this.widgetData.compact) {
|
||||
this.input[0].style.marginTop = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px'
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Knob.prototype.draw = function(){
|
||||
|
||||
var o = this.percentToAngle(this.valueToPercent(this.originValue)),
|
||||
d = this.percentToAngle(this.percent),
|
||||
min = this.percentToAngle(0),
|
||||
max = this.percentToAngle(100)
|
||||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
if (this.widgetData.compact) {
|
||||
|
||||
this.ctx.lineWidth = 10 * PXSCALE
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, min, max)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.save()
|
||||
this.ctx.globalAlpha = 0.5
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.stroke()
|
||||
this.ctx.restore()
|
||||
|
||||
|
||||
this.ctx.save()
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
this.ctx.strokeStyle = this.colors.knob
|
||||
this.ctx.lineWidth = 1 * PXSCALE
|
||||
this.ctx.moveTo(this.width / 2 + this.minDimension / 2 - (10 + this.margin - 5) * PXSCALE, this.height / 2)
|
||||
this.ctx.lineTo(this.width / 2 + this.minDimension / 2 - (10 + this.margin + 5) * PXSCALE, this.height / 2)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.restore()
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.raised
|
||||
this.ctx.arc(this.width / 2, this.height / 2, Math.max(this.minDimension / 2 - (30 + this.margin) * PXSCALE, 2 * PXSCALE), 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, min, max)
|
||||
this.ctx.stroke()
|
||||
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.save()
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 4 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 10 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var knob = new Knob(widgetData)
|
||||
return knob.widget
|
||||
}
|
||||
38
src/browser/js/app/widgets/strip.js
Normal file
38
src/browser/js/app/widgets/strip.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
module.exports.options = {
|
||||
type:'strip',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'children',
|
||||
|
||||
widgets:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parsewidgets = require('../parser').widgets
|
||||
|
||||
var widget = $(`
|
||||
<div class="strip">
|
||||
</div>
|
||||
`)
|
||||
if (widgetData.horizontal) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
}
|
||||
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
|
||||
return widget
|
||||
}
|
||||
83
src/browser/js/app/widgets/switch.js
Normal file
83
src/browser/js/app/widgets/switch.js
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
var sendOsc = require('./utils').sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'switch',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="switch">
|
||||
</div>
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
if (widgetData.horizontal) {
|
||||
widget.addClass('horizontal')
|
||||
}
|
||||
|
||||
widget.values = []
|
||||
|
||||
for (k in widgetData.values) {
|
||||
widget.values.push(widgetData.values[k])
|
||||
$('<div class="value">'+k+'</div>').data({value:widgetData.values[k]}).appendTo(widget)
|
||||
}
|
||||
|
||||
widget.value = undefined
|
||||
|
||||
widget.find('.value').on('draginit',function(e,dd){
|
||||
var data = $(this).data()
|
||||
if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,{sync:true,send:true})
|
||||
})
|
||||
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.value
|
||||
}
|
||||
widget.setValue = function(v,options={}) {
|
||||
var i = widget.values.indexOf(v)
|
||||
if (i!=-1) {
|
||||
widget.value = widget.values[i]
|
||||
widget.find('.on').removeClass('on')
|
||||
widget.find('.value').eq(i).addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
|
||||
$(this).removeClass('ripple')
|
||||
next()
|
||||
})
|
||||
if (options.send) widget.sendValue(widget.value)
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
return widget
|
||||
}
|
||||
88
src/browser/js/app/widgets/toggle.js
Normal file
88
src/browser/js/app/widgets/toggle.js
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
var sendOsc = require('./utils').sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'toggle',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="light">
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = widget.find('span')
|
||||
widget.state = 0
|
||||
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit.toggle',function(){
|
||||
widget.off('draginit.toggle')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
var newVal = widget.state?widgetData.off:widgetData.on
|
||||
widget.setValue(newVal,{sync:true,send:true})
|
||||
$document.on('dragend.toggle',function(){
|
||||
$document.off('dragend.toggle')
|
||||
widget.on('draginit.toggle',function(){
|
||||
widget.off('draginit.toggle')
|
||||
widget.fakeclick()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.state ?
|
||||
widgetData.on.value !== undefined ? widgetData.on.value : widgetData.on
|
||||
:
|
||||
widgetData.off.value !== undefined ? widgetData.off.value : widgetData.off
|
||||
}
|
||||
widget.setValue = function(v,options={}) {
|
||||
if (v===widgetData.on || (v.value === widgetData.on.value && v.value !== undefined)) {
|
||||
widget.addClass('on')
|
||||
widget.state = 1
|
||||
if (options.send) widget.sendValue(widgetData.on)
|
||||
} else if (v===widgetData.off || (v.value === widgetData.off.value && v.value !== undefined)) {
|
||||
widget.removeClass('on')
|
||||
widget.state = 0
|
||||
if (options.send) widget.sendValue(widgetData.off)
|
||||
}
|
||||
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
return widget
|
||||
}
|
||||
85
src/browser/js/app/widgets/utils.js
Normal file
85
src/browser/js/app/widgets/utils.js
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
module.exports = {
|
||||
|
||||
sendOsc: function(data){
|
||||
if (!OSCSYNCONLY) {
|
||||
IPC.send('sendOsc', data)
|
||||
} else {
|
||||
IPC.send('syncOsc', data)
|
||||
}
|
||||
},
|
||||
|
||||
clip: function(value,range) {
|
||||
var value = parseFloat(value)
|
||||
|
||||
if (isNaN(value)) value = range[0]
|
||||
return Math.max(Math.min(range[0],range[1]),Math.min(value,Math.max(range[0],range[1])))
|
||||
|
||||
},
|
||||
|
||||
// map a value from a scale to another input and output must be range arrays
|
||||
mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
|
||||
|
||||
var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]])
|
||||
|
||||
value = log?
|
||||
revertlog?
|
||||
(Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
|
||||
value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
|
||||
|
||||
if (precision!==false) value = module.exports.roundTo(value, precision)
|
||||
|
||||
|
||||
return value
|
||||
|
||||
},
|
||||
|
||||
roundTo: function(value, precision) {
|
||||
var roundFactor = precision!=undefined?Math.pow(10,precision):100
|
||||
return Math.round(value*roundFactor)/roundFactor
|
||||
},
|
||||
|
||||
hsbToRgb: function (hsb) {
|
||||
var rgb = {}
|
||||
var h = hsb.h
|
||||
var s = hsb.s*255/100
|
||||
var v = hsb.b*255/100
|
||||
if(s == 0) {
|
||||
rgb.r = rgb.g = rgb.b = v
|
||||
} else {
|
||||
var t1 = v
|
||||
var t2 = (255-s)*v/255
|
||||
var t3 = (t1-t2)*(h%60)/60
|
||||
if(h==360) h = 0
|
||||
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
||||
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
||||
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
||||
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
||||
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
||||
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
||||
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
||||
}
|
||||
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}
|
||||
},
|
||||
|
||||
rgbToHsb: function (rgb) {
|
||||
var hsb = {h: 0, s: 0, b: 0}
|
||||
var min = Math.min(rgb.r, rgb.g, rgb.b)
|
||||
var max = Math.max(rgb.r, rgb.g, rgb.b)
|
||||
var delta = max - min
|
||||
hsb.b = max
|
||||
hsb.s = max != 0 ? 255 * delta / max : 0
|
||||
if (hsb.s != 0) {
|
||||
if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta
|
||||
else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta
|
||||
else hsb.h = 4 + (rgb.r - rgb.g) / delta
|
||||
} else hsb.h = 0
|
||||
hsb.h *= 60
|
||||
if (hsb.h < 0) hsb.h += 360
|
||||
hsb.s *= 100/255
|
||||
hsb.b *= 100/255
|
||||
return hsb
|
||||
}
|
||||
}
|
||||
209
src/browser/js/app/widgets/xy.js
Normal file
209
src/browser/js/app/widgets/xy.js
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale,
|
||||
sendOsc = utils.sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'xy',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
rangeX:{min:0,max:1},
|
||||
rangeY:{min:0,max:1},
|
||||
logScaleX:false,
|
||||
logScaleY:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
split:false,
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="xy-wrapper">
|
||||
<div class="xy">
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="value">
|
||||
<div class="input disabled">X</div><div class="input disabled">Y</div>
|
||||
<div class="input x"></div><div class="input y"></div>
|
||||
</div>
|
||||
</div>
|
||||
`),
|
||||
handle = widget.find('.handle'),
|
||||
pad = widget.find('.xy'),
|
||||
value = {x:widget.find('.x').fakeInput({align:'center'}),y:widget.find('.y').fakeInput({align:'center'})},
|
||||
range = {x:widgetData.rangeX,y:widgetData.rangeY},
|
||||
snap = widgetData.snap,
|
||||
split = widgetData.split?
|
||||
typeof widgetData.split == 'object'?
|
||||
widgetData.split:{x:widgetData.path+'/x',y:widgetData.path+'/y'}
|
||||
:false;
|
||||
logScaleX = widgetData.logScaleX,
|
||||
logScaleY = widgetData.logScaleY,
|
||||
roundFactor = Math.pow(10,widgetData.precision)
|
||||
|
||||
|
||||
if (widgetData.height!='auto') widget.addClass('manual-height')
|
||||
|
||||
pad.width = 0
|
||||
pad.height = 0
|
||||
handle.height = 0
|
||||
handle.width = 0
|
||||
widget.value = undefined
|
||||
|
||||
pad.resize(function(){
|
||||
var width = pad.innerWidth(),
|
||||
height = pad.innerHeight()
|
||||
if (!width || (pad.height==height && pad.width==width)) return
|
||||
pad.width = width
|
||||
pad.height = height
|
||||
|
||||
widget.updateUi(handle.width,handle.height)
|
||||
})
|
||||
|
||||
var off = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data,traversing){
|
||||
|
||||
if (snap || traversing) {
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
off = {x:handle.width,y:handle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
|
||||
w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
widget.updateUi = function(w,h) {
|
||||
handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision,logScaleX),
|
||||
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision,logScaleY)
|
||||
|
||||
return [x,y]
|
||||
}
|
||||
widget.setValue = function(v,options={}) {
|
||||
if (!v || v.length!=2) return
|
||||
|
||||
for (i in [0,1]) {
|
||||
v[i] = clip(Math.round(v[i]*roundFactor)/roundFactor,[range[['x','y'][i]].min,range[['x','y'][i]].max])
|
||||
}
|
||||
|
||||
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],false,logScaleX,true)
|
||||
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],false,logScaleY,true),
|
||||
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
widget.value = v
|
||||
|
||||
widget.showValue(v)
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options})
|
||||
if (options.send) widget.sendValue(v)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:split?false:widgetData.target,
|
||||
path:widgetData.path,
|
||||
args:args,
|
||||
precision:widgetData.precision,
|
||||
})
|
||||
if (split) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.x,
|
||||
args:widgetData.preArgs.concat(v[0]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.y,
|
||||
args:widgetData.preArgs.concat(v[1]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
widget.showValue = function(v) {
|
||||
value.x.val(v[0])
|
||||
value.y.val(v[1])
|
||||
}
|
||||
|
||||
value.x.change(function(){
|
||||
var v = widget.getValue()
|
||||
v[0] = clip(value.x.val(),[range.x.min,range.x.max])
|
||||
widget.setValue(v,{sync:true,send:true})
|
||||
})
|
||||
value.y.change(function(){
|
||||
var v = widget.getValue()
|
||||
v[1] = clip(value.y.val(),[range.y.min,range.y.max])
|
||||
widget.setValue(v,{sync:true,send:true})
|
||||
})
|
||||
|
||||
widget.setValue([range.x.min,range.y.min])
|
||||
return widget
|
||||
}
|
||||
8
src/browser/js/browser.js
Normal file
8
src/browser/js/browser.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// mainProcess & renderProcess communication engine
|
||||
// electron's ipc module is not available here, we use socket.io as a replacement
|
||||
var socket = require('socket.io-client')
|
||||
|
||||
IPC = socket.connect()
|
||||
IPC.send = IPC.emit
|
||||
|
||||
require('./app')
|
||||
337
src/browser/js/jquery/jquery.drag.js
Normal file
337
src/browser/js/jquery/jquery.drag.js
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
// jQuery drag event handler
|
||||
// note: triggerHandler() is used instead of trigger() when event bubblig is not
|
||||
// necessary, this increases performances a lot.
|
||||
;(function($){
|
||||
var events = {
|
||||
touch:{start:'touchstart',stop:'touchend touchcancel',move:'touchmove',touch:true},
|
||||
mouse:{start:'mousedown',stop:'mouseup',move:'mousemove',out:'mouseout',touch:false}
|
||||
},
|
||||
|
||||
|
||||
$document = $(document),
|
||||
getOffset = function(obj) {
|
||||
var offsetLeft = 0
|
||||
var offsetTop = 0
|
||||
if (obj) {
|
||||
do {
|
||||
if (!isNaN(obj.offsetLeft)) {
|
||||
offsetLeft += obj.offsetLeft - obj.scrollLeft
|
||||
}
|
||||
if (!isNaN(obj.offsetTop)) {
|
||||
offsetTop += obj.offsetTop - obj.scrollTop
|
||||
}
|
||||
} while(obj = obj.offsetParent )
|
||||
}
|
||||
|
||||
return {left: offsetLeft, top: offsetTop}
|
||||
}
|
||||
|
||||
|
||||
$.event.special.draginit = $.event.special.drag = {
|
||||
setup:function(){
|
||||
|
||||
var $this = $(this)
|
||||
|
||||
if ($this.data('dragSetup')) return
|
||||
$this.data('dragSetup','true')
|
||||
|
||||
|
||||
// mouse single touch handler
|
||||
var previousEvent = null,
|
||||
target = null,
|
||||
traversing = false,
|
||||
mouseStartHandler = function(e){
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.originalEvent.sourceCapabilities.firesTouchEvents || e.button == 2) return
|
||||
|
||||
isPointerDown = true
|
||||
target = $this
|
||||
previousEvent = e
|
||||
|
||||
e.speedX = 0
|
||||
e.speedY = 0
|
||||
e.deltaX = 0
|
||||
e.deltaY = 0
|
||||
|
||||
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
|
||||
|
||||
$document.on(events.mouse.move,mouseMoveHandler)
|
||||
$document.on(events.mouse.stop,mouseStopHandler)
|
||||
$document.on(events.mouse.out,mouseOutHandler)
|
||||
|
||||
},
|
||||
mouseMoveHandler = function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.speedX + previousEvent.deltaX
|
||||
e.deltaY = e.speedY + previousEvent.deltaY
|
||||
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
target = $(e.target)
|
||||
e.preventDefault()
|
||||
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
|
||||
} else {
|
||||
target.triggerHandler('drag',[e,e.originalEvent.traversing])
|
||||
}
|
||||
|
||||
previousEvent = e
|
||||
},
|
||||
mouseStopHandler = function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
|
||||
target.trigger('dragend',[e,e.originalEvent.traversing])
|
||||
isPointerDown = false
|
||||
$document.off(events.mouse.move,mouseMoveHandler)
|
||||
$document.off(events.mouse.stop,mouseStopHandler)
|
||||
$document.off(events.mouse.out,mouseOutHandler)
|
||||
},
|
||||
mouseOutHandler = function(e){
|
||||
if (e.originalEvent.traversing) {
|
||||
e.stopPropagation()
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
target.trigger('dragend',[e,e.originalEvent.traversing])
|
||||
|
||||
previousEvent = e
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this.on(events.mouse.start,mouseStartHandler)
|
||||
|
||||
|
||||
// multi touch hanlder
|
||||
window.targets = window.targets || {}
|
||||
window.previousTouches = window.previousTouches || {}
|
||||
window.touchActive = window.touchActive || false
|
||||
|
||||
var self = this,
|
||||
touchStartHandler = function(e){
|
||||
e.preventDefault()
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
targets[id] = $(touch.target)
|
||||
previousTouches[id] = touch
|
||||
|
||||
touch.speedX = 0
|
||||
touch.speedY = 0
|
||||
|
||||
touch.deltaX = 0
|
||||
touch.deltaY = 0
|
||||
|
||||
var off = getOffset(touch.target)
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
|
||||
targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
|
||||
|
||||
}
|
||||
|
||||
if (!touchActive) {
|
||||
$document.on(events.touch.move,touchMoveHandler)
|
||||
$document.on(events.touch.stop,touchStopHandler)
|
||||
touchActive = true
|
||||
}
|
||||
|
||||
},
|
||||
touchMoveHandler = function(e){
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
if (isNaN(i)) continue
|
||||
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
targets[id] = $(document.elementFromPoint(touch.clientX, touch.clientY))
|
||||
}
|
||||
|
||||
// touched[targets[id]] = touched[targets[id]]?touched[targets[id]]+1:1
|
||||
|
||||
touch.speedX = touch.pageX - previousTouches[id].pageX
|
||||
touch.speedY = touch.pageY - previousTouches[id].pageY
|
||||
|
||||
touch.deltaX = touch.speedX + previousTouches[id].deltaX
|
||||
touch.deltaY = touch.speedY + previousTouches[id].deltaY
|
||||
|
||||
touch.offsetX = previousTouches[id].offsetX+touch.speedX
|
||||
touch.offsetY = previousTouches[id].offsetY+touch.speedY
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
touch.traversing = true
|
||||
var previousTarget = document.elementFromPoint(previousTouches[id].clientX, previousTouches[id].clientY)
|
||||
if (targets[id][0]!=previousTarget) {
|
||||
var off = getOffset(targets[id][0])
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
$(previousTarget).trigger('dragend',[touch,e.originalEvent.traversing])
|
||||
}
|
||||
e.preventDefault()
|
||||
if (oE.traversingContainer.contains(targets[id][0])) targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
|
||||
|
||||
} else {
|
||||
|
||||
targets[id].triggerHandler('drag',[touch,e.originalEvent.traversing])
|
||||
|
||||
}
|
||||
|
||||
previousTouches[id] = touch
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
touchStopHandler = function(e){
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
$(oE.changedTouches[i].target).trigger('dragend',[touch,e.originalEvent.traversing])
|
||||
|
||||
delete previousTouches[id]
|
||||
delete targets[id]
|
||||
|
||||
}
|
||||
|
||||
if (oE.touches.length==0) {
|
||||
$document.off(events.touch.move,touchMoveHandler)
|
||||
$document.off(events.touch.stop,touchStopHandler)
|
||||
touchActive = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this.on(events.touch.start,touchStartHandler)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var makeEventTraversing = function(e){
|
||||
e.traversing=true
|
||||
if (!e.traversingContainer) e.traversingContainer=this
|
||||
}
|
||||
|
||||
|
||||
$.fn.enableTraversingGestures = function() {
|
||||
|
||||
var self = this[0]
|
||||
|
||||
var down = function(e){
|
||||
makeEventTraversing(e)
|
||||
self.addEventListener("mousemove", makeEventTraversing, true)
|
||||
self.addEventListener("touchmove", makeEventTraversing, true)
|
||||
self.addEventListener("mouseout", makeEventTraversing, true)
|
||||
document.addEventListener("mouseup",up,true)
|
||||
document.addEventListener("touchend",up,true)
|
||||
},
|
||||
up = function(){
|
||||
self.removeEventListener("mousemove", makeEventTraversing, true)
|
||||
self.removeEventListener("touchmove", makeEventTraversing, true)
|
||||
self.removeEventListener("mouseout", makeEventTraversing, true)
|
||||
document.removeEventListener("mouseup",up,true)
|
||||
document.removeEventListener("touchend",up,true)
|
||||
}
|
||||
|
||||
self.addEventListener("mousedown", down, true)
|
||||
self.addEventListener("touchstart", down, true)
|
||||
|
||||
|
||||
this.on('disableTraversingGestures',function() {
|
||||
self.removeEventListener("mousedown", down, true)
|
||||
self.removeEventListener("touchstart", down, true)
|
||||
})
|
||||
|
||||
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
|
||||
$document.on('mousedown',function(e){
|
||||
|
||||
if (e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
$(e.target).trigger('fake-click')
|
||||
|
||||
if (e.button==2) {
|
||||
e.preventDefault()
|
||||
$(e.target).trigger('fake-right-click',e)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
var touchTapTimer = false,
|
||||
clearTouchTapTimer = function() {
|
||||
clearTimeout(touchTapTimer)
|
||||
touchTapTimer = false
|
||||
}
|
||||
|
||||
$document.on(events.touch.start,function(e){
|
||||
$(e.target).trigger('fake-click')
|
||||
|
||||
if (!touchTapTimer&&e.originalEvent.touches.length==1) {
|
||||
touchTapTimer = setTimeout(function(){
|
||||
if (touchTapTimer) {
|
||||
var touch = e.originalEvent.changedTouches[0],
|
||||
off = getOffset(touch.target)
|
||||
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
$(e.originalEvent.changedTouches[0].target).trigger('fake-right-click',touch)
|
||||
}
|
||||
touchTapTimer = false
|
||||
},600)
|
||||
} else {
|
||||
clearTouchTapTimer()
|
||||
}
|
||||
})
|
||||
|
||||
$document.on(events.touch.stop + ' ' + events.touch.move,function(e){
|
||||
clearTouchTapTimer()
|
||||
})
|
||||
|
||||
$document.on('contextmenu',function(){return false})
|
||||
|
||||
})(jQuery)
|
||||
87
src/browser/js/jquery/jquery.fake-input.js
Normal file
87
src/browser/js/jquery/jquery.fake-input.js
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
;(function ($) {
|
||||
$.fn.fakeInput = function(options) {
|
||||
|
||||
var settings = $.extend({
|
||||
align:'left'
|
||||
}, options );
|
||||
|
||||
var self= this,
|
||||
canvas = $('<canvas></canvas>').appendTo(self),
|
||||
ctx = canvas[0].getContext('2d')
|
||||
|
||||
self.value = undefined
|
||||
self.height = undefined
|
||||
self.width = undefined
|
||||
self.color = undefined
|
||||
self.center = settings.align == 'center'
|
||||
|
||||
self.attr('tabindex',"0")
|
||||
|
||||
canvas.resize(function(e,width,height){
|
||||
e.stopPropagation()
|
||||
|
||||
var width = width*2,
|
||||
height = height*2
|
||||
|
||||
if (height==100 && width==100) return
|
||||
|
||||
self.color = getComputedStyle(document.documentElement).getPropertyValue("--color-text")
|
||||
self.height=height
|
||||
self.width=width
|
||||
|
||||
canvas[0].setAttribute('width',width)
|
||||
canvas[0].setAttribute('height',height)
|
||||
|
||||
self.val(self.value)
|
||||
})
|
||||
|
||||
self.val = function(newVal) {
|
||||
if (newVal==undefined) return self.value
|
||||
|
||||
self.value = newVal
|
||||
|
||||
if (!self.height || !self.width || (self.height==100 && self.width==100)) return
|
||||
|
||||
ctx.clearRect(0,0,self.width,self.height)
|
||||
ctx.font = PXSCALE * 2 * 13 + 'px Droid Sans'
|
||||
ctx.textBaseline = "top"
|
||||
ctx.fillStyle = self.color
|
||||
|
||||
if (self.center) {
|
||||
ctx.textAlign = settings.align
|
||||
ctx.fillText(newVal,self.width/2,0)
|
||||
} else {
|
||||
ctx.fillText(newVal,0,0)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
self.on('focus',function(){
|
||||
self.attr('tabindex','-1')
|
||||
var i = $('<input></input>')
|
||||
.prependTo(self)
|
||||
.val(self.value)
|
||||
.focus()
|
||||
.change(function(){
|
||||
self.val($(this).val())
|
||||
i.blur()
|
||||
setTimeout(function(){self.focus()},1)
|
||||
})
|
||||
i.blur(function(){
|
||||
self.attr('tabindex','0')
|
||||
i.remove()
|
||||
$(document).off('.fakeInput')
|
||||
})
|
||||
$(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
|
||||
if (e.originalEvent.target!=i[0]) {
|
||||
i.blur()
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
return self
|
||||
|
||||
}
|
||||
})(jQuery)
|
||||
4
src/browser/js/jquery/jquery.min.js
vendored
Normal file
4
src/browser/js/jquery/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
95
src/browser/js/jquery/jquery.resize.js
Normal file
95
src/browser/js/jquery/jquery.resize.js
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/* jquery.resize
|
||||
* based on jQuery resize event (@ "Cowboy" Ben Alman http://benalman.com/projects/jquery-resize-plugin/)
|
||||
* just lighter and faster
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var elems = [],
|
||||
pollInterval = 250,
|
||||
resizeTimeout
|
||||
|
||||
$.event.special.resize = {
|
||||
setup: function() {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
var elem = this
|
||||
|
||||
// Add this element to the list of internal elements to monitor.
|
||||
elems.push( elem )
|
||||
|
||||
// If this is the first element added, start the polling loop.
|
||||
if ( elems.length === 1 ) {
|
||||
resizePollingLoop()
|
||||
}
|
||||
},
|
||||
teardown: function() {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
var elem = this
|
||||
|
||||
// Remove this element from the list of internal elements to monitor.
|
||||
for (var i = elems.length - 1; i >= 0; i--) {
|
||||
if(elems[i] == this){
|
||||
elems.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ( !elems.length ) {
|
||||
clearTimeout(resizeTimeout)
|
||||
}
|
||||
|
||||
},
|
||||
add: function(handleObj) {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
// Save a reference to the bound event handler.
|
||||
var old_handler = handleObj.handler
|
||||
|
||||
handleObj.handler = function(event,data) {
|
||||
// Call the originally-bound event handler and return its result.
|
||||
return old_handler.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkResizes(){
|
||||
// Iterate over all elements to which the 'resize' event is bound.
|
||||
for (var i = elems.length - 1; i >= 0; i--) {
|
||||
var elem = elems[i],
|
||||
width = elem.offsetWidth,
|
||||
height = elem.offsetHeight
|
||||
|
||||
if (!width) continue
|
||||
|
||||
var data = {
|
||||
w:elem.resizedataw,
|
||||
h:elem.resizedatah
|
||||
}
|
||||
|
||||
// If element size has changed since the last time, update the element
|
||||
// data store and trigger the 'resize' event.
|
||||
if ( width != data.w || height != data.h ) {
|
||||
elem.resizedataw = width
|
||||
elem.resizedatah = height
|
||||
$(elem).triggerHandler('resize',[width,height])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Loop.
|
||||
resizePollingLoop()
|
||||
}
|
||||
|
||||
function resizePollingLoop() {
|
||||
// yep, setTimeout, 'cuz requestAnimation doesn't seem to perform that well
|
||||
resizeTimeout = window.setTimeout(checkResizes, pollInterval)
|
||||
|
||||
}
|
||||
|
||||
$(window).resize(checkResizes)
|
||||
|
||||
})(jQuery)
|
||||
20
src/browser/js/jquery/jquery.ui.js
Normal file
20
src/browser/js/jquery/jquery.ui.js
Normal file
File diff suppressed because one or more lines are too long
266
src/browser/scss/_editor.scss
Normal file
266
src/browser/scss/_editor.scss
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
|
||||
.form {
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
margin-bottom:4rem;
|
||||
background:var(--color-bg);
|
||||
align-items: center;
|
||||
&:last-child {
|
||||
margin-bottom:0;
|
||||
}
|
||||
label {
|
||||
background: var(--color-fg);
|
||||
flex-shrink: 0;
|
||||
padding: 5rem;
|
||||
border:1rem solid var(--color-bg);
|
||||
}
|
||||
.input, input {
|
||||
background: var(--color-bg);
|
||||
width:100%;
|
||||
padding:5rem;
|
||||
}
|
||||
&.column {
|
||||
flex-direction: column;
|
||||
label {
|
||||
width:100%;
|
||||
padding:7rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
font-size: 10rem;
|
||||
background: var(--color-faded);
|
||||
}
|
||||
.info {
|
||||
color:var(--color-text-fade);
|
||||
margin-bottom:10rem;
|
||||
}
|
||||
input, .input {
|
||||
display:block;
|
||||
border:0;
|
||||
font:inherit;
|
||||
color:var(--color-text);
|
||||
width:100%;
|
||||
&:focus {
|
||||
border-color:var(--color-accent);
|
||||
}
|
||||
.btn {
|
||||
background:var(--color-raised);
|
||||
box-shadow: 0 0 0 1rem var(--color-bg);
|
||||
}
|
||||
}
|
||||
.checkbox {
|
||||
background:var(--color-raised);
|
||||
cursor: pointer;
|
||||
}
|
||||
.select-wrapper {
|
||||
position: relative;
|
||||
width:100%;
|
||||
&:after{
|
||||
content:"\f107";
|
||||
font-family: FontAwesome;
|
||||
position: absolute;
|
||||
padding:5rem;
|
||||
right:0;
|
||||
top:0;
|
||||
font-size: 20rem;
|
||||
}
|
||||
}
|
||||
select {
|
||||
-webkit-appearance:none;
|
||||
}
|
||||
.submit {
|
||||
margin-top:30rem;
|
||||
}
|
||||
.separator {
|
||||
line-height: 30rem;
|
||||
height: 30rem;
|
||||
margin-bottom: 5rem;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
&:before, &:after {
|
||||
content:"";
|
||||
top:14rem;
|
||||
width: 100%;
|
||||
height: 1rem;
|
||||
background: var(--color-text-fade);
|
||||
}
|
||||
span {
|
||||
font-variant: small-caps;
|
||||
position: relative;
|
||||
display: block;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.widget.editing {
|
||||
z-index: 11!important;
|
||||
overflow: hidden;
|
||||
}
|
||||
.widget.editing:after, li.editing a:before, a.editing:before, .content.editing:before, #container.editing:before{
|
||||
content:"";
|
||||
z-index: 999;
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
border:1rem dashed var(--color-accent);
|
||||
pointer-events: none;
|
||||
}
|
||||
.widget.editing:after {
|
||||
// right:-1rem;
|
||||
// bottom:-1rem;
|
||||
}
|
||||
|
||||
.context-menu {
|
||||
position:fixed;
|
||||
z-index: 999999999;
|
||||
background: var(--color-raised);
|
||||
box-shadow: 0 0 4rem 0;
|
||||
color:var(--color-track);
|
||||
.item {
|
||||
color:var(--color-text)
|
||||
}
|
||||
.context-menu {
|
||||
position: absolute;
|
||||
left:100%;
|
||||
top:0;
|
||||
opacity:0;
|
||||
pointer-events: none;
|
||||
margin-left: 2rem;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
left:-2rem;
|
||||
width:2rem;
|
||||
}
|
||||
}
|
||||
> .item {
|
||||
padding: 10rem 15rem 10rem 10rem;
|
||||
position:relative;
|
||||
cursor: pointer;
|
||||
i {
|
||||
margin-right:5rem;
|
||||
width: 15rem;
|
||||
text-align: center;
|
||||
}
|
||||
&:hover, &:focus {
|
||||
> .context-menu {
|
||||
pointer-events: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
background:var(--color-accent);
|
||||
}
|
||||
&.has-sub:before {
|
||||
content:"\f105";
|
||||
display: block;
|
||||
font-family: FontAwesome;
|
||||
float:right;
|
||||
margin-right:-10rem;
|
||||
padding-left: 10rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ui-resizable-handle {
|
||||
position: absolute;
|
||||
z-index: 1000000;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: var(--color-accent);
|
||||
width:10rem;
|
||||
height:10rem;
|
||||
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-5rem;
|
||||
right:-5rem;
|
||||
left:-5rem;
|
||||
bottom:-5rem;
|
||||
}
|
||||
&.ui-resizable-se {
|
||||
content:"";
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
cursor: se-resize;
|
||||
}
|
||||
&.ui-resizable-e {
|
||||
top: 50%;
|
||||
margin-top:-5rem;
|
||||
right: 0;
|
||||
cursor: e-resize;
|
||||
}
|
||||
&.ui-resizable-s {
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
margin-left:-5rem;
|
||||
cursor: s-resize;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.ui-helper {
|
||||
min-width:30rem!important;
|
||||
min-height:30rem!important;
|
||||
z-index: 12!important;
|
||||
opacity: 1!important;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:1rem;
|
||||
bottom:1rem;
|
||||
border:1rem dashed var(--color-accent);
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:1rem;
|
||||
bottom:1rem;
|
||||
background: var(--color-accent);
|
||||
opacity: .25;
|
||||
}
|
||||
}
|
||||
|
||||
.ui-draggable-handle:not(.label) {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 100000;
|
||||
height:10rem;
|
||||
width: 10rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: var(--color-accent);
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-5rem;
|
||||
right:-5rem;
|
||||
left:-5rem;
|
||||
bottom:-5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.ui-draggable-handle {
|
||||
cursor: -webkit-grab;
|
||||
&:active {
|
||||
cursor:-webkit-grabbing;
|
||||
}
|
||||
}
|
||||
128
src/browser/scss/_layout.scss
Normal file
128
src/browser/scss/_layout.scss
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
body {
|
||||
background:var(--color-bg);
|
||||
}
|
||||
|
||||
#container {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
bottom:0;
|
||||
right:0;
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
background:var(--color-bg);
|
||||
padding:2rem;
|
||||
// transition:right .2s;
|
||||
&.sidepanel-open {
|
||||
right:var(--sidepanel-size);
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
height:100%;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background:var(--color-fg);
|
||||
padding:2rem;
|
||||
}
|
||||
|
||||
.tab {
|
||||
position: absolute;
|
||||
overflow: auto;
|
||||
left:0;
|
||||
right:-1rem; // because widgets have a fake 1rem right-border
|
||||
top:0;
|
||||
bottom:0;
|
||||
background:var(--color-bg);
|
||||
transform: rotateZ(0);
|
||||
}
|
||||
.has-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
> .navigation {
|
||||
background:var(--color-bg);
|
||||
margin-right:1rem; // because widgets have a fake 1rem right-border
|
||||
}
|
||||
> .content {
|
||||
background:none;
|
||||
margin-right:1rem; // because widgets have a fake 1rem right-border
|
||||
}
|
||||
}
|
||||
|
||||
.navigation {
|
||||
height:var(--nav-height);
|
||||
margin-bottom: 2rem;
|
||||
flex-shrink:0;
|
||||
font-weight:bold;
|
||||
text-transform: uppercase;
|
||||
|
||||
&.main {
|
||||
li:last-child {
|
||||
width:var(--nav-height);
|
||||
max-width:var(--nav-height);
|
||||
min-width:var(--nav-height);
|
||||
i {
|
||||
margin:0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
ul {
|
||||
list-style:none;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
height:100%;
|
||||
|
||||
li {
|
||||
display:block;
|
||||
min-width:0;
|
||||
flex: 1;
|
||||
cursor:pointer;
|
||||
height:100%;
|
||||
margin-right: 1rem;
|
||||
|
||||
|
||||
&:last-child {
|
||||
margin-right:0;
|
||||
}
|
||||
a {
|
||||
background: var(--color-fg);
|
||||
pointer-events: none;
|
||||
padding: 5rem;
|
||||
height:100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow:hidden;
|
||||
text-align:center;
|
||||
position:relative;
|
||||
span {
|
||||
display:block;
|
||||
width:100%;
|
||||
-webkit-mask: linear-gradient(to left, rgba(0, 0, 0, 0), #000000 10rem) no-repeat;
|
||||
}
|
||||
}
|
||||
a:after {
|
||||
content:"";
|
||||
background:var(--color-accent);
|
||||
position: absolute;
|
||||
bottom:0;
|
||||
left:0;
|
||||
right:0;
|
||||
top:0;
|
||||
opacity: 0;
|
||||
transition: opacity .2s;
|
||||
z-index: -1;
|
||||
}
|
||||
&.on a, .sidepanel-open {
|
||||
position: relative;
|
||||
background: var(--color-raised);
|
||||
z-index: 0;
|
||||
&:after {
|
||||
opacity:0.3;
|
||||
}
|
||||
}
|
||||
}
|
||||
.parent + li a {
|
||||
padding-left: calc(5rem + 0.5 * var(--nav-height));
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/browser/scss/_reset.scss
Normal file
14
src/browser/scss/_reset.scss
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
border:0;
|
||||
box-sizing:border-box;
|
||||
text-decoration:none;
|
||||
outline:0;
|
||||
font:inherit;
|
||||
color:inherit;
|
||||
cursor: inherit;
|
||||
-webkit-tap-highlight-color:transparent;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
78
src/browser/scss/_scrollbars.scss
Normal file
78
src/browser/scss/_scrollbars.scss
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
::-webkit-scrollbar {
|
||||
width: var(--scrollbar-size);
|
||||
height:var(--scrollbar-size);
|
||||
opacity:1;
|
||||
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track-piece {
|
||||
background: var(--color-bg);
|
||||
&:vertical {
|
||||
border-left:2rem solid var(--color-bg);
|
||||
}
|
||||
&:horizontal {
|
||||
border-top:2rem solid var(--color-bg);
|
||||
}
|
||||
}
|
||||
::-webkit-scrollbar-corner {
|
||||
background: var(--color-fg);
|
||||
border-left:2rem solid var(--color-bg);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background:var(--color-raised);
|
||||
|
||||
&:vertical {
|
||||
border-left:2rem solid var(--color-bg);
|
||||
}
|
||||
&:horizontal {
|
||||
border-top:2rem solid var(--color-bg);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin arrow($i) {
|
||||
background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="50px" width="50px"><text x="50%" y="50%" font-size="30" fill="rgba(255,255,255,0.5)" alignment-baseline="central" text-anchor="middle" font-family="fontawesome"> '+$i+' </text></svg>');
|
||||
background-blend-mode: difference, normal;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-button:decrement:start, ::-webkit-scrollbar-button:increment:end {
|
||||
|
||||
background:var(--color-fg);
|
||||
height:var(--scrollbar-size);
|
||||
width: var(--scrollbar-size);
|
||||
|
||||
display: block;
|
||||
color:red;
|
||||
|
||||
background-size:contain;
|
||||
background-position: center;
|
||||
|
||||
&:vertical {
|
||||
&:decrement:start {
|
||||
border-left:2rem solid var(--color-bg);
|
||||
border-bottom:2rem solid var(--color-bg);
|
||||
@include arrow()
|
||||
}
|
||||
|
||||
&:increment:end {
|
||||
border-left:2rem solid var(--color-bg);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
@include arrow()
|
||||
}
|
||||
}
|
||||
&:horizontal {
|
||||
&:decrement:start {
|
||||
border-right:2rem solid var(--color-bg);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
@include arrow()
|
||||
}
|
||||
|
||||
&:increment:end {
|
||||
border-left:2rem solid var(--color-bg);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
@include arrow()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
149
src/browser/scss/_sidepanel.scss
Normal file
149
src/browser/scss/_sidepanel.scss
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
|
||||
#sidepanel {
|
||||
position:absolute;
|
||||
z-index: 999999;
|
||||
width:var(--sidepanel-size);
|
||||
border: 8rem solid var(--color-fg);
|
||||
top:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
margin-right:calc(-1 * var(--sidepanel-size));
|
||||
background:var(--color-fg);
|
||||
transition:transform .25s, opacity .25s;
|
||||
transform: translate3d(0,0,0);
|
||||
opacity: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: visible;
|
||||
|
||||
&.sidepanel-open {
|
||||
transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#options {
|
||||
position:absolute;
|
||||
left:0;top:0;
|
||||
right:0;bottom:0;
|
||||
list-style:none;
|
||||
|
||||
li {
|
||||
display:block;
|
||||
margin-bottom:8rem;
|
||||
position: relative;
|
||||
|
||||
&:last-child {
|
||||
margin: 0;
|
||||
}
|
||||
.btn + span {
|
||||
position: absolute;
|
||||
right:0rem;
|
||||
top:0rem;
|
||||
padding:8rem;
|
||||
color:var(--color-text-fade);
|
||||
&:hover {
|
||||
color:var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
padding: 4rem;
|
||||
li {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.editor .form {
|
||||
margin-top: 10rem;
|
||||
}
|
||||
.help {
|
||||
margin-top:10rem;
|
||||
font-size: .75em;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
&::-webkit-scrollbar-track-piece {
|
||||
background: var(--color-bg);
|
||||
&:vertical {
|
||||
border-left:8rem solid var(--color-fg);
|
||||
}
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background:var(--color-raised);
|
||||
&:vertical {
|
||||
border-left:8rem solid var(--color-fg);
|
||||
}
|
||||
}
|
||||
&::-webkit-scrollbar-button {
|
||||
border-color: var(--color-fg);
|
||||
border-width:8rem;
|
||||
background-color: var(--color-raised);
|
||||
}
|
||||
}
|
||||
.actions {
|
||||
padding:1rem;
|
||||
background:var(--color-bg);
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex-wrap:wrap;
|
||||
.title {
|
||||
background: var(--color-faded);
|
||||
min-width: 100%;
|
||||
flex-grow: 2;
|
||||
padding: 10rem;
|
||||
position: relative;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
box-shadow: 0 0 0 1rem;
|
||||
color:var(--color-bg);
|
||||
}
|
||||
|
||||
}
|
||||
a {
|
||||
min-width:33%;
|
||||
flex-grow:4;
|
||||
padding:10rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
color:var(--color-text);
|
||||
overflow: visible;
|
||||
|
||||
&.on {
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
&:after {
|
||||
opacity:.3;
|
||||
}
|
||||
}
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
box-shadow: 0 0 0 1rem;
|
||||
color:var(--color-bg);
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
background:var(--color-accent);
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
opacity: 0;
|
||||
transition: opacity .2s;
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/browser/scss/_vars.scss
Normal file
29
src/browser/scss/_vars.scss
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
:root {
|
||||
|
||||
--color-text:rgba(white,.8);
|
||||
--color-text-fade:rgba(white,0.5);
|
||||
|
||||
--color-bg:darken(#2b2f37,5%); // secondary
|
||||
--color-fg:lighten(#2b2f37,1%); // primary
|
||||
--color-raised:lighten(#2b2f37,5%); // raised
|
||||
--color-faded: darken(#2b2f37,1%); // faded
|
||||
|
||||
--color-track: lighten(#1a1d22,1%); // widgets unfilled value
|
||||
|
||||
--color-accent:#528bff;
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
|
||||
|
||||
--nav-height:40rem;
|
||||
--sidepanel-size:300rem;
|
||||
--scrollbar-size:30rem;
|
||||
|
||||
--pixel-scale:1;
|
||||
|
||||
/* Unset variables by default
|
||||
|
||||
--display-input:none; // Hides widgets' numeric inputs
|
||||
|
||||
*/
|
||||
}
|
||||
109
src/browser/scss/_widgets.scss
Normal file
109
src/browser/scss/_widgets.scss
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
|
||||
.widget {
|
||||
display:inline-block;
|
||||
height:auto;
|
||||
overflow: hidden;
|
||||
position:relative;
|
||||
vertical-align:top;
|
||||
box-shadow: -0.5rem -0.5rem 0 0.5rem;
|
||||
color:var(--color-bg);
|
||||
border-right:1rem solid var(--color-bg);
|
||||
border-bottom:1rem solid var(--color-bg);
|
||||
background:var(--color-fg);
|
||||
-webkit-tap-highlight-color:transparent;
|
||||
min-height:30rem;
|
||||
min-width:30rem;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
|
||||
> * {
|
||||
color:var(--color-text)
|
||||
}
|
||||
|
||||
&.absolute-position {
|
||||
position: absolute;
|
||||
// z-index: 10;
|
||||
}
|
||||
|
||||
&.nolabel {
|
||||
> .label {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
padding:10rem 10rem;
|
||||
text-overflow:ellipsis;
|
||||
overflow:hidden;
|
||||
text-align:center;
|
||||
height:35rem;
|
||||
max-height:35rem;
|
||||
width: 100%;
|
||||
background: var(--color-raised);
|
||||
border-bottom:1rem solid var(--color-bg);
|
||||
flex-shrink: 0;
|
||||
|
||||
&.accent {
|
||||
color:var(--color-accent);
|
||||
}
|
||||
}
|
||||
.input {
|
||||
width:100%;
|
||||
height:24rem;
|
||||
border:0;
|
||||
background:transparent;
|
||||
color:var(--color-text-fade);
|
||||
display:block;
|
||||
padding:4rem 5rem;
|
||||
position: relative;
|
||||
display: var(--display-input);
|
||||
|
||||
input {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
padding:4rem 5rem;
|
||||
width: 100%;
|
||||
font: inherit;
|
||||
text-align:center;
|
||||
border:0;
|
||||
background: transparent;
|
||||
color:var(--color-accent);
|
||||
}
|
||||
canvas {
|
||||
width:100%;
|
||||
height:100%;
|
||||
opacity: 0.8;
|
||||
}
|
||||
input + canvas {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
color:var(--color-accent);
|
||||
|
||||
}
|
||||
&[disabled] {
|
||||
color:var(--color-text-fade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@import 'widgets/fader';
|
||||
@import 'widgets/knob';
|
||||
|
||||
@import 'widgets/matrices';
|
||||
@import 'widgets/pads';
|
||||
|
||||
@import 'widgets/plots';
|
||||
|
||||
|
||||
@import 'widgets/toggle';
|
||||
@import 'widgets/push';
|
||||
@import 'widgets/switch';
|
||||
|
||||
@import 'widgets/strip';
|
||||
@import 'widgets/panel';
|
||||
252
src/browser/scss/style.scss
Normal file
252
src/browser/scss/style.scss
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
@import 'vars';
|
||||
@import 'reset';
|
||||
|
||||
|
||||
@import 'scrollbars';
|
||||
|
||||
@import 'layout';
|
||||
|
||||
@import 'editor';
|
||||
@import 'sidepanel';
|
||||
@import 'widgets';
|
||||
|
||||
|
||||
input:focus::selection{
|
||||
background:var(--color-accent);
|
||||
color:var(--color-text);
|
||||
}
|
||||
input {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
html, body {
|
||||
height:100%;
|
||||
overflow:hidden;
|
||||
position:relative;
|
||||
|
||||
}
|
||||
|
||||
html{
|
||||
// global pixel scaling
|
||||
font-size: calc(var(--pixel-scale) * 1px);
|
||||
|
||||
// prevent android's auto font-resize
|
||||
max-height: 999999px;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size:13rem;
|
||||
line-height:16rem;
|
||||
font-family:Droid Sans;
|
||||
color:var(--color-text);
|
||||
white-space:nowrap;
|
||||
opacity:1;
|
||||
cursor: default;
|
||||
}
|
||||
i {
|
||||
font-size: 14rem!important;
|
||||
}
|
||||
|
||||
|
||||
.btn {
|
||||
background: var(--color-raised);
|
||||
display: block;
|
||||
padding:15rem;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
&.small {
|
||||
padding:8rem;
|
||||
padding-right: 15rem;
|
||||
}
|
||||
&.warning {
|
||||
background:firebrick;
|
||||
}
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
color:var(--color-text-fade);
|
||||
}
|
||||
&.align-center {
|
||||
text-align: center
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#lobby {
|
||||
background: var(--color-bg);
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right: 0;
|
||||
bottom:0;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow-y: auto;
|
||||
padding:20rem;
|
||||
.main {
|
||||
width:600rem;
|
||||
max-width: 100%;
|
||||
max-height:100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.list {
|
||||
flex:1;
|
||||
overflow: auto;
|
||||
background: var(--color-fg);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
|
||||
}
|
||||
.header {
|
||||
padding:20rem;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-grow: 0;
|
||||
background-color: var(--color-faded);
|
||||
color:var(--color-accent);
|
||||
font-size:16rem;
|
||||
line-height: 24rem;
|
||||
}
|
||||
.footer {
|
||||
background: var(--color-raised);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-grow: 0;
|
||||
background: var(--color-faded);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
}
|
||||
a {
|
||||
display: block;
|
||||
padding-right:35rem;
|
||||
overflow: hidden;
|
||||
padding-top:15rem;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
background: none;
|
||||
border-bottom:1rem solid var(--color-bg);
|
||||
&:hover {
|
||||
background:var(--color-raised)
|
||||
}
|
||||
&:last-child {
|
||||
border-bottom:0;
|
||||
}
|
||||
span {
|
||||
position: absolute;
|
||||
right:0rem;
|
||||
top:0rem;
|
||||
padding:15rem;
|
||||
color:var(--color-text-fade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#loading {
|
||||
position: absolute;
|
||||
top:50%;
|
||||
left:50%;
|
||||
margin-top:-15rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
height:30rem;
|
||||
width:30rem;
|
||||
border-radius: 50%;
|
||||
border:2rem solid var(--color-track);
|
||||
border-top-color:var(--color-accent);
|
||||
animation: spin .5s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {transform: rotate(0deg);}
|
||||
100% {transform: rotate(360deg);}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.popup {
|
||||
position: fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
padding:10%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index:1000000;
|
||||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background:var(--color-bg);
|
||||
opacity: .5;
|
||||
}
|
||||
.popup-title {
|
||||
position: relative;
|
||||
padding:15rem;
|
||||
background:var(--color-raised);
|
||||
.closer {
|
||||
position:absolute;
|
||||
right:0rem;
|
||||
top:0;
|
||||
padding:15rem;
|
||||
color:var(--color-text-fade);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.popup-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
background:var(--color-fg);
|
||||
width:auto;
|
||||
max-width:600rem;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border:1rem solid var(--color-track);
|
||||
.popup-content {
|
||||
height:100%;
|
||||
width:100%;
|
||||
padding:10rem;
|
||||
overflow-y:auto;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
204
src/browser/scss/widgets/_fader.scss
Normal file
204
src/browser/scss/widgets/_fader.scss
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
.fader-container {
|
||||
--color-pips: var(--color-text-fade);
|
||||
--color-gauge: var(--color-custom);
|
||||
--color-knob: var(--color-custom);
|
||||
height:100%;
|
||||
width:100rem;
|
||||
}
|
||||
|
||||
.fader {
|
||||
height:100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
|
||||
.wrapper {
|
||||
overflow: hidden;
|
||||
flex:1;
|
||||
display: flex;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
canvas {
|
||||
flex:1;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.meter-container {
|
||||
pointer-events: none;
|
||||
|
||||
position: absolute;
|
||||
top:20rem;
|
||||
bottom:19rem;
|
||||
left:50%;
|
||||
height: auto;
|
||||
width:3rem;
|
||||
min-width: 3rem;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&.has-pips {
|
||||
|
||||
.wrapper canvas {
|
||||
padding-right: 28rem;
|
||||
}
|
||||
|
||||
.pips {
|
||||
pointer-events: none;
|
||||
|
||||
position: absolute;
|
||||
top:20rem;
|
||||
bottom:20rem;
|
||||
left:50%;
|
||||
z-index: 0;
|
||||
width: 4rem;
|
||||
margin-left: 7rem;
|
||||
background: linear-gradient(to bottom, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);
|
||||
background-size: 100% 5px;
|
||||
background-repeat: repeat-y;
|
||||
|
||||
.pip {
|
||||
height:1px;
|
||||
background: var(--color-pips);
|
||||
color:var(--color-fg);
|
||||
position: absolute;
|
||||
width:8rem;
|
||||
left:0;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4px;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:-4px;
|
||||
background: var(--color-fg);
|
||||
z-index: -1;
|
||||
}
|
||||
span {
|
||||
position: absolute;
|
||||
width:30rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size:10rem;
|
||||
line-height: 12rem;
|
||||
left:3rem;
|
||||
top:-5.5rem;
|
||||
color:var(--color-pips);
|
||||
}
|
||||
}
|
||||
}
|
||||
&.horizontal {
|
||||
.wrapper canvas {
|
||||
padding-right:0;
|
||||
padding-bottom: 20rem;
|
||||
}
|
||||
.wrapper .meter-container {
|
||||
left:20rem;
|
||||
right:20rem;
|
||||
height: 3rem;
|
||||
min-height: 3rem;
|
||||
width: auto;
|
||||
top:50%;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.pips {
|
||||
top:50%;
|
||||
left:20rem;
|
||||
right:20rem;
|
||||
font-size: 0;
|
||||
height:4rem;
|
||||
width:auto;
|
||||
margin:0;
|
||||
margin-top: 10rem;
|
||||
background: linear-gradient(to right, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);
|
||||
background-size: 5px 100%;
|
||||
background-repeat: repeat-x;
|
||||
.pip {
|
||||
width:1px;
|
||||
height:6rem;
|
||||
margin: 0;
|
||||
&:before {
|
||||
top:0;
|
||||
bottom:0;
|
||||
left:-4px;
|
||||
right:-4px;
|
||||
}
|
||||
span {
|
||||
top:15rem;
|
||||
left:-15rem!important;
|
||||
right:auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.align-right {
|
||||
.wrapper canvas {
|
||||
padding-right: 0;
|
||||
padding-left: 28rem;
|
||||
}
|
||||
.wrapper .meter-container {
|
||||
left: auto;
|
||||
right:50%;
|
||||
margin-left: 0;
|
||||
}
|
||||
.pips {
|
||||
margin-left: 0;
|
||||
margin-right: 7rem;
|
||||
left:auto;
|
||||
right:50%;
|
||||
.pip {
|
||||
right:0;
|
||||
left:auto;
|
||||
span {
|
||||
right:3rem;
|
||||
left:auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&.compact {
|
||||
.wrapper canvas {
|
||||
background: var(--color-faded)
|
||||
}
|
||||
.input {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top:50%;
|
||||
transform: rotate(-90deg);
|
||||
pointer-events: none;
|
||||
width: 100rem;
|
||||
margin-left: -50rem;
|
||||
left:50%;
|
||||
z-index: 3;
|
||||
margin-top: -12rem;
|
||||
}
|
||||
.meter-container {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: auto;
|
||||
right:0;
|
||||
}
|
||||
&.horizontal {
|
||||
.meter-container {
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right:0;
|
||||
height: 3rem;
|
||||
min-height: 3rem;
|
||||
width: auto;
|
||||
}
|
||||
.input {
|
||||
transform: none;
|
||||
top:50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
src/browser/scss/widgets/_knob.scss
Normal file
56
src/browser/scss/widgets/_knob.scss
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
.knob-container {
|
||||
--color-pips: var(--color-text-fade);
|
||||
--color-gauge: var(--color-custom);
|
||||
--color-knob: var(--color-custom);
|
||||
|
||||
width: 100rem;
|
||||
height: 120rem;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.knob {
|
||||
height:100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
|
||||
.wrapper {
|
||||
overflow: hidden;
|
||||
flex:1;
|
||||
display: flex;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
canvas {
|
||||
flex:1;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
&.compact {
|
||||
.input {
|
||||
position: absolute;
|
||||
top:calc(50% - 12rem);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
.pips {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
pointer-events: none;
|
||||
div {
|
||||
padding: 0 8%;
|
||||
font-size: 11rem;
|
||||
color: var(--color-text-fade);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
src/browser/scss/widgets/_matrices.scss
Normal file
44
src/browser/scss/widgets/_matrices.scss
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* Multiple widgets (push|toggle|fader) matrix */
|
||||
.multitoggle-container, .multipush-container, .multifader-container {
|
||||
height:200rem;
|
||||
width:200rem;
|
||||
&.nolabel .matrix {
|
||||
top:0;
|
||||
}
|
||||
}
|
||||
.matrix {
|
||||
flex:1;
|
||||
overflow: auto;
|
||||
background: var(--color-bg);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
margin-right:-1rem;
|
||||
margin-bottom: -1rem;
|
||||
|
||||
> .widget {
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
margin:0!important;
|
||||
.label {
|
||||
background:none;
|
||||
border:0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.multifader-container {
|
||||
.matrix {
|
||||
padding:0!important;
|
||||
align-items:stretch;
|
||||
}
|
||||
.widget {
|
||||
height: auto;
|
||||
}
|
||||
.fader-wrapper {
|
||||
padding:10rem 0 20rem!important;
|
||||
.fader {
|
||||
left:0!important;
|
||||
}
|
||||
}
|
||||
}
|
||||
172
src/browser/scss/widgets/_pads.scss
Normal file
172
src/browser/scss/widgets/_pads.scss
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
.xy-container, .rgb-container {
|
||||
width:200rem;
|
||||
height:250rem;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
.label {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
.xy-wrapper {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.value {
|
||||
width:100%;
|
||||
display:var(--display-input);
|
||||
}
|
||||
.input {
|
||||
width:50%;
|
||||
float:left;
|
||||
height: 24rem;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
.xy {
|
||||
position:relative;
|
||||
width:auto;
|
||||
height:100%;
|
||||
overflow: hidden;
|
||||
cursor: -webkit-grab;
|
||||
background:var(--color-faded);
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
.handle {
|
||||
position:absolute;
|
||||
bottom:0;
|
||||
left:0;
|
||||
z-index:2;
|
||||
pointer-events: none;
|
||||
backface-visibility: hidden;
|
||||
transform-origin: center;
|
||||
transform:translate3d(0,0,0);
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
right:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
background:var(--color-custom);
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-10rem;
|
||||
right:-10rem;
|
||||
height:20rem;
|
||||
width:20rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
background:var(--color-custom);
|
||||
opacity: .2; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.rgb-wrapper {
|
||||
.input, input {
|
||||
width:33.33%;
|
||||
}
|
||||
}
|
||||
|
||||
.rgb {
|
||||
.bg {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background-color: red;
|
||||
opacity: .75;
|
||||
pointer-events: none;
|
||||
&:before, &:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
&:before {
|
||||
background: linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
|
||||
}
|
||||
&:after {
|
||||
background:linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%);
|
||||
}
|
||||
}
|
||||
.handle {
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
right:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
background:var(--color-text);
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-10rem;
|
||||
right:-10rem;
|
||||
height:20rem;
|
||||
width:20rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
background:var(--color-text);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hue {
|
||||
width:auto;
|
||||
min-height:30rem;
|
||||
overflow: hidden;
|
||||
cursor: -webkit-grab;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
.bg {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
opacity: 0.5;
|
||||
background:transparent linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
|
||||
pointer-events: none;
|
||||
}
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
.handle {
|
||||
position:absolute;
|
||||
z-index:2;
|
||||
left:0;
|
||||
top:50%;
|
||||
pointer-events: none;
|
||||
transform: translate3d(0,0,0);
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
right:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
box-shadow: none;
|
||||
background:var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
64
src/browser/scss/widgets/_panel.scss
Normal file
64
src/browser/scss/widgets/_panel.scss
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
.panel-container {
|
||||
width: 200rem;
|
||||
height: 200rem;
|
||||
border:0;
|
||||
|
||||
background: var(--color-faded);
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
border-bottom: 1rem solid var(--color-bg);
|
||||
border-right: 1rem solid var(--color-bg);
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
&.nolabel .panel {
|
||||
top:0;
|
||||
}
|
||||
|
||||
.panel {
|
||||
overflow: auto;
|
||||
position: absolute;
|
||||
top:35rem;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
|
||||
&.has-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
&.noscroll {
|
||||
overflow: hidden;
|
||||
> .widget {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.navigation {
|
||||
border-top: 0;
|
||||
background: transparent;
|
||||
&:after {
|
||||
background: var(--color-bg);
|
||||
}
|
||||
a.on {
|
||||
border-color: var(--color-bg);
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
122
src/browser/scss/widgets/_plots.scss
Normal file
122
src/browser/scss/widgets/_plots.scss
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
.led-container {
|
||||
width:100rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.led {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
padding:10rem 0;
|
||||
overflow: hidden;
|
||||
|
||||
div {
|
||||
border-radius: 100%;
|
||||
width:calc(100% - 20rem);
|
||||
padding-bottom:calc(100% - 20rem);
|
||||
margin: 0 auto;
|
||||
background:var(--color-track);
|
||||
position: relative;
|
||||
span {
|
||||
position: absolute;
|
||||
top:0;left:0;right:0;bottom:0;
|
||||
border-radius: 100%;
|
||||
display:block;
|
||||
background-color:var(--color-custom);
|
||||
&:after {
|
||||
content:"";
|
||||
border-radius:100%;
|
||||
position: absolute;
|
||||
top:-1rem;left:-1rem;right:-1rem;bottom:-1rem;
|
||||
display:block;
|
||||
border: 6rem solid var(--color-fg);
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.plot-container, .visualizer-container, .eq-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
height: 200rem;
|
||||
width: 200rem;
|
||||
.plot {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex:1;
|
||||
position: relative;
|
||||
}
|
||||
canvas {
|
||||
position: absolute;
|
||||
top:0;left:0;
|
||||
width:100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.meter-container {
|
||||
--color-custom:var(--color-accent);
|
||||
--color-gauge: var(--color-custom);
|
||||
|
||||
height: 100rem;
|
||||
.meter {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex:1;
|
||||
position: relative;
|
||||
|
||||
background: var(--color-track);
|
||||
|
||||
.level {
|
||||
width:100%;
|
||||
flex:1;
|
||||
transform-origin: bottom;
|
||||
background:var(--color-custom);
|
||||
// opacity: .5;
|
||||
}
|
||||
&::after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
bottom:0;
|
||||
right:0;
|
||||
background-image: linear-gradient(transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px );
|
||||
background-size: 100% 2px;
|
||||
background-repeat: repeat;
|
||||
}
|
||||
&.horizontal {
|
||||
&::after {
|
||||
background-image: linear-gradient(to left, transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px );
|
||||
background-size: 2px 100% ;
|
||||
}
|
||||
.level {
|
||||
transform-origin: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.text-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
.text {
|
||||
flex: 1;
|
||||
height:35rem;
|
||||
padding: 10rem;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--color-faded);
|
||||
color:var(--color-custom);
|
||||
&.vertical {
|
||||
transform: rotate(180deg);
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
-webkit-writing-mode:vertical-lr;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/browser/scss/widgets/_push.scss
Normal file
9
src/browser/scss/widgets/_push.scss
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
.push-container {
|
||||
@extend .toggle-container;
|
||||
.active {
|
||||
background: var(--color-fg);
|
||||
}
|
||||
.light:after{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
83
src/browser/scss/widgets/_strip.scss
Normal file
83
src/browser/scss/widgets/_strip.scss
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
|
||||
|
||||
.strip-container {
|
||||
width:100rem;
|
||||
height:100%;
|
||||
overflow: visible;
|
||||
// background: var(--color-bg);
|
||||
border:0;
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
> .strip {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
> .widget {
|
||||
width:auto;
|
||||
margin:0;
|
||||
box-shadow: none;
|
||||
.label {
|
||||
background-image: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.vertical {
|
||||
> .strip > .widget {
|
||||
max-width: 100%;
|
||||
}
|
||||
&::before {
|
||||
border-right: 1rem solid var(--color-bg);
|
||||
}
|
||||
}
|
||||
&.horizontal {
|
||||
width:100%;
|
||||
height:200rem;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
&::before {
|
||||
border-bottom: 1rem solid var(--color-bg);
|
||||
}
|
||||
|
||||
> .strip {
|
||||
flex-direction: row;
|
||||
flex:1;
|
||||
> .widget {
|
||||
flex-shrink: initial;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
max-height: 100%;
|
||||
height:100%;
|
||||
}
|
||||
}
|
||||
> .label {
|
||||
width:35rem;
|
||||
height:100%;
|
||||
border-bottom:0;
|
||||
border-right:1rem solid var(--color-bg);
|
||||
max-height: initial;
|
||||
span {
|
||||
transform: rotate(180deg);
|
||||
display: block;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
-webkit-writing-mode:vertical-lr;
|
||||
text-align: center;
|
||||
height:100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
75
src/browser/scss/widgets/_switch.scss
Normal file
75
src/browser/scss/widgets/_switch.scss
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
.switch-container {
|
||||
width:100rem;
|
||||
flex-shrink: 0;
|
||||
.switch {
|
||||
height:100%;
|
||||
width:100%;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction:column;
|
||||
align-items: stretch;
|
||||
flex:1;
|
||||
z-index: 1;
|
||||
|
||||
&.horizontal {
|
||||
flex-direction:row;
|
||||
.value {
|
||||
padding:6rem;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
border-top:0;
|
||||
border-right:1rem solid var(--color-bg);
|
||||
flex:1;
|
||||
height:auto;
|
||||
&:last-child {
|
||||
border-right:0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.value {
|
||||
background:var(--color-raised);
|
||||
color:var(--color-text);
|
||||
width:100%;
|
||||
height:100%;
|
||||
position: relative;
|
||||
border-top: 1rem solid var(--color-bg);
|
||||
white-space: normal;
|
||||
padding:12rem;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
box-shadow: 0 0 1rem 0 var(--color-text-fade) inset;
|
||||
|
||||
&:first-child {
|
||||
border-top:0;
|
||||
}
|
||||
&:last-child {
|
||||
margin-bottom:0;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background: var(--color-custom);
|
||||
opacity: 0;
|
||||
z-index: 2;
|
||||
}
|
||||
&.on:before {
|
||||
opacity: .3;
|
||||
box-shadow: 0 0 1rem 0 var(--color-custom) inset;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
59
src/browser/scss/widgets/_toggle.scss
Normal file
59
src/browser/scss/widgets/_toggle.scss
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
.toggle-container {
|
||||
width:100rem;
|
||||
min-height: 65rem;
|
||||
flex-shrink: 0;
|
||||
padding:0!important;
|
||||
background: var(--color-raised);
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
top:1rem;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
height:auto;
|
||||
max-height: initial;
|
||||
border:0;
|
||||
background: none!important;
|
||||
text-align: center;
|
||||
pointer-events:none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
.light {
|
||||
box-shadow: 0 0 1rem 0 var(--color-text-fade) inset;
|
||||
flex:1;
|
||||
|
||||
&:after {
|
||||
content:"";
|
||||
border-top: 4rem solid var(--color-text-fade);
|
||||
opacity: .1;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
background: var(--color-custom);
|
||||
opacity: 0;
|
||||
}
|
||||
&.on {
|
||||
|
||||
box-shadow: 0 0 1rem 0 var(--color-custom) inset;
|
||||
&:before {
|
||||
opacity: .3;
|
||||
}
|
||||
&:after {
|
||||
border-top-color: var(--color-custom);
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue