diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-03 10:51:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-03 10:51:36 +0400 |
commit | 109a3b319830e6680c8d4eaf0d7076cfb1e7729c (patch) | |
tree | de4eec8a3eeb8b737a3224a17272b0b598046346 /source/blender | |
parent | 6d0769bc4216e79939c06888a8109796dc4824e5 (diff) |
pointer poll functions for object's, mainly for modifiers, constraints.
Lattice modifier only shows lattices types, Shrink wrap only meshes etc.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 34 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 1 |
11 files changed, 104 insertions, 19 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c56b3c31222..77551fbf211 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1111,6 +1111,12 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui if(itemptr.data == but->rnapoin.id.data) continue; + /* use filter */ + if(RNA_property_type(but->rnaprop)==PROP_POINTER) { + if(RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr)==0) + continue; + } + if(itemptr.type && RNA_struct_is_ID(itemptr.type)) { ID *id= itemptr.data; char name_ui[32]; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 3d32030326f..36f812e6206 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -178,7 +178,15 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea filter_yes= 0; /* use filter */ - if (template->filterop[0] != 0) { + if(RNA_property_type(template->prop)==PROP_POINTER) { + PointerRNA ptr; + RNA_id_pointer_create(id, &ptr); + if(RNA_property_pointer_poll(&template->ptr, template->prop, &ptr)==0) + filter_yes= 1; + } + + if (filter_yes==0 && template->filterop[0] != 0) { + /* XXX, remove this, use pointer filtering */ PointerRNA ptr; ReportList reports; FunctionRNA *func; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 8498d5b22a1..cbd2d7ec5b3 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -670,6 +670,7 @@ int RNA_property_enum_name(struct bContext *C, PointerRNA *ptr, PropertyRNA *pro int RNA_property_enum_bitflag_identifiers(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier); StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop); +int RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value); int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 62dd14b2ffa..b15f736ac76 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -786,6 +786,7 @@ int RNA_property_array_item_index(PropertyRNA *prop, char name) return -1; } + void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax) { IntPropertyRNA *iprop= (IntPropertyRNA*)rna_ensure_property(prop); @@ -990,6 +991,22 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop) return &RNA_UnknownType; } +int RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value) +{ + prop= rna_ensure_property(prop); + + if(prop->type == PROP_POINTER) { + PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop; + if(pprop->poll) + return pprop->poll(ptr, *value); + + return 1; + } + + printf("RNA_property_pointer_poll %s: is not a pointer property.\n", prop->identifier); + return 0; +} + /* Reuse for dynamic types */ EnumPropertyItem DummyRNA_NULL_items[] = { {0, NULL, 0, NULL, NULL} diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 05bddfa7a32..566e6fc0b83 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1067,6 +1067,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); @@ -1273,7 +1274,8 @@ static void rna_def_constraint_clamp_to(BlenderRNA *brna) RNA_def_struct_sdna_from(srna, "bClampToConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "tar"); // TODO: curve only! + RNA_def_property_pointer_sdna(prop, NULL, "tar"); // TODO: curve only for set function! + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); @@ -1707,7 +1709,8 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_struct_sdna_from(srna, "bShrinkwrapConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "target"); + RNA_def_property_pointer_sdna(prop, NULL, "target"); /* TODO, mesh type */ + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 878657e4f97..eea3c9c7679 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -285,6 +285,20 @@ static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value) } } +static int rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value) +{ + Curve *cu= (Curve*)ptr->id.data; + Object *ob= (Object*)value.data; + + if (ob) { + if (ob->type == OB_CURVE && ob->data != cu) { + return 1; + } + } + + return 0; +} + static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->id.data; @@ -819,6 +833,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) /* pointers */ prop= RNA_def_property(srna, "text_on_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "textoncurve"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_otherObject_poll"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object"); RNA_def_property_update(prop, 0, "rna_Curve_update_deps"); @@ -1144,7 +1159,7 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape"); RNA_def_property_update(prop, 0, "rna_Curve_update_deps"); - RNA_def_property_pointer_funcs(prop, "rna_Curve_bevelObject_get", "rna_Curve_bevelObject_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_Curve_bevelObject_get", "rna_Curve_bevelObject_set", NULL, "rna_Curve_otherObject_poll"); prop= RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); @@ -1152,7 +1167,7 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)"); RNA_def_property_update(prop, 0, "rna_Curve_update_deps"); - RNA_def_property_pointer_funcs(prop, "rna_Curve_taperObject_get", "rna_Curve_taperObject_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_Curve_taperObject_get", "rna_Curve_taperObject_set", NULL, "rna_Curve_otherObject_poll"); /* Flags */ diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 806a22dd3b8..1a7036c7a36 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -206,11 +206,18 @@ PointerRNA rna_object_shapekey_index_get(struct ID *id, int value); int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current); /* named internal so as not to conflict with obj.update() rna func */ -void rna_Object_internal_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); +/* basic poll functions for object types */ +int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +int rna_Camera_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +int rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +int rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +int rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value); + + char *rna_TextureSlot_path(struct PointerRNA *ptr); /* API functions */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index f9e3506379a..bf734f63e6e 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -659,7 +659,7 @@ static void rna_def_modifier_lattice(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_LatticeModifier_object_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_LatticeModifier_object_set", NULL, "rna_Lattice_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -691,7 +691,7 @@ static void rna_def_modifier_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Curve object to deform with"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set", NULL, "rna_Curve_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -983,7 +983,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Armature object to deform with"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set", NULL, "rna_Armature_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -1145,7 +1145,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curve_ob"); RNA_def_property_ui_text(prop, "Curve", "Curve object to fit array length to"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_set", NULL, "rna_Curve_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -1203,13 +1203,13 @@ static void rna_def_modifier_array(BlenderRNA *brna) /* Caps */ prop= RNA_def_property(srna, "start_cap", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Start Cap", "Mesh object to use as a start cap"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_start_cap_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_start_cap_set", NULL, "rna_Mesh_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "end_cap", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "End Cap", "Mesh object to use as an end cap"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set", NULL, "rna_Mesh_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); } @@ -1875,14 +1875,14 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Target", "Mesh target to shrink to"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_target_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_target_set", NULL, "rna_Mesh_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "auxiliary_target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "auxTarget"); RNA_def_property_ui_text(prop, "Auxiliary Target", "Additional mesh target to shrink to"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_auxiliary_target_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_auxiliary_target_set", NULL, "rna_Mesh_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -1986,7 +1986,7 @@ static void rna_def_modifier_mask(BlenderRNA *brna) prop= RNA_def_property(srna, "armature", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "ob_arm"); RNA_def_property_ui_text(prop, "Armature", "Armature to use as source of bones to mask"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskModifier_armature_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskModifier_armature_set", NULL, "rna_Armature_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 92bda4c5f74..51e2fc38014 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -129,18 +129,18 @@ EnumPropertyItem object_type_curve_items[] = { #include "ED_object.h" #include "ED_particle.h" -void rna_Object_internal_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Object_internal_update(Main *bmain, Scene *scene, PointerRNA *ptr) { DAG_id_flush_update(ptr->id.data, OB_RECALC_OB); } -void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) { object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat); rna_Object_internal_update(bmain, scene, ptr); } -void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) +static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob= ptr->id.data; @@ -154,7 +154,7 @@ void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) } } -void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) +static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) { Object *ob= ptr->id.data; @@ -1052,6 +1052,32 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) } +/* generic poll functions */ +int rna_Lattice_object_poll(PointerRNA *ptr, PointerRNA value) +{ + return ((Object *)value.id.data)->type == OB_LATTICE; +} + +int rna_Curve_object_poll(PointerRNA *ptr, PointerRNA value) +{ + return ((Object *)value.id.data)->type == OB_CURVE; +} + +int rna_Armature_object_poll(PointerRNA *ptr, PointerRNA value) +{ + return ((Object *)value.id.data)->type == OB_ARMATURE; +} + +int rna_Mesh_object_poll(PointerRNA *ptr, PointerRNA value) +{ + return ((Object *)value.id.data)->type == OB_MESH; +} + +int rna_Camera_object_poll(PointerRNA *ptr, PointerRNA value) +{ + return ((Object *)value.id.data)->type == OB_CAMERA; +} + #else static void rna_def_vertex_group(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index acd5f7dca42..611e4f02b43 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2929,6 +2929,7 @@ void RNA_def_scene(BlenderRNA *brna) /* Global Settings */ prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); RNA_def_property_ui_text(prop, "Camera", "Active camera used for rendering the scene"); RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_view3d_update"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index eb0c7cb7487..b39a9fecebf 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1218,6 +1218,7 @@ static void rna_def_scene(BlenderRNA *brna) prop= RNA_def_property(srna, "scene_camera", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); RNA_def_property_ui_text(prop, "Camera Override", "Override the scenes active camera"); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); |