-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Bugfix ofParameter change name #6614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Bugfix ofParameter change name #6614
Conversation
…terGroup] listen to nameChange event and update parametersIndex.
…n. ofParameterGroup: event for child name change. Cleanup
…ui updates accordingly.
ofParameter name change improvements
Changing to a name that already exists in some parent is not allowed, setName returns false, and name is not changed.
I found an issue with what we had. openFrameworks/libs/openFrameworks/types/ofParameterGroup.cpp Lines 15 to 17 in 51bcbf3
Maybe that is something that should be done outside this? First checking by yourself if the name exists in all of it's parents? I think that, as the error you create is irreversible, this should not be allowed, and notified accordingly. |
Thanks @eduardfrigola for bringing this issue back. |
As we only use the name for identifying parameters inside the group, if we want unique names, either only unique names are allowed, or ofParameterGroup adds something to the name of the parameter (modifying the original parameter) to be unique. Maybe this is something we need to discuss with @arturoc who created ofParameterGroup... |
…change_name # Conflicts: # libs/openFrameworks/types/ofParameter.cpp # libs/openFrameworks/types/ofParameter.h
this is a design problem as for many use cases, a group may hold multiple parameters with the same name... but in the context of so the design needs adjustment. if an accessor approach was used with
unfortunately, the |
Hi @artificiel, thanks for taking a look at this. As also stated in the issue @6576 I initially wanted to fix the issue from another approach #6577 (fixing the same as this PR) changing the way ofParameterGroup access it's elements, but we had a performance loss and was not an option. Just for a note, I have been using this PR in my fork and it has not caused me any issues. Let's see which way we can address this. Eduard |
@eduardfrigola ah sorry if i'm a bit off-topic; to be clear i think this PR's name change propagation idea is great. (i ended up here while checking your branch's commits because it's unfortunate that an actively developed addon like ofxOceanode requires OF 11.2). so i was reacting/expanding to your mention of:
which (vector for param and map for names) is a design problem for plain usage too, and unique name enforcement should be wider that just on checking changes, as it does not make much sense to have multiple params with the same name in a group if the name is to be relied upon. implying the uniqueness of names with an accessor interface like but that does not change your PR's core solution of what happens if someone changes the param's name later. i haven't run this PR (it unfortunately no longer auto merges) but i presume the usage expected to be: ofParameter<float> f1 {"f1",1}, f2 {"f2",2};
ofParameterGroup group {"group", g, f};
if (!f1.setName("f2")) {
// name change rejected because of a sibling in group
// f1 is still named f1
} else {
// f1 now named f2
} i guess where i'm going is that maybe ofParameterGroup should have an ofParameter<float> f2 {1}, g2 {2};
ofParameterGroup group2 {"group2", g2, f2}; which is a perfectly fine use (obviously not meant for ofxGui nor to retrieve with a name) but still generates so yeah, not strictly on topic with this PR in terms of "code review" but related in how names should be handled and presented to the user. |
Hi @artificiel Your idea of having an One other thing that might be a fix is to initialise Storing parameters as references could make the issue about names disappear (with If you want to test this proposed solution, you can checkout playmodesstudio/openframeworks:master, which has been been recently merged with the latest changes in master. There are changes in the unit test for ofParameter that check for changing the name after putting into the group. And the behaviour is exactly what you presumed. Eduard |
As discussed in #6576 and PlaymodesStudio#1 this PR fixes the issue when a parameter changed it's name.
It adds an event dispatched by ofParameter when the name is changed to its parents, which can also be captured externally.
Also adds implementations for ofxGui capturing those events and updating the gui accordingly.
cc @roymacdonald