Mercurial > code > home > repos > light9
changeset 2342:81d5b6d97ed3
UI for picking the midi controlled page of faders
author | drewp@bigasterisk.com |
---|---|
date | Sat, 03 Jun 2023 12:09:09 -0700 |
parents | 4f610ef6768d |
children | af38643cffd4 |
files | light9/fade/Light9FadeUi.ts |
diffstat | 1 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/fade/Light9FadeUi.ts Fri Jun 02 18:27:03 2023 -0700 +++ b/light9/fade/Light9FadeUi.ts Sat Jun 03 12:09:09 2023 -0700 @@ -29,6 +29,9 @@ display: block; user-select: none; /* really this is only desirable during slider drag events */ } + .mappedToHw { + background: #393945; + } `, ]; render() { @@ -37,15 +40,22 @@ <h1>Fade</h1> - ${(this.fadePages?.pages || []).map(this.renderPage)} + ${(this.fadePages?.pages || []).map(this.renderPage.bind(this))} <div><button @click=${this.addPage}>Add new page</button></div> `; } private renderPage(page: FadePage): TemplateResult { - return html`<div> + const mappedToHw = this.currentHwPage !== undefined && page.uri.equals(this.currentHwPage); + return html`<div class="${mappedToHw ? "mappedToHw" : ""}"> <fieldset> - <legend>Page <resource-display rename .uri=${page.uri}></resource-display></legend> + <legend> + Page + <resource-display rename .uri=${page.uri}></resource-display> + ${mappedToHw ? html`mapped to hardware sliders` : html` + <button @click=${(ev: Event) => this.mapThisToHw(page.uri)}>Map this to hw</button> + `} + </legend> ${page.faders.map((fd) => html` <light9-effect-fader .uri=${fd}></light9-effect-fader> `)} </fieldset> </div>`; @@ -55,6 +65,7 @@ ctx: NamedNode = new NamedNode(showRoot + "/fade"); @property() fadePages?: FadePages; + @property() currentHwPage?: NamedNode; constructor() { super(); @@ -88,6 +99,18 @@ return a.uri.value.localeCompare(b.uri.value); }); this.fadePages = fadePages; + this.currentHwPage = undefined; + try { + const mc = this.graph.uriValue(U(":midiControl"), U(":map")); + this.currentHwPage = this.graph.uriValue(mc, U(":outputs")); + } catch (e) {} + } + + mapThisToHw(page: NamedNode) { + const U = this.graph.U(); + log("map to hw", page); + const mc = this.graph.uriValue(U(":midiControl"), U(":map")); + this.graph.patchObject(mc, U(":outputs"), page, this.ctx); } addPage() {