[Bf-taskforce25] Using context itterators
Ton Roosendaal
ton at blender.org
Sun Dec 28 19:03:08 CET 2008
Hi all,
(To Michael especially :)
We should as much as possible prevent using our own loops, but rely on
the Context itterators for tools. A tool like 'select all by type' then
can be used generic, also outside of view3d. Here is what is was:
base= FIRSTBASE;
while(base) {
if((base->lay & v3d->lay) &&
(base->object->type == obtype) &&
(base->object->restrictflag & OB_RESTRICT_VIEW)==0
) {
select_base_v3d(base, BA_SELECT);
base->object->flag= base->flag;
}
base= base->next;
}
And how it should be:
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
if(base->object->type==obtype)
select_base_v3d(base, BA_SELECT);
}
CTX_DATA_END;
This way you let Context handle it all, if there's no function for
"selected_bases" defined in this context, it will skip the loop
entirely.
This also makes the call selectall_type() obsolete, just don't use this.
For the view3d_header.c menus, we will just simply call the operator by
name and provide a property. Later - for new buttons system - it can
become generated, and even check (poll) for the operators if they're
valid.
Lastly; if you encounter cases that work well this way (context free
ops), it's better to move them out of the view3d directory, this
operator then goes to the object directory, where we can keep all
generic object ops.
It also means to move the select_base_v3d() call to a more generic one,
providing notifiers. I will look into that.
Thanks!
-Ton-
------------------------------------------------------------------------
Ton Roosendaal Blender Foundation ton at blender.org www.blender.org
Blender Institute BV Entrepotdok 57A 1018AD Amsterdam The Netherlands
More information about the Bf-taskforce25
mailing list