Updating Parameter Flags


I’m trying to change parameter flags based on a user action.
For example: if the user toggles “Visualize” on or off, I want a parameter to be read only or editable based on the state of Visualize (true or false).

I can set flags, but can’t find methods to remove them (in the Parameter object). Is there a simple way to accomplish this?
Currenlty in the activate function i do?:

	bool blend_edges = BlendEdges;

	// Try to blank out
	if (!blend_edges)

mm, this seems to work when closing the parameter dialog and opening it again.
How can I refresh (or force a rebuild) of the parameter dialog?

Hi there,

what you want is a Parameter Dependency, where certain parameters enabled state can depend upon the value of another. There’s alot more I’d like to do with making complex sets of parameters accessible, but here’s how to do it currently:

  1. Add dependencies in your device constructor after creating your parameters
  2. (OPTIONAL) Create callback function if you have complex dependency needs, or want to do more than just enable or disable the target parameter.
  3. (OPTIONAL) If running your own UI dialog box, you must call ProcessDependencies() on your device’s parameter set to recheck dependencies after a changed value. HOWEVER, the default generic dialog interface does this step for you so if you are using the built in system you are good to go.

More detail on step 1:

(defined in Parameter.h):


bool AddDependence(const char *target, const char *trigger, DEPENDS_TYPE type, VAL dependsval, DEPENDS_FUNC func = NULL);

Where the parameters are:

target: parameter name of the parameter that should be MODIFIED based on dependency
trigger: parameter name of the parameter that, when changed, TRIGGERS the dependency
type: VALUE_CHANGE if the dependency function should be called for any change of the trigger
VALUE_EQUAL if the target should be turned on when the trigger value = dependsval, and off otherwise
dependsval: value of trigger parameter that triggers dependency
func: the callback assigned to this dependency (optional!)

So, wrapping it up:

A simple “turn this on when this one is turned on” dependency would be expressed like:

// example from the Lightmap Generator deice code!
// enable the sun color parameter only when Produce RGB is true
params.AddDependence("Sun Color", "Produce RGB Lightmap", VALUE_EQUAL, VAL(true));

Or, here’s a more complex dependence, making sure a filename always has the correct extension when you change the format:

void dependsChangeExtension(Device *dev, DependsPair &dep) {
// do string stuff

// call the function provided whenever the file format changes
params.AddDependence("File Name", "File Format", VALUE_CHANGE, 0, dependsChangeExtension); 

That’s exactly what I needed to know!
In the long run, having access to more comlex parameter sets would be beneficial as well.

Thanks :smiley:

I implemented the AddDepence Method in the constructor after adding the parameters.
It seems to work, but only for the depending parameter slider and value.

The actual parameter name doesn’t change color (grey to black, black to grey)

Is this expected behaviour?

// Add parameter dependencies params.AddDependence("Edge Blend", "Blend Edges", VALUE_EQUAL, VAL(true)); params.AddDependence("Edge Power", "Blend Edges", VALUE_EQUAL, VAL(true)); params.AddDependence("Min Height","Map Incoming Values",VALUE_EQUAL,VAL(true)); params.AddDependence("Max Height","Map Incoming Values",VALUE_EQUAL,VAL(true));

good catch, this is ‘normal’ but errant behavior – it should be disabling everything including the label. This will be fixed in the next beta!