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:
authorCampbell Barton <ideasman42@gmail.com>2017-10-09 12:49:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-09 12:49:27 +0300
commita5b4b0f21c1ae8c96e4fea9abdcfac2fab1cf300 (patch)
tree0658d8bdfb8ec03652aa04f82ee8a4d243ec6370 /source/blender/editors/space_outliner/outliner_collections.c
parentd68f698cf0321477c0734474150eb4bc43c4e85f (diff)
parentabcda06934aba054de8540b66b13c2bbc5f8f515 (diff)
Merge branch '28' into custom-manipulatorscustom-manipulators
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_collections.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 315a3af1898..092909cbcba 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -27,6 +27,7 @@
#include "BKE_context.h"
#include "BKE_collection.h"
#include "BKE_layer.h"
+#include "BKE_main.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
@@ -216,6 +217,7 @@ static int collection_unlink_poll(bContext *C)
static int collection_unlink_exec(bContext *C, wmOperator *op)
{
LayerCollection *lc = outliner_collection_active(C);
+ SpaceOops *soops = CTX_wm_space_outliner(C);
if (lc == NULL) {
BKE_report(op->reports, RPT_ERROR, "Active element is not a collection");
@@ -225,6 +227,10 @@ static int collection_unlink_exec(bContext *C, wmOperator *op)
SceneLayer *sl = CTX_data_scene_layer(C);
BKE_collection_unlink(sl, lc);
+ if (soops) {
+ outliner_cleanup_tree(soops);
+ }
+
DEG_relations_tag_update(CTX_data_main(C));
/* TODO(sergey): Use proper flag for tagging here. */
@@ -398,6 +404,82 @@ void OUTLINER_OT_collection_select(wmOperatorType *ot)
"Index of collection to select", 0, INT_MAX);
}
+#define ACTION_DISABLE 0
+#define ACTION_ENABLE 1
+#define ACTION_TOGGLE 2
+
+static int collection_toggle_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ SceneLayer *scene_layer = CTX_data_scene_layer(C);
+ int action = RNA_enum_get(op->ptr, "action");
+ LayerCollection *layer_collection = CTX_data_layer_collection(C);
+
+ if (layer_collection->flag & COLLECTION_DISABLED) {
+ if (ELEM(action, ACTION_TOGGLE, ACTION_ENABLE)) {
+ BKE_collection_enable(scene_layer, layer_collection);
+ }
+ else { /* ACTION_DISABLE */
+ BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already disabled",
+ layer_collection->scene_collection->name);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else {
+ if (ELEM(action, ACTION_TOGGLE, ACTION_DISABLE)) {
+ BKE_collection_disable(scene_layer, layer_collection);
+ }
+ else { /* ACTION_ENABLE */
+ BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already enabled",
+ layer_collection->scene_collection->name);
+ return OPERATOR_CANCELLED;
+ }
+ }
+
+ DEG_relations_tag_update(bmain);
+ /* TODO(sergey): Use proper flag for tagging here. */
+ DEG_id_tag_update(&scene->id, 0);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_collection_toggle(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ static EnumPropertyItem actions_items[] = {
+ {ACTION_DISABLE, "DISABLE", 0, "Disable", "Disable selected markers"},
+ {ACTION_ENABLE, "ENABLE", 0, "Enable", "Enable selected markers"},
+ {ACTION_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Toggle Collection";
+ ot->idname = "OUTLINER_OT_collection_toggle";
+ ot->description = "Deselect collection objects";
+
+ /* api callbacks */
+ ot->exec = collection_toggle_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ prop = RNA_def_int(ot->srna, "collection_index", -1, -1, INT_MAX, "Collection Index", "Index of collection to toggle", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_enum(ot->srna, "action", actions_items, ACTION_TOGGLE, "Action", "Selection action to execute");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+#undef ACTION_TOGGLE
+#undef ACTION_ENABLE
+#undef ACTION_DISABLE
+
/* -------------------------------------------------------------------- */
static int stubs_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))