- use double underscores to hide members in python (removes them from dir() therefor...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 11 Nov 2009 17:12:48 +0000 (17:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 11 Nov 2009 17:12:48 +0000 (17:12 +0000)
- collection functions rename eg. bones_active -> bones__active, add_object -> objects__add since these should be accessed from the collections only.
- fix warnings in last commit

source/blender/blenkernel/intern/group.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_fcurve_api.c
source/blender/makesrna/intern/rna_group.c
source/blender/makesrna/intern/rna_scene.c
source/blender/python/intern/bpy_rna.c

index 77bf5859385bc039a7fd688e02f89c89953933eb..3ab02a576d0c0ea1952a4b508b81588a29a283aa 100644 (file)
@@ -51,6 +51,7 @@
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
+#include "BKE_scene.h" /* object_in_scene */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
index e79d8091917c0b5e607d082cf06ba9a3c15c9ec9..f73ac517213c1830962f2d2d766ea2c00581f72c 100644 (file)
@@ -668,7 +668,7 @@ static void rna_def_armature(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Bones", "");
 
        { /* Collection active property */
-               prop_act= RNA_def_property(srna, "bones_active", PROP_POINTER, PROP_NONE);
+               prop_act= RNA_def_property(srna, "bones__active", PROP_POINTER, PROP_NONE);
                RNA_def_property_struct_type(prop_act, "Bone");
                RNA_def_property_pointer_sdna(prop_act, NULL, "act_bone");
                RNA_def_property_flag(prop_act, PROP_EDITABLE);
@@ -685,7 +685,7 @@ static void rna_def_armature(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Edit Bones", "");
        
        { /* Collection active property */
-               prop_act= RNA_def_property(srna, "edit_bones_active", PROP_POINTER, PROP_NONE);
+               prop_act= RNA_def_property(srna, "edit_bones__active", PROP_POINTER, PROP_NONE);
                RNA_def_property_struct_type(prop_act, "EditBone");
                RNA_def_property_pointer_sdna(prop_act, NULL, "act_edbone");
                RNA_def_property_flag(prop_act, PROP_EDITABLE);
index cdaebb2a3dbeac925591ae583b7f62702250769d..294f38cf3f79b750ee71195bd580e515253ae166 100644 (file)
@@ -611,7 +611,7 @@ static void rna_def_channeldriver(BlenderRNA *brna)
        /* Collections */
        prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "targets", NULL);
-       RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "add_target", "remove_target");
+       RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "targets__add", "targets__remove");
        RNA_def_property_struct_type(prop, "DriverTarget");
        RNA_def_property_ui_text(prop, "Target Variables", "Properties acting as targets for this driver.");
        
index 12ffb3e26fbb553f41fb93325a63ad0922d1e13c..0abb5e8e499c2f726f2f548f158600239d1d0412 100644 (file)
@@ -71,7 +71,7 @@ void RNA_api_drivers(StructRNA *srna)
        PropertyRNA *parm;
 
        /* add target */
-       func= RNA_def_function(srna, "add_target", "rna_Driver_add_target");
+       func= RNA_def_function(srna, "targets__add", "rna_Driver_add_target");
        RNA_def_function_ui_description(func, "Add a new target for the driver.");
                /* return type */
        parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Newly created Driver Target.");
@@ -80,7 +80,7 @@ void RNA_api_drivers(StructRNA *srna)
        parm= RNA_def_string(func, "name", "", 64, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)");
        
        /* remove target */
-       func= RNA_def_function(srna, "remove_target", "rna_Driver_remove_target");
+       func= RNA_def_function(srna, "targets__remove", "rna_Driver_remove_target");
                RNA_def_function_ui_description(func, "Remove an existing target from the driver.");
                /* target to remove*/
        parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Target to remove from the driver.");
index 8f6a5f1005c26d41e38d984feb3537b00660554d..8babb9593a031447b7288bb75b67ef7b88f572ce 100644 (file)
@@ -38,6 +38,9 @@
 
 #include "BKE_group.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
 {
        ListBaseIterator *internal= iter->internal;
@@ -48,11 +51,13 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
 
 static int rna_Group_objects_add(Group *group, bContext *C, Object *object)
 {
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
        return add_to_group(group, object, CTX_data_scene(C), NULL);
 }
 
 static int rna_Group_objects_remove(Group *group, bContext *C, Object *object)
 {
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
        return rem_from_group(group, object, CTX_data_scene(C), NULL);
 }
 
@@ -63,6 +68,9 @@ void RNA_def_group(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
+       FunctionRNA *func;
+       PropertyRNA *parm;
+
        srna= RNA_def_struct(brna, "Group", "ID");
        RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks.");
        RNA_def_struct_ui_icon(srna, ICON_GROUP);
@@ -79,9 +87,7 @@ void RNA_def_group(BlenderRNA *brna)
 
 
        /* add object */
-       FunctionRNA *func;
-       PropertyRNA *parm;
-       func= RNA_def_function(srna, "add_object", "rna_Group_objects_add");
+       func= RNA_def_function(srna, "objects__add", "rna_Group_objects_add");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
        RNA_def_function_ui_description(func, "Add this object to a group");
        /* return type */
@@ -92,7 +98,7 @@ void RNA_def_group(BlenderRNA *brna)
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
        /* remove object */
-       func= RNA_def_function(srna, "remove_object", "rna_Group_objects_remove");
+       func= RNA_def_function(srna, "objects__remove", "rna_Group_objects_remove");
        RNA_def_function_ui_description(func, "Remove this object to a group");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
        /* return type */
@@ -106,7 +112,7 @@ void RNA_def_group(BlenderRNA *brna)
        RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL);
        RNA_def_property_struct_type(prop, "Object");
        RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects.");
-       RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, "add_object", "remove_object");
+       RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, "objects__add", "objects__remove");
 }
 
 #endif
index 6d198e10b38bd8e91ee2ec292cfcf75bc38987c1..943d559133f18b343b495b409c1bd9bd4610efec 100644 (file)
@@ -2225,7 +2225,7 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Bases", "");
 
        { /* Collection active property */
-               prop_act= RNA_def_property(srna, "base_active", PROP_POINTER, PROP_NONE);
+               prop_act= RNA_def_property(srna, "bases__active", PROP_POINTER, PROP_NONE);
                RNA_def_property_struct_type(prop_act, "ObjectBase");
                RNA_def_property_pointer_sdna(prop_act, NULL, "basact");
                RNA_def_property_flag(prop_act, PROP_EDITABLE);
@@ -2241,7 +2241,7 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0, 0);
 
        { /* Collection active property */
-               prop_act= RNA_def_property(srna, "objects_active", PROP_POINTER, PROP_NONE);
+               prop_act= RNA_def_property(srna, "objects__active", PROP_POINTER, PROP_NONE);
                RNA_def_property_struct_type(prop_act, "Object");
                RNA_def_property_pointer_funcs(prop_act, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL);
                RNA_def_property_flag(prop_act, PROP_EDITABLE);
index b47214bdded4ebf935cbf92f27ca50646c012199..3dcb47a0905ebaa03783f921d117f0ac83abf2a4 100644 (file)
@@ -1306,10 +1306,11 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
                        nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
 
                        if(nameptr) {
-                               pystring = PyUnicode_FromString(nameptr);
-                               PyList_Append(ret, pystring);
-                               Py_DECREF(pystring);
-                               
+                               if(strstr(nameptr, "__")==NULL) { /* __ for hidden props, used for active object for eg. */
+                                       pystring = PyUnicode_FromString(nameptr);
+                                       PyList_Append(ret, pystring);
+                                       Py_DECREF(pystring);
+                               }
                                if(name != nameptr)
                                        MEM_freeN(nameptr);
                        }
@@ -1323,14 +1324,19 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
                 * Collect RNA function items
                 */
                PointerRNA tptr;
+               const char *idname;
 
                RNA_pointer_create(NULL, &RNA_Struct, self->ptr.type, &tptr);
                iterprop= RNA_struct_find_property(&tptr, "functions");
 
                RNA_PROP_BEGIN(&tptr, itemptr, iterprop) {
-                       pystring = PyUnicode_FromString(RNA_function_identifier(itemptr.data));
-                       PyList_Append(ret, pystring);
-                       Py_DECREF(pystring);
+                       idname= RNA_function_identifier(itemptr.data);
+
+                       if(strstr(idname, "__")==NULL) { /* __ for hidden function members, used for collection add/remove for eg. */
+                               pystring = PyUnicode_FromString(idname);
+                               PyList_Append(ret, pystring);
+                               Py_DECREF(pystring);
+                       }
                }
                RNA_PROP_END;
        }