Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-01-31 15:03:53 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-01-31 15:05:23 +0300
commitc955b77f7d177fc0875a3262101b047165af2e80 (patch)
tree708ef7c299f92e31d3f17f85d2012dfc7d86a6bd
parenta0e4ae5d378aa6514108b45fe70bc579c1ff4d8e (diff)
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
-rw-r--r--source/blender/editors/space_collections/collections_ops.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/editors/space_collections/collections_ops.c b/source/blender/editors/space_collections/collections_ops.c
index 21d6e2e37b8..123a722fc3f 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))