Inspector with attributes that depend on each other (like filtergraph~)

Dec 2, 2010 at 1:33pm

Inspector with attributes that depend on each other (like filtergraph~)

For a UI object I am working on, I need to have attributes that depend on each other. Much like filtergraph~, where changing the value for Active Filter(s) changes the number of items in the Currently Selected Filter popup, and changing the latter updates the Filter Type.

This presumably makes use of object notification. The documentation here leaves some questions open… is there any source code available on how to do this sort of thing? Sample code would be a big help.

Dec 2, 2010 at 2:52pm

filtergraph~ uses attributes with custom setters and gettrs to set and get the value of specific filter parameters depending on the state of other attributes. Changing active filters only changes the number of items in the enum values for the other edit_filter attribute. Is that what you need to achieve?

Dec 2, 2010 at 4:38pm

That, plus a behavior exactly like the relationship between Current Selection and Active Filter. When Current Selection is changed, the selected item in Active Filter is updated to reflect the change.

Is this all done with custom get/set methods?

Dec 2, 2010 at 6:05pm

To change the enum values you need to change the enumvals attribute of the attribute. That’s what we do in filtergraph~:

t_object *efattr = object_attr_get((t_object *)x, gensym("edit_filter"));

for (i = 0; i < x->x_nfilters; i++) {
sprintf(str," %ld",i);
object_attr_setparse(efattr, gensym("enumvals"), nums);

For the rest, it’s all done with the custom get/set methods. So when you change the current filter, you set the values of the edit_whatever attributes (using object_attr_setvalueof to notify the attributes so the inspector redraws, not by accessing directly to their values in the object structure). Hope this makes sense.

Dec 2, 2010 at 7:05pm

Sure, doing this with getters/setters makes sense enough, and seems more straight-forward that what I was originally thinking. Off to try to get this working.

Je t’remercie pour l’aide.


You must be logged in to reply to this topic.