Changeset 57
- Timestamp:
- 07/16/08 00:15:59 (2 months ago)
- Files:
-
- trunk/lily/lily/chrome/content/externals.js (modified) (2 diffs)
- trunk/lily/lily/chrome/content/externals/patcher.js (modified) (1 diff)
- trunk/lily/lily/chrome/content/externals/subpatch.js (modified) (7 diffs)
- trunk/lily/lily/chrome/content/externals/wow.js (modified) (1 diff)
- trunk/lily/lily/chrome/content/lily.js (modified) (7 diffs)
- trunk/lily/lily/chrome/content/model.js (modified) (1 diff)
- trunk/lily/lily/chrome/content/patch.js (modified) (4 diffs)
- trunk/lily/lily/chrome/content/patch.xul (modified) (1 diff)
- trunk/lily/lily/chrome/content/utils.js (modified) (4 diffs)
- trunk/lily/lily/chrome/locale/en-US/lily.dtd (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lily/lily/chrome/content/externals.js
r42 r57 125 125 */ 126 126 includeAll:function() { 127 127 128 for(var i=0;i<this.objArray.length;i++) { //don't load patches 128 129 if(this.isLoadable(this.objArray[i].name) && this.objArray[i].path && typeof this.objLeaf[this.objArray[i].name]=="undefined") { 129 //log(this.objArray[i].name)130 130 var extName = LilyUtils.stripExtension(this.objArray[i].name); 131 131 try { … … 135 135 this.objArray[i].menuName=LilyUtils.getObjectMetaData(objName).textName; 136 136 this.objArray[i].catName=LilyUtils.getObjectMetaData(objName).objectCategory; 137 this.objArray[i].objSummary= LilyUtils.getObjectMetaData(objName).objectSummary;137 this.objArray[i].objSummary=(LilyUtils.getObjectMetaData(objName).objectSummary?LilyUtils.getObjectMetaData(objName).objectSummary:LilyUtils.extractPatchDesc(this.objArray[i].sourceCode)); 138 138 this.objArray[i].objArguments=LilyUtils.getObjectMetaData(objName).objectArguments; 139 139 this.objDisplay[((this.objArray[i].menuName)?this.objArray[i].menuName:"tmp")]=objName; trunk/lily/lily/chrome/content/externals/patcher.js
r47 r57 179 179 function openPatch(data,file) { 180 180 181 var sizeArr=Lily .extractPatchSize(data); //get the patch size w/o having to eval the json.181 var sizeArr=LilyUtils.extractPatchSize(data); //get the patch size w/o having to eval the json. 182 182 var parentDir=(file.parent.isDirectory())?file.parent:null; //patch's parent dir. 183 183 thisPatch.obj = new LilyPatch(pid,Lily,sizeArr[0],sizeArr[1],false,{type:"iframe",win:iframe,parent:thisPtr.parent.patchView.xulWin}); //call the patch constructor trunk/lily/lily/chrome/content/externals/subpatch.js
r47 r57 40 40 //inspector values 41 41 var argsArr = LilyUtils.splitArgs(args); //split the args 42 this.fPath = argsArr.shift()||""; //path to patch or null 42 43 this.fPath = (argsArr.length>0)?argsArr.shift():""; //path to patch or null 43 44 this.patchArgs = argsArr.join(" ")||""; //the remainder of the args as string 45 46 if(/##\w+##/.test(this.patchArgs)) { 47 //pull out the patch name and use that as the display 48 this.displayName = this.patchArgs.match(/##(\w+)##/)[1]; 49 //if there any additional args, strip out the classname and assign them to display args. otherwise displayargs = false. 50 this.displayArgs = (!/^##\w+##/.test(this.patchArgs))?this.patchArgs.replace(/##\w+##/,""):false; 51 this.loadsSubPatchByName = true; 52 } 44 53 45 54 //inlet/outlet arrays … … 49 58 this.setInspectorConfig([ 50 59 {name:"fPath",value:thisPtr.fPath,label:"Patch Path",type:"string",input:"file"}, 51 {name:"patchArgs",value:this .patchArgs,label:"Patch Arguments",type:"string",input:"text"}60 {name:"patchArgs",value:thisPtr.patchArgs,label:"Patch Arguments",type:"string",input:"text"} 52 61 ]); 53 62 … … 73 82 function replacePatchArgs(arg_str,data) { 74 83 var patch_str = data; 75 var tmp = LilyUtils.splitArgs(arg_str );84 var tmp = LilyUtils.splitArgs(arg_str.replace(/##\w+##/,"")); 76 85 for(var i=0;i<tmp.length;i++) { 77 86 var re = new RegExp("\\#"+(i+1),"g"); … … 86 95 setTimeout(function(){ 87 96 //thisPatch = {obj:null,id:pid,file:null,json:null}; //reset the thispatch object 88 var o = thisPtr.parent.replaceObject(thisPtr,"subpatch",thisPtr. args);97 var o = thisPtr.parent.replaceObject(thisPtr,"subpatch",thisPtr.patchArgs.replace(/##\w+##/,"")); 89 98 o.setHeight(thisPtr.height); 90 99 o.setWidth(thisPtr.width); … … 177 186 function openPatch(data,file) { 178 187 179 var sizeArr=Lily .extractPatchSize(data); //get the patch size w/o having to eval the json.188 var sizeArr=LilyUtils.extractPatchSize(data); //get the patch size w/o having to eval the json. 180 189 var parentDir=(file.parent.isDirectory())?file.parent:null; //patch's parent dir. 181 190 thisPatch.obj = new LilyPatch(pid,Lily,sizeArr[0],sizeArr[1],false,{type:"iframe",win:thisPtr.displayElement,parent:thisPtr.parent.patchView.xulWin}); //call the patch constructor … … 234 243 235 244 var parent_patch = thisPatch.obj.getTopPatch(); //get the top level patch 236 parent_patch.patchController.patchLoaded(thisPtr.objID,thisPatch.obj); //tell the patch we're loaded. 237 238 } 245 parent_patch.patchController.patchLoaded(thisPtr.objID,thisPatch.obj); //tell the patch we're loaded. 246 247 //size the subpatch to the size set in patch we're loading... 248 if(parseInt(thisPatch.obj.heightInSubPatch) != 0 && parseInt(thisPatch.obj.widthInSubPatch) != 0) 249 iframe.resize(parseInt(thisPatch.obj.widthInSubPatch), parseInt(thisPatch.obj.heightInSubPatch)); 250 251 } 239 252 240 253 } … … 251 264 function frameLoad() { 252 265 thisPtr.displayElement.removeEventListener("load",frameLoad,true); //remove this so we don't loop 253 if(thisPtr.fPath&&thisPatch.json&&thisPatch.file) { openPatch(thisPatch.json,thisPatch.file); }//open the patch if we've got the data 266 if(thisPtr.fPath&&thisPatch.json&&thisPatch.file) { 267 openPatch(thisPatch.json,thisPatch.file); 268 }//open the patch if we've got the data 254 269 } 255 270 trunk/lily/lily/chrome/content/externals/wow.js
r1 r57 274 274 function openPatch(data,file) { 275 275 276 var sizeArr=Lily .extractPatchSize(data); //get the patch size w/o having to eval the json.276 var sizeArr=LilyUtils.extractPatchSize(data); //get the patch size w/o having to eval the json. 277 277 var parentDir=(file.parent.isDirectory())?file.parent:null; //patch's parent dir. 278 278 thisPatch.obj = new LilyPatch(pid,Lily,sizeArr[0],sizeArr[1],false,{type:"iframe",win:_iframe,parent:thisPtr.parent.patchView.xulWin}); //call the patch constructor trunk/lily/lily/chrome/content/lily.js
r21 r57 591 591 var hidden=hide||false; 592 592 593 var sizeArr= this.extractPatchSize(data); //get the patch size w/o having to eval the json.593 var sizeArr=LilyUtils.extractPatchSize(data); //get the patch size w/o having to eval the json. 594 594 var patchID=this.newPatch(sizeArr[0],sizeArr[1],readonly,hidden); //patch constructor- opens blank window. 595 595 var parentDir=(file.parent.isDirectory())?file.parent:null; //patch's parent dir. … … 643 643 } else { 644 644 645 var sizeArr= this.extractPatchSize(data);645 var sizeArr=LilyUtils.extractPatchSize(data); 646 646 var patchID=this.newPatch(sizeArr[0],sizeArr[1],readonly,false); 647 647 … … 714 714 var data=fileObj.data; 715 715 716 var sizeArr= this.extractPatchSize(data); //get the patch size w/o having to eval the json.716 var sizeArr=LilyUtils.extractPatchSize(data); //get the patch size w/o having to eval the json. 717 717 718 718 document.getElementById("lilyContentSplitter").setAttribute("collapsed",false); … … 748 748 749 749 }, 750 751 /*752 Method: extractPatchSize753 get the patch size without having to eval the patch JSON.754 755 Arguments:756 data - JSON patch string.757 758 Returns:759 An array of patch width & height.760 */761 extractPatchSize: function(data) {762 var wArr=data.match(/'width':(\d+)/);763 var hArr=data.match(/'height':(\d+)/);764 765 if(wArr && hArr)766 return [wArr[1],hArr[1]];767 else768 return [0,0];769 },770 750 771 751 /* … … 834 814 var data=LilyUtils.readFile(file); 835 815 836 var sizeArr= this.extractPatchSize(data);816 var sizeArr=LilyUtils.extractPatchSize(data); 837 817 var patchID=this.newPatch(sizeArr[0],sizeArr[1],false,false); 838 818 … … 974 954 //update the patch name before we serialize 975 955 //yes, this is a mess 976 this.patchObj[pID].obj.title=LilyUtils.stripExtension(file.leafName); 977 this.patchObj[pID].obj.patchView.setPatchTitle(LilyUtils.stripExtension(file.leafName)); 978 956 if(this.patchObj[pID].obj.title == "Untitled") { 957 this.patchObj[pID].obj.title=LilyUtils.stripExtension(file.leafName); 958 this.patchObj[pID].obj.patchView.setPatchTitle(LilyUtils.stripExtension(file.leafName)); 959 } 960 979 961 //now we've updated the patch title, so serialize 980 962 var data=this.patchObj[pID].obj.patchModel.serializeDom(); … … 1198 1180 if(this.patchObj[id]&&this.patchObj[id].obj.patchController.getEditable()=="edit") 1199 1181 this.patchObj[id].obj.patchController.selectAll(); 1182 }, 1183 1184 /* 1185 Method: openPatchProperties 1186 dispatch menu command. 1187 */ 1188 openPatchProperties: function() { 1189 var p = this.patchObj[this.currPatch].obj; 1190 var win = p.patchView.xulWin; 1191 1192 var initVals = { 1193 title: p.title, 1194 color: p.color, 1195 height: p.heightInSubPatch, 1196 width: p.widthInSubPatch, 1197 desc: LilyUtils.unescape(p.description) 1198 }; 1199 1200 win.openDialog("chrome://lily/content/patch-properties.xul", "cWin","width=450,height=405,left=50,top=550,close=no,scrollbars=no,dialog=yes,resizable=no,toolbar=no,menubar=no,location=no,status=no,chrome=yes,alwaysRaised=yes",function(val){ 1201 for(var x in val) { 1202 switch(x) { 1203 case "title": 1204 p.patchView.setPatchTitle(val[x]); 1205 case "color": 1206 p.patchView.setPatchColor(val[x]); 1207 case "height": 1208 p.heightInSubPatch=val[x]; 1209 case "width": 1210 p.widthInSubPatch=val[x]; 1211 case "desc": 1212 p.description=LilyUtils.escape(val[x]); 1213 } 1214 } 1215 },initVals); 1216 1200 1217 }, 1201 1218 trunk/lily/lily/chrome/content/model.js
r14 r57 103 103 j+="'height':"+this.patch.height+comma; 104 104 j+="'color':"+quote+this.patch.color+quote+comma; 105 j+="'mode':"+quote+this.patch.patchController.editable+quote+comma; 105 j+="'mode':"+quote+this.patch.patchController.editable+quote+comma; 106 j+="'description':"+quote+this.patch.description+quote+comma; 107 j+="'heightInSubPatch':"+quote+this.patch.heightInSubPatch+quote+comma; 108 j+="'widthInSubPatch':"+quote+this.patch.widthInSubPatch+quote+comma; 106 109 107 110 j+="'objArray':"+oBrace; trunk/lily/lily/chrome/content/patch.js
r44 r57 33 33 this.width=(width&&!hide)?width:(hide)?0:800; //width 34 34 this.height=(height&&!hide)?height:(hide)?0:600; //height 35 this.heightInSubPatch=0; //height when loaded in a subpatch 36 this.widthInSubPatch=0; //width when loaded in a subpatch 37 this.description=""; //patch description. 35 38 this.color="#FFFFFF" //background color 39 this.desc=""; //patch description 36 40 this.fontSize=LilyUtils.getDefaultFont()[1]; //font size in px 37 41 this.fontFamily=LilyUtils.getDefaultFont()[0]; //font face … … 416 420 o.init(); //generic- user defined 417 421 } else if(obj && typeof obj == "string") { 418 return this.createObject("patcher",pID,t,l,id,(obj+" "+argStr+" ##"+className+"##")); 422 var sizeArr = LilyUtils.extractSizeInSubPatch(LilyUtils.readFileFromPath(obj).data); 423 if(sizeArr[0]||sizeArr[1]) { 424 return this.createObject("subpatch",pID,t,l,id,(obj+" "+argStr+" ##"+className+"##")); 425 } else { 426 return this.createObject("patcher",pID,t,l,id,(obj+" "+argStr+" ##"+className+"##")); 427 } 428 419 429 } 420 430 … … 729 739 if(typeof patch.color!="undefined" && !subPatchID && !opID) 730 740 this.patchView.setPatchColor(patch.color); //update color 741 742 if(typeof patch.description!="undefined" && !subPatchID && !opID) 743 this.description=patch.description; //update color 744 745 if(typeof patch.heightInSubPatch!="undefined" && !subPatchID && !opID) 746 this.heightInSubPatch=parseInt(patch.heightInSubPatch); //update color 747 748 if(typeof patch.widthInSubPatch!="undefined" && !subPatchID && !opID) 749 this.widthInSubPatch=parseInt(patch.widthInSubPatch); //update color 731 750 732 751 var oArray=patch.objArray; //top level 'patch' object defined in the patch json … … 1679 1698 var patchArr = thisPtr.patch.patchModel.subPatchArray; 1680 1699 for(var x in patchArr) { 1681 var p = patchArr[x].obj.patchView; 1682 try { 1683 var evt = p.document.createEvent("Event"); 1684 evt.initEvent(e, true, false); 1685 p.document.dispatchEvent(evt); 1686 } catch(e) {} 1700 if(patchArr[x].obj && patchArr[x].obj.patchView) { 1701 var p = patchArr[x].obj.patchView; 1702 try { 1703 var evt = p.document.createEvent("Event"); 1704 evt.initEvent(e, true, false); 1705 p.document.dispatchEvent(evt); 1706 } catch(e) {} 1707 } 1687 1708 } 1688 1709 } trunk/lily/lily/chrome/content/patch.xul
r23 r57 83 83 <menuitem id="patchEditOption" key="lilyToggleEditKey" label="&lily.Edit;" type="checkbox" autocheck="true" checked="false" option="patchEdit" oncommand="opener.Lily.toggleEdit()"/> 84 84 <menuitem id="menu_PatchColor" label="&lily.Color;" oncommand="opener.Lily.openColorPicker('patch')"/> 85 <menuitem id="menu_PatchProperties" label="&lily.PatchProperties;..." oncommand="opener.Lily.openPatchProperties()"/> 85 86 <!--<menuitem id="menu_PatchZoomIn" label="&lily.ZoomIn;" oncommand="opener.Lily.zoomIn()"/> 86 87 <menuitem id="menu_PatchZoomOut" label="&lily.ZoomOut;" oncommand="opener.Lily.zoomOut()"/> trunk/lily/lily/chrome/content/utils.js
r40 r57 441 441 */ 442 442 stripLTQuotes: function(str) { 443 if(str && str.length) return str.replace(/^['"]|['"]$/ig, ''); 443 if(str && str.length) { 444 return str.replace(/^['"]|['"]$/ig, ''); 445 } else { 446 return ""; 447 } 444 448 }, 445 449 … … 1401 1405 isPatchString: function(str) { 1402 1406 return (/var patch={/.test(str)); 1407 }, 1408 1409 /* 1410 Method: extractPatchDesc 1411 get the patch size without having to eval the patch JSON. 1412 1413 Arguments: 1414 data - JSON patch string. 1415 1416 Returns: 1417 Patch description. 1418 */ 1419 extractPatchDesc: function(data) { 1420 var desc=data.match(/'description':'([\S|\s]+)','heightInSubPatch'/); 1421 1422 if(desc && desc.length>1) 1423 return desc[1]; 1424 else 1425 return ""; 1426 }, 1427 1428 /* 1429 Method: extractPatchSize 1430 get the patch size without having to eval the patch JSON. 1431 1432 Arguments: 1433 data - JSON patch string. 1434 1435 Returns: 1436 An array of patch width & height. 1437 */ 1438 extractPatchSize: function(data) { 1439 var wArr=data.match(/'width':(\d+)/); 1440 var hArr=data.match(/'height':(\d+)/); 1441 1442 if(wArr && hArr) 1443 return [wArr[1],hArr[1]]; 1444 else 1445 return [0,0]; 1446 }, 1447 1448 /* 1449 Method: extractSizeInSubPatch 1450 get the size in subpatch without having to eval the patch JSON. 1451 1452 Arguments: 1453 data - JSON patch string. 1454 1455 Returns: 1456 An array of patch width & height when opened in subpatch. 1457 */ 1458 extractSizeInSubPatch: function(data) { 1459 1460 if(typeof data == "string") { 1461 var wArr=data.match(/'widthInSubPatch':'(\d+)'/); 1462 var hArr=data.match(/'heightInSubPatch':'(\d+)'/); 1463 1464 if(wArr && hArr){ 1465 return [parseInt(wArr[1]),parseInt(hArr[1])]; 1466 }else{ 1467 return [0,0]; 1468 } 1469 1470 } else { 1471 return [0,0]; 1472 } 1403 1473 }, 1404 1474 … … 2331 2401 } 2332 2402 2403 this.resize=function(w,h) { 2404 parent.setHeight(h); 2405 parent.setWidth(w); 2406 frameCover.style.height=(h+5)+"px"; 2407 frameCover.style.width=(w+5)+"px"; 2408 } 2409 2333 2410 //set the object size 2334 2411 if(h) … … 2341 2418 frameCover=parent.parent.patchView.displayHTML(""); 2342 2419 frameCover.id=parent.createElID("frameCover"); 2343 // frameCover.style.backgroundColor='red'; 2420 // frameCover.style.backgroundColor='red'; //debug 2344 2421 frameCover.style.position='absolute'; 2345 2422 frameCover.style.left=(parent.left)+"px"; trunk/lily/lily/chrome/locale/en-US/lily.dtd
r20 r57 32 32 <!ENTITY lily.Show "Show on Lock"> 33 33 <!ENTITY lily.PatchFolder "Open Patch Directory"> 34 <!ENTITY lily.PatchProperties "Patch Properties"> 34 35 35 36 <!ENTITY lily.ObjectMenu "Externals">
