/* draw keyframe lines for timeline */
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) {
		UI_ThemeColor(TH_TIME_GP_KEYFRAME);
		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
	 */
	if (onlysel == 0) {
		/* set draw color */
		UI_ThemeColorShade(TH_TIME_KEYFRAME, -50);
		time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
	}
	
	/* draw keyframes from selected objects 
	 *  - only do the active object if in posemode (i.e. showing only keyframes for the bones)
	 *    OR the onlysel flag was set, which means that only active object's keyframes should
	 *    be considered
	 */
	UI_ThemeColor(TH_TIME_KEYFRAME);
	
	if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
		/* draw keyframes for active object only */
		time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);
	}
	else {
		bool active_done = false;
		
		/* draw keyframes from all selected objects */
		CTX_DATA_BEGIN (C, Object *, obsel, selected_objects)
		{
			/* last arg is 0, since onlysel doesn't apply here... */
			time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
			
			/* if this object is the active one, set flag so that we don't draw again */
			if (obsel == ob)
				active_done = true;
		}
		CTX_DATA_END;
		
		/* if active object hasn't been done yet, draw it... */
		if (ob && (active_done == 0))
			time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
	}
Example #2
0
static void time_draw_caches_keyframes(Main *bmain, Scene *scene, View2D *v2d, bool onlysel)
{
	CacheFile *cache_file;

	for (cache_file = bmain->cachefiles.first;
	     cache_file;
	     cache_file = cache_file->id.next)
	{
		cache_file->draw_flag &= ~CACHEFILE_KEYFRAME_DRAWN;
	}

	for (Base *base = scene->base.first; base; base = base->next) {
		Object *ob = base->object;

		ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);

		if (md) {
			MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;

			cache_file = mcmd->cache_file;

			if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
				continue;
			}

			cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;

			time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel);
		}

		for (bConstraint *con = ob->constraints.first; con; con = con->next) {
			if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
				continue;
			}

			bTransformCacheConstraint *data = con->data;

			cache_file = data->cache_file;

			if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
				continue;
			}

			cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;

			time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel);
		}
	}
}
Example #3
0
/* draw keyframe lines for timeline */
static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar)
{
	Scene *scene= CTX_data_scene(C);
	Object *ob= CTX_data_active_object(C);
	View2D *v2d= &ar->v2d;
	short onlysel= (stime->flag & TIME_ONLYACTSEL);
	
	/* draw scene keyframes first 
	 *	- don't try to do this when only drawing active/selected data keyframes,
	 *	  since this can become quite slow
	 */
	if (scene && onlysel==0) {
		/* set draw color */
		glColor3ub(0xDD, 0xA7, 0x00);
		time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
	}
	
	/* draw keyframes from selected objects 
	 *	- only do the active object if in posemode (i.e. showing only keyframes for the bones)
	 *	  OR the onlysel flag was set, which means that only active object's keyframes should
	 *	  be considered
	 */
	glColor3ub(0xDD, 0xD7, 0x00);
	
	if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
		/* draw keyframes for active object only */
		time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);
	}
	else {
		short active_done = 0;
		
		/* draw keyframes from all selected objects */
		CTX_DATA_BEGIN(C, Object*, obsel, selected_objects) 
		{
			/* last arg is 0, since onlysel doesn't apply here... */
			time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
			
			/* if this object is the active one, set flag so that we don't draw again */
			if (obsel == ob)
				active_done= 1;
		}
		CTX_DATA_END;
		
		/* if active object hasn't been done yet, draw it... */
		if (ob && (active_done == 0))
			time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
	}