[Bf-committers] RNA template filtering (proposal)
ideasman42 at gmail.com
Sat Jul 31 09:22:14 CEST 2010
Recently I looked into filtering the lists for the lattice modifier to
only show lattice objects, curve bevel to only show curves, scene
camera only show cameras, armature modifier only show armature objects
etc (there are a few more like this).
... and found that currently the filter works by having an RNA
function which is called to check if the value should be displayed.
This is the python equivalent of...
for obj in bpy.data.objects:
if obj.is_lattice(context): # <-- doesn't exist but would need to,
to make use of current filtering.
...add to list...
The thing I don't like about this is you need to add rna functions
even for simple type checking. it would get worse if you wanted to do
checks like... obj.is_in_scene_and_local(context)
Basically I don't think this extends very well at all to different
situations and we need to add functions directly in the object api
which only exist for filtering.
Currently this is only used for brushes but we should probably use in
many other places as mentioned above.
Id suggest we change this to have an optional pointer function
associated with the property its self.
We could add a poll function to the existing set of pointer funcs...
RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get,
const char *set, const char *typef, const char *poll)
This poll function would mainly be used for filtering and (not the
python api for eg), and would be more flexible since properties could
check for more specific cases.
The one way its more limiting is if for some reason you wanted a
property list not to be filtered in certain cases it would not support
this however I cant think of where this would be needed.
This isn't all that hard to change and I'm fine to go ahead and do it,
just want to make sure its ok with other devs.
More information about the Bf-committers