(api: alphaTab.AlphaTabApi, track: alphaTab.model.Track)
| 96 | onSelect: ((e: MouseEvent) => void) | null = null; |
| 97 | |
| 98 | constructor(api: alphaTab.AlphaTabApi, track: alphaTab.model.Track) { |
| 99 | this.track = track; |
| 100 | this.root = parseHtml(html` |
| 101 | <div class="at-track"> |
| 102 | <div class="at-track-icon"></div> |
| 103 | <span class="at-track-name">${track.name}</span> |
| 104 | <div class="at-track-controls"> |
| 105 | <div class="cmp-mute"></div> |
| 106 | <div class="cmp-solo"></div> |
| 107 | <span class="at-track-volume-icon"></span> |
| 108 | <div class="cmp-volume"></div> |
| 109 | </div> |
| 110 | </div> |
| 111 | `); |
| 112 | this.root.querySelector('.at-track-icon')!.appendChild(renderIcon(pickTrackIcon(track))); |
| 113 | this.root.querySelector('.at-track-volume-icon')!.appendChild(renderIcon(Icons.Volume)); |
| 114 | |
| 115 | this.muteBtn = mount( |
| 116 | this.root, |
| 117 | '.cmp-mute', |
| 118 | new ToggleButton({ icon: Icons.Track, label: 'Mute', tooltip: 'Mute track' }) |
| 119 | ); |
| 120 | // Replace the IconButton svg with simple text button by clearing the icon slot |
| 121 | const muteIconSlot = this.muteBtn.root.querySelector('.at-icon-btn-icon'); |
| 122 | if (muteIconSlot) { |
| 123 | muteIconSlot.remove(); |
| 124 | } |
| 125 | this.muteBtn.root.classList.remove('at-icon-btn'); |
| 126 | this.muteBtn.root.classList.add('at-track-mute'); |
| 127 | this.muteBtn.onChange = active => { |
| 128 | api.changeTrackMute([this.track], active); |
| 129 | }; |
| 130 | |
| 131 | this.soloBtn = mount( |
| 132 | this.root, |
| 133 | '.cmp-solo', |
| 134 | new ToggleButton({ icon: Icons.Track, label: 'Solo', tooltip: 'Solo track' }) |
| 135 | ); |
| 136 | const soloIconSlot = this.soloBtn.root.querySelector('.at-icon-btn-icon'); |
| 137 | if (soloIconSlot) { |
| 138 | soloIconSlot.remove(); |
| 139 | } |
| 140 | this.soloBtn.root.classList.remove('at-icon-btn'); |
| 141 | this.soloBtn.root.classList.add('at-track-solo'); |
| 142 | this.soloBtn.onChange = active => { |
| 143 | api.changeTrackSolo([this.track], active); |
| 144 | }; |
| 145 | |
| 146 | this.volume = mount( |
| 147 | this.root, |
| 148 | '.cmp-volume', |
| 149 | new Slider({ min: 0, max: 16, step: 1, initialValue: track.playbackInfo.volume }) |
| 150 | ); |
| 151 | this.volume.onInput = value => { |
| 152 | api.changeTrackVolume([this.track], value / Math.max(1, this.track.playbackInfo.volume)); |
| 153 | }; |
| 154 | |
| 155 | this.root.addEventListener('click', e => this.onSelect?.(e)); |
nothing calls this directly
no test coverage detected