diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-01-30 20:23:05 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-01-30 20:23:05 +0300 |
commit | 45b9dee8bd7ec38e31ce95721290a90c0efc18dd (patch) | |
tree | 21a60e72f5cac86b0f63b895d0baeb114d2bc652 /source/blender | |
parent | 8605eb9c971db41a350a1f11d08bc0d56cecae2d (diff) |
SceneCollection.objects.active_index (for user interface)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesdna/DNA_layer_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index d45334a227f..d725a56d826 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 3456c7107c2..bc442692b67 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); |