Changeset 9276
- Timestamp:
- 06/13/07 17:44:00 (5 years ago)
- Location:
- branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit
- Files:
-
- 6 edited
-
area.xml (modified) (6 diffs)
-
audio.xml (modified) (31 diffs)
-
background.xml (modified) (1 diff)
-
section.xml (modified) (13 diffs)
-
subplayer.xml (modified) (16 diffs)
-
waves.xml (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/area.xml
r9275 r9276 1 1 <?xml version="1.0"?> 2 3 4 5 2 <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 6 3 xmlns:html="http://www.w3.org/1999/xhtml" … … 14 11 <svg:rect x="0" y="0" width="1000" height="20" fill="#fff" stroke-width="0" /> 15 12 <svg:rect x="0" y="20" width="1000" height="80" fill="#f6e69d" opacity="0.8" stroke-width="0" /> 13 16 14 <svg:g anonid="area_rules"> 17 15 <svg:line x1="0" x2="1000" y1="20" y2="20" stroke="#aaa" fill="black" stroke-width="1" /> 18 16 </svg:g> 17 19 18 <svg:g anonid="sections"> 20 19 <children /> 21 20 </svg:g> 21 22 22 <svg:svg anonid="cursor" x="0" y="0" width="2%" height="100" viewBox="0 0 10 10" 23 23 preserveAspectRatio="none"> 24 24 <svg:line x1="0" x2="0" y1="0" y2="10" fill="red" stroke-width="2" /> 25 25 </svg:svg> 26 27 26 </content> 28 27 … … 31 30 this._cursor = document.getAnonymousElementByAttribute(this, "anonid", "cursor"); 32 31 ]]></constructor> 32 33 <property name="rootSection"> 34 <getter><![CDATA[ 35 var firstSection = this.firstChild; 36 while(firstSection && firstSection.localName != "section") { 37 firstSection = firstSection.nextSibling; 38 } 39 return firstSection; 40 ]]></getter> 41 </property> 42 43 <property name="inner" readonly="true"> 44 <getter><![CDATA[ 45 return document.getAnonymousNodes(this)[0]; 46 ]]></getter> 47 </property> 48 49 <property name="cursor"> 50 <getter><![CDATA[ 51 return this._cursor.x.baseVal.value; 52 ]]></getter> 53 <setter><![CDATA[ 54 if (val < 0) val = 0; 55 if (val > 1000 ) val = 1000; 56 this._cursor.x.baseVal.value = val; 57 ]]></setter> 58 </property> 59 33 60 <method name="init"> 34 61 <parameter name="audioElt" /> … … 86 113 ]]></body> 87 114 </method> 115 88 116 <method name="updateRatio"> 89 117 <body><![CDATA[ … … 103 131 ]]></body> 104 132 </method> 133 105 134 <method name="drawGraph"> 106 135 <body><![CDATA[ 107 var graph = document.getAnonymousElementByAttribute(this, "anonid", "audiograph");108 if (this._audioElt.srcAudio) {109 graph.drawGraph(this._audioElt.srcAudio, "daim://zoomedGraph", 1, 10000, 80);110 } else {111 graph.hideGraph();112 }136 var graph = document.getAnonymousElementByAttribute(this, "anonid", "audiograph"); 137 if (this._audioElt.srcAudio) { 138 graph.drawGraph(this._audioElt.srcAudio, "daim://zoomedGraph", 1, 10000, 80); 139 } else { 140 graph.hideGraph(); 141 } 113 142 ]]></body> 114 143 </method> 115 <property name="rootSection"> 116 <getter> 117 <![CDATA[ 118 var firstSection = this.firstChild; 119 while(firstSection && firstSection.localName != "section") { 120 firstSection = firstSection.nextSibling; 121 } 122 return firstSection; 123 ]]></getter> 124 </property> 144 125 145 <method name="newSectionWalker"> 126 146 <body><![CDATA[ 127 function sectionFilter(node) {128 if (node.localName == "section")129 return NodeFilter.FILTER_ACCEPT130 else131 return NodeFilter.FILTER_SKIP132 }147 function sectionFilter(node) { 148 if (node.localName == "section") 149 return NodeFilter.FILTER_ACCEPT 150 else 151 return NodeFilter.FILTER_SKIP 152 } 133 153 134 return document.createTreeWalker(this.rootSection, NodeFilter.SHOW_ELEMENT, sectionFilter, false);154 return document.createTreeWalker(this.rootSection, NodeFilter.SHOW_ELEMENT, sectionFilter, false); 135 155 ]]></body> 136 156 </method> 137 <property name="inner" readonly="true"> 138 <getter><![CDATA[ 139 return document.getAnonymousNodes(this)[0]; 140 ]]></getter> 141 </property> 157 </implementation> 142 158 143 144 <property name="cursor">145 <getter><![CDATA[146 return this._cursor.x.baseVal.value;147 ]]></getter>148 <setter><![CDATA[149 if (val < 0) val = 0;150 if (val > 1000 ) val = 1000;151 this._cursor.x.baseVal.value = val;152 ]]></setter>153 </property>154 </implementation>155 156 159 <handlers> 157 160 <handler event="DOMMouseScroll"><![CDATA[ … … 167 170 ]]></handler> 168 171 </handlers> 169 170 172 </binding> 171 173 </bindings> -
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/audio.xml
r9275 r9276 1 1 <?xml version="1.0"?> 2 3 4 2 <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 5 3 xmlns:html="http://www.w3.org/1999/xhtml" … … 11 9 <content> 12 10 <xul:vbox anonid="xulroot"> 13 14 11 <svg:svg width="550px" height="200px" viewBox="0 0 1100 400" anonid="svgbody" 15 12 preserveAspectRatio="xMinYMin meet" opacity="0.3"> … … 25 22 leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 26 23 rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 24 27 25 <svg:g transform="translate(0, 140)" class="zoomarea"> 28 26 <svg:g anonid="plotbox" /> … … 30 28 <svg:line class="zmarker" anonid="zmarker2" x1="925" y1="0" x2="995" y2="50" /> 31 29 <svg:rect anonid="ground" x="70" y="50" height="200" width="925" stroke="black" /> 30 32 31 <svg:svg anonid="zoomarea" x="70" y="50" height="200" width="925" viewBox="0 0 1000 100" 33 32 preserveAspectRatio="none" overflow="hidden"> … … 35 34 </svg:svg> 36 35 </svg:g> 36 37 37 <svg:svg x="1040" y="0" width="60" height="400" stroke="red" fill="red" class="svgtoolbar" 38 38 viewBox="0 0 60 400" overflow="visible"> … … 41 41 stroke="#444" rx="5" ry="5" /> 42 42 </svg:g> 43 43 44 <svg:g anonid="button_add" transform="translate(0, 50)"> 44 45 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" … … 46 47 <svg:path d="M8,17 l18,0 M17,8 l0,18" stroke="#000" stroke-width="5" /> 47 48 </svg:g> 49 48 50 <svg:g anonid="button_zoom1" transform="translate(0, 100)"> 49 51 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" … … 53 55 </svg:g> 54 56 </svg:svg> 57 55 58 <svg:rect anonid="disablelayer" x="0" y="0" height="100%" width="100%" opacity="0" /> 56 59 </svg:svg> … … 69 72 this._zoomarea= document.getAnonymousElementByAttribute(this, "anonid", "zoomarea"); 70 73 71 72 74 this.updateZoom(0, 1000); 73 75 ]]></constructor> 76 74 77 <field name="playState" /> 78 75 79 <field name="statusEditor" /> 80 81 <field name="focusedSegment" /> 82 76 83 <property name="title"> 77 84 <setter><![CDATA[ … … 79 86 this._mainplayer.setText("left", val); 80 87 ]]></setter> 88 81 89 <getter><![CDATA[ 82 90 return this._title; 83 91 ]]></getter> 84 92 </property> 93 85 94 <property name="srcAudio"> 86 95 <getter><![CDATA[ 87 96 return this._srcAudio; 97 ]]></getter> 98 </property> 99 100 <property name="audioStream"> 101 <getter><![CDATA[ 102 if (!this.srcAudio) 103 return null; 104 if (!this._audioStream) { 105 this._audioStream = Components.classes["@scenari.org/audio/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); 106 this._audioStream.init(this.srcAudio, 1, 0, Components.interfaces.nsIFileInputStream.REOPEN_ON_REWIND); 107 this._audioStream.QueryInterface(Components.interfaces.scIAudioStream); 108 } 109 110 return this._audioStream; 111 ]]></getter> 112 </property> 113 114 <property name="innerSvg" readonly="true"> 115 <getter><![CDATA[ 116 return document.getAnonymousElementByAttribute(this, "anonid", "svgbody"); 117 ]]></getter> 118 </property> 119 120 <property name="inner" readonly="true"> 121 <getter><![CDATA[ 122 return document.getAnonymousNodes(this)[0]; 123 ]]></getter> 124 </property> 125 126 <property name="duration"> 127 <getter><![CDATA[ 128 return this._duration; 129 ]]></getter> 130 </property> 131 132 <property name="cursor"> 133 <setter><![CDATA[ 134 this._mainplayer.cursor = val; 135 this._segplayer.cursor = val; 136 this._zoomplayer.cursor = val; 137 138 var i; 139 var child; 140 for (i = 0; i < this.childNodes.length; i++) { 141 child = this.childNodes[i]; 142 if (child.localName == "area") { 143 child.cursor = val; 144 } 145 } 146 ]]></setter> 147 148 <getter><![CDATA[ 149 return this._mainplayer.cursor; 88 150 ]]></getter> 89 151 </property> … … 112 174 ]]></body> 113 175 </method> 176 114 177 <method name="setFocusOnSegment"> 115 178 <parameter name="aSegment" /> … … 143 206 ]]></body> 144 207 </method> 145 <field name="focusedSegment" /> 208 146 209 <method name="beginBatch"> 147 210 <body><![CDATA[ … … 151 214 ]]></body> 152 215 </method> 216 153 217 <method name="refresh"> 154 218 <body><![CDATA[ … … 183 247 this.setFocusOnSegment(vNewFocus); 184 248 185 this.updatePlot();249 this.updatePlot(); 186 250 this.innerSvg.unsuspendRedraw(this._suspendId); 187 251 188 252 ]]></body> 189 253 </method> 254 190 255 <method name="s2Str"> 191 256 <parameter name="aMs" /> … … 218 283 ]]></body> 219 284 </method> 285 220 286 <method name="removeSection"> 221 287 <parameter name="pSection" /> 222 288 <body><![CDATA[ 223 if (pSection == this.focusedSegment) {224 this.setFocusOnSegment(null);225 }289 if (pSection == this.focusedSegment) { 290 this.setFocusOnSegment(null); 291 } 226 292 var vParentSection = pSection.parentSection; 227 try {228 pSection.parentNode.removeChild(pSection);229 } catch(e) {}230 vParentSection.init(this);293 try { 294 pSection.parentNode.removeChild(pSection); 295 } catch(e) {} 296 vParentSection.init(this); 231 297 var sectionWalker = vParentSection.ownerArea.newSectionWalker(); 232 298 while (sectionWalker.nextNode()) { 233 sectionWalker.currentNode.updateStartRequest(null); 234 } 235 var vUpdatedSegments = this.getUpdatedSegmentsAndCompute(vParentSection); 236 this.updatePlot(); 237 this.setFocusOnSegment(this.focusedSegment); 238 return vUpdatedSegments; 239 ]]></body> 240 </method> 299 sectionWalker.currentNode.updateStartRequest(null); 300 } 301 var vUpdatedSegments = this.getUpdatedSegmentsAndCompute(vParentSection); 302 this.updatePlot(); 303 this.setFocusOnSegment(this.focusedSegment); 304 return vUpdatedSegments; 305 ]]></body> 306 </method> 307 241 308 <method name="init"> 242 309 <parameter name="aAudioObject" /> … … 426 493 this.statusEditor |= 2; 427 494 428 429 430 495 /// Player listener 431 432 496 this._playerListener = { 433 497 mPlayer:null, … … 441 505 resume : function () { 442 506 if(this.mPlayer) 443 this.mPlayer.resume(); 507 this.mPlayer.resume(); 444 508 }, 445 509 cancel: function () { … … 450 514 dump("===> onStartRequest\n"); 451 515 if(request instanceof Components.interfaces.scIAsyncAudioPlayer) 452 this.mPlayer = request; 516 this.mPlayer = request; 453 517 }, 454 518 … … 476 540 // nsIProgressEventSink 477 541 478 onProgress: function ( request, ctxt , progress , progressMax ) {542 onProgress: function ( request, ctxt , progress , progressMax ) { 479 543 var value = 1000 * (self._offset + (self._window * progress / progressMax)); 480 544 self.cursor = value; … … 482 546 483 547 onStatus: function ( request , ctxt , status , statusArg ) { 484 dump("===> onStatus status: "+status+" statusArg: "+statusArg+"\n"); 548 dump("===> onStatus status: "+status+" statusArg: "+statusArg+"\n"); 485 549 }, 486 550 … … 489 553 if(iid.equals(Components.interfaces.nsIProgressEventSink)) { 490 554 return this; 491 } 555 } 492 556 Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE; 493 557 return null; … … 505 569 506 570 this._zoomplayer.drawGraph(); 507 this.cursor = 0;571 this.cursor = 0; 508 572 509 573 this.updatePlot(); 510 574 ]]></body> 511 575 </method> 512 513 <property name="audioStream">514 <getter><![CDATA[515 if (!this.srcAudio)516 return null;517 if (!this._audioStream) {518 this._audioStream = Components.classes["@scenari.org/audio/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);519 this._audioStream.init(this.srcAudio, 1, 0, Components.interfaces.nsIFileInputStream.REOPEN_ON_REWIND);520 this._audioStream.QueryInterface(Components.interfaces.scIAudioStream);521 }522 523 return this._audioStream;524 ]]></getter>525 </property>526 576 527 577 <method name="play"> … … 544 594 this._audioPlayer.contentStream = this.audioStream; 545 595 546 this._audioPlayer.frameSegmentSize = 512;596 this._audioPlayer.frameSegmentSize = 512; 547 597 this._audioPlayer.frameSegmentCount = 10; 548 598 … … 555 605 ]]></body> 556 606 </method> 607 557 608 <method name="stop"> 558 609 <body><![CDATA[ … … 588 639 <method name="redraw"> 589 640 <body><![CDATA[ 590 this.innerSvg.style.visibility = "hidden";591 this.innerSvg.style.visibility = "visible";592 this._zoomarea.style.visibility = "hidden";593 this._zoomarea.style.visibility = "visible";641 this.innerSvg.style.visibility = "hidden"; 642 this.innerSvg.style.visibility = "visible"; 643 this._zoomarea.style.visibility = "hidden"; 644 this._zoomarea.style.visibility = "visible"; 594 645 ]]></body> 595 646 </method> … … 611 662 </method> 612 663 613 <property name="innerSvg" readonly="true">614 <getter><![CDATA[615 return document.getAnonymousElementByAttribute(this, "anonid", "svgbody");616 ]]></getter>617 </property>618 619 <property name="inner" readonly="true">620 <getter><![CDATA[621 return document.getAnonymousNodes(this)[0];622 ]]></getter>623 </property>624 625 664 <method name="updateZoom"> 626 665 <parameter name="x1" /> … … 632 671 ]]></body> 633 672 </method> 634 635 <property name="duration">636 <getter><![CDATA[637 return this._duration;638 ]]></getter>639 </property>640 673 641 674 <method name="askForCutRequest"> … … 666 699 ]]></body> 667 700 </method> 701 668 702 <method name="updatePlot"> 669 703 <body><![CDATA[ … … 681 715 var vNode; 682 716 while ( (vNode = sectionWalker.nextNode()) ) { 683 var plot = document.createElementNS("http://www.w3.org/2000/svg", "line");717 var plot = document.createElementNS("http://www.w3.org/2000/svg", "line"); 684 718 plot.setAttribute("x1", 70 + (vNode.start * 0.925)); 685 719 plot.setAttribute("x2", 70 + (vNode.start * 0.925)); … … 694 728 ]]></body> 695 729 </method> 730 696 731 <method name="playFromCursor"> 697 732 <body><![CDATA[ … … 701 736 ]]></body> 702 737 </method> 703 704 <property name="cursor">705 <setter><![CDATA[706 this._mainplayer.cursor = val;707 this._segplayer.cursor = val;708 this._zoomplayer.cursor = val;709 710 var i;711 var child;712 for (i = 0; i < this.childNodes.length; i++) {713 child = this.childNodes[i];714 if (child.localName == "area") {715 child.cursor = val;716 }717 }718 ]]></setter>719 <getter><![CDATA[720 return this._mainplayer.cursor;721 ]]></getter>722 </property>723 724 738 </implementation> 725 739 </binding> 726 727 728 740 </bindings> -
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/background.xml
r9275 r9276 44 44 xmlns:ec="http://ircam.fr/ecoute" xmlns:xlink="http://www.w3.org/1999/xlink" 45 45 xmlns:svg="http://www.w3.org/2000/svg"> 46 47 48 49 46 <binding id="background" extends="svg:generic"> </binding> 50 51 52 47 </bindings> -
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/section.xml
r9275 r9276 1 1 <?xml version="1.0"?> 2 3 4 2 <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 5 3 xmlns:html="http://www.w3.org/1999/xhtml" … … 56 54 const RIGHT = 1; 57 55 58 59 60 56 this.isBinded = true; 61 57 this._handles_rect = document.getAnonymousElementByAttribute(this, "anonid", "handles_rect"); … … 66 62 this._sectioneltAnchorRect = document.getAnonymousElementByAttribute(this, "anonid", "sectionAnchorRect"); 67 63 68 69 64 var self = this; 70 65 … … 73 68 if (self.audioElt.focusedSegment == self) return; 74 69 self.audioElt.setFocusOnSegment(self); 75 event.stopPropagation();76 } else { 77 self.ownerArea.updateRatio();78 var ratio = self.ownerArea._ratio;79 var val = event.layerX - (self.audioElt._zoomarea.x.baseVal.value * self.audioElt._segplayer._ratio);80 var z1 = self.audioElt._zoomplayer.t1;81 self.audioElt.cursor = (z1 * ratio + val) / ratio;70 event.stopPropagation(); 71 } else { 72 self.ownerArea.updateRatio(); 73 var ratio = self.ownerArea._ratio; 74 var val = event.layerX - (self.audioElt._zoomarea.x.baseVal.value * self.audioElt._segplayer._ratio); 75 var z1 = self.audioElt._zoomplayer.t1; 76 self.audioElt.cursor = (z1 * ratio + val) / ratio; 82 77 self.audioElt.playFromCursor(); 83 78 } … … 107 102 } 108 103 ]]></constructor> 104 109 105 <field name="audioElt" /> 106 107 <field name="segmentOwner" /> 108 109 <field name="isModified" /> 110 111 <property name="start_Second"> 112 <getter><![CDATA[ 113 return this.start * this.audioElt.duration / 1000; 114 ]]></getter> 115 </property> 116 117 <property name="end_Second"> 118 <getter><![CDATA[ 119 return this.end * (this.audioElt.duration / 1000); 120 ]]></getter> 121 </property> 122 123 <property name="childSections"> 124 <getter><![CDATA[ 125 var child = new Array(); 126 if (this.hasChildSections()) { 127 var aChild = this.firstSection; 128 do { 129 child.push(aChild); 130 aChild = aChild.nextSection; 131 } while(aChild); 132 } 133 return child; 134 ]]></getter> 135 </property> 136 137 <property name="end"> 138 <getter><![CDATA[ 139 return this._inMemoryEnd; 140 ]]></getter> 141 142 <setter><![CDATA[ 143 if (this._sectionelt) { 144 if (this._inMemoryEnd != val) { 145 this.isModified = true; 146 } 147 var vLength = val - this._inMemoryStart; 148 this._sectionelt.width.baseVal.value = vLength; 149 this._handles_rect.width.baseVal.value = vLength; 150 this._handles_right.x.baseVal.value = val; 151 this._inMemoryEnd = val; 152 } 153 ]]></setter> 154 </property> 155 156 157 <property name="previousSection"> 158 <getter><![CDATA[ 159 var previoussibling = this; 160 do { 161 previoussibling = previoussibling.previousSibling; 162 } while (previoussibling && previoussibling.localName != "section"); 163 if (previoussibling && previoussibling.localName != "section") return null; 164 return previoussibling; 165 166 ]]></getter> 167 </property> 168 169 <property name="parentSection"> 170 <getter><![CDATA[ 171 if (this.parentNode.localName == "section") { 172 return this.parentNode; 173 } else { 174 if (this.parentNode.parentNode && this.parentNode.parentNode.localName == "section") { 175 return this.parentNode.parentNode; 176 } else { 177 return null; 178 } 179 } 180 ]]></getter> 181 </property> 182 183 <property name="firstSection"> 184 <getter><![CDATA[ 185 var nextsibling = this.container; 186 nextsibling = nextsibling.firstChild; 187 while (nextsibling && nextsibling.localName != "section") { 188 nextsibling = nextsibling.nextSibling; 189 } 190 return nextsibling; 191 ]]></getter> 192 </property> 193 194 <property name="lastSection"> 195 <getter><![CDATA[ 196 var previoussibling = this.container; 197 previoussibling = previoussibling.lastChild; 198 while (previoussibling && previoussibling.localName != "section") { 199 previoussibling = previoussibling.previousSibling; 200 } 201 return previoussibling; 202 ]]></getter> 203 </property> 204 205 <property name="nextSection"> 206 <getter><![CDATA[ 207 var nextsibling = this; 208 do { 209 nextsibling = nextsibling.nextSibling; 210 } while (nextsibling && nextsibling.localName != "section"); 211 if (nextsibling && nextsibling.localName != "section") return null; 212 return nextsibling; 213 ]]></getter> 214 </property> 215 216 <property name="ownerArea"> 217 <getter><![CDATA[ 218 if (!this.parentSection && this.parentNode.localName == "area") 219 return this.parentNode; 220 else 221 if (this.parentSection) 222 return this.parentSection.ownerArea; 223 else 224 return null; 225 ]]></getter> 226 </property> 227 228 <property name="inner" readonly="true"> 229 <getter><![CDATA[ 230 return document.getAnonymousNodes(this)[0]; 231 ]]></getter> 232 </property> 233 234 <property name="container"> 235 <getter><![CDATA[ 236 //return this; 237 var i; 238 for (i = 0; i < this.childNodes.length; i++) { 239 if (this.childNodes[i].localName == "g") 240 return this.childNodes[i]; 241 } 242 throw "A section *must* host a <svg:g> element" + this.firstChild; 243 ]]></getter> 244 </property> 245 110 246 <method name="init"> 111 247 <parameter name="audioElt" /> … … 120 256 var vChilds = this.childSections; 121 257 for (i = 0; i < vChilds.length; i++) { 122 if ("init" in vChilds[i]) 123 vChilds[i].init(audioElt); 124 } 125 ]]></body> 126 </method> 127 128 <property name="start_Second"> 129 <getter><![CDATA[ 130 return this.start * this.audioElt.duration / 1000; 131 ]]></getter> 132 </property> 133 <property name="end_Second"> 134 <getter><![CDATA[ 135 return this.end * (this.audioElt.duration / 1000); 136 ]]></getter> 137 </property> 258 if ("init" in vChilds[i]) 259 vChilds[i].init(audioElt); 260 } 261 ]]></body> 262 </method> 263 138 264 <method name="resetStart"> 139 265 <parameter name="newStart_msSecond" /> 140 141 <body><![CDATA[ 142 this._inMemoryEnd = null; 143 this._inMemoryStart = null; 144 this.setAttribute("start", newStart_msSecond); 145 //update _inMemoryStart 146 this.start; 147 this.end; 148 ]]></body> 149 </method> 150 151 <field name="segmentOwner" /> 266 <body><![CDATA[ 267 this._inMemoryEnd = null; 268 this._inMemoryStart = null; 269 this.setAttribute("start", newStart_msSecond); 270 //update _inMemoryStart 271 this.start; 272 this.end; 273 ]]></body> 274 </method> 152 275 153 276 <method name="removeSection"> … … 193 316 this.container.insertBefore(pNewSection, pBeforeSection); 194 317 } else { 195 if (this.hasChildSections()) {196 var oldLastChild = this.lastSection;197 var vInsertPos = ("_TimeToCut" in this.audioElt) ? this.audioElt._TimeToCut : null;198 if(vInsertPos == null || vInsertPos < oldLastChild.start_Second || vInsertPos > oldLastChild.end_Second) {199 var vInsertPos = (oldLastChild.start_Second + oldLastChild.end_Second) / 2;200 }201 pNewSection.setAttribute("start", vInsertPos);202 pOthersSegmentsUpdated.push(oldLastChild);203 this.container.appendChild(pNewSection);204 } else {205 pNewSection.setAttribute("start", this.start_Second);206 this.container.appendChild(pNewSection);207 }318 if (this.hasChildSections()) { 319 var oldLastChild = this.lastSection; 320 var vInsertPos = ("_TimeToCut" in this.audioElt) ? this.audioElt._TimeToCut : null; 321 if(vInsertPos == null || vInsertPos < oldLastChild.start_Second || vInsertPos > oldLastChild.end_Second) { 322 var vInsertPos = (oldLastChild.start_Second + oldLastChild.end_Second) / 2; 323 } 324 pNewSection.setAttribute("start", vInsertPos); 325 pOthersSegmentsUpdated.push(oldLastChild); 326 this.container.appendChild(pNewSection); 327 } else { 328 pNewSection.setAttribute("start", this.start_Second); 329 this.container.appendChild(pNewSection); 330 } 208 331 } 209 332 pNewSection.segmentOwner = pSegmentOwner; … … 214 337 </method> 215 338 216 <property name="nextSection">217 <getter><![CDATA[218 var nextsibling = this;219 do {220 nextsibling = nextsibling.nextSibling;221 } while (nextsibling && nextsibling.localName != "section");222 if (nextsibling && nextsibling.localName != "section") return null;223 return nextsibling;224 ]]></getter>225 </property>226 <property name="previousSection">227 <getter><![CDATA[228 var previoussibling = this;229 do {230 previoussibling = previoussibling.previousSibling;231 } while (previoussibling && previoussibling.localName != "section");232 if (previoussibling && previoussibling.localName != "section") return null;233 return previoussibling;234 235 ]]></getter>236 </property>237 <property name="parentSection">238 <getter><![CDATA[239 if (this.parentNode.localName == "section") {240 return this.parentNode;241 } else {242 if (this.parentNode.parentNode && this.parentNode.parentNode.localName == "section") {243 return this.parentNode.parentNode;244 } else {245 return null;246 }247 }248 ]]></getter>249 </property>250 <property name="firstSection">251 <getter><![CDATA[252 var nextsibling = this.container;253 nextsibling = nextsibling.firstChild;254 while (nextsibling && nextsibling.localName != "section") {255 nextsibling = nextsibling.nextSibling;256 }257 return nextsibling;258 ]]></getter>259 </property>260 <property name="lastSection">261 <getter><![CDATA[262 var previoussibling = this.container;263 previoussibling = previoussibling.lastChild;264 while (previoussibling && previoussibling.localName != "section") {265 previoussibling = previoussibling.previousSibling;266 }267 return previoussibling;268 ]]></getter>269 </property>270 339 <method name="hasChildSections"> 271 340 <body><![CDATA[ … … 273 342 ]]></body> 274 343 </method> 275 <property name="childSections">276 <getter><![CDATA[277 var child = new Array();278 if (this.hasChildSections()) {279 var aChild = this.firstSection;280 do {281 child.push(aChild);282 aChild = aChild.nextSection;283 } while(aChild);284 }285 return child;286 ]]></getter>287 </property>288 289 <field name="isModified" />290 <property name="end">291 <getter><![CDATA[292 return this._inMemoryEnd;293 ]]></getter>294 <setter><![CDATA[295 if (this._sectionelt) {296 if (this._inMemoryEnd != val) {297 this.isModified = true;298 }299 var vLength = val - this._inMemoryStart;300 this._sectionelt.width.baseVal.value = vLength;301 this._handles_rect.width.baseVal.value = vLength;302 this._handles_right.x.baseVal.value = val;303 this._inMemoryEnd = val;304 }305 ]]></setter>306 </property>307 344 308 345 <method name="updateEndRequest"> … … 316 353 ]]></body> 317 354 </method> 318 355 319 356 <method name="updateStartRequest"> 320 357 <parameter name="value" /> … … 329 366 var start = this.getAttribute("start"); 330 367 331 if (this.previousSection) {332 if (start && start != "") {333 this._inMemoryStart = start * 1000 / this.audioElt.duration;334 return this._inMemoryStart;335 } else {368 if (this.previousSection) { 369 if (start && start != "") { 370 this._inMemoryStart = start * 1000 / this.audioElt.duration; 371 return this._inMemoryStart; 372 } else { 336 373 if (this.nextSection) 337 374 this.resetStart(this.audioElt.duration * (this.previousSection.start + this.nextSection.start) / 2000); 338 375 else 339 376 this.resetStart(1000); 340 }341 } else {342 this._inMemoryStart = 0;343 return this._inMemoryStart;344 }345 346 /*377 } 378 } else { 379 this._inMemoryStart = 0; 380 return this._inMemoryStart; 381 } 382 383 /* 347 384 if (start && start != "") { 348 385 this._inMemoryStart = start * 1000 / this.audioElt.duration; … … 360 397 } 361 398 }; 362 */399 */ 363 400 364 401 return this.start; 365 402 ]]></getter> 403 366 404 <setter><![CDATA[ 367 405 if (val === null) { 368 406 val = this.start; 369 407 } 370 if (!this.previousSection && val != 0) {408 if (!this.previousSection && val != 0) { 371 409 return; 372 }410 } 373 411 374 412 if (this._inMemoryStart != val) … … 417 455 ]]></setter> 418 456 </property> 457 419 458 <method name="compute"> 420 459 <body><![CDATA[ 421 this.setAttribute("start", this._inMemoryStart * (this.audioElt.duration / 1000)); 422 this._collided_prev = null; 423 this._collided_next = null; 424 ]]></body> 425 </method> 426 427 428 <property name="ownerArea"> 429 <getter><![CDATA[ 430 if (!this.parentSection && this.parentNode.localName == "area") 431 return this.parentNode; 432 else 433 if (this.parentSection) 434 return this.parentSection.ownerArea; 435 else 436 return null; 437 ]]></getter> 438 </property> 439 440 <property name="inner" readonly="true"> 441 <getter><![CDATA[ 442 return document.getAnonymousNodes(this)[0]; 443 ]]></getter> 444 </property> 445 446 <property name="container"> 447 <getter><![CDATA[ 448 //return this; 449 var i; 450 for (i = 0; i < this.childNodes.length; i++) { 451 if (this.childNodes[i].localName == "g") 452 return this.childNodes[i]; 453 } 454 throw "A section *must* host a <svg:g> element" + this.firstChild; 455 ]]></getter> 456 </property> 460 this.setAttribute("start", this._inMemoryStart * (this.audioElt.duration / 1000)); 461 this._collided_prev = null; 462 this._collided_next = null; 463 ]]></body> 464 </method> 465 457 466 </implementation> 458 467 </binding> 459 468 460 <binding id="section-ro" extends="svg:generic"> </binding> 461 469 <binding id="section-ro" extends="svg:generic" /> 462 470 </bindings> -
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/subplayer.xml
r9275 r9276 1 1 <?xml version="1.0"?> 2 3 4 2 <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 5 3 xmlns:html="http://www.w3.org/1999/xhtml" … … 11 9 <content> 12 10 <svg:g xbl:inherits="transform"> 13 14 11 <svg:g class="buttonplayer" anonid="button"> 15 12 <svg:rect anonid="" x="0" y="0" width="40" height="40" /> … … 17 14 <svg:rect anonid="stop" x="8" y="8" width="24" height="24" /> 18 15 </svg:g> 16 19 17 <svg:rect anonid="ext" x="70" y="0" width="1000" height="40" stroke-width="0" /> 20 18 <svg:text anonid="text1" x="84" y="30" font-size="28" fill="#000" stroke-width="0" /> … … 23 21 <svg:audiograph x="70" y="0" height="40" width="925" anonid="audiograph" /> 24 22 <svg:rect anonid="ground" x="70" y="0" width="925" height="40" fill-opacity="0" /> 23 25 24 <svg:g class="subzone" style="visibility: hidden;"> 26 27 25 <svg:symbol id="zoneAnchorLeft" viewBox="15 0 40 40" preserveAspectRatio="none" 28 26 overflow="visible"> … … 42 40 height="36" stroke-width="2" /> 43 41 </svg:g> 42 44 43 <svg:svg anonid="cursor" x="0" y="0" width="10" height="40" viewBox="0 0 10 10" 45 44 preserveAspectRatio="none"> … … 48 47 </svg:g> 49 48 </content> 49 50 50 <implementation> 51 <method name="init">52 <parameter name="audioElt" />53 <body><![CDATA[54 this._audioElt = audioElt;55 56 while (this._modificationListeners.length)57 this._modificationListeners.pop();58 ]]></body>59 </method>60 <method name="drawGraph">61 <body><![CDATA[62 var graph = document.getAnonymousElementByAttribute(this, "anonid", "audiograph");63 if (this._audioElt.srcAudio) {64 graph.drawGraph(this._audioElt.srcAudio, "daim://fullGraph", 0, 950, 40);65 } else {66 graph.hideGraph();67 }68 ]]></body>69 </method>70 51 <constructor><![CDATA[ 71 52 //FIXME: init() … … 132 113 var initValue = handle.x.baseVal.value; 133 114 var newValue = initValue + delta / self._ratio; 134 self._resizeZone(self._selectedHandle == LEFT ? "left" : "right", newValue, true);115 self._resizeZone(self._selectedHandle == LEFT ? "left" : "right", newValue, true); 135 116 } 136 117 var groundClientLeft = self._audioElt._xulroot.boxObject.x + (self._ground.x.baseVal.value * self._ratio); … … 147 128 148 129 function _mousedownMiddle(event) { 149 if (event.button == 0) {150 self._state = DRAG;151 self._selectedHandle = MIDDLE;152 self.oriX = event.clientX;153 }130 if (event.button == 0) { 131 self._state = DRAG; 132 self._selectedHandle = MIDDLE; 133 self.oriX = event.clientX; 134 } 154 135 } 155 136 … … 199 180 this._ratio = coordTrans2.x - coordTrans1.x; 200 181 201 ]]></constructor> 182 ]]></constructor> 183 184 185 <property name="cursor"> 186 <getter><![CDATA[ 187 return 1000 * (this._cursor.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value; 188 ]]></getter> 189 190 <setter><![CDATA[ 191 if (val < 0) val = 0; 192 if (val > 1000 ) val = 1000; 193 this._cursor.x.baseVal.value = (val / 1000) * this._ground.width.baseVal.value + this._ground.x.baseVal.value; 194 ]]></setter> 195 </property> 196 197 <property name="t1"> 198 <getter><![CDATA[ 199 return 1000 * (this._zone.c1.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value; 200 ]]></getter> 201 </property> 202 203 <property name="t2"> 204 <getter><![CDATA[ 205 return 1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value; 206 ]]></getter> 207 </property> 208 209 <method name="setT2"> 210 <parameter name="val" /> 211 <parameter name="notify" /> 212 <body><![CDATA[ 213 if (val < 0) val = 0; 214 if (val > 1000 ) val = 1000; 215 this.showZone(true); 216 this._resizeZone("right", this._ground.x.baseVal.value + this._ground.width.baseVal.value * (val / 1000), notify); 217 ]]></body> 218 </method> 219 220 <property name="inner" readonly="true"> 221 <getter><![CDATA[ 222 return document.getAnonymousNodes(this)[0]; 223 ]]></getter> 224 </property> 225 226 <method name="init"> 227 <parameter name="audioElt" /> 228 <body><![CDATA[ 229 this._audioElt = audioElt; 230 231 while (this._modificationListeners.length) 232 this._modificationListeners.pop(); 233 ]]></body> 234 </method> 235 236 <method name="drawGraph"> 237 <body><![CDATA[ 238 var graph = document.getAnonymousElementByAttribute(this, "anonid", "audiograph"); 239 if (this._audioElt.srcAudio) { 240 graph.drawGraph(this._audioElt.srcAudio, "daim://fullGraph", 0, 950, 40); 241 } else { 242 graph.hideGraph(); 243 } 244 ]]></body> 245 </method> 202 246 203 247 <method name="_notifyPlayListeners"> … … 269 313 if (notify && modif) this._notifyResizeListeners( 270 314 1000 * (this._zone.c1.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value, 271 1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value,315 1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value, 272 316 handle); 273 317 return modif; … … 293 337 if (notify && modif) this._notifyResizeListeners( 294 338 1000 * (this._zone.c1.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value, 295 1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value,339 1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value, 296 340 'middle'); 297 341 return modif; 298 342 ]]></body> 299 343 </method> 300 301 344 302 345 <method name="addResizeListener"> … … 325 368 ]]></body> 326 369 </method> 370 327 371 <method name="showZone"> 328 372 <parameter name="show" /> … … 336 380 </method> 337 381 338 <property name="cursor">339 <getter><![CDATA[340 return 1000 * (this._cursor.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value;341 ]]></getter>342 <setter><![CDATA[343 if (val < 0) val = 0;344 if (val > 1000 ) val = 1000;345 this._cursor.x.baseVal.value = (val / 1000) * this._ground.width.baseVal.value + this._ground.x.baseVal.value;346 ]]></setter>347 </property>348 349 <property name="t1">350 <getter><![CDATA[351 return 1000 * (this._zone.c1.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value;352 ]]></getter>353 </property>354 355 382 <method name="setT1"> 356 383 <parameter name="val" /> … … 364 391 </method> 365 392 366 <property name="t2">367 <getter><![CDATA[368 return 1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value;369 ]]></getter>370 </property>371 <method name="setT2">372 <parameter name="val" />373 <parameter name="notify" />374 <body><![CDATA[375 if (val < 0) val = 0;376 if (val > 1000 ) val = 1000;377 this.showZone(true);378 this._resizeZone("right", this._ground.x.baseVal.value + this._ground.width.baseVal.value * (val / 1000), notify);379 ]]></body>380 </method>381 382 <property name="inner" readonly="true">383 <getter><![CDATA[384 return document.getAnonymousNodes(this)[0];385 ]]></getter>386 </property>387 393 <method name="startplay"> 388 394 <body><![CDATA[ … … 390 396 ]]></body> 391 397 </method> 398 392 399 <method name="stopplay"> 393 400 <body><![CDATA[ … … 395 402 ]]></body> 396 403 </method> 397 398 404 </implementation> 405 399 406 <handlers> 400 407 <handler event="DOMMouseScroll"><![CDATA[ -
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/waves.xml
r9275 r9276 53 53 preserveAspectRatio="none" /> 54 54 </content> 55 55 56 <implementation> 56 57 <property name="inner" readonly="true"> … … 59 60 ]]></getter> 60 61 </property> 62 61 63 <method name="drawGraph"> 62 64 <parameter name="file" /> … … 95 97 96 98 var mIoSrvc = Components.classes["@mozilla.org/network/io-service;1"] 97 .getService(Components.interfaces.nsIIOService); 99 .getService(Components.interfaces.nsIIOService); 98 100 99 101 var src = audioGraphUri + "?index=" + idx; … … 127 129 128 130 // Create a Parameter objects which will hold the images list 129 var gParameters = DaimFactory.createInstance("@daim.project/parameters;1", Components.interfaces.nsIDaimParameters);131 var gParameters = DaimFactory.createInstance("@daim.project/parameters;1", Components.interfaces.nsIDaimParameters); 130 132 131 133 // Assign imagelist … … 135 137 // Drawing helper 136 138 137 var gCanvas = DaimFactory.createInstance("@daim.project/draw2d;1", Components.interfaces.nsIDaimDraw2d); 139 var gCanvas = DaimFactory.createInstance("@daim.project/draw2d;1", Components.interfaces.nsIDaimDraw2d); 138 140 139 141 // Create the image in which the graph will be drawn … … 155 157 ]]></body> 156 158 </method> 159 157 160 <method name="hideGraph"> 158 161 <body><![CDATA[
Note: See TracChangeset
for help on using the changeset viewer.