Skip to content

Commit

Permalink
UI: b/track*.js: use properties for track mute/solo/volume
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Westerfeld <[email protected]>
  • Loading branch information
swesterfeld committed Nov 20, 2023
1 parent 8d08c35 commit d32b9fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ui/b/trackview.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const HTML = (t, d) => html`
>${t.wtrack_.name}</b-editable>
</span>
<span class="-mute-solo">
<b-toggle @valuechange=${event => t.track.mute (event.target.value)} label="M"></b-toggle>
<b-toggle @valuechange=${event => t.track.solo (event.target.value)} label="S"></b-toggle>
<b-toggle @valuechange=${event => t.track.set_value ("mute", event.target.value)} label="M"></b-toggle>
<b-toggle @valuechange=${event => t.track.set_value ("solo", event.target.value)} label="S"></b-toggle>
<b-trackvolume .track="${t.track}" @valuechange=${event => t.track.volume (event.target.value)}></b-trackvolume>
</span>
<div class="-lvm-main">
Expand Down
11 changes: 9 additions & 2 deletions ui/b/trackvolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BTrackVolume extends LitComponent {
this.percent = 0;
this.last_ = 0;
this.track = null;
this.prop = null;
}
updated (changed_props)
{
Expand All @@ -75,7 +76,12 @@ class BTrackVolume extends LitComponent {
}
async update_value()
{
this.value = await this.track.volume();
if (!this.prop)
{
let prop = await this.track.access_property ("volume");
this.prop = prop;
}
this.value = await this.prop.get_normalized();
this.percent = this.value * 100;
this.last_ = this.value;
}
Expand All @@ -86,9 +92,10 @@ class BTrackVolume extends LitComponent {
drag_change (distance)
{
this.last_ = Util.clamp (this.last_ + distance, 0, +1);
this.track.volume (this.last_);
this.value = this.last_;
this.percent = this.value * 100;
if (this.prop)
this.prop.set_normalized (this.value);
}
}
customElements.define ('b-trackvolume', BTrackVolume);
Expand Down

0 comments on commit d32b9fe

Please sign in to comment.