Changeset - 83135b0c8bba
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-06-03 21:51:06
drewp@bigasterisk.com
sort faders in a page by column
1 file changed with 10 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light9/fade/Light9FadeUi.ts
Show inline comments
 
import debug from "debug";
 
import { css, html, LitElement, TemplateResult } from "lit";
 
import { customElement, property } from "lit/decorators.js";
 
import * as N3 from "n3";
 
import { NamedNode, Quad } from "n3";
 
import { Patch } from "../web/patch";
 
import { getTopGraph } from "../web/RdfdbSyncedGraph";
 
import { showRoot } from "../web/show_specific";
 
import { SyncedGraph } from "../web/SyncedGraph";
 
export { EditChoice } from "../web/EditChoice";
 
export { Light9EffectFader } from "./Light9EffectFader";
 

	
 
debug.enable("*,autodep");
 
debug.enable("*,-autodep");
 
const log = debug("fade");
 

	
 
class FaderConfig {
 
constructor(public uri: NamedNode,public column: number){}
 
}
 

	
 
class FadePage {
 
  constructor(public uri: NamedNode) {}
 
  faders: NamedNode[] = [];
 
  faders: FaderConfig[] = [];
 
}
 
class FadePages {
 
  pages: FadePage[] = [];
 
}
 

	
 
@customElement("light9-fade-ui")
 
export class Light9FadeUi extends LitElement {
 
  static styles = [
 
    css`
 
      :host {
 
        display: block;
 
        user-select: none; /* really this is only desirable during slider drag events */
 
@@ -47,25 +51,25 @@ export class Light9FadeUi extends LitEle
 
  }
 
  private renderPage(page: FadePage): TemplateResult {
 
    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>
 
          ${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> `)}
 
        ${page.faders.map((fd) => html` <light9-effect-fader .uri=${fd.uri}></light9-effect-fader> `)}
 
      </fieldset>
 
    </div>`;
 
  }
 

	
 
  graph!: SyncedGraph;
 
  ctx: NamedNode = new NamedNode(showRoot + "/fade");
 

	
 
  @property() fadePages?: FadePages;
 
  @property() currentHwPage?: NamedNode;
 

	
 
  constructor() {
 
    super();
 
@@ -77,29 +81,29 @@ export class Light9FadeUi extends LitEle
 
  connectedCallback(): void {
 
    super.connectedCallback();
 
  }
 

	
 
  compile() {
 
    const U = this.graph.U();
 
    this.fadePages = undefined;
 
    const fadePages = new FadePages();
 
    for (let page of this.graph.subjects(U("rdf:type"), U(":FadePage"))) {
 
      const fp = new FadePage(page as NamedNode);
 
      try {
 
        for (let fader of this.graph.objects(page, U(":fader"))) {
 
          fp.faders.push(fader as NamedNode);
 
          const colLit = this.graph.stringValue(fader, U(':column'))
 
          fp.faders.push(new FaderConfig(fader as NamedNode, parseFloat(colLit)));
 
        }
 
        fp.faders.sort((a, b) => {
 
          // todo this is supposed to sort by :column so you can reorder
 
          return a.value.localeCompare(b.value);
 
          return a.column-(b.column);
 
        });
 
        fadePages.pages.push(fp);
 
      } catch (e) {}
 
    }
 
    fadePages.pages.sort((a, b) => {
 
      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"));
0 comments (0 inline, 0 general)