[Bf-blender-cvs] [589e760a34c] temp-group-collections: Outliner: Support enable/disable group collections and fix select icon

Dalai Felinto noreply at git.blender.org
Wed Nov 1 18:14:57 CET 2017


Commit: 589e760a34ce177a432f846b9912988937cbc533
Author: Dalai Felinto
Date:   Mon Oct 30 21:03:01 2017 -0200
Branches: temp-group-collections
https://developer.blender.org/rB589e760a34ce177a432f846b9912988937cbc533

Outliner: Support enable/disable group collections and fix select icon

You can select only non-group collections.

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/intern/layer.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/makesrna/intern/rna_layer.c

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 1ef8ffec99a..b4a14bcf71f 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -69,7 +69,7 @@ void BKE_scene_layer_free(struct SceneLayer *sl);
 
 void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag);
 
-struct SceneLayer *BKE_scene_layer_find_from_collection(const struct Scene *scene, struct LayerCollection *lc);
+struct SceneLayer *BKE_scene_layer_find_from_collection(const struct ID *id, struct LayerCollection *lc);
 struct Base *BKE_scene_layer_base_find(struct SceneLayer *sl, struct Object *ob);
 void BKE_scene_layer_base_deselect_all(struct SceneLayer *sl);
 void BKE_scene_layer_base_select(struct SceneLayer *sl, struct Base *selbase);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index d2962a66773..eb7a4d63e1b 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -227,14 +227,25 @@ static bool find_scene_collection_in_scene_collections(ListBase *lb, const Layer
 /**
  * Find the SceneLayer a LayerCollection belongs to
  */
-SceneLayer *BKE_scene_layer_find_from_collection(const Scene *scene, LayerCollection *lc)
+SceneLayer *BKE_scene_layer_find_from_collection(const ID *id, LayerCollection *lc)
 {
-	for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
-		if (find_scene_collection_in_scene_collections(&sl->layer_collections, lc)) {
-			return sl;
+	switch (GS(id->name)) {
+		case ID_GR:
+			return ((Group *)id)->scene_layer;
+		case ID_SCE:
+		{
+			Scene *scene = (Scene *)id;
+			for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
+				if (find_scene_collection_in_scene_collections(&sl->layer_collections, lc)) {
+					return sl;
+				}
+			}
+			return NULL;
 		}
+		default:
+			BLI_assert(!"ID doesn't support scene layers");
+			return NULL;
 	}
-	return NULL;
 }
 
 /* Base */
@@ -673,10 +684,10 @@ static void layer_collection_swap(
  */
 bool BKE_layer_collection_move_into(const Scene *scene, LayerCollection *lc_dst, LayerCollection *lc_src)
 {
-	SceneLayer *sl = BKE_scene_layer_find_from_collection(scene, lc_src);
+	SceneLayer *sl = BKE_scene_layer_find_from_collection(&scene->id, lc_src);
 	bool is_directly_linked = false;
 
-	if ((!sl) || (sl != BKE_scene_layer_find_from_collection(scene, lc_dst))) {
+	if ((!sl) || (sl != BKE_scene_layer_find_from_collection(&scene->id, lc_dst))) {
 		return false;
 	}
 
@@ -740,11 +751,11 @@ bool BKE_layer_collection_move_into(const Scene *scene, LayerCollection *lc_dst,
  */
 bool BKE_layer_collection_move_above(const Scene *scene, LayerCollection *lc_dst, LayerCollection *lc_src)
 {
-	SceneLayer *sl = BKE_scene_layer_find_from_collection(scene, lc_src);
+	SceneLayer *sl = BKE_scene_layer_find_from_collection(&scene->id, lc_src);
 	const bool is_directly_linked_src = BLI_findindex(&sl->layer_collections, lc_src) != -1;
 	const bool is_directly_linked_dst = BLI_findindex(&sl->layer_collections, lc_dst) != -1;
 
-	if ((!sl) || (sl != BKE_scene_layer_find_from_collection(scene, lc_dst))) {
+	if ((!sl) || (sl != BKE_scene_layer_find_from_collection(&scene->id, lc_dst))) {
 		return false;
 	}
 
@@ -815,11 +826,11 @@ bool BKE_layer_collection_move_above(const Scene *scene, LayerCollection *lc_dst
  */
 bool BKE_layer_collection_move_below(const Scene *scene, LayerCollection *lc_dst, LayerCollection *lc_src)
 {
-	SceneLayer *sl = BKE_scene_layer_find_from_collection(scene, lc_src);
+	SceneLayer *sl = BKE_scene_layer_find_from_collection(&scene->id, lc_src);
 	const bool is_directly_linked_src = BLI_findindex(&sl->layer_collections, lc_src) != -1;
 	const bool is_directly_linked_dst = BLI_findindex(&sl->layer_collections, lc_dst) != -1;
 
-	if ((!sl) || (sl != BKE_scene_layer_find_from_collection(scene, lc_dst))) {
+	if ((!sl) || (sl != BKE_scene_layer_find_from_collection(&scene->id, lc_dst))) {
 		return false;
 	}
 
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 09f6f306b50..312c9e1b7d9 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -250,9 +250,10 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
 static void enablebutton_collection_flag_cb(bContext *C, void *poin, void *poin2)
 {
 	Main *bmain = CTX_data_main(C);
-	Scene *scene = poin;
+	Scene *scene = CTX_data_scene(C);
+	ID *id = poin;
 	LayerCollection *layer_collection = poin2;
-	SceneLayer *scene_layer = BKE_scene_layer_find_from_collection(scene, layer_collection);
+	SceneLayer *scene_layer = BKE_scene_layer_find_from_collection(id, layer_collection);
 
 	/* TODO: This breaks when you see the collections of a group. (dfelinto) */
 	if (scene_layer == NULL) {
@@ -277,9 +278,9 @@ static void enablebutton_collection_flag_cb(bContext *C, void *poin, void *poin2
 	WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
 }
 
-static void restrictbutton_collection_flag_cb(bContext *C, void *poin, void *UNUSED(poin2))
+static void restrictbutton_collection_flag_cb(bContext *C, void *UNUSED(poin), void *UNUSED(poin2))
 {
-	Scene *scene = poin;
+	Scene *scene = CTX_data_scene(C);
 	/* hide and deselect bases that are directly influenced by this LayerCollection */
 	/* TODO(sergey): Use proper flag for tagging here. */
 	DEG_id_tag_update(&scene->id, 0);
@@ -599,22 +600,24 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
 				                      (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), te->ys, UI_UNIT_X,
 				                      UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
 				                      TIP_("Enable/Disable collection from depsgraph"));
-				UI_but_func_set(bt, enablebutton_collection_flag_cb, scene, collection);
+				UI_but_func_set(bt, enablebutton_collection_flag_cb, tselem->id, collection);
 				UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
 
 				bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VISIBLE, 0, ICON_RESTRICT_VIEW_OFF,
 				                      (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
 				                      UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
 				                      TIP_("Restrict/Allow 3D View visibility of objects in the collection"));
-				UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
+				UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
 				UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
 
-				bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_SELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
-				                      (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
-				                      UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
-				                      TIP_("Restrict/Allow 3D View selection of objects in the collection"));
-				UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
-				UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+				if (collection->scene_collection->type == COLLECTION_TYPE_NONE) {
+					bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_SELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
+										  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
+										  UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+										  TIP_("Restrict/Allow 3D View selection of objects in the collection"));
+					UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
+					UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+				}
 
 				UI_block_emboss_set(block, UI_EMBOSS);
 			}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index fbb1ee185b0..894a6a601d6 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -89,7 +89,7 @@
 
 /* prototypes */
 static void outliner_add_layer_collections_recursive(
-        SpaceOops *soops, ListBase *tree, ListBase *layer_collections, TreeElement *parent_ten);
+        SpaceOops *soops, ListBase *tree, ID *id, ListBase *layer_collections, TreeElement *parent_ten);
 static void outliner_make_hierarchy(ListBase *lb);
 
 /* ********************************************************* */
@@ -869,7 +869,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
 	}
 
 	/* exceptions */
-	if (ELEM(type, TSE_ID_BASE, TSE_LAYER_COLLECTION)) {
+	if (type == TSE_ID_BASE) {
 		/* pass */
 	}
 	else if (id == NULL) {
@@ -1207,9 +1207,9 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
 			te->flag |= TE_LAZY_CLOSED;
 	}
 
-	if (GS(id->name) == ID_GR) {
+	if ((type !=  TSE_LAYER_COLLECTION) && GS(id->name) == ID_GR) {
 		Group *group = (Group *)id;
-		outliner_add_layer_collections_recursive(soops, &te->subtree, &group->scene_layer->layer_collections, NULL);
+		outliner_add_layer_collections_recursive(soops, &te->subtree, id, &group->scene_layer->layer_collections, NULL);
 	}
 
 	return te;
@@ -1392,17 +1392,17 @@ static bool outliner_layer_collections_reorder_poll(
 }
 
 static void outliner_add_layer_collections_recursive(
-        SpaceOops *soops, ListBase *tree, ListBase *layer_collections, TreeElement *parent_ten)
+        SpaceOops *soops, ListBase *tree, ID *id, ListBase *layer_collections, TreeElement *parent_ten)
 {
 	for (LayerCollection *collection = layer_collections->first; collection; collection = collection->next) {
-		TreeElement *ten = outliner_add_element(soops, tree, collection, parent_ten, TSE_LAYER_COLLECTION, 0);
+		TreeElement *ten = outliner_add_element(soops, tree, id, parent_ten, TSE_LAYER_COLLECTION, 0);
 
 		ten->name = collection->scene_collection->name;
 		ten->directdata = collection;
 		ten->reinsert = outliner_layer_collections_reorder;
 		ten->reinsert_poll = outliner_layer_collections_reorder_poll;
 
-		outliner_add_layer_collections_recursive(soops, &ten->subtree, &collection->layer_collections, ten);
+		outliner_add_layer_co

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list