////////////////////////////////////////////// 
//         SoundOutTheBox vuMeter1          // 
//  Copyright © SoundOutTheBox 2012-2013    // 
//           License-CC-BY-NC-ND            // 
////////////////////////////////////////////// 
(function(e){e.widget("mui.vuMeter1",{options:{publicVariables:{Name:{value:"no name",type:"StringData",dynamic:!1},Left:{value:0,type:"IntegerData",dynamic:!1},Top:{value:0,type:"IntegerData",dynamic:!1},Width:{value:383,type:"IntegerData",dynamic:!1},Height:{value:282,type:"IntegerData",dynamic:!1},Value:{value:-20,type:"IntegerData",write:!0,dynamic:!0},Visible:{value:["no","yes"],type:"EnumData",defaultvalue:"yes",write:!0,dynamic:!0}},privateVariables:{pageNumber:0,motifType:0,userScreen:0,vuMeterImg:null,
canvas:null},config:{main:"vuMeter1.js",description:"vuMeter1 is a widget which displays a vuMeter with a static size. The level is defined between -20 and 3.",author:"SoundOutTheBox",version:"1.0.0.0.Final",dependencies:"",widgetID:"6c94696b9e6995729a306a6665696e6e689a9c33666562677069669b6e326b6a",widgetPackages:["6b6a656a9a6d639a6e349c9265986b6a696b66336d6263987199936e9c306d65"]}},_create:function(){},_init:function(){},_destroy:function(){},_setOption:function(){e.Widget.prototype._setOption.apply(this,arguments)},_render:function(){var b=this,a=b.options.publicVariables,
d=b.options.privateVariables,c=b.element,f=a.Top.value,g=a.Height.value,h=a.Left.value,i=a.Width.value;console.log("_render()  object="+a.Name.value);c.disableSelection();c.css({position:"absolute",left:h+"px",top:f+"px",width:i+"px",height:g+"px",zIndex:10});c.addClass("dynamicObject");canvas=e("<canvas/>");d.canvas=canvas;canvas.css({position:"absolute",left:h+"px",top:f+"px",width:i+"px",height:g+"px"});canvas.attr("id",a.Name.value);canvas.appendTo(c);d.vuMeterImg=new Image;c=UTIL.getDirectoryByScriptFileName("vuMeter1.js");
d.vuMeterImg.src=c+"/img/vumeter.gif";d.vuMeterImg.onload=function(){b.drawVumeter(b.options.publicVariables.Value.value)};b.setVisible(a.Visible.value)},drawVumeter:function(b){var a=document.getElementById(this.options.publicVariables.Name.value);vuMeterImg=this.options.privateVariables.vuMeterImg;var d=0;if(a.getContext){var c=a.getContext("2d");width=a.clientWidth;height=a.clientHeight;a.width=width;a.height=height;c.shadowOffsetX=0;c.shadowOffsetY=0;c.shadowBlur=0;c.clearRect(0,0,width,height);
c.drawImage(vuMeterImg,0,0);c.strokeStyle="#000000";c.shadowOffsetX=-3;c.shadowOffsetY=3;c.shadowBlur=3;c.shadowColor="rgba(0, 0, 0, 0.6)";b<-20&&(b=-20);b>3&&(b=3);d=Math.pow(10,b/20);x=0.0163*((d-0.1)*100/1.3125375446227543);cosA=Math.cos(2.3562-x);sinA=Math.sin(2.3562-x);deltaX=148*cosA;deltaY=148*sinA;c.beginPath();c.moveTo(191,224);c.lineTo(191+deltaX,224-deltaY);c.stroke()}},setVisible:function(b){var a=this.options.publicVariables,d=this.element;if(b!==a.Visible.value)a.Visible.value=b;a.Visible.value!==
"no"?UTIL.setOpacity(d,1):UTIL.setOpacity(d,0)},readFromXML:function(b){var a=this.options.publicVariables,b=e(b);a.Name.value=UTIL.getStringAttr(b,"Name",a.Name.value);a.Value.value=UTIL.getIntAttr(b,"Value",a.Value.value);a.Visible.value=UTIL.getStringAttr(b,"Visible",a.Visible.value);UTIL.readPositionFromXML(b,a)},setValue:function(b){this.drawVumeter(b)},onPropertyChange:function(b,a){switch(b){case "Value":this.setValue(eval(a));break;case "Visible":this.setVisible(a)}},onReleaseCapture:function(){}})})(jQuery);
