- Timestamp:
- 06/13/07 16:55:58 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/section.xml
r9197 r9275 2 2 3 3 4 <bindings xmlns = "http://www.mozilla.org/xbl" 5 xmlns:xbl = "http://www.mozilla.org/xbl" 6 xmlns:html = "http://www.w3.org/1999/xhtml" 7 xmlns:xul = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 8 xmlns:ec = "http://ircam.fr/ecoute" 9 xmlns:xlink="http://www.w3.org/1999/xlink" 4 <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 5 xmlns:html="http://www.w3.org/1999/xhtml" 6 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 7 xmlns:ec="http://ircam.fr/ecoute" xmlns:xlink="http://www.w3.org/1999/xlink" 10 8 xmlns:svg="http://www.w3.org/2000/svg"> 11 9 12 13 <binding id="section-editable" extends="svg:generic"> 14 <content> 15 <svg:g> 16 <svg:symbol id="anchorCircle" viewBox="0 0 10 10" preserveAspectRatio="none" overflow="visible"> 17 <svg:circle cx="0" cy="5" r="5" fill="white"/> 18 </svg:symbol> 19 20 <svg:symbol id="handleLeft" viewBox="13 0 40 40" preserveAspectRatio="none" overflow="visible"> 21 <svg:path d="M10,30 a10,10 0 0,1 0,-20 v -10 h 5 v 40 h -5 v 10"/> 22 </svg:symbol> 23 <svg:symbol id="handleRight" viewBox="7 0 40 40" preserveAspectRatio="none" overflow="visible"> 24 <svg:path d="M10,30 a10,10 0 1,0 0,-20 v -10 h -5 v 40 h 5 v 10"/> 25 </svg:symbol> 26 27 28 <svg:symbol id="anchorRect" viewBox="0 0 2 10" preserveAspectRatio="none" overflow="visible"> 29 <svg:rect x="-2" y="0" width="4" height="10"/> 30 </svg:symbol> 31 32 <svg:rect anonid="section" fill-opacity="0" stroke-width="0" y="20" height="80"/> 33 <svg:use anonid="sectionAnchorRect" xlink:href="#anchorRect" width="0.2%" y="20" height="80"/> 34 <svg:g class="handles"> 35 36 <svg:rect anonid="handles_rect" x="0" y="0" width="10" height="100" fill="red"/> 37 <svg:svg x="0" y="0" height="20" width="4%" anonid="handle_left" viewBox="0 0 20 20" preserveAspectRatio="none" overflow="visible"> 38 <svg:image class="anchor" xlink:href="chrome://audio-toolkit/content/images/handleLeftSeg.png" x="-10" y="0" height="20" width="10" preserveAspectRatio="none"/> 39 </svg:svg> 40 <svg:image class="anchor" anonid="handle_right" xlink:href="chrome://audio-toolkit/content/images/handleRightSeg.png" x="10" y="0" height="20" width="2%" preserveAspectRatio="none"/> 41 </svg:g> 42 <children/> 43 </svg:g> 44 </content> 45 <implementation> 46 <constructor> 47 <![CDATA[ 48 const FREE = 0; 49 const DRAG = 1; 50 const LEFT = 0; 51 const RIGHT = 1; 52 53 54 55 this.isBinded = true; 56 this._handles_rect = document.getAnonymousElementByAttribute(this, "anonid", "handles_rect"); 57 this._handles_left = document.getAnonymousElementByAttribute(this, "anonid", "handle_left"); 58 this._handles_right = document.getAnonymousElementByAttribute(this, "anonid", "handle_right"); 59 60 this._sectionelt = document.getAnonymousElementByAttribute(this, "anonid", "section"); 61 this._sectioneltAnchorRect = document.getAnonymousElementByAttribute(this, "anonid", "sectionAnchorRect"); 62 63 64 var self = this; 65 66 function _click(event) { 67 if (event.button == 0) { 68 if (self.audioElt.focusedSegment == self) return; 69 self.audioElt.setFocusOnSegment(self); 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; 77 self.audioElt.playFromCursor(); 78 } 79 } 80 81 function _mousedownLeft(event) { 82 self.ownerArea.updateRatio(); 83 self._state = DRAG; 84 self._selectedHandle = LEFT; 85 self.oriX = event.clientX; 86 } 87 88 function _mousedownRight(event) { 89 self.ownerArea.updateRatio(); 90 self._state = DRAG; 91 self._selectedHandle = RIGHT; 92 self.oriX = event.clientX; 93 } 94 95 this._state = FREE; 96 this._handles_left.addEventListener("mousedown", _mousedownLeft, false); 97 this._handles_right.addEventListener("mousedown", _mousedownRight, false); 98 99 if (this.parentSection) { 100 this.addEventListener("click", _click, false); 101 this.addEventListener("contextmenu", _click, false); 102 } 103 ]]> 104 </constructor> 105 <field name="audioElt"/> 106 <method name="init"> 107 <parameter name="audioElt"/> 108 <body> 109 <![CDATA[ 10 11 <binding id="section-editable" extends="svg:generic"> 12 <content> 13 <svg:g> 14 <svg:symbol id="anchorCircle" viewBox="0 0 10 10" preserveAspectRatio="none" 15 overflow="visible"> 16 <svg:circle cx="0" cy="5" r="5" fill="white" /> 17 </svg:symbol> 18 19 <svg:symbol id="handleLeft" viewBox="13 0 40 40" preserveAspectRatio="none" 20 overflow="visible"> 21 <svg:path d="M10,30 a10,10 0 0,1 0,-20 v -10 h 5 v 40 h -5 v 10" /> 22 </svg:symbol> 23 <svg:symbol id="handleRight" viewBox="7 0 40 40" preserveAspectRatio="none" 24 overflow="visible"> 25 <svg:path d="M10,30 a10,10 0 1,0 0,-20 v -10 h -5 v 40 h 5 v 10" /> 26 </svg:symbol> 27 28 29 <svg:symbol id="anchorRect" viewBox="0 0 2 10" preserveAspectRatio="none" overflow="visible"> 30 <svg:rect x="-2" y="0" width="4" height="10" /> 31 </svg:symbol> 32 33 <svg:rect anonid="section" fill-opacity="0" stroke-width="0" y="20" height="80" /> 34 <svg:use anonid="sectionAnchorRect" xlink:href="#anchorRect" width="0.2%" y="20" height="80" /> 35 <svg:g class="handles"> 36 37 <svg:rect anonid="handles_rect" x="0" y="0" width="10" height="100" fill="red" /> 38 <svg:svg x="0" y="0" height="20" width="4%" anonid="handle_left" viewBox="0 0 20 20" 39 preserveAspectRatio="none" overflow="visible"> 40 <svg:image class="anchor" 41 xlink:href="chrome://audio-toolkit/content/images/handleLeftSeg.png" x="-10" y="0" 42 height="20" width="10" preserveAspectRatio="none" /> 43 </svg:svg> 44 <svg:image class="anchor" anonid="handle_right" 45 xlink:href="chrome://audio-toolkit/content/images/handleRightSeg.png" x="10" y="0" 46 height="20" width="2%" preserveAspectRatio="none" /> 47 </svg:g> 48 <children /> 49 </svg:g> 50 </content> 51 <implementation> 52 <constructor><![CDATA[ 53 const FREE = 0; 54 const DRAG = 1; 55 const LEFT = 0; 56 const RIGHT = 1; 57 58 59 60 this.isBinded = true; 61 this._handles_rect = document.getAnonymousElementByAttribute(this, "anonid", "handles_rect"); 62 this._handles_left = document.getAnonymousElementByAttribute(this, "anonid", "handle_left"); 63 this._handles_right = document.getAnonymousElementByAttribute(this, "anonid", "handle_right"); 64 65 this._sectionelt = document.getAnonymousElementByAttribute(this, "anonid", "section"); 66 this._sectioneltAnchorRect = document.getAnonymousElementByAttribute(this, "anonid", "sectionAnchorRect"); 67 68 69 var self = this; 70 71 function _click(event) { 72 if (event.button == 0) { 73 if (self.audioElt.focusedSegment == self) return; 74 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; 82 self.audioElt.playFromCursor(); 83 } 84 } 85 86 function _mousedownLeft(event) { 87 self.ownerArea.updateRatio(); 88 self._state = DRAG; 89 self._selectedHandle = LEFT; 90 self.oriX = event.clientX; 91 } 92 93 function _mousedownRight(event) { 94 self.ownerArea.updateRatio(); 95 self._state = DRAG; 96 self._selectedHandle = RIGHT; 97 self.oriX = event.clientX; 98 } 99 100 this._state = FREE; 101 this._handles_left.addEventListener("mousedown", _mousedownLeft, false); 102 this._handles_right.addEventListener("mousedown", _mousedownRight, false); 103 104 if (this.parentSection) { 105 this.addEventListener("click", _click, false); 106 this.addEventListener("contextmenu", _click, false); 107 } 108 ]]></constructor> 109 <field name="audioElt" /> 110 <method name="init"> 111 <parameter name="audioElt" /> 112 <body><![CDATA[ 110 113 this.audioElt = audioElt; 111 114 … … 120 123 vChilds[i].init(audioElt); 121 124 } 122 ]]> 123 </body> 124 </method> 125 126 127 <property name="start_Second"> 128 <getter> 129 <![CDATA[ 130 return this.start * this.audioElt.duration / 1000; 131 ]]> 132 </getter> 133 </property> 134 <property name="end_Second"> 135 <getter> 136 <![CDATA[ 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[ 137 135 return this.end * (this.audioElt.duration / 1000); 138 ]]> 139 </getter> 140 </property> 141 <method name="resetStart"> 142 <parameter name="newStart_msSecond"/> 143 144 <body> 145 <![CDATA[ 136 ]]></getter> 137 </property> 138 <method name="resetStart"> 139 <parameter name="newStart_msSecond" /> 140 141 <body><![CDATA[ 146 142 this._inMemoryEnd = null; 147 143 this._inMemoryStart = null; … … 150 146 this.start; 151 147 this.end; 152 ]]> 153 </body> 154 </method> 155 156 <field name="segmentOwner"/> 157 158 <method name="removeSection"> 159 <body> 160 <![CDATA[ 161 return this.audioElt.removeSection(this); 162 ]]> 163 </body> 164 </method> 165 166 <method name="insertChildSection"> 167 <parameter name="pNewSection"/> 168 <parameter name="pBeforeSection"/> 169 <parameter name="pSegmentOwner"/> 170 <body> 171 <![CDATA[ 172 this.audioElt.beginBatch(); 173 //FIXME: dans le cas d'une section avec uniquement un fils, on ne le voit pas :/ 174 if (pBeforeSection && pBeforeSection.parentSection != this) 175 throw "pBeforeSection is not a child of this section."; 176 177 var pOthersSegmentsUpdated = new Array(); 178 if (pBeforeSection) { 179 var beforeSectionStart = pBeforeSection.start_Second; 180 var beforeSectionEnd = pBeforeSection.end_Second; 181 var vInsertPos = ("_TimeToCut" in this.audioElt) ? this.audioElt._TimeToCut : null; 182 var vInsertOnPreviousSection = false; 183 if(vInsertPos == null || vInsertPos < beforeSectionStart || vInsertPos > beforeSectionEnd) { 184 var vPreviousSection = pBeforeSection.previousSection; 185 if(vInsertPos != null && vPreviousSection && vInsertPos < beforeSectionStart && vInsertPos >= vPreviousSection.start_Second) { 186 //On bascule l'insertion sur la secton précédente. 187 vInsertOnPreviousSection = true; 188 } else { 189 vInsertPos = (beforeSectionStart + beforeSectionEnd) / 2; 190 } 148 ]]></body> 149 </method> 150 151 <field name="segmentOwner" /> 152 153 <method name="removeSection"> 154 <body><![CDATA[ 155 return this.audioElt.removeSection(this); 156 ]]></body> 157 </method> 158 159 <method name="insertChildSection"> 160 <parameter name="pNewSection" /> 161 <parameter name="pBeforeSection" /> 162 <parameter name="pSegmentOwner" /> 163 <body><![CDATA[ 164 this.audioElt.beginBatch(); 165 //FIXME: dans le cas d'une section avec uniquement un fils, on ne le voit pas :/ 166 if (pBeforeSection && pBeforeSection.parentSection != this) 167 throw "pBeforeSection is not a child of this section."; 168 169 var pOthersSegmentsUpdated = new Array(); 170 if (pBeforeSection) { 171 var beforeSectionStart = pBeforeSection.start_Second; 172 var beforeSectionEnd = pBeforeSection.end_Second; 173 var vInsertPos = ("_TimeToCut" in this.audioElt) ? this.audioElt._TimeToCut : null; 174 var vInsertOnPreviousSection = false; 175 if(vInsertPos == null || vInsertPos < beforeSectionStart || vInsertPos > beforeSectionEnd) { 176 var vPreviousSection = pBeforeSection.previousSection; 177 if(vInsertPos != null && vPreviousSection && vInsertPos < beforeSectionStart && vInsertPos >= vPreviousSection.start_Second) { 178 //On bascule l'insertion sur la secton précédente. 179 vInsertOnPreviousSection = true; 180 } else { 181 vInsertPos = (beforeSectionStart + beforeSectionEnd) / 2; 191 182 } 192 193 if(vInsertOnPreviousSection) { 194 pOthersSegmentsUpdated.push(vPreviousSection); 195 } else { 196 pBeforeSection.resetStart(vInsertPos); 197 vInsertPos = beforeSectionStart; 198 pOthersSegmentsUpdated.push(pBeforeSection); 199 } 200 pNewSection.setAttribute("start", vInsertPos); 201 this.container.insertBefore(pNewSection, pBeforeSection); 183 } 184 185 if(vInsertOnPreviousSection) { 186 pOthersSegmentsUpdated.push(vPreviousSection); 202 187 } else { 203 if (this.hasChildSections()) { 204 var oldLastChild = this.lastSection; 205 var vInsertPos = ("_TimeToCut" in this.audioElt) ? this.audioElt._TimeToCut : null; 206 if(vInsertPos == null || vInsertPos < oldLastChild.start_Second || vInsertPos > oldLastChild.end_Second) { 207 var vInsertPos = (oldLastChild.start_Second + oldLastChild.end_Second) / 2; 208 } 209 pNewSection.setAttribute("start", vInsertPos); 210 pOthersSegmentsUpdated.push(oldLastChild); 211 this.container.appendChild(pNewSection); 212 } else { 213 pNewSection.setAttribute("start", this.start_Second); 214 this.container.appendChild(pNewSection); 215 } 216 } 217 pNewSection.segmentOwner = pSegmentOwner; 218 this.audioElt.setFocusOnSegment(pNewSection); 219 this.audioElt.refresh(); 220 return pOthersSegmentsUpdated; 221 ]]> 222 </body> 223 </method> 224 225 226 227 228 229 230 231 <property name="nextSection"> 232 <getter> 233 <![CDATA[ 188 pBeforeSection.resetStart(vInsertPos); 189 vInsertPos = beforeSectionStart; 190 pOthersSegmentsUpdated.push(pBeforeSection); 191 } 192 pNewSection.setAttribute("start", vInsertPos); 193 this.container.insertBefore(pNewSection, pBeforeSection); 194 } 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 } 208 } 209 pNewSection.segmentOwner = pSegmentOwner; 210 this.audioElt.setFocusOnSegment(pNewSection); 211 this.audioElt.refresh(); 212 return pOthersSegmentsUpdated; 213 ]]></body> 214 </method> 215 216 <property name="nextSection"> 217 <getter><![CDATA[ 234 218 var nextsibling = this; 235 219 do { … … 238 222 if (nextsibling && nextsibling.localName != "section") return null; 239 223 return nextsibling; 240 ]]> 241 </getter> 242 </property> 243 <property name="previousSection"> 244 <getter> 245 <![CDATA[ 224 ]]></getter> 225 </property> 226 <property name="previousSection"> 227 <getter><![CDATA[ 246 228 var previoussibling = this; 247 229 do { … … 251 233 return previoussibling; 252 234 253 ]]> 254 </getter> 255 </property> 256 <property name="parentSection"> 257 <getter> 258 <![CDATA[ 235 ]]></getter> 236 </property> 237 <property name="parentSection"> 238 <getter><![CDATA[ 259 239 if (this.parentNode.localName == "section") { 260 240 return this.parentNode; … … 266 246 } 267 247 } 268 ]]> 269 </getter> 270 </property> 271 <property name="firstSection"> 272 <getter> 273 <![CDATA[ 248 ]]></getter> 249 </property> 250 <property name="firstSection"> 251 <getter><![CDATA[ 274 252 var nextsibling = this.container; 275 253 nextsibling = nextsibling.firstChild; … … 278 256 } 279 257 return nextsibling; 280 ]]> 281 </getter> 282 </property> 283 <property name="lastSection"> 284 <getter> 285 <![CDATA[ 258 ]]></getter> 259 </property> 260 <property name="lastSection"> 261 <getter><![CDATA[ 286 262 var previoussibling = this.container; 287 263 previoussibling = previoussibling.lastChild; … … 290 266 } 291 267 return previoussibling; 292 ]]> 293 </getter> 294 </property> 295 <method name="hasChildSections"> 296 <body> 297 <![CDATA[ 298 return this.firstSection != null; 299 ]]> 300 </body> 301 </method> 302 <property name="childSections"> 303 <getter> 304 <![CDATA[ 305 var child = new Array(); 306 if (this.hasChildSections()) { 307 var aChild = this.firstSection; 308 do { 309 child.push(aChild); 310 aChild = aChild.nextSection; 311 } while(aChild); 312 } 313 return child; 314 ]]> 315 </getter> 316 </property> 317 318 <field name="isModified"/> 319 320 321 <property name="end"> 322 <getter> 323 <![CDATA[ 268 ]]></getter> 269 </property> 270 <method name="hasChildSections"> 271 <body><![CDATA[ 272 return this.firstSection != null; 273 ]]></body> 274 </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[ 324 292 return this._inMemoryEnd; 325 ]]> 326 </getter> 327 <setter> 328 <![CDATA[ 293 ]]></getter> 294 <setter><![CDATA[ 329 295 if (this._sectionelt) { 330 296 if (this._inMemoryEnd != val) { … … 337 303 this._inMemoryEnd = val; 338 304 } 339 ]]> 340 </setter> 341 </property> 342 343 <method name="updateEndRequest"> 344 <parameter name="value"/> 345 <body> 346 <![CDATA[ 305 ]]></setter> 306 </property> 307 308 <method name="updateEndRequest"> 309 <parameter name="value" /> 310 <body><![CDATA[ 347 311 if (this.nextSection) { 348 312 this.nextSection.updateStartRequest(value); … … 350 314 this.end = 1000; 351 315 } 352 ]]> 353 </body> 354 </method> 355 356 357 <method name="updateStartRequest"> 358 <parameter name="value"/> 359 <body> 360 <![CDATA[ 361 this.start = value; 362 ]]> 363 </body> 364 </method> 365 366 <property name="start"> 367 <getter> 368 <![CDATA[ 316 ]]></body> 317 </method> 318 319 <method name="updateStartRequest"> 320 <parameter name="value" /> 321 <body><![CDATA[ 322 this.start = value; 323 ]]></body> 324 </method> 325 326 <property name="start"> 327 <getter><![CDATA[ 369 328 if (this._inMemoryStart !== null) return this._inMemoryStart; 370 329 var start = this.getAttribute("start"); … … 404 363 405 364 return this.start; 406 ]]> 407 </getter> 408 <setter> 409 <![CDATA[ 365 ]]></getter> 366 <setter><![CDATA[ 410 367 if (val === null) { 411 368 val = this.start; … … 458 415 this.end = 1000; 459 416 } 460 ]]> 461 </setter> 462 </property> 463 <method name="compute"> 464 <body> 465 <![CDATA[ 417 ]]></setter> 418 </property> 419 <method name="compute"> 420 <body><![CDATA[ 466 421 this.setAttribute("start", this._inMemoryStart * (this.audioElt.duration / 1000)); 467 422 this._collided_prev = null; 468 423 this._collided_next = null; 469 ]]> 470 </body> 471 </method> 472 473 474 <property name="ownerArea"> 475 <getter> 476 <![CDATA[ 424 ]]></body> 425 </method> 426 427 428 <property name="ownerArea"> 429 <getter><![CDATA[ 477 430 if (!this.parentSection && this.parentNode.localName == "area") 478 431 return this.parentNode; … … 482 435 else 483 436 return null; 484 ]]> 485 </getter> 486 </property> 487 488 <property name="inner" readonly="true"> 489 <getter> 490 <![CDATA[ 491 return document.getAnonymousNodes(this)[0]; 492 ]]> 493 </getter> 494 </property> 495 496 497 498 499 <property name="container"> 500 <getter> 501 <![CDATA[ 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[ 502 448 //return this; 503 449 var i; … … 507 453 } 508 454 throw "A section *must* host a <svg:g> element" + this.firstChild; 509 ]]> 510 </getter> 511 </property> 512 </implementation> 513 </binding> 514 515 <binding id="section-ro" extends="svg:generic"> 516 </binding> 517 455 ]]></getter> 456 </property> 457 </implementation> 458 </binding> 459 460 <binding id="section-ro" extends="svg:generic"> </binding> 518 461 519 462 </bindings>
Note: See TracChangeset
for help on using the changeset viewer.