|
@@ -12,9 +12,10 @@ module values structure are in sync. If out of sync, you may either rebuild valu
|
|
|
from sequence or rebuild sequence from values
|
|
|
|
|
|
*/
|
|
|
-var syncRatems = 10;
|
|
|
+var syncRatems = 100;
|
|
|
var syncDelta = 0.;
|
|
|
var doSync = false ;
|
|
|
+var inibValuesChanged = false ;
|
|
|
|
|
|
var debug = true;
|
|
|
var debugFile;
|
|
@@ -31,8 +32,8 @@ var newGroupLayers = local.values.newGroup.layers ;
|
|
|
var groups = local.values.groups ;
|
|
|
var cues = local.getChild("values").keys.cues ;
|
|
|
// var cuesList = []; //holds cues containers reference
|
|
|
-var layers = local.values.keys.layers ;
|
|
|
-var layerList = {}; //holds layer container as object with reference and an array of keys containers references
|
|
|
+var layers = local.getChild("values").keys.layers ;
|
|
|
+// var layerList = {}; //holds layer container as object with reference and an array of keys containers references
|
|
|
|
|
|
|
|
|
|
|
@@ -65,7 +66,8 @@ function init() {
|
|
|
updateSyncRate();
|
|
|
updateSynchronize();
|
|
|
|
|
|
-
|
|
|
+ // layers = local.getChild("values").keys.layers ;
|
|
|
+ // printMethodsAndProperties(layers);
|
|
|
|
|
|
//test if a sequence is already choosen else refresh and unlock sequence enum
|
|
|
sequence = sequencePath.getKey();
|
|
@@ -245,38 +247,31 @@ a nogroup container shows keys that are not grouped
|
|
|
|
|
|
// Value callback
|
|
|
function moduleValueChanged(value){
|
|
|
- if (value.name == "addGroup"){createNewGroup(sequence_structure.params.sequence);}
|
|
|
-}
|
|
|
-
|
|
|
-//rebuild container references lists reading values structure
|
|
|
-function struct_syncList(){
|
|
|
+ if(!inibValuesChanged){
|
|
|
+ doSync = false;
|
|
|
|
|
|
+ script.log(value.getParent().name);
|
|
|
|
|
|
+ doSync = true;
|
|
|
+
|
|
|
+ }
|
|
|
+ // script.log(value.getParent().name);
|
|
|
+ // if(value.getParent().name = "cue"){script.log("changed");}
|
|
|
+ if (value.name == "addGroup"){createNewGroup(sequence_structure.params.sequence);}
|
|
|
}
|
|
|
|
|
|
-//check if sequence and structure lists are in sync (same cues, layers, and keys)
|
|
|
-function struct_checkSeqSync(){
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
//rebuild values.keys structure from sequence
|
|
|
|
|
|
function struct_buildValuesFromSeq(){
|
|
|
|
|
|
+ inibValuesChanged = true;
|
|
|
+
|
|
|
var tl_seq = root.sequences.getItemWithName(sequence);
|
|
|
|
|
|
- var tl_cues = tl_seq.cues.getItems();
|
|
|
- var tl_layers = tl_seq.layers.getItems();
|
|
|
|
|
|
- //clear and rebuild containers
|
|
|
- // local.values.removeContainer("keys");
|
|
|
- // keys = local.values.addContainer("keys");
|
|
|
- // cues = keys.addContainer("Cues");
|
|
|
- // layers = keys.addContainer("layers");
|
|
|
-
|
|
|
-
|
|
|
- //build cues
|
|
|
+ //build cues if needed
|
|
|
+ var tl_cues = tl_seq.cues.getItems();
|
|
|
cues = local.getChild("values").keys.cues ;
|
|
|
var cuesList = util.getObjectProperties(cues, true, false);
|
|
|
// script.log("cueList : " +cuesList.length);
|
|
@@ -303,7 +298,7 @@ function struct_buildValuesFromSeq(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //update values
|
|
|
+ //update cues
|
|
|
cues = local.getChild("values").keys.cues ;
|
|
|
var cuesList = util.getObjectProperties(cues, true, false);
|
|
|
if(tl_cues.length){
|
|
@@ -313,11 +308,100 @@ function struct_buildValuesFromSeq(){
|
|
|
currentCue.time.set(tl_cues[i].time.get());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
+ //build layers if needed
|
|
|
+ var layersChanged = false ;
|
|
|
+ var tl_layers = tl_seq.layers.getItems();
|
|
|
+ layers = local.getChild("values").keys.layers ;
|
|
|
+ var layersList = util.getObjectProperties(layers, true, false);
|
|
|
+ if (layersList.length != tl_layers.length){
|
|
|
+ layersChanged = true ;
|
|
|
+ var delta = layersList.length-tl_layers.length;
|
|
|
+ var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
|
|
|
+ delta = Math.abs(delta);
|
|
|
+ script.log("change "+ delta + (addRemove ? " up" : " down"));
|
|
|
+ for(var i=0; i<delta; i++){
|
|
|
+ // script.log(i);
|
|
|
+ if(addRemove){
|
|
|
+ var newLayer = layers.addContainer("newLayer"+i);
|
|
|
+ // newLayer.addFloatParameter("time", "position in time", 0., 0.);
|
|
|
+ newLayer.setCollapsed(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ script.log(util.getObjectProperties(layers, true, false)[0]);
|
|
|
+ layers.removeContainer(util.getObjectProperties(layers, true, false)[0]);
|
|
|
+ }
|
|
|
+ // cuesList = ;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //update layers value if there was a change in structure
|
|
|
+ if(layersChanged){
|
|
|
+ layers = local.getChild("values").keys.layers ;
|
|
|
+ var layerList = util.getObjectProperties(layers, true, false);
|
|
|
+ if(tl_layers.length){
|
|
|
+ for (var i=0; i<tl_layers.length; i++){
|
|
|
+ var currentLayer = layers.getChild(layerList[i]);
|
|
|
+ currentLayer.setName(tl_layers[i].name);
|
|
|
+
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //build keys if needed
|
|
|
+ layers = local.getChild("values").keys.layers ;
|
|
|
+ layersList = util.getObjectProperties(layers, true, false);
|
|
|
|
|
|
- //build layers
|
|
|
+ if(layersList.length){
|
|
|
+ for(var layerIndex=0; layerIndex<layersList.length; layerIndex++){
|
|
|
+
|
|
|
+ var currentLayer = layers.getChild(layersList[layerIndex]);
|
|
|
+ var keyList = util.getObjectProperties(currentLayer, true, false);
|
|
|
+
|
|
|
+ var tl_lay = tl_seq.layers.getItemWithName(layersList[layerIndex]);
|
|
|
+ var tl_keys = tl_lay.automation.getItems();
|
|
|
+ //rebuild key structure for currentLayer
|
|
|
+ if (keyList.length != tl_keys.length){
|
|
|
+ var delta = keyList.length-tl_keys.length;
|
|
|
+ var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
|
|
|
+ delta = Math.abs(delta);
|
|
|
+ script.log("change "+ delta + (addRemove ? " up" : " down"));
|
|
|
+ for(var i=0; i<delta; i++){
|
|
|
+
|
|
|
+ // script.log(i);
|
|
|
+ if(addRemove){
|
|
|
+ var newKey = currentLayer.addContainer("newkey"+i);
|
|
|
+ newKey.addFloatParameter("time", "position in time", 0., 0.);
|
|
|
+ newKey.addFloatParameter("value", "vertical value", 0., 0.);
|
|
|
+ newKey.setCollapsed(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ script.log(util.getObjectProperties(currentLayer, true, false)[0]);
|
|
|
+ currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ currentLayer = layers.getChild(layersList[layerIndex]);
|
|
|
+ keyList = util.getObjectProperties(currentLayer, true, false);
|
|
|
+ //update values for currentLayer
|
|
|
+ if(tl_keys.length){
|
|
|
+ for(var i=0; i<tl_keys.length; i++){
|
|
|
+ var currentKey = currentLayer.getChild(keyList[i]);
|
|
|
+ currentKey.setName(tl_keys[i].name);
|
|
|
+ currentKey.time.set(tl_keys[i].position.get());
|
|
|
+ currentKey.value.set(tl_keys[i].value.get());
|
|
|
|
|
|
- //build keys in layers
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ inibValuesChanged = false;
|
|
|
|
|
|
}
|
|
|
|