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:
authorNathan Craddock <nzcraddock@gmail.com>2020-09-15 21:29:26 +0300
committerNathan Craddock <nzcraddock@gmail.com>2020-09-15 21:47:09 +0300
commit33d7b36cecd4a6dab2bd5798071f58545ae0cabe (patch)
tree421a7b793d86b650406fc32f1eb9e554d3bac8f3 /source/blender/editors/space_outliner/outliner_collections.c
parent26a40ac8facfdc4a35ac2fb2daf339787ea1f6c4 (diff)
Outliner: Set collection color tag operator
This adds a new operator to the outliner context menu. The collections context menu now shows inline icons to set the color tag for all selected collections. Manifest Task: https://developer.blender.org/T77777 Differential Revision: https://developer.blender.org/D8622
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_collections.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index efb91528e14..13086655998 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -1529,3 +1529,66 @@ void OUTLINER_OT_unhide_all(wmOperatorType *ot)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Collection Color Tags
+ * \{ */
+
+static int outliner_color_tag_set_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ const short color_tag = RNA_enum_get(op->ptr, "color");
+
+ struct IDsSelectedData selected = {
+ .selected_array = {NULL, NULL},
+ };
+
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_selected_collections,
+ &selected);
+
+ LISTBASE_FOREACH (LinkData *, link, &selected.selected_array) {
+ TreeElement *te_selected = (TreeElement *)link->data;
+
+ Collection *collection = outliner_collection_from_tree_element(te_selected);
+ if (collection == scene->master_collection) {
+ continue;
+ }
+ if (ID_IS_LINKED(collection)) {
+ BKE_report(op->reports, RPT_WARNING, "Can't add a color tag to a linked collection");
+ continue;
+ }
+
+ collection->color_tag = color_tag;
+ };
+
+ BLI_freelistN(&selected.selected_array);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_collection_color_tag_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Color Tag";
+ ot->idname = "OUTLINER_OT_collection_color_tag_set";
+ ot->description = "Set a color tag for the selected collections";
+
+ /* api callbacks */
+ ot->exec = outliner_color_tag_set_exec;
+ ot->poll = ED_outliner_collections_editor_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_enum(
+ ot->srna, "color", rna_enum_collection_color_items, COLLECTION_COLOR_NONE, "Color Tag", "");
+}
+
+/** \} */