jean-emmanuel / open-stage-control

Libre and modular OSC / MIDI controller
https://openstagecontrol.ammd.net
GNU General Public License v3.0
702 stars 88 forks source link

[Bug] Actions propagated to same name objects, 'clone' must do that exclusively #762

Closed groolot closed 2 years ago

groolot commented 2 years ago

The osc_demo.json file is master file and integrates the frag_instrument.json as fragment. Both of them have a knob called knob_1. Events seems to be propagated to each of them. A move on one actor the other.

The goal of clone should be this behavior.

The value transmission should'nt be done with an inheritance mechanism as described in https://openstagecontrol.ammd.net/docs/widgets/advanced-syntaxes/#javascript-js-code ?

Cheers my friend.

jean-emmanuel commented 2 years ago

Hello my friend,

Widgets with identical ids do sync indeed (as per this) and it's what you've witnessed here because fragments acts like clones unless the widgets in the fragment are manually scoped (for example, by post-fixing their id). It's very likely you'll want to override other properties in the fragment as well such as the knob's address. The common pattern for this in o-s-c it to define a set of arbitray variables in the fragment container's variables property and override them using the props property of the fragment widget:

osc_demo.json.txt frag_instrument.json.txt

Now the widgets in the panel all have an id that depends on one of the panel's variables, this allows us to create a scope for these widget (see how the knob's target is defined now). As an example I also set the knob's address to @{parent.variables.address} to show how we could create multiple variants of this fragment.

groolot commented 2 years ago

Ok, it's a bit confusing to have several ways to achieve the same result. Thus I will change the way I create patches. Thank's big boy!

jean-emmanuel commented 2 years ago

Yes it's not ideal, features have been added on top of each others over the years and some redundancies could be removed now but at the cost of breaking many existing sessions..