[Bf-blender-cvs] [45b9dee8bd] render-layers: SceneCollection.objects.active_index (for user interface)

Dalai Felinto noreply at git.blender.org
Mon Jan 30 18:26:34 CET 2017


Commit: 45b9dee8bd7ec38e31ce95721290a90c0efc18dd
Author: Dalai Felinto
Date:   Mon Jan 30 18:23:05 2017 +0100
Branches: render-layers
https://developer.blender.org/rB45b9dee8bd7ec38e31ce95721290a90c0efc18dd

SceneCollection.objects.active_index (for user interface)

===================================================================

M	source/blender/makesdna/DNA_layer_types.h
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h
index d45334a227..d725a56d82 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -73,6 +73,8 @@ typedef struct SceneCollection {
 	struct SceneCollection *next, *prev;
 	char name[64]; /* MAX_NAME */
 	char filter[64]; /* MAX_NAME */
+	int active_object_index; /* for UI */
+	int pad;
 	ListBase objects;           /* (Object *)LinkData->data */
 	ListBase filter_objects;    /* (Object *)LinkData->data */
 	ListBase scene_collections; /* nested collections */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 3456c7107c..bc442692b6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2254,6 +2254,26 @@ static void rna_SceneCollection_remove(
 	WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
 }
 
+static int rna_SceneCollection_objects_active_index_get(PointerRNA *ptr)
+{
+	SceneCollection *sc = (SceneCollection *)ptr->data;
+	return sc->active_object_index;
+}
+
+static void rna_SceneCollection_objects_active_index_set(PointerRNA *ptr, int value)
+{
+	SceneCollection *sc = (SceneCollection *)ptr->data;
+	sc->active_object_index = value;
+}
+
+static void rna_SceneCollection_objects_active_index_range(
+        PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
+{
+	SceneCollection *sc = (SceneCollection *)ptr->data;
+	*min = 0;
+	*max = max_ii(0, BLI_listbase_count(&sc->objects) - 1);
+}
+
 void rna_SceneCollection_object_link(
         ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob)
 {
@@ -5501,12 +5521,20 @@ static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop)
 	StructRNA *srna;
 	FunctionRNA *func;
 	PropertyRNA *parm;
+	PropertyRNA *prop;
 
 	RNA_def_property_srna(cprop, "CollectionObjects");
 	srna = RNA_def_struct(brna, "CollectionObjects", NULL);
 	RNA_def_struct_sdna(srna, "SceneCollection");
 	RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection");
 
+	prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_int_funcs(prop, "rna_SceneCollection_objects_active_index_get",
+	                           "rna_SceneCollection_objects_active_index_set",
+	                           "rna_SceneCollection_objects_active_index_range");
+	RNA_def_property_ui_text(prop, "Active Object Index", "Active index in collection objects array");
+	RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
 	func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link");
 	RNA_def_function_ui_description(func, "Link an object to collection");
 	RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);




More information about the Bf-blender-cvs mailing list