[Bf-blender-cvs] [ec5f0d2] GPencil_EditStrokes: Grease Pencil layers can be rearranged from the DopeSheet Editor

Joshua Leung noreply at git.blender.org
Sat Oct 11 14:01:18 CEST 2014


Commit: ec5f0d27b5f48c79e99362ee43c79ed7ec9ca5df
Author: Joshua Leung
Date:   Sat Oct 11 22:02:49 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rBec5f0d27b5f48c79e99362ee43c79ed7ec9ca5df

Grease Pencil layers can be rearranged from the DopeSheet Editor

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

M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/animation/anim_filter.c

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

diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index ec4e85b..242d588 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -856,6 +856,13 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
 			is_sel = SEL_NLT(nlt);
 			break;
 		}
+		case ANIMTYPE_GPLAYER:
+		{
+			bGPDlayer *gpl = (bGPDlayer *)channel;
+			
+			is_sel = SEL_GPL(gpl);
+			break;
+		}
 		default:
 			printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %d\n", type);
 			return;
@@ -1180,6 +1187,47 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
 
 /* ------------------- */
 
+static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode mode)
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	/* get rearranging function */
+	AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
+	
+	if (rearrange_func == NULL)
+		return;
+	
+	/* get Grease Pencil datablocks */
+	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
+	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+	
+	for (ale = anim_data.first; ale; ale = ale->next) {
+		ListBase anim_data_visible = {NULL, NULL};
+		bGPdata *gpd = ale->data;
+		
+		/* only consider layers if this datablock is open */
+		BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK);
+		if ((gpd->flag & GP_DATA_EXPAND) == 0)
+			continue;
+		
+		/* Filter visible data. */
+		rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER);
+		
+		/* rearrange datablock's layers */
+		rearrange_animchannel_islands(&gpd->layers, rearrange_func, mode, ANIMTYPE_GPLAYER, &anim_data_visible);
+		
+		/* free visible layers data */
+		BLI_freelistN(&anim_data_visible);
+	}
+	
+	/* free GPD channel data */
+	ANIM_animdata_freelist(&anim_data);
+}
+
+/* ------------------- */
+
 static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
 {
 	bAnimContext ac;
@@ -1195,7 +1243,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
 	/* method to move channels depends on the editor */
 	if (ac.datatype == ANIMCONT_GPENCIL) {
 		/* Grease Pencil channels */
-		printf("Grease Pencil not supported for moving yet\n");
+		rearrange_gpencil_channels(&ac, mode);
 	}
 	else if (ac.datatype == ANIMCONT_MASK) {
 		/* Grease Pencil channels */
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index dad25eb..1192b7c 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1413,26 +1413,36 @@ static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), i
 		/* only show if gpd is used by something... */
 		if (ID_REAL_USERS(gpd) < 1)
 			continue;
-			
-		/* add gpencil animation channels */
-		BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
-		{
-			tmp_items += animdata_filter_gpencil_data(&tmp_data, gpd, filter_mode);
-		}
-		END_ANIMFILTER_SUBCHANNELS;
 		
-		/* did we find anything? */
-		if (tmp_items) {
-			/* include data-expand widget first */
-			if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
-				/* add gpd as channel too (if for drawing, and it has layers) */
-				ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL);
+		/* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation),
+		 * for convenience, this will return GP Datablocks instead. This may cause issues down
+		 * the track, but for now, this will do...
+		 */
+		if (filter_mode & ANIMFILTER_ANIMDATA) {
+			/* just add GPD as a channel - this will add everything needed */
+			ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL);
+		}
+		else {
+			/* add gpencil animation channels */
+			BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
+			{
+				tmp_items += animdata_filter_gpencil_data(&tmp_data, gpd, filter_mode);
 			}
+			END_ANIMFILTER_SUBCHANNELS;
 			
-			/* now add the list of collected channels */
-			BLI_movelisttolist(anim_data, &tmp_data);
-			BLI_assert(BLI_listbase_is_empty(&tmp_data));
-			items += tmp_items;
+			/* did we find anything? */
+			if (tmp_items) {
+				/* include data-expand widget first */
+				if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+					/* add gpd as channel too (if for drawing, and it has layers) */
+					ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL);
+				}
+				
+				/* now add the list of collected channels */
+				BLI_movelisttolist(anim_data, &tmp_data);
+				BLI_assert(BLI_listbase_is_empty(&tmp_data));
+				items += tmp_items;
+			}
 		}
 	}




More information about the Bf-blender-cvs mailing list