Changeset 9275

Show
Ignore:
Timestamp:
13.06.2007 16:55:58 (3 years ago)
Author:
dar
Message:

Indentation

Location:
branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/area.xml

    r9197 r9275  
    33  
    44 
    5 <bindings xmlns = "http://www.mozilla.org/xbl" 
    6         xmlns:xbl = "http://www.mozilla.org/xbl" 
    7         xmlns:html = "http://www.w3.org/1999/xhtml" 
    8         xmlns:xul = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
    9         xmlns:ec = "http://ircam.fr/ecoute" 
    10         xmlns:xlink="http://www.w3.org/1999/xlink" 
     5<bindings xmlns="http://www.mozilla.org/xbl" 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" xmlns:xlink="http://www.w3.org/1999/xlink" 
    119        xmlns:svg="http://www.w3.org/2000/svg"> 
    1210 
    13 <binding id="area" extends="svg:generic"> 
    14 <content> 
    15 <svg:audiograph x="0" y="20" height="80" width="1000" anonid="audiograph"/> 
    16 <svg:rect x="0" y="0" width="1000" height="20" fill="#fff" stroke-width="0"/> 
    17 <svg:rect x="0" y="20" width="1000" height="80" fill="#f6e69d" opacity="0.8" stroke-width="0"/> 
    18 <svg:g anonid="area_rules"> 
    19 <svg:line x1="0" x2="1000" y1="20" y2="20" stroke="#aaa" fill="black" stroke-width="1"/> 
    20 </svg:g> 
    21 <svg:g anonid="sections"> 
    22 <children/> 
    23 </svg:g> 
    24 <svg:svg anonid="cursor" x="0" y="0" width="2%" height="100" viewBox="0 0 10 10" preserveAspectRatio="none"> 
    25 <svg:line x1="0" x2="0" y1="0" y2="10" fill="red" stroke-width="2"/> 
    26 </svg:svg> 
     11        <binding id="area" extends="svg:generic"> 
     12                <content> 
     13                        <svg:audiograph x="0" y="20" height="80" width="1000" anonid="audiograph" /> 
     14                        <svg:rect x="0" y="0" width="1000" height="20" fill="#fff" stroke-width="0" /> 
     15                        <svg:rect x="0" y="20" width="1000" height="80" fill="#f6e69d" opacity="0.8" stroke-width="0" /> 
     16                        <svg:g anonid="area_rules"> 
     17                                <svg:line x1="0" x2="1000" y1="20" y2="20" stroke="#aaa" fill="black" stroke-width="1" /> 
     18                        </svg:g> 
     19                        <svg:g anonid="sections"> 
     20                                <children /> 
     21                        </svg:g> 
     22                        <svg:svg anonid="cursor" x="0" y="0" width="2%" height="100" viewBox="0 0 10 10" 
     23                                preserveAspectRatio="none"> 
     24                                <svg:line x1="0" x2="0" y1="0" y2="10" fill="red" stroke-width="2" /> 
     25                        </svg:svg> 
    2726 
    28 </content> 
     27                </content> 
    2928 
    30 <implementation> 
    31 <constructor> 
    32 <![CDATA[ 
     29                <implementation> 
     30                        <constructor><![CDATA[ 
    3331                                this._cursor = document.getAnonymousElementByAttribute(this, "anonid", "cursor"); 
    34                                 ]]> 
    35 </constructor> 
    36 <method name="init"> 
    37 <parameter name="audioElt"/> 
    38 <body> 
    39 <![CDATA[ 
     32                        ]]></constructor> 
     33                        <method name="init"> 
     34                                <parameter name="audioElt" /> 
     35                                <body><![CDATA[ 
    4036                                        this._audioElt = audioElt; 
    4137                                        var aSectionWalker = this.newSectionWalker(); 
     
    8884 
    8985                                        this.updateRatio(); 
    90                                         ]]> 
    91 </body> 
    92 </method> 
    93 <method name="updateRatio"> 
    94 <body> 
    95 <![CDATA[ 
     86                                ]]></body> 
     87                        </method> 
     88                        <method name="updateRatio"> 
     89                                <body><![CDATA[ 
    9690                                        var sections = document.getAnonymousElementByAttribute(this, "anonid", "sections"); 
    9791                                        var aMatrix = sections.ownerSVGElement.getViewboxToViewportTransform(); 
     
    107101                                        var coordTrans2 = coord2.matrixTransform(aMatrix); 
    108102                                        this._ratio = (coordTrans2.x - coordTrans1.x) * this._audioElt._segplayer._ratio; 
    109  
    110                                         ]]> 
    111 </body> 
    112 </method> 
    113 <method name="drawGraph"> 
    114 <body> 
    115 <![CDATA[ 
     103                                ]]></body> 
     104                        </method> 
     105                        <method name="drawGraph"> 
     106                                <body><![CDATA[ 
    116107                                                var graph = document.getAnonymousElementByAttribute(this, "anonid", "audiograph"); 
    117108                                                if (this._audioElt.srcAudio) { 
     
    120111                                                        graph.hideGraph(); 
    121112                                                } 
    122                                         ]]> 
    123 </body> 
    124 </method> 
    125 <property name="rootSection"> 
    126 <getter> 
    127 <![CDATA[ 
     113                                ]]></body> 
     114                        </method> 
     115                        <property name="rootSection"> 
     116                                <getter> 
     117                                        <![CDATA[ 
    128118                                        var firstSection = this.firstChild; 
    129119                                        while(firstSection && firstSection.localName != "section") { 
     
    131121                                        } 
    132122                                        return firstSection; 
    133                                         ]]> 
    134 </getter> 
    135 </property> 
    136 <method name="newSectionWalker"> 
    137 <body> 
    138 <![CDATA[ 
     123                                ]]></getter> 
     124                        </property> 
     125                        <method name="newSectionWalker"> 
     126                                <body><![CDATA[ 
    139127                                                function sectionFilter(node) { 
    140128                                                        if (node.localName == "section") 
     
    145133 
    146134                                                return document.createTreeWalker(this.rootSection, NodeFilter.SHOW_ELEMENT, sectionFilter, false); 
    147                                         ]]> 
    148 </body> 
    149 </method> 
    150 <property name="inner" readonly="true"> 
    151 <getter> 
    152 <![CDATA[ 
    153                                                 return document.getAnonymousNodes(this)[0]; 
    154                                         ]]> 
    155 </getter> 
    156 </property> 
     135                                ]]></body> 
     136                        </method> 
     137                        <property name="inner" readonly="true"> 
     138                                <getter><![CDATA[ 
     139                                        return document.getAnonymousNodes(this)[0]; 
     140                                ]]></getter> 
     141                        </property> 
    157142 
    158143 
    159 <property name="cursor"> 
    160 <getter> 
    161 <![CDATA[ 
     144                        <property name="cursor"> 
     145                                <getter><![CDATA[ 
    162146                                        return this._cursor.x.baseVal.value; 
    163                                         ]]> 
    164 </getter> 
    165 <setter> 
    166 <![CDATA[ 
     147                                ]]></getter> 
     148                                <setter><![CDATA[ 
    167149                                        if (val < 0) val = 0; 
    168150                                        if (val > 1000 ) val = 1000; 
    169151                                        this._cursor.x.baseVal.value = val; 
    170                                         ]]> 
    171 </setter> 
    172 </property> 
     152                                ]]></setter> 
     153                        </property> 
     154                </implementation> 
     155                 
     156                <handlers> 
     157                        <handler event="DOMMouseScroll"><![CDATA[ 
     158                                var delta = event.detail; 
     159                                var z1 = this._audioElt._zoomplayer.t1; 
     160                                var z2 = this._audioElt._zoomplayer.t2; 
     161                                var width = z2 - z1; 
     162                                z1 -= (delta * width / 100); 
     163                                z2 += (delta * width / 100); 
     164                                this._audioElt._zoomplayer.setZone(z1, z2); 
     165                                 
     166                                return; 
     167                        ]]></handler> 
     168                </handlers> 
    173169 
    174  
    175  
    176 </implementation> 
    177 <handlers> 
    178 <handler event="DOMMouseScroll"> 
    179 <![CDATA[ 
    180                                         var delta = event.detail; 
    181                                         var z1 = this._audioElt._zoomplayer.t1; 
    182                                         var z2 = this._audioElt._zoomplayer.t2; 
    183                                         var width = z2 - z1; 
    184                                         z1 -= (delta * width / 100); 
    185                                         z2 += (delta * width / 100); 
    186                                         this._audioElt._zoomplayer.setZone(z1, z2); 
    187                                          
    188                                         return; 
    189                                 ]]> 
    190 </handler> 
    191 </handlers> 
    192  
    193 </binding> 
     170        </binding> 
    194171</bindings> 
  • branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/audio.xml

    r9200 r9275  
    22   
    33 
    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" 
    108        xmlns:svg="http://www.w3.org/2000/svg"> 
    119 
    12 <binding id="audio" extends="svg:generic"> 
    13 <content> 
    14 <xul:vbox anonid="xulroot"> 
    15                                  
    16 <svg:svg width="550px" height="200px" viewBox="0 0 1100 400" anonid="svgbody" preserveAspectRatio="xMinYMin meet" opacity="0.3"> 
    17  
    18  
    19  
    20 <svg:subplayer anonid="mainplayer" leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" rightHandle="chrome://audio-toolkit/content/images/handleRight.png"/> 
    21 <svg:subplayer anonid="segplayer" selstyle="fill:       #cc9dfa; opacity: 0.7" transform="translate(0, 50)" leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" rightHandle="chrome://audio-toolkit/content/images/handleRight.png"/> 
    22 <svg:subplayer anonid="zoomplayer" selstyle="fill:      #f6e69d; opacity: 0.7" transform="translate(0, 100)" leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" rightHandle="chrome://audio-toolkit/content/images/handleRight.png"/> 
    23  
    24  
    25                                          
    26 <svg:g transform="translate(0, 140)" class="zoomarea"> 
    27 <svg:g anonid="plotbox"/> 
    28 <svg:line class="zmarker" anonid="zmarker1" x1="70" y1="0" x2="70" y2="50"/> 
    29 <svg:line class="zmarker" anonid="zmarker2" x1="925" y1="0" x2="995" y2="50"/> 
    30 <svg:rect anonid="ground" x="70" y="50" height="200" width="925" stroke="black"/> 
    31 <svg:svg anonid="zoomarea" x="70" y="50" height="200" width="925" viewBox="0 0 1000 100" preserveAspectRatio="none" overflow="hidden"> 
    32 <children/> 
    33 </svg:svg> 
    34 </svg:g> 
    35  
    36  
    37  
    38 <svg:svg x="1040" y="0" width="60" height="400" stroke="red" fill="red" class="svgtoolbar" viewBox="0 0 60 400" overflow="visible"> 
    39 <svg:g anonid="button_pitch" transform="translate(0, 0)"> 
    40 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" stroke="#444" rx="5" ry="5"/> 
    41 </svg:g> 
    42 <svg:g anonid="button_add" transform="translate(0, 50)"> 
    43 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" stroke="#444" rx="5" ry="5"/> 
    44 <svg:path d="M8,17 l18,0 M17,8 l0,18" stroke="#000" stroke-width="5"/> 
    45 </svg:g> 
    46 <svg:g anonid="button_zoom1" transform="translate(0, 100)"> 
    47 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" stroke="#444" rx="5" ry="5"/> 
    48 <svg:path d="M10,8 l0,18 M17,12 l0,4 M17,17 l0,4 M24,8 l0,18" stroke="#000" stroke-width="4"/> 
    49 </svg:g> 
    50 </svg:svg> 
    51 <svg:rect anonid="disablelayer" x="0" y="0" height="100%" width="100%" opacity="0"/> 
    52 </svg:svg> 
    53 </xul:vbox> 
    54 </content> 
    55 <implementation> 
    56                          
    57 <constructor> 
    58 <![CDATA[ 
     10        <binding id="audio" extends="svg:generic"> 
     11                <content> 
     12                        <xul:vbox anonid="xulroot"> 
     13 
     14                                <svg:svg width="550px" height="200px" viewBox="0 0 1100 400" anonid="svgbody" 
     15                                        preserveAspectRatio="xMinYMin meet" opacity="0.3"> 
     16                                        <svg:subplayer anonid="mainplayer" 
     17                                                leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 
     18                                                rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 
     19                                        <svg:subplayer anonid="segplayer" selstyle="fill:       #cc9dfa; opacity: 0.7" 
     20                                                transform="translate(0, 50)" 
     21                                                leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 
     22                                                rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 
     23                                        <svg:subplayer anonid="zoomplayer" selstyle="fill:      #f6e69d; opacity: 0.7" 
     24                                                transform="translate(0, 100)" 
     25                                                leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 
     26                                                rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 
     27                                        <svg:g transform="translate(0, 140)" class="zoomarea"> 
     28                                                <svg:g anonid="plotbox" /> 
     29                                                <svg:line class="zmarker" anonid="zmarker1" x1="70" y1="0" x2="70" y2="50" /> 
     30                                                <svg:line class="zmarker" anonid="zmarker2" x1="925" y1="0" x2="995" y2="50" /> 
     31                                                <svg:rect anonid="ground" x="70" y="50" height="200" width="925" stroke="black" /> 
     32                                                <svg:svg anonid="zoomarea" x="70" y="50" height="200" width="925" viewBox="0 0 1000 100" 
     33                                                        preserveAspectRatio="none" overflow="hidden"> 
     34                                                        <children /> 
     35                                                </svg:svg> 
     36                                        </svg:g> 
     37                                        <svg:svg x="1040" y="0" width="60" height="400" stroke="red" fill="red" class="svgtoolbar" 
     38                                                viewBox="0 0 60 400" overflow="visible"> 
     39                                                <svg:g anonid="button_pitch" transform="translate(0, 0)"> 
     40                                                        <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" 
     41                                                                stroke="#444" rx="5" ry="5" /> 
     42                                                </svg:g> 
     43                                                <svg:g anonid="button_add" transform="translate(0, 50)"> 
     44                                                        <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" 
     45                                                                stroke="#444" rx="5" ry="5" /> 
     46                                                        <svg:path d="M8,17 l18,0 M17,8 l0,18" stroke="#000" stroke-width="5" /> 
     47                                                </svg:g> 
     48                                                <svg:g anonid="button_zoom1" transform="translate(0, 100)"> 
     49                                                        <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" 
     50                                                                stroke="#444" rx="5" ry="5" /> 
     51                                                        <svg:path d="M10,8 l0,18 M17,12 l0,4 M17,17 l0,4 M24,8 l0,18" stroke="#000" 
     52                                                                stroke-width="4" /> 
     53                                                </svg:g> 
     54                                        </svg:svg> 
     55                                        <svg:rect anonid="disablelayer" x="0" y="0" height="100%" width="100%" opacity="0" /> 
     56                                </svg:svg> 
     57                        </xul:vbox> 
     58                </content> 
     59 
     60                <implementation> 
     61                        <constructor><![CDATA[ 
    5962                                this.statusEditor = 0; 
    6063 
     
    6871 
    6972                                this.updateZoom(0, 1000); 
    70  
    71  
    72                                 ]]> 
    73 </constructor> 
    74 <field name="playState"/> 
    75 <field name="statusEditor"/> 
    76 <property name="title"> 
    77 <setter> 
    78 <![CDATA[ 
    79                                                         this._title = val; 
    80                                                         this._mainplayer.setText("left", val); 
    81                                                 ]]> 
    82 </setter> 
    83 <getter> 
    84 <![CDATA[ 
    85                                                         return this._title; 
    86                                                 ]]> 
    87 </getter> 
    88 </property> 
    89 <property name="srcAudio"> 
    90 <getter> 
    91 <![CDATA[ 
    92                                                         return this._srcAudio; 
    93                                                 ]]> 
    94 </getter> 
    95 </property> 
    96                          
    97 <method name="zoomToSegment"> 
    98 <parameter name="aSegment"/> 
    99 <body> 
    100 <![CDATA[ 
    101                                                 if (!this.srcAudio) return; 
    102                                                 if( (this.statusEditor & 4) == 4) return; //en cours de batch, impossible car temps invalides 
    103          
    104                                                 var x1 = aSegment.start; 
    105                                                 var x2 = aSegment.end; 
    106                                                 var t1 = this._zoomplayer.t1; 
    107                                                 var t2 = this._zoomplayer.t2; 
    108                                                 if (x2 - x1 <= t2 - t1) { 
    109                                                         if (x2 <= t2 && x1 >= t1) { 
    110                                                                 return; 
    111                                                         } else { 
    112                                                                 this._zoomplayer.setT1(x1 - ((t2 - t1) - (x2 - x1)) / 2, true); 
    113                                                                 this._zoomplayer.setT2(this._zoomplayer.t1 + t2 - t1, true); 
    114                                                         } 
     73                        ]]></constructor> 
     74                        <field name="playState" /> 
     75                        <field name="statusEditor" /> 
     76                        <property name="title"> 
     77                                <setter><![CDATA[ 
     78                                        this._title = val; 
     79                                        this._mainplayer.setText("left", val); 
     80                                ]]></setter> 
     81                                <getter><![CDATA[ 
     82                                        return this._title; 
     83                                ]]></getter> 
     84                        </property> 
     85                        <property name="srcAudio"> 
     86                                <getter><![CDATA[ 
     87                                        return this._srcAudio; 
     88                                ]]></getter> 
     89                        </property> 
     90 
     91                        <method name="zoomToSegment"> 
     92                                <parameter name="aSegment" /> 
     93                                <body><![CDATA[ 
     94                                        if (!this.srcAudio) return; 
     95                                        if( (this.statusEditor & 4) == 4) return; //en cours de batch, impossible car temps invalides 
     96 
     97                                        var x1 = aSegment.start; 
     98                                        var x2 = aSegment.end; 
     99                                        var t1 = this._zoomplayer.t1; 
     100                                        var t2 = this._zoomplayer.t2; 
     101                                        if (x2 - x1 <= t2 - t1) { 
     102                                                if (x2 <= t2 && x1 >= t1) { 
     103                                                        return; 
    115104                                                } else { 
    116                                                         this._zoomplayer.setT1(x1 - (x2 - x1) / 2, true); 
    117                                                         this._zoomplayer.setT2(x2 + (x2 - x1) / 2, true); 
    118                                                 } 
    119                                         ]]> 
    120 </body> 
    121 </method> 
    122 <method name="setFocusOnSegment"> 
    123 <parameter name="aSegment"/> 
    124 <body> 
    125 <![CDATA[ 
    126                                                 if (!this.srcAudio) return; 
    127                                                 if (this.focusedSegment && !(aSegment === this.focusedSegment )) { 
    128                                                         this.focusedSegment.removeAttribute("checked"); 
    129                                                         if (this.focusedSegment.segmentOwner) { 
    130                                                                 this.focusedSegment.segmentOwner.segLooseFocus(this.focusedSegment); 
    131                                                         } 
    132                                                 } 
    133                                                 this.focusedSegment = aSegment; 
    134                                                 if( (this.statusEditor & 4) == 4) return; //en cours de batch, on recalculera tout ca plus tard.  
    135                                                 if (!aSegment) { 
    136                                                         this._segplayer.showZone(false); 
    137                                                         this._segplayer.setText("left", ""); 
    138                                                         this._segplayer.setText("right", ""); 
    139                                                 } else { 
    140                                                         this._segplayer.setText("left", aSegment.getAttribute("title")); 
    141                                                         this._segplayer.setText("right", 
    142                                                                 "(" + this.s2Str(aSegment.start * (this.duration / 1000), 0) + "-" + 
    143                                                                 this.s2Str((aSegment.end) * (this.duration / 1000), 0) + ") " + 
    144                                                                 this.s2Str((aSegment.end - aSegment.start) * (this.duration / 1000), 2)); 
    145                                                         aSegment.setAttribute("checked", "true"); 
    146                                                         this._segplayer.setT1(aSegment.start, false); 
    147                                                         this._segplayer.setT2(aSegment.end, false); 
    148                                                         if (aSegment.segmentOwner) { 
    149                                                                 aSegment.segmentOwner.segGainFocus(aSegment); 
    150                                                         } 
    151                                                 } 
    152  
    153                                         ]]> 
    154 </body> 
    155 </method> 
    156 <field name="focusedSegment"/> 
    157 <method name="beginBatch"> 
    158 <body> 
    159 <![CDATA[ 
    160                                                 //FIXME: disable input events 
    161                                                 this._suspendId = this.innerSvg.suspendRedraw(0); 
    162                                                 this.statusEditor |= 4; 
    163                                         ]]> 
    164 </body> 
    165 </method> 
    166 <method name="refresh"> 
    167                                  
    168 <body> 
    169 <![CDATA[ 
    170                                                 var child; 
    171                                                 var i; 
    172                                                 //Utiliser un treeWalker 
    173                                                 for (i = 0; i < this.childNodes.length; i++) { 
    174                                                         child = this.childNodes[i]; 
    175                                                         if (child.localName == "area") { 
    176                                                                 child.init(this); 
    177                                                         } 
    178                                                 } 
    179                                                 //Memoire du point de cut. 
    180                                                 delete this._TimeToCut; 
    181  
    182                                                 //On sort du mode batch avant le refresh du focus. 
    183                                                 this.statusEditor ^= 4; 
    184  
    185                                                 //Gestion du focus 
    186                                                 var vNewFocus = null; 
    187                                                 if(this.focusedSegment) { 
    188                                                         var vParent = this.focusedSegment.parentNode; 
    189                                                         while(vParent) { 
    190                                                                 if(vParent === this) { 
    191                                                                         //Ce segment est toujours dans la hiérachie. 
    192                                                                         vNewFocus = this.focusedSegment; 
    193                                                                         break; 
    194                                                                 } 
    195                                                                 vParent = vParent.parentNode; 
    196                                                         } 
    197                                                 } 
    198                                                 this.setFocusOnSegment(vNewFocus); 
    199  
    200             this.updatePlot(); 
    201                                                 this.innerSvg.unsuspendRedraw(this._suspendId); 
    202  
    203                                         ]]> 
    204 </body> 
    205 </method> 
    206 <method name="s2Str"> 
    207 <parameter name="aMs"/> 
    208 <parameter name="round"/> 
    209 <body> 
    210 <![CDATA[ 
    211                                                 var resStr = ""; 
    212                                                 var resDouble; 
    213  
    214                                                 resDouble = aMs % 60; 
    215                                                 if (round != null) 
    216                                                         resDouble = Math.floor(resDouble * Math.pow(10, round)) / Math.pow(10, round); 
    217                                                 resStr = ((resDouble < 10) ? "0" + resDouble : resDouble); 
    218                                                 resStr += ""; 
    219                                                 if (round && round != 0) { 
    220                                                         while (resStr.length < (round + 3)) { 
    221                                                                         if (resStr.length == 2) resStr += "."; 
    222                                                                         resStr += "0"; 
    223                                                         } 
    224                                                 } 
    225  
    226                                                 aMs = Math.floor(aMs / 60); 
    227                                                 resDouble = (aMs % 60) 
    228                                                 resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
    229  
    230                                                 aMs = Math.floor(aMs / 60); 
    231                                                 resDouble = (aMs % 60); 
    232                                                 resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
    233  
    234                                                 return resStr; 
    235                                         ]]> 
    236 </body> 
    237 </method> 
    238 <method name="removeSection"> 
    239 <parameter name="pSection"/>  
    240 <body>  
    241             <![CDATA[  
    242               if (pSection == this.focusedSegment) { 
    243                 this.setFocusOnSegment(null); 
    244               } 
    245                                                         var vParentSection = pSection.parentSection;  
    246               try { 
    247                 pSection.parentNode.removeChild(pSection);  
    248               } catch(e) {} 
    249               vParentSection.init(this); 
    250                                                         var sectionWalker = vParentSection.ownerArea.newSectionWalker(); 
    251                                                         while (sectionWalker.nextNode()) { 
    252                 sectionWalker.currentNode.updateStartRequest(null); 
    253                                                         } 
    254               var vUpdatedSegments = this.getUpdatedSegmentsAndCompute(vParentSection);  
    255               this.updatePlot(); 
    256               this.setFocusOnSegment(this.focusedSegment); 
    257               return vUpdatedSegments;  
    258                                                 ]]> 
    259 </body> 
    260 </method> 
    261 <method name="init"> 
    262 <parameter name="aAudioObject"/> 
    263 <body> 
    264 <![CDATA[ 
    265  
     105                                                        this._zoomplayer.setT1(x1 - ((t2 - t1) - (x2 - x1)) / 2, true); 
     106                                                        this._zoomplayer.setT2(this._zoomplayer.t1 + t2 - t1, true); 
     107                                                } 
     108                                        } else { 
     109                                                this._zoomplayer.setT1(x1 - (x2 - x1) / 2, true); 
     110                                                this._zoomplayer.setT2(x2 + (x2 - x1) / 2, true); 
     111                                        } 
     112                                ]]></body> 
     113                        </method> 
     114                        <method name="setFocusOnSegment"> 
     115                                <parameter name="aSegment" /> 
     116                                <body><![CDATA[ 
     117                                        if (!this.srcAudio) return; 
     118                                        if (this.focusedSegment && !(aSegment === this.focusedSegment )) { 
     119                                                this.focusedSegment.removeAttribute("checked"); 
     120                                                if (this.focusedSegment.segmentOwner) { 
     121                                                        this.focusedSegment.segmentOwner.segLooseFocus(this.focusedSegment); 
     122                                                } 
     123                                        } 
     124                                        this.focusedSegment = aSegment; 
     125                                        if( (this.statusEditor & 4) == 4) return; //en cours de batch, on recalculera tout ca plus tard.  
     126                                        if (!aSegment) { 
     127                                                this._segplayer.showZone(false); 
     128                                                this._segplayer.setText("left", ""); 
     129                                                this._segplayer.setText("right", ""); 
     130                                        } else { 
     131                                                this._segplayer.setText("left", aSegment.getAttribute("title")); 
     132                                                this._segplayer.setText("right", 
     133                                                        "(" + this.s2Str(aSegment.start * (this.duration / 1000), 0) + "-" + 
     134                                                        this.s2Str((aSegment.end) * (this.duration / 1000), 0) + ") " + 
     135                                                        this.s2Str((aSegment.end - aSegment.start) * (this.duration / 1000), 2)); 
     136                                                aSegment.setAttribute("checked", "true"); 
     137                                                this._segplayer.setT1(aSegment.start, false); 
     138                                                this._segplayer.setT2(aSegment.end, false); 
     139                                                if (aSegment.segmentOwner) { 
     140                                                        aSegment.segmentOwner.segGainFocus(aSegment); 
     141                                                } 
     142                                        } 
     143                                ]]></body> 
     144                        </method> 
     145                        <field name="focusedSegment" /> 
     146                        <method name="beginBatch"> 
     147                                <body><![CDATA[ 
     148                                        //FIXME: disable input events 
     149                                        this._suspendId = this.innerSvg.suspendRedraw(0); 
     150                                        this.statusEditor |= 4; 
     151                                ]]></body> 
     152                        </method> 
     153                        <method name="refresh"> 
     154                                <body><![CDATA[ 
     155                                        var child; 
     156                                        var i; 
     157                                        //Utiliser un treeWalker 
     158                                        for (i = 0; i < this.childNodes.length; i++) { 
     159                                                child = this.childNodes[i]; 
     160                                                if (child.localName == "area") { 
     161                                                        child.init(this); 
     162                                                } 
     163                                        } 
     164                                        //Memoire du point de cut. 
     165                                        delete this._TimeToCut; 
     166 
     167                                        //On sort du mode batch avant le refresh du focus. 
     168                                        this.statusEditor ^= 4; 
     169 
     170                                        //Gestion du focus 
     171                                        var vNewFocus = null; 
     172                                        if(this.focusedSegment) { 
     173                                                var vParent = this.focusedSegment.parentNode; 
     174                                                while(vParent) { 
     175                                                        if(vParent === this) { 
     176                                                                //Ce segment est toujours dans la hiérachie. 
     177                                                                vNewFocus = this.focusedSegment; 
     178                                                                break; 
     179                                                        } 
     180                                                        vParent = vParent.parentNode; 
     181                                                } 
     182                                        } 
     183                                        this.setFocusOnSegment(vNewFocus); 
     184 
     185          this.updatePlot(); 
     186                                        this.innerSvg.unsuspendRedraw(this._suspendId); 
     187 
     188                                ]]></body> 
     189                        </method> 
     190                        <method name="s2Str"> 
     191                                <parameter name="aMs" /> 
     192                                <parameter name="round" /> 
     193                                <body><![CDATA[ 
     194                                        var resStr = ""; 
     195                                        var resDouble; 
     196 
     197                                        resDouble = aMs % 60; 
     198                                        if (round != null) 
     199                                                resDouble = Math.floor(resDouble * Math.pow(10, round)) / Math.pow(10, round); 
     200                                        resStr = ((resDouble < 10) ? "0" + resDouble : resDouble); 
     201                                        resStr += ""; 
     202                                        if (round && round != 0) { 
     203                                                while (resStr.length < (round + 3)) { 
     204                                                                if (resStr.length == 2) resStr += "."; 
     205                                                                resStr += "0"; 
     206                                                } 
     207                                        } 
     208 
     209                                        aMs = Math.floor(aMs / 60); 
     210                                        resDouble = (aMs % 60) 
     211                                        resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
     212 
     213                                        aMs = Math.floor(aMs / 60); 
     214                                        resDouble = (aMs % 60); 
     215                                        resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
     216 
     217                                        return resStr; 
     218                                ]]></body> 
     219                        </method> 
     220                        <method name="removeSection"> 
     221                                <parameter name="pSection" /> 
     222                                <body><![CDATA[  
     223          if (pSection == this.focusedSegment) { 
     224            this.setFocusOnSegment(null); 
     225          } 
     226                                        var vParentSection = pSection.parentSection;  
     227          try { 
     228            pSection.parentNode.removeChild(pSection);  
     229          } catch(e) {} 
     230          vParentSection.init(this); 
     231                                        var sectionWalker = vParentSection.ownerArea.newSectionWalker(); 
     232                                        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> 
     241                        <method name="init"> 
     242                                <parameter name="aAudioObject" /> 
     243                                <body><![CDATA[ 
    266244                                        var self = this; 
    267245                                        this.playState = "stop"; 
     
    530508 
    531509                                        this.updatePlot(); 
    532                                         ]]> 
    533 </body> 
    534 </method> 
    535  
    536                          
    537 <property name="audioStream"> 
    538 <getter> 
    539 <![CDATA[ 
    540                                                  
    541                                                 if (!this.srcAudio) 
    542                                                         return null; 
    543                                                 if (!this._audioStream) { 
    544                                                         this._audioStream = Components.classes["@scenari.org/audio/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); 
    545                                                         this._audioStream.init(this.srcAudio, 1, 0, Components.interfaces.nsIFileInputStream.REOPEN_ON_REWIND); 
    546                                                         this._audioStream.QueryInterface(Components.interfaces.scIAudioStream); 
    547                                                 } 
    548                                                  
    549                                                 return this._audioStream; 
    550  
    551                                         ]]> 
    552 </getter> 
    553 </property> 
    554                          
    555 <method name="play"> 
    556 <parameter name="t1"/> 
    557 <parameter name="t2"/> 
    558 <body> 
    559 <![CDATA[ 
    560                                                 if (t1 < 0) t1 = 0; 
    561                                                 var f1 = t1 * this._sampleRate; 
    562  
    563                                                 var f2; 
    564  
    565                                                 if (t2 < 0) { 
    566                                                         t2 = this._duration; 
    567                                                 } 
    568                                                 f2 = t2 * this._sampleRate; 
    569  
    570                                                 if (!this._audioPlayer) { 
    571                                                         var gAudioSrvc = Components.classes['@scenari.org/audio-service;1'].getService(Components.interfaces.scIAudioService); 
    572                                                         this._audioPlayer = gAudioSrvc.newAudioPlayer(-1, this.audioStream); 
    573                                                         this._audioPlayer.contentStream = this.audioStream; 
    574  
    575                                                         this._audioPlayer.frameSegmentSize  = 512; 
    576                                                         this._audioPlayer.frameSegmentCount = 10; 
    577  
    578                                                 } 
    579                                                 this.audioStream.seekFrame(0, f1); 
    580                                                 this._offset = t1 / this._duration; 
    581                                                 this._window = (t2 - t1) / this._duration; 
    582                                                 this._audioPlayer.notificationCallbacks = this._playerListener; 
    583                                                 this._audioPlayer.asyncWrite(this._playerListener, null, f2 - f1, false); 
    584                                         ]]> 
    585 </body> 
    586 </method> 
    587 <method name="stop"> 
    588 <body> 
    589 <![CDATA[ 
    590                                                 this._mainplayer.stopplay(); 
    591                                                 this._zoomplayer.stopplay(); 
    592                                                 this._segplayer.stopplay(); 
    593                                                 this.playState = "stop"; 
    594  
    595                                                 if (this._audioPlayer) { 
    596                                                         this._playerListener.cancel(); 
    597                                                 } 
    598                                         ]]> 
    599 </body> 
    600 </method> 
    601                          
    602 <method name="createSection"> 
    603 <body> 
    604 <![CDATA[ 
     510                                ]]></body> 
     511                        </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                                        } 
    605522                                         
     523                                        return this._audioStream; 
     524                                ]]></getter> 
     525                        </property> 
     526 
     527                        <method name="play"> 
     528                                <parameter name="t1" /> 
     529                                <parameter name="t2" /> 
     530                                <body><![CDATA[ 
     531                                        if (t1 < 0) t1 = 0; 
     532                                        var f1 = t1 * this._sampleRate; 
     533 
     534                                        var f2; 
     535 
     536                                        if (t2 < 0) { 
     537                                                t2 = this._duration; 
     538                                        } 
     539                                        f2 = t2 * this._sampleRate; 
     540 
     541                                        if (!this._audioPlayer) { 
     542                                                var gAudioSrvc = Components.classes['@scenari.org/audio-service;1'].getService(Components.interfaces.scIAudioService); 
     543                                                this._audioPlayer = gAudioSrvc.newAudioPlayer(-1, this.audioStream); 
     544                                                this._audioPlayer.contentStream = this.audioStream; 
     545 
     546                                                this._audioPlayer.frameSegmentSize  = 512; 
     547                                                this._audioPlayer.frameSegmentCount = 10; 
     548 
     549                                        } 
     550                                        this.audioStream.seekFrame(0, f1); 
     551                                        this._offset = t1 / this._duration; 
     552                                        this._window = (t2 - t1) / this._duration; 
     553                                        this._audioPlayer.notificationCallbacks = this._playerListener; 
     554                                        this._audioPlayer.asyncWrite(this._playerListener, null, f2 - f1, false); 
     555                                ]]></body> 
     556                        </method> 
     557                        <method name="stop"> 
     558                                <body><![CDATA[ 
     559                                        this._mainplayer.stopplay(); 
     560                                        this._zoomplayer.stopplay(); 
     561                                        this._segplayer.stopplay(); 
     562                                        this.playState = "stop"; 
     563 
     564                                        if (this._audioPlayer) { 
     565                                                this._playerListener.cancel(); 
     566                                        } 
     567                                ]]></body> 
     568                        </method> 
     569 
     570                        <method name="createSection"> 
     571                                <body><![CDATA[ 
    606572                                        var g = document.createElementNS("http://www.w3.org/2000/svg", "g"); 
    607573                                        var aSection = document.createElementNS("http://www.w3.org/2000/svg", "section"); 
    608574                                        aSection.appendChild(g); 
    609575                                        return aSection; 
    610                                         ]]> 
    611 </body> 
    612 </method> 
    613  
    614  
    615                          
    616 <method name="forceRedraw"> 
    617 <body> 
    618 <![CDATA[ 
    619                                                 this.innerSvg.style.display = "none"; 
    620                                                 this.innerSvg.style.display = "block"; 
    621                                                 this._zoomarea.style.display = "none"; 
    622                                                 this._zoomarea.style.display = "block"; 
    623                                         ]]> 
    624 </body> 
    625 </method> 
    626 <method name="redraw"> 
    627 <body> 
    628 <![CDATA[ 
     576                                ]]></body> 
     577                        </method> 
     578 
     579                        <method name="forceRedraw"> 
     580                                <body><![CDATA[ 
     581                                        this.innerSvg.style.display = "none"; 
     582                                        this.innerSvg.style.display = "block"; 
     583                                        this._zoomarea.style.display = "none"; 
     584                                        this._zoomarea.style.display = "block"; 
     585                                ]]></body> 
     586                        </method> 
     587 
     588                        <method name="redraw"> 
     589                                <body><![CDATA[ 
    629590                                                this.innerSvg.style.visibility = "hidden"; 
    630591                                                this.innerSvg.style.visibility = "visible"; 
    631592                                                this._zoomarea.style.visibility = "hidden"; 
    632593                                                this._zoomarea.style.visibility = "visible"; 
    633                                         ]]> 
    634 </body> 
    635 </method> 
    636 <method name="getUpdatedSegmentsAndCompute"> 
    637 <parameter name="aSegment"/> 
    638 <body> 
    639 <![CDATA[ 
     594                                ]]></body> 
     595                        </method> 
     596 
     597                        <method name="getUpdatedSegmentsAndCompute"> 
     598                                <parameter name="aSegment" /> 
     599                                <body><![CDATA[ 
    640600                                        var sectionWalker = aSegment.ownerArea.newSectionWalker(); 
    641601                                        var updatedSegments = new Array(); 
     
    648608                                        } 
    649609                                        return updatedSegments; 
    650                                         ]]> 
    651 </body> 
    652 </method> 
    653  
    654 <property name="innerSvg" readonly="true"> 
    655 <getter> 
    656 <![CDATA[ 
    657                                                 return document.getAnonymousElementByAttribute(this, "anonid", "svgbody"); 
    658                                         ]]> 
    659 </getter> 
    660 </property> 
    661 <property name="inner" readonly="true"> 
    662 <getter> 
    663 <![CDATA[ 
    664                                                 return document.getAnonymousNodes(this)[0]; 
    665                                         ]]> 
    666 </getter> 
    667 </property> 
    668  
    669 <method name="updateZoom"> 
    670 <parameter name="x1"/> 
    671 <parameter name="x2"/> 
    672 <body> 
    673 <![CDATA[ 
     610                                ]]></body> 
     611                        </method> 
     612 
     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                        <method name="updateZoom"> 
     626                                <parameter name="x1" /> 
     627                                <parameter name="x2" /> 
     628                                <body><![CDATA[ 
    674629                                        this._mark1.x1.baseVal.value = this._ground.width.baseVal.value * x1 / 1000 + this._ground.x.baseVal.value; 
    675630                                        this._mark2.x1.baseVal.value = this._ground.width.baseVal.value * x2 / 1000 + this._ground.x.baseVal.value; 
    676631                                        this._zoomarea.setAttribute("viewBox", x1 + " 0 " + (x2 - x1) + " 100"); 
    677                                         ]]> 
    678 </body> 
    679 </method> 
    680  
    681 <property name="duration"> 
    682 <getter> 
    683 <![CDATA[ 
    684                                                 return this._duration;           
    685                                         ]]> 
    686 </getter> 
    687 </property> 
    688  
    689 <method name="askForCutRequest"> 
    690 <body> 
    691 <![CDATA[ 
    692                                                 if (this.cursor <= 0) return; 
    693  
    694                                                 var child; 
    695                                                 var i; 
    696                                                 for (i = 0; i < this.childNodes.length; i++) { 
    697                                                         child = this.childNodes[i]; 
    698                                                         if (child.localName == "area") { 
    699                                                                 var sectionWalker = child.newSectionWalker(); 
    700                                                                 var vNode; 
    701                                                                 while ( (vNode = sectionWalker.nextNode()) ) { 
    702                                                                         if ((vNode.start < this.cursor) && (vNode.end > this.cursor)) { 
    703                                                                                 if (vNode.segmentOwner) { 
    704                                                                                         //Mem cursor position. 
    705                                                                                         this._TimeToCut = this.cursor * this.duration / 1000; 
    706                                                                                         vNode.segmentOwner.segAskForCut(vNode, 0); 
    707                                                                                         //Impossible : l'odre d'insertion par le XED est asynchrone. => Reporté dans le refresh() 
    708                                                                                         //delete this._TimeToCut; 
    709                                                                                 } 
    710                                                                                 return; 
     632                                ]]></body> 
     633                        </method> 
     634 
     635                        <property name="duration"> 
     636                                <getter><![CDATA[ 
     637                                        return this._duration;           
     638                                ]]></getter> 
     639                        </property> 
     640 
     641                        <method name="askForCutRequest"> 
     642                                <body><![CDATA[ 
     643                                        if (this.cursor <= 0) return; 
     644 
     645                                        var child; 
     646                                        var i; 
     647                                        for (i = 0; i < this.childNodes.length; i++) { 
     648                                                child = this.childNodes[i]; 
     649                                                if (child.localName == "area") { 
     650                                                        var sectionWalker = child.newSectionWalker(); 
     651                                                        var vNode; 
     652                                                        while ( (vNode = sectionWalker.nextNode()) ) { 
     653                                                                if ((vNode.start < this.cursor) && (vNode.end > this.cursor)) { 
     654                                                                        if (vNode.segmentOwner) { 
     655                                                                                //Mem cursor position. 
     656                                                                                this._TimeToCut = this.cursor * this.duration / 1000; 
     657                                                                                vNode.segmentOwner.segAskForCut(vNode, 0); 
     658                                                                                //Impossible : l'odre d'insertion par le XED est asynchrone. => Reporté dans le refresh() 
     659                                                                                //delete this._TimeToCut; 
    711660                                                                        } 
     661                                                                        return; 
    712662                                                                } 
    713663                                                        } 
    714664                                                } 
    715  
    716  
    717                                         ]]> 
    718 </body> 
    719 </method> 
    720 <method name="updatePlot"> 
    721 <body> 
    722 <![CDATA[ 
     665                                        } 
     666                                ]]></body> 
     667                        </method> 
     668                        <method name="updatePlot"> 
     669                                <body><![CDATA[ 
    723670                                        var plotbox = document.getAnonymousElementByAttribute(this, "anonid", "plotbox"); 
    724671                                        while (plotbox.hasChildNodes()) { 
     
    745692                                                } 
    746693                                        } 
    747  
    748  
    749                                         ]]> 
    750 </body> 
    751 </method> 
    752 <method name="playFromCursor"> 
    753 <body> 
    754 <![CDATA[ 
    755                                                 var self = this; 
    756  
    757  
    758                                                 this.stop(); 
    759                                                 this.replayFromCursor = true; 
    760                                         ]]> 
    761 </body> 
    762 </method> 
    763 <property name="cursor"> 
    764 <setter> 
    765 <![CDATA[ 
    766                                                 this._mainplayer.cursor = val; 
    767                                                 this._segplayer.cursor = val; 
    768                                                 this._zoomplayer.cursor = val; 
    769  
    770                                                 var i; 
    771                                                 var child; 
    772                                                 for (i = 0; i < this.childNodes.length; i++) { 
    773                                                 child = this.childNodes[i]; 
    774                                                         if (child.localName == "area") { 
    775                                                                 child.cursor = val; 
    776                                                         } 
    777                                                 } 
    778  
    779                                                 ]]> 
    780 </setter> 
    781 <getter> 
    782 <![CDATA[ 
    783                                                         return this._mainplayer.cursor; 
    784                                                 ]]> 
    785 </getter> 
    786 </property> 
    787  
    788 </implementation> 
    789 </binding> 
     694                                ]]></body> 
     695                        </method> 
     696                        <method name="playFromCursor"> 
     697                                <body><![CDATA[ 
     698                                        var self = this; 
     699                                        this.stop(); 
     700                                        this.replayFromCursor = true; 
     701                                ]]></body> 
     702                        </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                </implementation> 
     725        </binding> 
    790726 
    791727 
  • branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/background.xml

    r7950 r9275  
    3939-->  
    4040 
    41 <bindings xmlns = "http://www.mozilla.org/xbl" 
    42         xmlns:xbl = "http://www.mozilla.org/xbl" 
    43         xmlns:html = "http://www.w3.org/1999/xhtml" 
    44         xmlns:xul = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
    45         xmlns:ec = "http://ircam.fr/ecoute" 
    46         xmlns:xlink="http://www.w3.org/1999/xlink" 
     41<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 
     42        xmlns:html="http://www.w3.org/1999/xhtml" 
     43        xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
     44        xmlns:ec="http://ircam.fr/ecoute" xmlns:xlink="http://www.w3.org/1999/xlink" 
    4745        xmlns:svg="http://www.w3.org/2000/svg"> 
    4846 
    4947 
    5048 
    51         <binding id="background" extends="svg:generic"> 
    52         </binding> 
     49        <binding id="background" extends="svg:generic"> </binding> 
    5350 
    5451 
    5552</bindings> 
    56  
  • branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/section.xml

    r9197 r9275  
    22  
    33 
    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" 
    108        xmlns:svg="http://www.w3.org/2000/svg"> 
    119 
    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[ 
    110113                                        this.audioElt = audioElt; 
    111114 
     
    120123                                                vChilds[i].init(audioElt); 
    121124                                        } 
    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[ 
    137135                                                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[ 
    146142                                                this._inMemoryEnd = null; 
    147143                                                this._inMemoryStart = null; 
     
    150146                                                this.start; 
    151147            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; 
    191182                                                        } 
    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); 
    202187                                                } 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[ 
    234218                                        var nextsibling = this; 
    235219                                        do { 
     
    238222          if (nextsibling && nextsibling.localName != "section") return null; 
    239223                                        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[ 
    246228                                        var previoussibling = this; 
    247229                                        do { 
     
    251233                                        return previoussibling;  
    252234                                         
    253                                         ]]> 
    254 </getter> 
    255 </property> 
    256 <property name="parentSection"> 
    257 <getter> 
    258 <![CDATA[ 
     235                                ]]></getter> 
     236                        </property> 
     237                        <property name="parentSection"> 
     238                                <getter><![CDATA[ 
    259239                                        if (this.parentNode.localName == "section") { 
    260240                                                return this.parentNode; 
     
    266246                                                } 
    267247                                        } 
    268                                         ]]> 
    269 </getter> 
    270 </property> 
    271 <property name="firstSection"> 
    272 <getter> 
    273 <![CDATA[ 
     248                                ]]></getter> 
     249                        </property> 
     250                        <property name="firstSection"> 
     251                                <getter><![CDATA[ 
    274252                                        var nextsibling = this.container; 
    275253                                        nextsibling = nextsibling.firstChild; 
     
    278256                                        } 
    279257                                        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[ 
    286262                                        var previoussibling = this.container; 
    287263                                        previoussibling = previoussibling.lastChild; 
     
    290266                                        } 
    291267                                        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[ 
    324292                                        return this._inMemoryEnd; 
    325                                         ]]> 
    326 </getter> 
    327 <setter> 
    328 <![CDATA[ 
     293                                ]]></getter> 
     294                                <setter><![CDATA[ 
    329295                                        if (this._sectionelt) { 
    330296                                                if (this._inMemoryEnd != val) { 
     
    337303                                                this._inMemoryEnd = val; 
    338304                                        } 
    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[ 
    347311                                        if (this.nextSection) { 
    348312                                                this.nextSection.updateStartRequest(value); 
     
    350314                                                this.end = 1000; 
    351315                                        } 
    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[ 
    369328                                        if (this._inMemoryStart !== null) return this._inMemoryStart; 
    370329                                        var start = this.getAttribute("start"); 
     
    404363 
    405364                                        return this.start; 
    406                                         ]]> 
    407 </getter> 
    408 <setter> 
    409 <![CDATA[ 
     365                                ]]></getter> 
     366                                <setter><![CDATA[ 
    410367                                        if (val === null) { 
    411368                                                val = this.start; 
     
    458415                                                this.end = 1000; 
    459416                                        } 
    460                                         ]]> 
    461 </setter> 
    462 </property> 
    463 <method name="compute"> 
    464 <body> 
    465 <![CDATA[ 
     417                                ]]></setter> 
     418                        </property> 
     419                        <method name="compute"> 
     420                                <body><![CDATA[ 
    466421                                                this.setAttribute("start", this._inMemoryStart * (this.audioElt.duration / 1000)); 
    467422                                                this._collided_prev = null; 
    468423                                                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[ 
    477430                                        if (!this.parentSection && this.parentNode.localName == "area") 
    478431                                                return this.parentNode; 
     
    482435                                                else 
    483436                                                        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[ 
    502448                                        //return this; 
    503449                                        var i; 
     
    507453                                        } 
    508454                                        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> 
    518461 
    519462</bindings> 
  • branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/subplayer.xml

    r9198 r9275  
    22  
    33 
    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" 
    108        xmlns:svg="http://www.w3.org/2000/svg"> 
    119 
    12 <binding id="subplayer" extends="svg:generic"> 
    13 <content> 
    14 <svg:g xbl:inherits="transform"> 
    15  
    16 <svg:g class="buttonplayer" anonid="button"> 
    17 <svg:rect anonid="" x="0" y="0" width="40" height="40"/> 
    18 <svg:polyline anonid="play" points="70,20 30,20 10,10 10,30 30,20" fill="#79bc5d"/> 
    19 <svg:rect anonid="stop" x="8" y="8" width="24" height="24"/> 
    20 </svg:g> 
    21 <svg:rect anonid="ext" x="70" y="0" width="1000" height="40" stroke-width="0"/> 
    22 <svg:text anonid="text1" x="84" y="30" font-size="28" fill="#000" stroke-width="0"/> 
    23 <svg:text anonid="text2" x="990" y="30" font-size="28" fill="#000" stroke-width="0" text-anchor="end"/> 
    24 <svg:audiograph x="70" y="0" height="40" width="925" anonid="audiograph"/> 
    25 <svg:rect anonid="ground" x="70" y="0" width="925" height="40" fill-opacity="0"/> 
    26 <svg:g class="subzone" style="visibility: hidden;"> 
    27  
    28 <svg:symbol id="zoneAnchorLeft" viewBox="15 0 40 40" preserveAspectRatio="none" overflow="visible"> 
    29 <svg:path d="M10,30 a10,10 0 0,1 0,-20 v -10 h 5 v 40 h -5 v 10"/> 
    30 </svg:symbol> 
    31 <svg:symbol id="zoneAnchorRight" viewBox="5 0 40 40" preserveAspectRatio="none" overflow="visible"> 
    32 <svg:path d="M10,30 a10,10 0 1,0 0,-20 v -10 h -5 v 40 h 5 v 10"/> 
    33 </svg:symbol> 
    34  
    35 <svg:image class="anchor" anonid="zoneCircleLeft" xbl:inherits="xlink:href=leftHandle" x="0" y="0" height="40" width="20" transform="translate(-20)"/> 
    36 <svg:image class="anchor" anonid="zoneCircleRight" xbl:inherits="xlink:href=rightHandle" x="1000" y="0" height="40" width="20" overflow="visible"/> 
    37  
    38 <svg:rect xbl:inherits="style=selstyle" x="70" width="925" anonid="zoneRect" y="2" height="36" stroke-width="2"/> 
    39 </svg:g> 
    40 <svg:svg anonid="cursor" x="0" y="0" width="10" height="40" viewBox="0 0 10 10" preserveAspectRatio="none"> 
    41 <svg:line x1="0" x2="0" y1="0" y2="10" fill="red" stroke-width="2"/> 
    42 </svg:svg> 
    43 </svg:g> 
    44 </content> 
    45 <implementation> 
    46 <method name="init"> 
    47 <parameter name="audioElt"/> 
    48 <body> 
    49 <![CDATA[ 
    50                                                 this._audioElt = audioElt; 
    51                                                  
    52                                                 while (this._modificationListeners.length) 
    53                                                         this._modificationListeners.pop(); 
    54                                         ]]> 
    55 </body> 
    56 </method> 
    57 <method name="drawGraph"> 
    58 <body> 
    59 <![CDATA[ 
     10        <binding id="subplayer" extends="svg:generic"> 
     11                <content> 
     12                        <svg:g xbl:inherits="transform"> 
     13 
     14                                <svg:g class="buttonplayer" anonid="button"> 
     15                                        <svg:rect anonid="" x="0" y="0" width="40" height="40" /> 
     16                                        <svg:polyline anonid="play" points="70,20 30,20 10,10 10,30 30,20" fill="#79bc5d" /> 
     17                                        <svg:rect anonid="stop" x="8" y="8" width="24" height="24" /> 
     18                                </svg:g> 
     19                                <svg:rect anonid="ext" x="70" y="0" width="1000" height="40" stroke-width="0" /> 
     20                                <svg:text anonid="text1" x="84" y="30" font-size="28" fill="#000" stroke-width="0" /> 
     21                                <svg:text anonid="text2" x="990" y="30" font-size="28" fill="#000" stroke-width="0" 
     22                                        text-anchor="end" /> 
     23                                <svg:audiograph x="70" y="0" height="40" width="925" anonid="audiograph" /> 
     24                                <svg:rect anonid="ground" x="70" y="0" width="925" height="40" fill-opacity="0" /> 
     25                                <svg:g class="subzone" style="visibility: hidden;"> 
     26 
     27                                        <svg:symbol id="zoneAnchorLeft" viewBox="15 0 40 40" preserveAspectRatio="none" 
     28                                                overflow="visible"> 
     29                                                <svg:path d="M10,30 a10,10 0 0,1 0,-20 v -10 h 5 v 40 h -5 v 10" /> 
     30                                        </svg:symbol> 
     31                                        <svg:symbol id="zoneAnchorRight" viewBox="5 0 40 40" preserveAspectRatio="none" 
     32                                                overflow="visible"> 
     33                                                <svg:path d="M10,30 a10,10 0 1,0 0,-20 v -10 h -5 v 40 h 5 v 10" /> 
     34                                        </svg:symbol> 
     35 
     36                                        <svg:image class="anchor" anonid="zoneCircleLeft" xbl:inherits="xlink:href=leftHandle" 
     37                                                x="0" y="0" height="40" width="20" transform="translate(-20)" /> 
     38                                        <svg:image class="anchor" anonid="zoneCircleRight" xbl:inherits="xlink:href=rightHandle" 
     39                                                x="1000" y="0" height="40" width="20" overflow="visible" /> 
     40 
     41                                        <svg:rect xbl:inherits="style=selstyle" x="70" width="925" anonid="zoneRect" y="2" 
     42                                                height="36" stroke-width="2" /> 
     43                                </svg:g> 
     44                                <svg:svg anonid="cursor" x="0" y="0" width="10" height="40" viewBox="0 0 10 10" 
     45                                        preserveAspectRatio="none"> 
     46                                        <svg:line x1="0" x2="0" y1="0" y2="10" fill="red" stroke-width="2" /> 
     47                                </svg:svg> 
     48                        </svg:g> 
     49                </content> 
     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[ 
    6062                                                var graph = document.getAnonymousElementByAttribute(this, "anonid", "audiograph"); 
    6163                                                if (this._audioElt.srcAudio) { 
     
    6466                                                        graph.hideGraph(); 
    6567                                                } 
    66                                         ]]> 
    67 </body> 
    68 </method> 
    69 <constructor> 
    70 <![CDATA[ 
     68                                ]]></body> 
     69                        </method> 
     70                        <constructor><![CDATA[ 
    7171                                //FIXME: init() 
    7272                                const FREE = 0; 
     
    199199                                this._ratio = coordTrans2.x - coordTrans1.x; 
    200200 
    201                                 ]]> 
    202 </constructor> 
    203  
    204 <method name="_notifyPlayListeners"> 
    205 <body> 
    206 <![CDATA[ 
     201                        ]]></constructor> 
     202 
     203                        <method name="_notifyPlayListeners"> 
     204                                <body><![CDATA[ 
    207205                                        var i; 
    208206                                        for (i = 0; i < this._modificationListeners.length; i++) { 
    209207                                                this._modificationListeners[i].onCheck(); 
    210208                                        } 
    211  
    212                                         ]]> 
    213 </body> 
    214 </method> 
    215  
    216 <method name="_notifyReleaseListeners"> 
    217 <body> 
    218 <![CDATA[ 
     209                                ]]></body> 
     210                        </method> 
     211 
     212                        <method name="_notifyReleaseListeners"> 
     213                                <body><![CDATA[ 
    219214                                        var i; 
    220215                                        for (i = 0; i < this._modificationListeners.length; i++) { 
    221216                                                this._modificationListeners[i].onRelease(this); 
    222217                                        } 
    223  
    224                                         ]]> 
    225 </body> 
    226 </method> 
    227  
    228 <method name="_notifyResizeListeners"> 
    229 <parameter name="x1"/> 
    230 <parameter name="x2"/> 
    231 <parameter name="handle"/> 
    232 <body> 
    233 <![CDATA[ 
     218                                ]]></body> 
     219                        </method> 
     220 
     221                        <method name="_notifyResizeListeners"> 
     222                                <parameter name="x1" /> 
     223                                <parameter name="x2" /> 
     224                                <parameter name="handle" /> 
     225                                <body><![CDATA[ 
    234226                                        var i; 
    235227                                        for (i = 0; i < this._modificationListeners.length; i++) { 
    236228                                                this._modificationListeners[i].onResize(this, x1, x2, handle); 
    237229                                        } 
    238  
    239                                         ]]> 
    240 </body> 
    241 </method> 
    242  
    243 <method name="setZone"> 
    244 <parameter name="t1"/> 
    245 <parameter name="t2"/> 
    246 <body> 
    247 <![CDATA[ 
     230                                ]]></body> 
     231                        </method> 
     232 
     233                        <method name="setZone"> 
     234                                <parameter name="t1" /> 
     235                                <parameter name="t2" /> 
     236                                <body><![CDATA[ 
    248237                                                if (t1 < this.t1) { 
    249238                                                        this.setT1(t1, true); 
     
    253242                                                        this.setT1(t1, true); 
    254243                                                } 
    255                                         ]]> 
    256 </body> 
    257 </method> 
    258  
    259 <method name="_resizeZone"> 
    260 <parameter name="handle"/> 
    261 <parameter name="value"/> 
    262 <parameter name="notify"/> 
    263 <body> 
    264 <![CDATA[ 
     244                                ]]></body> 
     245                        </method> 
     246 
     247                        <method name="_resizeZone"> 
     248                                <parameter name="handle" /> 
     249                                <parameter name="value" /> 
     250                                <parameter name="notify" /> 
     251                                <body><![CDATA[ 
    265252                                        var modif = false; 
    266253                                        var newValue = value; 
     
    285272                                                handle); 
    286273                                        return modif; 
    287                                         ]]> 
    288 </body> 
    289 </method> 
    290          
    291 <method name="_moveZone"> 
    292         <parameter name="value"/> 
    293         <parameter name="notify"/> 
    294         <body> 
    295                 <![CDATA[ 
    296                                 var newValue = value; 
    297                                 var min = this._ground.x.baseVal.value; 
    298                                 var max = min + this._ground.width.baseVal.value; 
    299                                 if (newValue < 0 && this._zone.c1.x.baseVal.value + newValue < min) { 
    300                                         newValue = min - this._zone.c1.x.baseVal.value; 
    301                                 } else if (newValue > 0 && this._zone.c2.x.baseVal.value + newValue > max) { 
    302                                         newValue = max - this._zone.c2.x.baseVal.value; 
    303                                 } 
    304                                 this._zone.rect.x.baseVal.value += newValue; 
    305                                 this._zone.c1.x.baseVal.value += newValue; 
    306                                 this._zone.c2.x.baseVal.value += newValue; 
    307                                 modif = (newValue != 0); 
    308                                 if (notify && modif) this._notifyResizeListeners( 
    309                                         1000 * (this._zone.c1.x.baseVal.value - this._ground.x.baseVal.value) / this._ground.width.baseVal.value, 
    310                                         1000 * (this._zone.c2.x.baseVal.value - this._ground.x.baseVal.value)  / this._ground.width.baseVal.value, 
    311                                         'middle'); 
    312                                 return modif; 
    313                                 ]]> 
    314         </body> 
    315 </method> 
    316  
    317                          
    318 <method name="addResizeListener"> 
    319 <parameter name="listener"/> 
    320 <body> 
    321 <![CDATA[ 
     274                                ]]></body> 
     275                        </method> 
     276 
     277                        <method name="_moveZone"> 
     278                                <parameter name="value" /> 
     279                                <parameter name="notify" /> 
     280                                <body><![CDATA[ 
     281                                        var newValue = value; 
     282                                        var min = this._ground.x.baseVal.value; 
     283                                        var max = min + this._ground.width.baseVal.value; 
     284                                        if (newValue < 0 && this._zone.c1.x.baseVal.value + newValue < min) { 
     285                                                newValue = min - this._zone.c1.x.baseVal.value; 
     286                                        } else if (newValue > 0 && this._zone.c2.x.baseVal.value + newValue > max) { 
     287                                                newValue = max - this._zone.c2.x.baseVal.value; 
     288                                        } 
     289                                        this._zone.rect.x.baseVal.value += newValue; 
     290                                        this._zone.c1.x.baseVal.value += newValue; 
     291                                        this._zone.c2.x.baseVal.value += newValue; 
     292                                        modif = (newValue != 0); 
     293                                        if (notify && modif) this._notifyResizeListeners( 
     294                                                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, 
     296                                                'middle'); 
     297                                        return modif; 
     298                                ]]></body> 
     299                        </method> 
     300 
     301 
     302                        <method name="addResizeListener"> 
     303                                <parameter name="listener" /> 
     304                                <body><![CDATA[ 
    322305                                        this._modificationListeners.push(listener); 
    323                                         ]]> 
    324 </body> 
    325 </method> 
    326  
    327 <method name="setText"> 
    328 <parameter name="where"/> 
    329 <parameter name="text"/> 
    330 <body> 
    331 <![CDATA[ 
     306                                ]]></body> 
     307                        </method> 
     308 
     309                        <method name="setText"> 
     310                                <parameter name="where" /> 
     311                                <parameter name="text" /> 
     312                                <body><![CDATA[ 
    332313                                        /* Hack pour contourner le bug de rendu de texte */ 
    333314                                        text = text ? text + ' ' : ''; 
     
    342323                                                this._text2.appendChild(node); 
    343324                                        } 
    344                                         ]]> 
    345 </body> 
    346 </method> 
    347 <method name="showZone"> 
    348 <parameter name="show"/> 
    349 <body> 
    350 <![CDATA[