[Bf-blender-cvs] [ca96664] GPencil_Editing_Stage3: 3D View: Object name changes colour on frames with GP keyframes (if no other keyframes are present)

Joshua Leung noreply at git.blender.org
Sun Dec 6 14:49:37 CET 2015


Commit: ca966644a863f736311af0a5f8435cddd5edcb01
Author: Joshua Leung
Date:   Mon Dec 7 02:49:27 2015 +1300
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rBca966644a863f736311af0a5f8435cddd5edcb01

3D View: Object name changes colour on frames with GP keyframes (if no other keyframes are present)

The colour used needs to be tweaked/changed (TH_TIME_GP_KEYFRAME would be ideal,
but since it's probably not initialised in many themes, we'll stick with
TH_CFRAME for now, even if it looks a bit rough)

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

M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/editors/space_view3d/view3d_draw.c

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

diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index b9b9871..3650875 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -212,6 +212,45 @@ bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene, View3D *v3d)
 }
 
 /* ******************************************************** */
+/* Keyframe Indicator Checks */
+
+/* Check whether there's an active GP keyframe on the current frame */
+bool ED_gpencil_has_keyframe_v3d(Scene *scene, Object *ob, int cfra)
+{
+	/* just check both for now... */
+	// XXX: this could get confusing (e.g. if only on the object, but other places don't show this)
+	if (scene->gpd) {
+		bGPDlayer *gpl = gpencil_layer_getactive(scene->gpd);
+		if (gpl) {
+			if (gpl->actframe) {
+				// XXX: assumes that frame has been fetched already
+				return (gpl->actframe->framenum == cfra);
+			}
+			else {
+				/* XXX: disabled as could be too much of a penalty */
+				/* return BKE_gpencil_layer_find_frame(gpl, cfra); */
+			}
+		}
+	}
+	
+	if (ob && ob->gpd) {
+		bGPDlayer *gpl = gpencil_layer_getactive(ob->gpd);
+		if (gpl) {
+			if (gpl->actframe) {
+				// XXX: assumes that frame has been fetched already
+				return (gpl->actframe->framenum == cfra);
+			}
+			else {
+				/* XXX: disabled as could be too much of a penalty */
+				/* return BKE_gpencil_layer_find_frame(gpl, cfra); */
+			}
+		}
+	}
+	
+	return false;
+}
+
+/* ******************************************************** */
 /* Poll Callbacks */
 
 /* poll callback for adding data/layers - special */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index f24705e..4761903 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -79,6 +79,8 @@ struct bGPdata *ED_gpencil_data_get_active_direct(struct ID *screen_id, struct S
 /* 3D View */
 struct bGPdata  *ED_gpencil_data_get_active_v3d(struct Scene *scene, struct View3D *v3d);
 
+bool ED_gpencil_has_keyframe_v3d(struct Scene *scene, struct Object *ob, int cfra);
+
 /* ----------- Stroke Editing Utilities ---------------- */
 
 bool ED_gpencil_stroke_can_use_direct(const struct ScrArea *sa, const struct bGPDstroke *gps);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 361cf2d..dc0047d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -941,6 +941,8 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
 		/* color depends on whether there is a keyframe */
 		if (id_frame_has_keyframe((ID *)ob, /* BKE_scene_frame_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL))
 			UI_ThemeColor(TH_VERTEX_SELECT);
+		else if (ED_gpencil_has_keyframe_v3d(scene, ob, cfra))
+			UI_ThemeColor(TH_CFRAME); // XXX
 		else
 			UI_ThemeColor(TH_TEXT_HI);
 	}




More information about the Bf-blender-cvs mailing list