changeset 2261:a460ce76b301

almost rm
author drewp@bigasterisk.com
date Mon, 29 May 2023 11:45:06 -0700
parents 4b04bf5c4a85
children cab292b3ad38
files light9/live/GraphToControls.ts
diffstat 1 files changed, 83 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/light9/live/GraphToControls.ts	Mon May 29 11:44:54 2023 -0700
+++ b/light9/live/GraphToControls.ts	Mon May 29 11:45:06 2023 -0700
@@ -1,96 +1,96 @@
-import debug from "debug";
-import { NamedNode } from "n3";
-import { SyncedGraph } from "../web/SyncedGraph";
-import { ControlValue, Effect } from "./Effect";
-const log = debug("g2c");
+// import debug from "debug";
+// import { NamedNode } from "n3";
+// import { SyncedGraph } from "../web/SyncedGraph";
+// import { ControlValue, Effect } from "./Effect";
+// const log = debug("g2c");
 
-// Callback for GraphToControls to set a ControlValue on a
-// Light9LiveControl (widget for a Device+Attr)
-type NewValueCb = (newValue: ControlValue | null) => void;
+// // Callback for GraphToControls to set a ControlValue on a
+// // Light9LiveControl (widget for a Device+Attr)
+// type NewValueCb = (newValue: ControlValue | null) => void;
 
-// More efficient bridge between liveControl widgets and graph edits (inside Effect),
-// as opposed to letting each widget scan the graph and push lots of
-// tiny patches to it.
-//
-// When you create a Light9LiveControl, it registers with GraphToControls (and does not
-// watch value updates from the graph).
-export class GraphToControls {
-  // rename to PageControls?
-  private effect: Effect | null = null; // this uri should sync to the editchoice
+// // More efficient bridge between liveControl widgets and graph edits (inside Effect),
+// // as opposed to letting each widget scan the graph and push lots of
+// // tiny patches to it.
+// //
+// // When you create a Light9LiveControl, it registers with GraphToControls (and does not
+// // watch value updates from the graph).
+// export class GraphToControls {
+//   // rename to PageControls?
+//   private effect: Effect | null = null; // this uri should sync to the editchoice
 
-  // This will fill with every device+attr in the show. Currently there's no unregister to forget a device or attr.
-  private registeredWidgets: Map<
-    NamedNode /*Device*/,
-    Map<
-      NamedNode /*DeviceAttr*/, //
-      NewValueCb
-    >
-  > = new Map();
-  constructor(public graph: SyncedGraph) {
+//   // This will fill with every device+attr in the show. Currently there's no unregister to forget a device or attr.
+//   private registeredWidgets: Map<
+//     NamedNode /*Device*/,
+//     Map<
+//       NamedNode /*DeviceAttr*/, //
+//       NewValueCb
+//     >
+//   > = new Map();
+//   constructor(public graph: SyncedGraph) {
     
-  }
+//   }
 
-  debugDump() {
-    log("dump: effect", this.effect);
-    log("registered widgets");
-    for (let e of this.registeredWidgets.entries()) {
-      log(" rw:", e[0], e[1]);
-    }
-  }
+//   debugDump() {
+//     log("dump: effect", this.effect);
+//     log("registered widgets");
+//     for (let e of this.registeredWidgets.entries()) {
+//       log(" rw:", e[0], e[1]);
+//     }
+//   }
 
-  setEffect(effect: NamedNode | null) {
-    log(`setEffect ${effect?.value}`);
-    this.effect = effect ? new Effect(this.graph, effect, this.onValuesChanged.bind(this)) : null;
-  }
+//   setEffect(effect: NamedNode | null) {
+//     log(`setEffect ${effect?.value}`);
+//     this.effect = effect ? new Effect(this.graph, effect, this.onValuesChanged.bind(this)) : null;
+//   }
 
-  newEffect(): NamedNode {
-    // wrong- this should be our editor's scratch effect, promoted to a
-    // real one when you name it.
-    const uri = this.graph.nextNumberedResource(this.graph.Uri("http://light9.bigasterisk.com/effect/effect"));
+//   newEffect(): NamedNode {
+//     // wrong- this should be our editor's scratch effect, promoted to a
+//     // real one when you name it.
+//     const uri = this.graph.nextNumberedResource(this.graph.Uri("http://light9.bigasterisk.com/effect/effect"));
 
-    this.effect = new Effect(this.graph, uri, this.onValuesChanged.bind(this));
-    log("add new eff");
-    this.effect.addNewEffectToGraph();
-    return this.effect.uri;
-  }
+//     this.effect = new Effect(this.graph, uri, this.onValuesChanged.bind(this));
+//     log("add new eff");
+//     this.effect.addNewEffectToGraph();
+//     return this.effect.uri;
+//   }
 
-  emptyEffect() {
-    throw new Error("not implemented");
-  }
+//   emptyEffect() {
+//     throw new Error("not implemented");
+//   }
 
-  private onValuesChanged() {
-    log(`i learned values changed for ${this.effect?.uri.value} `);
-    this.registeredWidgets.forEach((d1: Map<NamedNode, NewValueCb>, device: NamedNode) => {
-      d1.forEach((cb: NewValueCb, deviceAttr: NamedNode) => {
-        const v = this.effect ? this.effect.currentValue(device, deviceAttr) : null;
-        cb(v);
-      });
-    });
-  }
+//   private onValuesChanged() {
+//     log(`i learned values changed for ${this.effect?.uri.value} `);
+//     this.registeredWidgets.forEach((d1: Map<NamedNode, NewValueCb>, device: NamedNode) => {
+//       d1.forEach((cb: NewValueCb, deviceAttr: NamedNode) => {
+//         const v = this.effect ? this.effect.currentValue(device, deviceAttr) : null;
+//         cb(v);
+//       });
+//     });
+//   }
 
-  register(device: NamedNode, deviceAttr: NamedNode, graphValueChanged: NewValueCb) {
-    // log(`control for ${device.value}-${deviceAttr.value} registring with g2c`);
-    let d1 = this.registeredWidgets.get(device);
-    if (!d1) {
-      d1 = new Map();
-      this.registeredWidgets.set(device, d1);
-    }
-    d1.set(deviceAttr, graphValueChanged);
+//   register(device: NamedNode, deviceAttr: NamedNode, graphValueChanged: NewValueCb) {
+//     // log(`control for ${device.value}-${deviceAttr.value} registring with g2c`);
+//     let d1 = this.registeredWidgets.get(device);
+//     if (!d1) {
+//       d1 = new Map();
+//       this.registeredWidgets.set(device, d1);
+//     }
+//     d1.set(deviceAttr, graphValueChanged);
 
-    if (this.effect) {
-      const nv = this.effect.currentValue(device, deviceAttr);
-      // log(`i have a a cb for ${device.value}-${deviceAttr.value}; start value is ${nv}`);
-      graphValueChanged(nv);
-    }
-  }
+//     if (this.effect) {
+//       const nv = this.effect.currentValue(device, deviceAttr);
+//       // log(`i have a a cb for ${device.value}-${deviceAttr.value}; start value is ${nv}`);
+//       graphValueChanged(nv);
+//     }
+//   }
 
-  controlChanged(device: NamedNode, deviceAttr: NamedNode, value: ControlValue) {
-    // todo: controls should be disabled if there's no effect and they won't do anything.
-    if (!this.effect) {
-      log("controlChanged, no effect");
-      return;
-    }
-    const p = this.effect.edit(device, deviceAttr, value);
-    this.graph.applyAndSendPatch(p);
-  }
-}
+//   controlChanged(device: NamedNode, deviceAttr: NamedNode, value: ControlValue) {
+//     // todo: controls should be disabled if there's no effect and they won't do anything.
+//     if (!this.effect) {
+//       log("controlChanged, no effect");
+//       return;
+//     }
+//     const p = this.effect.edit(device, deviceAttr, value);
+//     this.graph.applyAndSendPatch(p);
+//   }
+// }