[Bf-blender-cvs] [ef71a77] GPencil_EditStrokes: Support for jumping between Grease Pencil keyframes

Joshua Leung noreply at git.blender.org
Tue Oct 21 15:23:45 CEST 2014


Commit: ef71a77e565ac17ffc4457756c1b989942eeecdd
Author: Joshua Leung
Date:   Sun Oct 19 02:24:02 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rBef71a77e565ac17ffc4457756c1b989942eeecdd

Support for jumping between Grease Pencil keyframes

* Added support for jumping between Grease Pencil keyframes (for the currently
  visible context).

* Also added support for showing Grease Pencil keyframes in the timeline,
  though this doesn't currently work because of context issues. We need to find
  a way around not being able to know what other views are showing GP data
  (e.g. maybe default to only showing stuff for 3D views, since that's the primary
   usecase for animation-type work)?

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

M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/include/ED_keyframes_draw.h
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_time/space_time.c

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

diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index c5e5068..c786cd3 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -737,6 +737,21 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos)
 	BLI_dlrbTree_free(&blocks);
 }
 
+void draw_gpencil_channel(View2D *v2d, bDopeSheet *ads, bGPdata *gpd, float ypos)
+{
+	DLRBT_Tree keys;
+	
+	BLI_dlrbTree_init(&keys);
+	
+	gpencil_to_keylist(ads, gpd, &keys);
+	
+	BLI_dlrbTree_linkedlist_sync(&keys);
+	
+	draw_keylist(v2d, &keys, NULL, ypos, 0);
+	
+	BLI_dlrbTree_free(&keys);
+}
+
 void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos)
 {
 	DLRBT_Tree keys;
@@ -929,6 +944,20 @@ void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree
 }
 
 
+void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, DLRBT_Tree *keys)
+{
+	bGPDlayer *gpl;
+	
+	if (gpd && keys) {
+		/* for now, just aggregate out all the frames, but only for visible layers */
+		for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+			if ((gpl->flag & GP_LAYER_HIDE) == 0) {
+				gpl_to_keylist(ads, gpl, keys);
+			}
+		}
+	}
+}
+
 void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys)
 {
 	bGPDframe *gpf;
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 58a262e..0359153 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -120,8 +120,9 @@ void draw_object_channel(struct View2D *v2d, struct bDopeSheet *ads, struct Obje
 void draw_scene_channel(struct View2D *v2d, struct bDopeSheet *ads, struct Scene *sce, float ypos);
 /* DopeSheet Summary */
 void draw_summary_channel(struct View2D *v2d, struct bAnimContext *ac, float ypos);
-/* Grease Pencil Layer */ 
-// XXX not restored 
+/* Grease Pencil datablock summary */
+void draw_gpencil_channel(struct View2D *v2d, struct bDopeSheet *ads, struct bGPdata *gpd, float ypos);
+/* Grease Pencil Layer */
 void draw_gpl_channel(struct View2D *v2d, struct bDopeSheet *ads, struct bGPDlayer *gpl, float ypos);
 /* Mask Layer */
 void draw_masklay_channel(struct View2D *v2d, struct bDopeSheet *ads, struct MaskLayer *masklay, float ypos);
@@ -139,11 +140,11 @@ void ob_to_keylist(struct bDopeSheet *ads, struct Object *ob, struct DLRBT_Tree
 void scene_to_keylist(struct bDopeSheet *ads, struct Scene *sce, struct DLRBT_Tree *keys, struct DLRBT_Tree *blocks);
 /* DopeSheet Summary */
 void summary_to_keylist(struct bAnimContext *ac, struct DLRBT_Tree *keys, struct DLRBT_Tree *blocks);
+/* Grease Pencil datablock summary */
+void gpencil_to_keylist(struct bDopeSheet *ads, struct bGPdata *gpd, struct DLRBT_Tree *keys);
 /* Grease Pencil Layer */
-// XXX not restored
 void gpl_to_keylist(struct bDopeSheet *ads, struct bGPDlayer *gpl, struct DLRBT_Tree *keys);
 /* Mask */
-// XXX not restored
 void mask_to_keylist(struct bDopeSheet *UNUSED(ads), struct MaskLayer *masklay, struct DLRBT_Tree *keys);
 
 /* ActKeyColumn API ---------------- */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 8be25e3..c837302 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -43,6 +43,7 @@
 #include "DNA_lattice_types.h"
 #include "DNA_object_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_gpencil_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_mask_types.h"
@@ -2150,6 +2151,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	Object *ob = CTX_data_active_object(C);
+	bGPdata *gpd = CTX_data_gpencil_data(C);
 	bDopeSheet ads = {NULL};
 	DLRBT_Tree keys;
 	ActKeyColumn *ak;
@@ -2177,7 +2179,9 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
 
 	if (ob)
 		ob_to_keylist(&ads, ob, &keys, NULL);
-
+	
+	gpencil_to_keylist(&ads, gpd, &keys);
+	
 	{
 		Mask *mask = CTX_data_edit_mask(C);
 		if (mask) {
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 88c57d4..3698821 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <stdio.h>
 
+#include "DNA_gpencil_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
@@ -310,6 +311,9 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
 		case ID_OB:
 			ob_to_keylist(&ads, (Object *)id, &keys, NULL);
 			break;
+		case ID_GD:
+			gpencil_to_keylist(&ads, (bGPdata *)id, &keys);
+			break;
 	}
 		
 	/* build linked-list for searching */
@@ -339,9 +343,16 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar)
 {
 	Scene *scene = CTX_data_scene(C);
 	Object *ob = CTX_data_active_object(C);
+	bGPdata *gpd = CTX_data_gpencil_data(C);
 	View2D *v2d = &ar->v2d;
 	bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
 	
+	/* draw grease pencil keyframes (if available) */
+	if (gpd) {
+		glColor3ub(0xB5, 0xE6, 0x1D);
+		time_draw_idblock_keyframes(v2d, (ID *)gpd, onlysel);
+	}
+	
 	/* draw scene keyframes first 
 	 *	- don't try to do this when only drawing active/selected data keyframes,
 	 *	  since this can become quite slow




More information about the Bf-blender-cvs mailing list