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-11-30 23:38:07 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-12-01 19:15:54 +0300
commitf91e05778612712050ed6f19ce9a2223c0404653 (patch)
tree573e49186df2af01e2feb9bb09ad8513d7eeb8c9 /source/blender/editors
parentaeaf87bbeb011e9a571eefa12d81fa6fb2b8bd5b (diff)
Groups and collection: editing group collections
Allow users to edit either the object group active collection or view layer one We can't support users selecting the group collections from the outliner group because that would be imply having an active group for the scene or workspace. But the way it is now allows to see and edit the collection values after the group is instanced.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c22
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h1
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c23
3 files changed, 34 insertions, 12 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 183d715a93e..8866c6b6c40 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -39,6 +39,7 @@
#include "BLT_translation.h"
#include "DNA_armature_types.h"
+#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
@@ -177,7 +178,7 @@ static int buttons_context_path_workspace(ButsContextPath *path)
return RNA_struct_is_a(ptr->type, &RNA_WorkSpace);
}
-static int buttons_context_path_collection(ButsContextPath *path)
+static int buttons_context_path_collection(ButsContextPath *path, eSpaceButtons_Collection_Context collection_context)
{
PointerRNA *ptr = &path->ptr[path->len - 1];
@@ -187,10 +188,21 @@ static int buttons_context_path_collection(ButsContextPath *path)
}
ViewLayer *view_layer = ptr->data;
- LayerCollection *sc = BKE_layer_collection_get_active(view_layer);
- if (sc) {
- RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]);
+ if (collection_context == SB_COLLECTION_CTX_GROUP) {
+ Object *ob = OBACT(view_layer);
+ if (ob && ob->dup_group) {
+ view_layer = ob->dup_group->view_layer;
+
+ /* Replace the view layer by the group in the context path. */
+ RNA_pointer_create(NULL, &RNA_Group, ob->dup_group, &path->ptr[path->len - 1]);
+ }
+ }
+
+ LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer);
+
+ if (layer_collection) {
+ RNA_pointer_create(NULL, &RNA_LayerCollection, layer_collection, &path->ptr[path->len]);
path->len++;
return 1;
}
@@ -650,7 +662,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
found = buttons_context_path_workspace(path);
break;
case BCONTEXT_COLLECTION:
- found = buttons_context_path_collection(path);
+ found = buttons_context_path_collection(path, sbuts->collection_context);
break;
case BCONTEXT_OBJECT:
case BCONTEXT_PHYSICS:
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 7fc35a6b1e7..e6d19caad47 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -65,6 +65,7 @@ typedef struct ButsContextPath {
int len;
int flag;
int tex_ctx;
+ int collection_ctx;
} ButsContextPath;
typedef struct ButsTextureUser {
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 70d01007d89..08b5f337936 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -781,15 +781,24 @@ static eOLDrawState tree_element_active_collection(
/* don't allow selecting a scene collection, it can have multiple layer collection
* instances (which one would the user want to be selected then?) */
else if (tselem->type == TSE_LAYER_COLLECTION) {
- ViewLayer *view_layer = CTX_data_view_layer(C);
- LayerCollection *lc = te->directdata;
- const int collection_index = BKE_layer_collection_findindex(view_layer, lc);
+ LayerCollection *layer_collection = te->directdata;
+
+ switch (layer_collection->scene_collection->type) {
+ case COLLECTION_TYPE_NONE:
+ case COLLECTION_TYPE_GROUP_INTERNAL:
+ {
+ ViewLayer *view_layer = BKE_view_layer_find_from_collection(tselem->id, layer_collection);
+ const int collection_index = BKE_layer_collection_findindex(view_layer, layer_collection);
- /* If the collection is part of a group we don't change active collection. */
- if (collection_index > -1) {
- view_layer->active_collection = collection_index;
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
+ if (collection_index > -1) {
+ view_layer->active_collection = collection_index;
+ }
+ break;
+ }
+ default:
+ BLI_assert(!"Collection type not fully implemented");
}
+ WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
}
return OL_DRAWSEL_NONE;