[Bf-blender-cvs] [c955b77f7d] render-layers: bpy.ops.collections.select()

Dalai Felinto noreply at git.blender.org
Tue Jan 31 13:07:08 CET 2017


Commit: c955b77f7d177fc0875a3262101b047165af2e80
Author: Dalai Felinto
Date:   Tue Jan 31 13:03:53 2017 +0100
Branches: render-layers
https://developer.blender.org/rBc955b77f7d177fc0875a3262101b047165af2e80

bpy.ops.collections.select()

When we introduce overrides we will extend it to have override_index,
and if it is -1, only set the collection

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

M	source/blender/editors/space_collections/collections_ops.c

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

diff --git a/source/blender/editors/space_collections/collections_ops.c b/source/blender/editors/space_collections/collections_ops.c
index 21d6e2e37b..123a722fc3 100644
--- a/source/blender/editors/space_collections/collections_ops.c
+++ b/source/blender/editors/space_collections/collections_ops.c
@@ -31,6 +31,9 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "RNA_access.h"
+#include "RNA_define.h"
+
 #include "collections_intern.h" /* own include */
 
 /* -------------------------------------------------------------------- */
@@ -200,11 +203,13 @@ static void COLLECTIONS_OT_delete(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-static int select_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+static int select_exec(bContext *C, wmOperator *op)
 {
-	TODO_LAYER_OPERATORS;
-	BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_select not implemented yet");
-	return OPERATOR_CANCELLED;
+	SceneLayer *sl = CTX_data_scene_layer(C);
+	const int collection_index = RNA_int_get(op->ptr, "collection_index");
+	sl->active_collection = collection_index;
+	WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
+	return OPERATOR_FINISHED;
 }
 
 static void COLLECTIONS_OT_select(wmOperatorType *ot)
@@ -215,11 +220,13 @@ static void COLLECTIONS_OT_select(wmOperatorType *ot)
 	ot->description = "Change active collection or override";
 
 	/* api callbacks */
-	ot->invoke = select_invoke;
-	ot->poll = ED_operator_collections_active;
+	ot->exec = select_exec;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+	RNA_def_int(ot->srna, "collection_index", 0, 0, INT_MAX, "Index",
+	            "Index of collection to select", 0, INT_MAX);
 }
 
 static int rename_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))




More information about the Bf-blender-cvs mailing list