watch(node.params, () => {
this.update_params(node);
});
watch(node.buttons, () => {
this.trigger_button(node);
});
}
remove_node(node) {
this.send_message('remove_node',
{'name':node.name})
}
add_edge(edge) {
this.send_message('add_edge',
{'name': edge.name,
'src':edge.src.name,
'output': edge.output,
'dest' : edge.dest.name,
'input': edge.input});
this.update_params(edge.dest);
}
remove_edge(edge) {
this.send_message('remove_edge',
{'src':edge.src.name,
'output': edge.output,
'dest' : edge.dest.name,
'input': edge.input});
this.update_params(edge.dest);
}
trigger_button(node) {
let triggered = [];
for (let button of this.graph.defs.buttons(node.type)) {
if (node.buttons[button.callback]) {
triggered.push(button.callback);
WatchJS.noMore = true;
node.buttons[button.callback] = false;
WatchJS.noMore = false;
}
}
if (triggered.length == 0) { return }
else if (triggered.length > 1) {
console.log('Warning: Multiple buttons triggered simultaneously.')
}
else {
this.send_message('trigger_button',
{'name': node.name,
'button': triggered[0] })
}
}
update_params(node) {
this.send_message('update_params',
{'name' : node.name,
'params' : node.params })
}
unwatch_params(node) {
}
}