[Bf-blender-cvs] [bccbc935a0f] greasepencil-object: Outliner: Clicking on GP Layers will activate them

Joshua Leung noreply at git.blender.org
Fri Mar 16 15:10:45 CET 2018


Commit: bccbc935a0f4d6566bf6396f0dd1aee678ae979c
Author: Joshua Leung
Date:   Sat Mar 17 03:06:55 2018 +1300
Branches: greasepencil-object
https://developer.blender.org/rBbccbc935a0f4d6566bf6396f0dd1aee678ae979c

Outliner: Clicking on GP Layers will activate them

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

M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_select.c

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 2a20a51d6ff..ad17a4c43fc 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -49,6 +49,7 @@
 #include "BKE_context.h"
 #include "BKE_deform.h"
 #include "BKE_fcurve.h"
+#include "BKE_gpencil.h"
 #include "BKE_global.h"
 #include "BKE_layer.h"
 #include "BKE_library.h"
@@ -394,12 +395,16 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
 				}
 				case TSE_GP_LAYER:
 				{
-					bGPdata *gpd = (bGPdata *)tselem->id; // id = GP Datablock
+					bGPdata *gpd = (bGPdata *)tselem->id; /* id = GP Datablock */
 					bGPDlayer *gpl = te->directdata;
 					
+					/* always make layer active */
+					BKE_gpencil_layer_setactive(gpd, gpl);
+					
 					// XXX: name needs translation stuff
 					BLI_uniquename(&gpd->layers, gpl, "GP Layer", '.',
 					               offsetof(bGPDlayer, info), sizeof(gpl->info));
+					
 					WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, gpd);
 					break;
 				}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index f540f188a85..b1ea4372094 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -45,6 +45,7 @@
 #include "BLI_listbase.h"
 
 #include "BKE_context.h"
+#include "BKE_gpencil.h"
 #include "BKE_group.h"
 #include "BKE_object.h"
 #include "BKE_layer.h"
@@ -436,6 +437,29 @@ static eOLDrawState tree_element_active_defgroup(
 	return OL_DRAWSEL_NONE;
 }
 
+static eOLDrawState tree_element_active_gplayer(
+        bContext *C, Scene *UNUSED(scene), ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
+{
+	bGPdata *gpd = (bGPdata *)tselem->id;
+	bGPDlayer *gpl = te->directdata;
+	
+	/* We can only have a single "active" layer at a time
+	 * and there must always be an active layer...
+	 */
+	if (set != OL_SETSEL_NONE) {
+		if (gpl) {
+			BKE_gpencil_layer_setactive(gpd, gpl);
+			WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, gpd);		
+		}
+	}
+	else {
+		return OL_DRAWSEL_NORMAL;
+	}
+	
+	
+	return OL_DRAWSEL_NONE;
+}
+
 static eOLDrawState tree_element_active_posegroup(
         bContext *C, Scene *UNUSED(scene), ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
 {
@@ -884,8 +908,7 @@ eOLDrawState tree_element_type_active(
 		case TSE_KEYMAP_ITEM:
 			return tree_element_active_keymap_item(C, scene, view_layer, te, tselem, set);
 		case TSE_GP_LAYER:
-			//return tree_element_active_gplayer(C, scene, s, te, tselem, set);
-			break;
+			return tree_element_active_gplayer(C, scene, view_layer, te, tselem, set);
 		case TSE_SCENE_COLLECTION:
 		case TSE_LAYER_COLLECTION:
 			return tree_element_active_collection(C, te, tselem, set);



More information about the Bf-blender-cvs mailing list