active property for collections for things like scene.objects.active
[blender.git] / source / blender / makesrna / intern / rna_scene.c
index e7aeac96aef6d75eb7113ed98e846c48cb3ff5f3..667f88a3a337a3dd5f157738f0e63027c877e350 100644 (file)
@@ -2175,6 +2175,7 @@ void RNA_def_scene(BlenderRNA *brna)
 {
        StructRNA *srna;
        PropertyRNA *prop;
+       PropertyRNA *prop_act;
        FunctionRNA *func;
        
        static EnumPropertyItem audio_distance_model_items[] = {
@@ -2206,15 +2207,6 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_pointer_funcs(prop, NULL, "rna_Scene_set_set", NULL);
        RNA_def_property_ui_text(prop, "Set Scene", "Background set scene.");
 
-       prop= RNA_def_property(srna, "active_object", PROP_POINTER, PROP_NONE);
-       RNA_def_property_struct_type(prop, "Object");
-       RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL);
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Object", "Object to use as projector transform.");
-       /* Could call: ED_base_object_activate(C, scene->basact);
-        * but would be a bad level call and it seems the notifier is enough */
-       RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL);
-
        prop= RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "World", "World used for rendering the scene.");
@@ -2232,12 +2224,35 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "Base");
        RNA_def_property_ui_text(prop, "Bases", "");
 
+       { /* Collection active property */
+               prop_act= RNA_def_property(srna, "base_active", PROP_POINTER, PROP_NONE);
+               RNA_def_property_struct_type(prop_act, "Base");
+               RNA_def_property_pointer_sdna(prop_act, NULL, "basact");
+               RNA_def_property_flag(prop_act, PROP_EDITABLE);
+               RNA_def_property_ui_text(prop_act, "Active Base", "Active object in the scene.");
+               RNA_def_property_update(prop_act, NC_SCENE|ND_OB_ACTIVE, NULL);
+               RNA_def_property_collection_active(prop, prop_act);
+       }
+
        prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "base", NULL);
        RNA_def_property_struct_type(prop, "Object");
        RNA_def_property_ui_text(prop, "Objects", "");
        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);
+               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);
+               RNA_def_property_ui_text(prop_act, "Object", "Object to use as projector transform.");
+               /* Could call: ED_base_object_activate(C, scene->basact);
+                * but would be a bad level call and it seems the notifier is enough */
+               RNA_def_property_update(prop_act, NC_SCENE|ND_OB_ACTIVE, NULL);
+
+               RNA_def_property_collection_active(prop, prop_act);
+       }
+
        /* Layers */
        prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
        RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);