From 89c89dbfce70b3403474cf00a79405d5ae075038 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 27 Feb 2017 22:12:21 +0100 Subject: [PATCH] remote-control: rename that api --- CHANGELOG.md | 3 ++- .../{remote-editing.md => remote-control.md} | 18 ++++++------- src/browser/js/app/actions.js | 5 ---- src/browser/js/app/osc.js | 7 +++-- .../app/{remote-exec.js => remote-control.js} | 27 ++++++++++++++----- 5 files changed, 34 insertions(+), 26 deletions(-) rename resources/docs/user-guide/{remote-editing.md => remote-control.md} (59%) rename src/browser/js/app/{remote-exec.js => remote-control.js} (62%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c612b0f..53797a4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,10 @@ ## next - main - - **new** `midi` support + - **new** `midi` support ([http://osc.ammd.net/user-guide/midi/](documentation)) - ui - **new** `/TABS id1 id2 etc` osc address to remotely enable tabs + - remote editing through `/EXEC` command is now deprecated, use `/EDIT` and `/EDIT_SOFT` instead - bug fixes - `push` widgets (and `keyboards`) not correctly synchronizing each other (with shared widget ids or between different clients) - widgets diff --git a/resources/docs/user-guide/remote-editing.md b/resources/docs/user-guide/remote-control.md similarity index 59% rename from resources/docs/user-guide/remote-editing.md rename to resources/docs/user-guide/remote-control.md index f3b3c174..d2144e69 100644 --- a/resources/docs/user-guide/remote-editing.md +++ b/resources/docs/user-guide/remote-control.md @@ -1,14 +1,9 @@ -# Remote editing +# Remote control -The interface can be remotely edited by sending the appropriate osc messages (from an external source with `-o` / `--osc-port` set, or via `custom-module` scripting). +All widgets that send osc messages respond to the same messages. Additionnaly, Open Stage Control responds to some general osc commands. -``` -/EXEC COMMAND ARGS -``` -## Supported commands - -#### `edit` : `/EXEC edit id options` +## `/EDIT id options` Apply a set of options to an existing widget by replacing the old ones with the new ones. @@ -20,8 +15,7 @@ Apply a set of options to an existing widget by replacing the old ones with the *Editing a widget can be cpu expensive, hence updating the UI continuously is not a good idea.* -#### `edit_soft` : `/EXEC edit_soft id options` - +## `/EDIT_SOFT id options` Apply a set of options to an existing widget by merging them to the widget's options. @@ -31,3 +25,7 @@ Apply a set of options to an existing widget by merging them to the widget's opt - example: `{"label":"New Label", "color":"red"}` *Editing a widget can be cpu expensive, hence updating the UI continuously is not a good idea.* + +## `/TABS id id etc` + +Open the tabs designated by the `id` parameters. The target tab link must be accesible (opening a tab located in a disabled tab won't work unless you specify the parent tab's `id` before; the safest way to go is to pass the whole tab tree to enable). diff --git a/src/browser/js/app/actions.js b/src/browser/js/app/actions.js index d387b099..1eb56e43 100644 --- a/src/browser/js/app/actions.js +++ b/src/browser/js/app/actions.js @@ -158,11 +158,6 @@ module.exports = { $('#grid-width-input').remove() EDITING = false }, - tabsEnable: function(tabs){ - for (i in tabs) { - $(`[data-id="${tabs[i]}"]`).trigger('fake-click') - } - }, traversingDisable: function(){ $('.traversingEnable, .traversingDisable').toggleClass('on') $('#container').trigger('disableTraversingGestures') diff --git a/src/browser/js/app/osc.js b/src/browser/js/app/osc.js index b18535c8..de2ee125 100644 --- a/src/browser/js/app/osc.js +++ b/src/browser/js/app/osc.js @@ -5,12 +5,12 @@ var {widgetManager} = require('./managers'), var Osc = function(){ this.syncOnly = false - this.remoteExec = ()=>{console.error('remote-exec module not loaded')} + this.remoteControl = ()=>{console.error('remote-control module not loaded')} } Osc.prototype.init = function(data) { - this.remoteExec = require('./remote-exec') + this.remoteControl = require('./remote-control') } Osc.prototype.send = function(data) { @@ -29,8 +29,7 @@ Osc.prototype.send = function(data) { Osc.prototype.receive = function(data){ - if (data.address == '/EXEC') return this.remoteExec(data.args) - if (data.address == '/TABS') return actions.tabsEnable(data.args) + if (this.remoteControl.exists(data.address)) return this.remoteControl.exec(data.address, data.args) // fetch ids corresponding to the osc address var address = data.address, diff --git a/src/browser/js/app/remote-exec.js b/src/browser/js/app/remote-control.js similarity index 62% rename from src/browser/js/app/remote-exec.js rename to src/browser/js/app/remote-control.js index 3d73f62f..bbe61f26 100644 --- a/src/browser/js/app/remote-exec.js +++ b/src/browser/js/app/remote-control.js @@ -2,7 +2,13 @@ var {getObjectData, updateDom} = require('./editor/data-workers'), {widgetManager} = require('./managers') var callbacks = { - edit: function(args) { + '/EXEC': function(args) { + // backward-compatibility + var [name, ...args] = args + if (name == 'edit') return callbacks['/EDIT'](args) + if (name == 'edit_soft') return callbacks['/EDIT_SOFT'](args) + }, + '/EDIT': function(args) { var [id, json] = args, newdata = JSON.parse(json), containers = widgetManager.getWidgetById(id) @@ -18,7 +24,7 @@ var callbacks = { updateDom(container,data,true) } }, - edit_soft: function(args) { + '/EDIT_SOFT': function(args) { var [id, json] = args, newdata = JSON.parse(json), containers = widgetManager.getWidgetById(id) @@ -31,12 +37,21 @@ var callbacks = { $.extend(true,data,newdata) updateDom(container,data,true) } + }, + '/TABS': function(args) { + for (i in args) { + $(`[data-id="${args[i]}"]`).trigger('fake-click') + } } } -module.exports = function(args){ - var [name, ...args] = args - if (callbacks[name]) { - callbacks[name](args) +module.exports = { + exec: function(name, args){ + if (callbacks[name]) { + callbacks[name](args) + } + }, + exists: function(name){ + return name in callbacks } }