- big optimizations :

- remove nouislider and jquery-ui dependency (along with touch punch js hack for jqueryui)
 - rewrote slider and xy/rgb pads, lighter and faster, with  much better touch support/performances
This commit is contained in:
jean-emmanuel 2015-09-08 13:08:07 +02:00 • committed by bordun
parent a47307ad1e
commit b6254c954e
13 changed files with 563 additions and 2930 deletions

View file

@ -3,6 +3,10 @@
"sessionPath": "/home/bordun/oscwork/oschtmlgui/sessions/",
"recentSessions": [
"/home/bordun/oscwork/oschtmlgui/sessions/demo.js",
"/home/bordun/oscwork/oschtmlgui/sessions/demo-full.js"
"/home/bordun/oscwork/oschtmlgui/sessions/xy.js",
"/home/bordun/oscwork/oschtmlgui/sessions/demo-full.js",
"/home/bordun/oscwork/oschtmlgui/sessions/fadertest.js",
"/home/bordun/oscwork/oschtmlgui/sessions/monitorsjeannot.js",
"/home/bordun/oscwork/oschtmlgui/sessions/sebkhachott.js"
]
}

View file

@ -1,296 +0,0 @@
/* Functional styling;
* These styles are required for noUiSlider to function.
* You don't need to change these rules to apply your design.
*/
.noUi-target,
.noUi-target * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-ms-touch-action: none;
-ms-user-select: none;
-moz-user-select: none;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.noUi-target {
position: relative;
}
.noUi-base {
width: 100%;
height: 100%;
position: relative;
}
.noUi-origin {
position: absolute;
right: 0;
top: 0;
left: 0;
bottom: 0;
}
.noUi-handle {
position: relative;
z-index: 1;
}
.noUi-stacking .noUi-handle {
/* This class is applied to the lower origin when
its values is > 50%. */
z-index: 10;
}
.noUi-stacking + .noUi-origin {
/* Fix stacking order in IE7, which incorrectly
creates a new context for the origins. */
*z-index: -1;
}
.noUi-state-tap .noUi-origin {
-webkit-transition: left 0.3s, top 0.3s;
transition: left 0.3s, top 0.3s;
}
.noUi-state-drag * {
cursor: inherit !important;
}
/* Painting and performance;
* Browsers can paint handles in their own layer.
*/
.noUi-base {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
/* Slider size and handle placement;
*/
.noUi-horizontal {
height: 4px!important;
}
.noUi-handle {
border-radius:100%!important;
background:$color-accent!important;
box-shadow:0 0 10px 0px #aaa inset,0 0 1px 1px rgba(0,0,0,.5),0 0 0 3px rgba(255,255,255,.2)!important
}
.noUi-horizontal .noUi-handle {
width: 10px;
height: 10px;
left: -5px;
top: -3px;
border:0;
padding:0;
}
.noUi-vertical {
width: 4px;
}
.noUi-vertical .noUi-handle {
width: 10px;
height: 10px;
left: -3px;
top: -5px;
}
/* Styling;
*/
.noUi-background {
background: #FAFAFA;
}
.noUi-connect {
background: $color-accent;
-webkit-transition: background 450ms;
transition: background 450ms;
}
.noUi-origin {
border-radius: 2px;
}
.noUi-target {
border-radius: 4px;
border: 1px solid #D3D3D3;
}
.noUi-target.noUi-connect {
}
/* Handles;
*/
.noUi-handle {
background: #FFF;
box-shadow: inset 0 0 1px #FFF,
inset 0 1px 7px #EBEBEB,
0 3px 6px -3px #BBB;
cursor: -webkit-grab;
&:active {
cursor: -webkit-grabbing;
}
}
.noUi-active {
box-shadow: inset 0 0 1px #FFF,
inset 0 1px 7px #DDD,
0 3px 6px -3px #BBB;
}
/* Disabled state;
*/
[disabled].noUi-connect,
[disabled] .noUi-connect {
background: #B8B8B8;
}
[disabled] .noUi-handle {
cursor: not-allowed;
}
/* PIPS */
/* Base;
*
*/
.noUi-pips,
.noUi-pips * {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.noUi-pips {
position: absolute;
font: 400 12px Arial;
color: #999;
}
/* Values;
*
*/
.noUi-value {
width: 40px;
position: absolute;
text-align: center;
}
.noUi-value-sub {
color: #ccc;
font-size: 10px;
}
/* Markings;
*
*/
.noUi-marker {
position: absolute;
background: #CCC;
}
.noUi-marker-sub {
background: #AAA;
}
.noUi-marker-large {
background: #AAA;
}
/* Horizontal layout;
*
*/
.noUi-pips-horizontal {
padding: 10px 0;
height: 50px;
top: 100%;
left: 0;
width: 100%;
}
.noUi-value-horizontal {
margin-left: -20px;
padding-top: 20px;
}
.noUi-value-horizontal.noUi-value-sub {
padding-top: 15px;
}
.noUi-marker-horizontal.noUi-marker {
margin-left: -1px;
width: 2px;
height: 5px;
}
.noUi-marker-horizontal.noUi-marker-sub {
height: 10px;
}
.noUi-marker-horizontal.noUi-marker-large {
height: 15px;
}
/* Vertical layout;
*
*/
.noUi-pips-vertical {
padding: 0 10px;
height: 100%;
top: 0;
left: 100%;
}
.noUi-value-vertical {
width: 15px;
margin-left: 20px;
margin-top: -5px;
}
.noUi-marker-vertical.noUi-marker {
width: 5px;
height: 2px;
margin-top: -1px;
}
.noUi-marker-vertical.noUi-marker-sub {
width: 10px;
}
.noUi-marker-vertical.noUi-marker-large {
width: 15px;
}
.noUi-background {
background:#222;
border:0px;
border-radius:0px;
box-shadow:0 0 0;
}
.noUi-target {
box-shadow:0 0 0;
}
.noUi-base {
z-index:2;
}
.noUi-handle {
border-radius:0;
box-shadow:0 0 0;
border-color:rgba(255,255,255,0.4);
}
.noUi-connect {
background:$color-accent;
border:0;
border-radius:0;
}
.noUi-handle:after {
content:"";
position:absolute;
height:500px;
left:-5000px;
width:10000px;
top:-250px;
background:none;
display:block!important;
}
.noUi-pips {
font-size:11px;
font-family:sans;
}
.noUi-value-vertical {
margin-top:-7px;
}
.noUi-marker-vertical.noUi-marker {
height:1px;
}
.noUi-marker-horizontal.noUi-marker {
width:1px;
}

View file

@ -444,18 +444,28 @@ a {
.spinner {
#loading {
position: absolute;
top:50%;
left:50%;
margin:-15px 0 0 -15px;
height:30px;
width:30px;
border-radius: 50%;
border:2px solid rgba(0,0,0,.2);
border-top-color:$color-accent;
animation: spin .5s linear infinite;
margin-top:-15px;
text-align: center;
.spinner {
display: block;
margin: 0 auto;
height:30px;
width:30px;
border-radius: 50%;
border:2px solid rgba(0,0,0,.2);
border-top-color:$color-accent;
animation: spin .5s linear infinite;
}
#status {
margin-top: 10px;
display: inline-block;
}
}
@keyframes spin {
@ -534,51 +544,92 @@ a {
position:relative;vertical-align:top;
}
/* BUTTON */
$button-size:20px;
.button-wrapper {
height:100%;
/* BUTTONS */
.toggle {
width:95px;
overflow:hidden;
padding: 10px 0 40px;
position: relative;
.button {
width:100%;
height:100%;
padding:10px 1px 0;
cursor: pointer;
div {
display: flex;
align-items: center;
justify-content: center;
height:100%;
position:relative;
outline:1px solid $color-bg;
outline-offset: -10px;
text-align: center;
span {
white-space: nowrap;
text-overflow: ellipsis;
}
background:$bg-button;
box-shadow: 0 0 0 1px $color-bg inset;
cursor: pointer;
&:after{
content:"";
position:absolute;
height:$button-size;
width:$button-size;
top:50%;left:50%;
margin:(- $button-size/2) 0 0 (- $button-size/2);
border-radius:$button-size;
background:$color-bg;
}
&.on:after {
background:$color-accent;
box-shadow:0 0 0 4px rgba(255,255,255,0.1);
}
color:$color-text-fade;
}
input {
position:absolute;
bottom:0;
box-shadow: 0 0 1px 0 $color-border inset;
&.on div {
background:transparentize($color-accent,.4);
color:$color-text;
}
}
.stack .toggle {
float:right;
width:70%;
height:70px;
padding: 0 0 0 10px;
position: static;
}
.switch {
width:95px;
height:100%;
padding:10px 1px 0;
cursor: pointer;
display: flex;
flex-direction:column;
align-items: stretch;
.value {
background:$bg-button;
color:$color-text-fade;
display: flex;
align-items: center;
justify-content: center;
height:100%;
width:100%;
margin-bottom:2px;
&:last-child {
margin-bottom:0;
}
&.on {
background:transparentize($color-accent,.4);
color:$color-text;
}
}
}
.stack .switch {
float:right;
width:70%;
height:70px;
padding: 0 0 0 10px;
position: static;
flex-direction:row;
.value {
margin-bottom:0px;
margin-right:2px;
&:last-child {
margin-right:0;
}
}
}
/* STACK (contains any widgets) */
.stack {
width:400px;
width:400px;
height:auto;
padding-bottom:0;
border-bottom: 0;
@ -611,18 +662,7 @@ width:400px;
clear:both;
}
}
.stack .fader {
width:100%;
}
.stack .fader-wrapper-outer {
padding:0;
}
.stack .fader-wrapper {
padding:20px 20px;
float:right;
width:70%;
height:70px;
}
.stack .button-wrapper {
float:right;
width:70%;
@ -636,17 +676,14 @@ width:400px;
.stack .widget .title {
width:30%;
height:35px;
//border-right:1px solid $color-border;
}
.stack .fader-wrapper-outer input, .stack .button-wrapper input {
width:30%;
height:35px;
left:0;
right:auto;
border-top:0;
//border-right:1px solid $color-border;
}
.stack .xy-wrapper {
float:right;
width:70%;
@ -655,6 +692,14 @@ width:400px;
padding-left:10px;
}
/* STRIP (vertical fader) */
.fader-wrapper-outer {
@ -711,8 +756,12 @@ width:400px;
overflow: hidden;
.handle {
position:absolute;
height:0;
width:0;
height:0px;
width:0px;
bottom:0;
left:0;
max-height:100%;
max-width:100%;
z-index:2;
cursor: -webkit-grab;
&:active {
@ -722,13 +771,13 @@ width:400px;
content:"";
position:absolute;
top:-.5px;
left:-1px;
right:-1px;
//box-shadow:0 0 10px 0px #aaa inset,0 0 1px 1px rgba(0,0,0,.5),0 0 0 3px rgba(255,255,255,.2)!important;
border-radius:100%!important;
//background:$color-accent!important;
width: 20px;
height: 20px;
margin:-10px 0 0 -10px;
margin:-10px -10px 0 0;
box-shadow: 0 0 0 1000px rgba(black,.5), 0 0 0 1px rgba(white,.2);
}
@ -782,23 +831,32 @@ width:400px;
margin-top:10px;
background:transparent linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
overflow: hidden;
position: relative;
.handle {
position:absolute;
height:100%;
width:1px;
max-width: 100%;
width:0;
z-index:2;
left:0;
bottom:0;
cursor: -webkit-grab;
&:active {
cursor: -webkit-grabbing;
}
&:after {
content:"";
position:absolute;
top:50%;
left:-1px;
right:-1px;
box-shadow: 0 0 0 1000px rgba(black,.5), 0 0 0 1px rgba(white,.2);
border-radius:100%!important;
width: 11px;
height: 11px;
margin:-5px 0 0 -4px;
margin:-5px -4px 0 0;
}
span {
&:before {
content:"";
position:absolute;
top:0;
left:0;
@ -810,3 +868,132 @@ width:400px;
}
}
.f-wrapper-outer {
padding-bottom:30px;
overflow:hidden;
height:100%;
width:100%;
position: relative;
input {
position:absolute;
bottom:0;
box-shadow: 0 0 1px 0 $color-border inset;
}
}
.f-wrapper {
padding:20px 15px 20px 20px ;
overflow:hidden;
height:100%;
width:95px;
position: relative;
.f {
height:100%;
width:4px;
background:#222;
position: relative;
.handle {
position: absolute;
bottom:0!important;
top:auto!important;
width:100%;
height:0px;
max-height:100%;
max-width:100%;
cursor: -webkit-grab;
background:$color-accent;
z-index: 1;
&:after { //.ui-resizable-handle {
content:"";
position: absolute;
height:2000px;
width:2000px;
margin:-1000px 0 0 -1000px;
}
}
}
.pips {
position: absolute;
top:-1%;
bottom:1%;
left:14px;
}
.pip {
height:1%;
width:4px;
border-bottom:1px solid $color-text;
&.val {
width:10px;
position: relative;
span {
position: relative;
width:30px;
display: block;
text-align: center;
font-size:11px;
line-height: 12px;
left:15px;
top:-2px;
color:#ccc;
}
}
}
}
.stack .f-wrapper-outer {
input {
width:30%;
height:35px;
left:0;
right:auto;
border-top:0;
top:35px;
}
.f {
width:100%;
height:4px;
.handle {
height:100%!important;
width:0;
}
}
.f-wrapper-outer {
padding:0;
}
.f-wrapper {
padding:20px 20px;
float:right;
width:70%;
height:70px;
}
.pips {
top:14px;left:0;
right:0;
display: flex;
flex-direction:row;
align-items: stretch;
}
.pip {
width:100%;
display: block;
height:4px;
border-bottom:0;
border-right:1px solid $color-text;
&.val {
width:1%;
float:left;
height:10px;
span {
top:15px;
left:-15px;
}
}
}
}

View file

@ -34,9 +34,9 @@ ipc.on('openSession',function(data){
require(data)
if (TABS!=false) {
$('#lobby').hide()
$('#container').append('<div class="spinner"></div>')
$('#container').append('<div id="loading"><div class="spinner"></div></div>')
setTimeout(function(){
init(function(){$('#container .spinner').hide()});
init(function(){$('#loading').hide()});
},1)
} else {

View file

@ -1,4 +1,5 @@
init = function(callback) {
parsetabs(TABS,false,false)
@ -55,12 +56,13 @@ init = function(callback) {
// horizontal scrolling with mousewheel
// if shift is pressed or if mouse is on h-scrollbar
// if shift is pressed (native), or if there is no vertical scrollbar,
// or if mouse is on h-scrollbar
$('.tab').on('mousewheel',function(e) {
// console.log(e)
var h = $('#container').innerHeight()-20-$(this).parents('.tab').length*5;
if (e.shiftKey) {
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaX);
if ($(this).get(0).scrollHeight+20 == $(this).height()) {
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
e.preventDefault();
} else if (e.pageY>=h) {
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
@ -74,9 +76,9 @@ init = function(callback) {
$('#sidepanel').append('\
<div class="open-toggle">\
<a class="open-toggle">\
<span class="bars"></span>\
</div>\
</a>\
<ul id="options">\
<li><a class="saveState btn">Save</a></li>\
<li><a href="#" class="loadState btn">Load</a></li>\

View file

@ -1,5 +1,4 @@
parsetabs = function(tabs,parent,sub){
if (!sub) {
var $nav = $(document.createElement('div')).addClass('main navigation'),
$navtabs = $(document.createElement('ul')).addClass('tablist'),
@ -34,8 +33,8 @@ parsetabs = function(tabs,parent,sub){
$content.append($tabContent);
// console.log('OK parsing tab ' + title )
}
}
}
__widgets__ = {}

View file

@ -20,39 +20,43 @@ createWidget.stack = function(widgetData) {
return widget;
}
createWidget.button = function(widgetData) {
createWidget.toggle = createWidget.button = function(widgetData) {
widgetData.on = widgetData.on || 1
widgetData.off = widgetData.off || 0
var widget = $('\
<div class="button-wrapper">\
<div class="button"></div>\
<input disabled></input>\
<div class="toggle">\
<div class="value"><span>'+widgetData.off+'</span></div>\
</div>\
');
widget.input = widget.find('input')
widget.button = widget.find('.button')
widgetData.args = widgetData.args || {off:0,on:1}
widget.value = widget.find('.value')
widget.button.click(function(){
var newVal = widget.button.hasClass('on')?widgetData.args.off||0:widgetData.args.on||1
widget.click(function(){
var newVal = widget.hasClass('on')?widgetData.off:widgetData.on
widget.setValue(newVal,true)
})
widget.getValue = function() {
return widget.button.hasClass('on')?widgetData.args.on||1:widgetData.args.off||0
return widget.hasClass('on')?widgetData.on:widgetData.off
}
widget.setValue = function(v,send,sync) {
var on = widgetData.args.on||1,
off= widgetData.args.off||0
var on = widgetData.on,
off= widgetData.off
if (v==on) {
widget.button.addClass('on')
widget.addClass('on')
widget.value.text(on)
if (send) widget.sendValue(v)
} else if (v==off) {
widget.button.removeClass('on')
widget.removeClass('on')
widget.value.text(off)
if (send) widget.sendValue(v)
}
widget.input.val(widget.getValue())
if (send) widget.trigger('sync')
}
@ -66,6 +70,51 @@ createWidget.button = function(widgetData) {
}
createWidget.switch = function(widgetData) {
widgetData.on = widgetData.on || 1
widgetData.off = widgetData.off || 0
var widget = $('\
<div class="switch">\
</div>\
');
for (v in widgetData.values) {
widget.append('<div class="value" data-value="'+widgetData.values[v]+'"><span>'+widgetData.values[v]+'</span></div>')
}
widget.find('.value').click(function(){
if ($(this).hasClass('on')) return;
var newVal = $(this).data('value')
widget.setValue(newVal,true)
})
widget.getValue = function() {
return widget.find('.on').data('value')
}
widget.setValue = function(v,send,sync) {
var e = widget.find('.value[data-value="'+v+'"]')
if (e.length) {
widget.find('.on').removeClass('on')
e.addClass('on')
if (send) widget.sendValue(v)
if (send) widget.trigger('sync')
}
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
return widget;
}
createWidget.xy = function(widgetData) {
var widget = $('\
<div class="xy-wrapper">\
@ -77,40 +126,46 @@ createWidget.xy = function(widgetData) {
<input type="number" class="x"></input><input type="number" class="y"></input>\
</div>\
</div>\
');
widget.xy = widget.find('.xy')
widget.xy.handle = widget.find('.handle')
widget.xy.handle.css({top:0,left:0}).draggable({
addClasses: false,
scroll:false,
containment:'parent'
});
'),
handle = widget.find('.handle'),
pad = widget.find('.xy'),
value = {x:widget.find('.x'),y:widget.find('.y')}
widget.xy.value = {x:widget.find('.x'),y:widget.find('.y')}
widget.xy.on('drag',function(e, data){
var v = widget.getValue();
widget.sendValue(v);
widget.showValue(v)
widget.trigger('sync')
})
widgetData.range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
handle.drag('init',function(){
offX = handle.width()
})
handle.drag(function( ev, dd ){
var h = pad.height()-dd.offsetY,
w = dd.deltaX+offX
handle.css({'height':h+'px','width':w+'px'})
var v = widget.getValue()
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
widget.getValue = function() {
var x = mapToScale(widget.xy.handle.css('left'),[0,widget.xy.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
y = mapToScale(widget.xy.handle.css('top'),[0,widget.xy.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max],true)
var x = mapToScale(handle.width(),[0,pad.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
y = mapToScale(handle.height(),[0,pad.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max])
return [x,y]
}
widget.setValue = function(v,send,sync) {
if (v[1]==undefined) var v = [v,v]
var left = mapToScale(v[0],[widgetData.range.x.min,widgetData.range.x.max],[0,widget.xy.innerWidth()])
ytop = mapToScale(v[1],[widgetData.range.y.min,widgetData.range.y.max],[0,widget.xy.innerHeight()],true),
var w = mapToScale(v[0],[widgetData.range.x.min,widgetData.range.x.max],[0,pad.innerWidth()])
h = mapToScale(v[1],[widgetData.range.y.min,widgetData.range.y.max],[0,pad.innerHeight()]),
widget.xy.handle.css({'top':ytop+'px','left':left+'px'})
handle.css({'height':h+'px','width':w+'px'})
widget.showValue(v)
if (sync) widget.trigger('sync')
@ -123,50 +178,23 @@ createWidget.xy = function(widgetData) {
}
widget.showValue = function(v) {
widget.xy.value.x.val(v[0])
widget.xy.value.y.val(v[1])
value.x.val(v[0])
value.y.val(v[1])
}
widget.xy.value.x.change(function(){
value.x.change(function(){
var v = widget.getValue();
v[0] = limit($(this).val(),[widgetData.range.x.min,widgetData.range.x.max])
v[0] = clip(value.x.val(),[widgetData.range.x.min,widgetData.range.x.max])
widget.setValue(v,true,true)
})
widget.xy.value.y.change(function(){
value.y.change(function(){
var v = widget.getValue();
v[1] = limit($(this).val(),[widgetData.range.y.min,widgetData.range.y.max])
v[1] = clip(value.y.val(),[widgetData.range.y.min,widgetData.range.y.max])
widget.setValue(v,true,true)
})
return widget;
// alternate technique to jqueryui using css transform (hw accelerated)
// doesn't seem to increase performance (there's no transition to optimize)
// add require( __dirname + "/js/jquery.event.drag-2.2.js") to index.html to enable
// widget.xy.handle.drag(function( ev, dd ){
// var x = limit(dd.offsetX,[0,widget.xy.innerWidth()]),
// y = limit(dd.offsetY,[0,widget.xy.innerHeight()])
// $( this ).css({
// 'transform': 'translate3d('+x+'px,'+y+'px,0px)'
// });
//
// var v = widget.getValue([0,0,0,x,y]);
// widget.sendValue(v);
// widget.showValue(v)
// widget.trigger('sync')
// },{ relative:true });
//
// widgetData.range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
//
// widget.getValue = function(css) {
// var css = css || widget.xy.handle.css('transform').split('(')[1].split(',')
// x = mapToScale(css[4],[0,widget.xy.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
// y = mapToScale(css[5],[0,widget.xy.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max],true)
// return [x,y]
// }
}
@ -213,7 +241,7 @@ var rgbToHsb = function (rgb) {
};
var limit = function(value,range) {
var clip = function(value,range) {
var max = Math.max,
min = Math.min
@ -230,7 +258,7 @@ var mapToScale = function(value,rangeIn,rangeOut,reverse) {
value = max(min(rangeIn[0],rangeIn[1]),min(parseFloat(value),max(rangeIn[0],rangeIn[1])))
value = (value/rangeIn[1]-rangeIn[0]) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
value = ((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
if (reverse) value = max(rangeOut[0],rangeOut[1])+min(rangeOut[0],rangeOut[1])-value
@ -244,10 +272,6 @@ var mapToScale = function(value,rangeIn,rangeOut,reverse) {
createWidget.rgb = function(widgetData) {
var widget = $('\
<div class="xy-wrapper rgb-wrapper">\
@ -261,63 +285,59 @@ createWidget.rgb = function(widgetData) {
<input disabled value="R"></input><input disabled value="G"></input><input disabled value="B"></input>\
<input class="r" type="number"></input><input class="g" type="number"></input><input class="b" type="number"></input>\
</div>\
</div>\
');
widget.xy = widget.find('.xy')
widget.xy.saturation = widget.find('.rgb .handle')
widget.xy.hue = widget.find('.hue .handle')
widget.xy.saturation.css({top:0,left:0}).draggable({
addClasses: false,
scroll:false,
containment:'parent'
});
widget.xy.hue.css({left:0}).draggable({
addClasses: false,
scroll:false,
containment:'parent'
});
widget.xy.value = {r:widget.find('input.r'),g:widget.find('input.g'),b:widget.find('input.b')}
widget.xy.hue.on('drag',function(e, data){
var h = parseFloat(widget.xy.hue.css('left'))/widget.xy.innerWidth()*360,
rgb = hsbToRgb({h:h,s:100,b:100}),
v = widget.getValue();
widget.xy.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
})
widget.xy.saturation.on('drag',function(e, data){
var v = widget.getValue();
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
})
widget.xy.saturation.on('stop',function(e, data){
var v = widget.getValue();
widget.sendValue(v);
widget.showValue(v);
//widget.trigger('sync')
})
</div>'),
rgbHandle = widget.find('.rgb .handle'),
hueHandle = widget.find('.hue .handle'),
pad = widget.find('.xy'),
value = {r:widget.find('input.r'),g:widget.find('input.g'),b:widget.find('input.b')}
widgetData.range = {r:{min:0,max:255},g:{min:0,max:255},b:{min:255}}
rgbHandle.drag('init',function(){
rgbOffX = rgbHandle.width()
})
rgbHandle.drag(function( ev, dd ){
var h = pad.height()-dd.offsetY,
w = dd.deltaX+rgbOffX
rgbHandle.css({'height':h+'px','width':w+'px'})
var v = widget.getValue()
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
hueHandle.drag('init',function(){
rgbOffX = hueHandle.width()
})
hueHandle.drag(function( ev, dd ){
var w = dd.deltaX+rgbOffX
hueHandle.css({'width':w+'px'})
var h = parseFloat(hueHandle.width())/pad.innerWidth()*360,
rgb = hsbToRgb({h:h,s:100,b:100}),
v = widget.getValue();
pad.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
widget.getValue = function() {
var s = mapToScale(widget.xy.saturation.css('left'),[0,widget.xy.innerWidth()],[0,100]),
l = mapToScale(widget.xy.saturation.css('top'),[0,widget.xy.innerHeight()],[0,100],true),
h = mapToScale(widget.xy.hue.css('left'),[0,widget.xy.innerWidth()],[0,360]),
var s = mapToScale(rgbHandle.width(),[0,pad.innerWidth()],[0,100]),
l = mapToScale(rgbHandle.height(),[0,pad.innerHeight()],[0,100]),
h = mapToScale(hueHandle.width(),[0,pad.innerWidth()],[0,360]),
rgb = hsbToRgb({h:h,s:s,b:l})
return [rgb.r,rgb.g,rgb.b]
}
@ -332,15 +352,16 @@ createWidget.rgb = function(widgetData) {
var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
var left = mapToScale(hsb.s,[0,100],[0,widget.xy.innerWidth()]),
top = mapToScale(hsb.b,[0,100],[0,widget.xy.innerHeight()],true),
leftHue = mapToScale(hsb.h,[0,360],[0,widget.xy.innerWidth()])
widget.xy.saturation.css({'top':top+'px','left':left+'px'})
widget.xy.hue.css({'left':leftHue+'px'})
var w = mapToScale(hsb.s,[0,100],[0,pad.innerWidth()]),
h = mapToScale(hsb.b,[0,100],[0,pad.innerHeight()]),
hueW = mapToScale(hsb.h,[0,360],[0,pad.innerWidth()])
rgbHandle.css({'height':h+'px','width':w+'px'})
hueHandle.css({'width':hueW+'px'})
var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
widget.xy.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
pad.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.showValue(v);
@ -358,24 +379,24 @@ createWidget.rgb = function(widgetData) {
widget.showValue = function(v) {
widget.xy.value.r.val(v[0])
widget.xy.value.g.val(v[1])
widget.xy.value.b.val(v[2])
value.r.val(v[0])
value.g.val(v[1])
value.b.val(v[2])
}
widget.xy.value.r.change(function(){
if (!0<=$(this).val()<=255) {$(this).val(Math.min(255,Math.max(0,$(this).val())))}
value.r.change(function(){
var r = clip(value.r.val(),[0,255])
var v = widget.getValue()
widget.setValue([$(this).val(),v[1],v[2]],true,true)
widget.setValue([r,v[1],v[2]],true,true)
})
widget.xy.value.g.change(function(){
if (!0<=$(this).val()<=255) {$(this).val(Math.min(255,Math.max(0,$(this).val())))}
value.g.change(function(){
var g = clip(value.g.val(),[0,255])
var v = widget.getValue()
widget.setValue([v[0],$(this).val(),v[2]],true,true)
widget.setValue([v[0],g,v[2]],true,true)
})
widget.xy.value.b.change(function(){
if (!0<=$(this).val()<=255) {$(this).val(Math.min(255,Math.max(0,$(this).val())))}
value.b.change(function(){
var b = clip(value.b.val(),[0,255])
var v = widget.getValue()
widget.setValue([v[0],v[1],$(this).val()],true,true)
widget.setValue([v[0],v[1],b],true,true)
})
@ -384,99 +405,129 @@ createWidget.rgb = function(widgetData) {
createWidget.fader = function(widgetData,parent) {
createWidget.fader = function(widgetData,parent){
var widget = $('\
<div class="fader-wrapper-outer">\
<div class="fader-wrapper">\
<div class="fader locked"></div>\
<div class="f-wrapper-outer">\
<div class="f-wrapper">\
<div class="f">\
<div class="handle"></div>\
<div class="pips"></div>\
</div>\
</div>\
<input value="0"></input>\
</div>\
');
'),
handle = widget.find('.handle'),
fader = widget.find('.f'),
pips = widget.find('.pips'),
input = widget.find('input'),
widget.fader = widget.find('.fader')
widget.lock = false
var range = (widgetData.range=='db'||!widgetData.range)?{'min': -70,'20%': -40,'45%': -20,'60%': -10,'max': 6}:widgetData.range;
dimension = parent.hasClass('stack')?'width':'height';
handle.size = function() {
return (dimension=='height')?handle.height():handle.width()
}
fader.size = function() {
return (dimension=='height')?fader.height():fader.width()
}
var pips = function() {
if (widgetData.range=='db'||!widgetData.range) {
return [-70,-60,-50,-40,-30,-20,-10,-6,-3,0,3,6];
var offX=0
if (dimension=='width') {
handle.drag('init',function(){
offX = handle.size()
})
}
handle.drag(function( ev, dd ){
var d = (dimension=='height')?fader.size()-dd.offsetY:dd.deltaX+offX
handle.css(dimension, d+'px')
var v = widget.getValue()
widget.sendValue(v);
widget.showValue(v);
widget.trigger('sync')
},{ relative:true });
widgetData.range = widgetData.range || {'min':0,'100%':1}
widgetData.range = (widgetData.range=='db')?{'min': -70,'20%': -40,'45%': -20,'60%': -10,'71%':-6,'78%':-3,'85%':0,'92%':3,'max': 6}:widgetData.range;
var range = {}
for (k in widgetData.range) {
if (k=='min') {
range[0]=widgetData.range[k]
} else if (k=='max') {
range[100]=widgetData.range[k]
} else {
var autopips = [];
var i=0;
for (key in range) {
autopips[i]=range[key];
i=i+1;
}
if (range.min<0 && 0<range.max){
autopips.push(0);
}
//autopips.push((range.max-range.min)/2);
//autopips.push((range.max-range.min)/4);
//autopips.push((range.max-range.min)*.75);
return autopips;
range[parseInt(k)]=widgetData.range[k]
}
}
var pips = pips();
var orientation = parent.hasClass('stack')?'horizontal':'vertical',
direction = parent.hasClass('stack')?'ltr':'rtl',
density = parent.hasClass('stack')?'2':'1';
widget.fader
.noUiSlider({
orientation:orientation,
direction: direction,
behaviour: "drag",
connect: "lower",
//animate:false,
start: 0,
range: range
})
.noUiSlider_pips({
mode: 'values',
density: density,
filter:function(v,t){return v==0?1:2;},
values: pips,
format: wNumb({})
})
.Link('lower').to(widget.find('input'))
.on('slide',function(){
if (!widget.lock) {
widget.sendValue();
}
})
.on('set',function(){
if (!widget.lock) {
widget.sendValue();
widget.trigger('sync')
}
});
widget.getValue = function(v,send){
return widget.fader.val();
var scale = []
for (var i=0;i<=100;i++) {scale.push(i)}
for (i in scale) {
var pip = $('<div class="pip"></div>')
if (range[i]!=undefined) {
pip.addClass('val').append('<span>'+range[i]+'</span>')
}
pips.append(pip)
}
if (dimension=='height') {
pips.append(pips.find('.pip').get().reverse())
}
widget.setValue = function(v,send,sync){
if (!send) {widget.lock=true}
widget.fader.val(v);
if (sync) widget.trigger('sync')
widget.lock=false;
var rangeKeys = Object.keys(range).map(function (key) {return parseInt(key)}),
rangeVals = Object.keys(range).map(function (key) {return parseInt(range[key])})
widget.getValue = function(){
var v
var h = handle.size() * 100 / fader.size()
for (var i=0;i<rangeKeys.length-1;i++) {
if (h <= rangeKeys[i+1] && h >= rangeKeys[i]) {
return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]])
}
}
}
widget.sendValue = function(){
widget.setValue = function(v,send,sync) {
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]])
break
}
}
handle.css(dimension,h+'%')
widget.showValue(v);
if (sync) widget.trigger('sync');
if (send) widget.sendValue(v);
}
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path,
v = widgetData.scale1?
Math.max(0,Math.round(10000*((Math.abs(range.min)/(range.max-range.min)) + widget.fader.val()/(range.max-range.min)))/10000)
: widget.fader.val();
sendOsc([t,p,parseFloat(v)]);
p = widgetData.path
sendOsc([t,p,v]);
}
widget.showValue = function(v) {
input.val(v)
}
input.change(function(){
widget.setValue(input.val(),true,true)
})
return widget
}

View file

@ -11,13 +11,7 @@ window.$ = window.jQuery = require( __dirname + "/jquery/jquery.min.js")
// third-party js libraries
require( __dirname + "/jquery/jquery.nouislider.all.js")
require( __dirname + "/jquery/jquery-ui.draggable.min.js")
require( __dirname + "/jquery/jquery.mousewheel.min.js")
// mouse to touch emulation
require( __dirname + "/jquery/jquery.ui.touch-punch.min.js")
require( __dirname + "/jquery/jquery.event.drag-2.2.js")
// main js
@ -31,7 +25,7 @@ var Sass = require( __dirname + "/sass/sass.js")
var sass = new Sass()
sass.options({style: Sass.style.compact})
var styles = ["/../css/style.scss","/../css/jquery.nouislider.scss"]
var styles = ["/../css/style.scss"]
, stylesdata = ''
, done = 0;

File diff suppressed because one or more lines are too long

View file

@ -1,8 +0,0 @@
/*!
* jQuery Mousewheel 3.1.13
*
* Copyright 2015 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});

File diff suppressed because it is too large Load diff

View file

@ -1,11 +0,0 @@
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);

View file

@ -18,10 +18,23 @@ TABS = {
testingshits: {
widgets:{
switchtest: {
type:'switch',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522',
values:[0,1,2]
},
stacktest: {
type:'stack',
widgets:{
switchtest: {
type:'switch',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522',
values:[0,1,2]
},
Drums: {
title:'BassesXXX',
range:'db',
@ -41,7 +54,7 @@ TABS = {
path:'/strip/Guitars/Gain/Gain%20(dB)/unscaled'
},
button1: {
type:'button',
type:'toggle',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522'
@ -57,7 +70,7 @@ TABS = {
path:'/pad'
},
button1: {
type:'button',
type:'toggle',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522'