Beispiel #1
0
static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
{
	bAnimContext ac;
	Scene *scene;
	float min, max;
	
	/* get editor data */
	if (ANIM_animdata_get_context(C, &ac) == 0)
		return OPERATOR_CANCELLED;
	if (ac.scene == NULL)
		return OPERATOR_CANCELLED;
	else
		scene = ac.scene;
	
	/* set the range directly */
	get_keyframe_extents(&ac, &min, &max, FALSE);
	scene->r.flag |= SCER_PRV_RANGE;
	scene->r.psfra = (int)floor(min + 0.5f);
	scene->r.pefra = (int)floor(max + 0.5f);
	
	/* set notifier that things have changed */
	// XXX err... there's nothing for frame ranges yet, but this should do fine too
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
	
	return OPERATOR_FINISHED;
}
Beispiel #2
0
static int actkeys_viewall(bContext *C, const short onlySel)
{
	bAnimContext ac;
	View2D *v2d;
	float extra;
	
	/* get editor data */
	if (ANIM_animdata_get_context(C, &ac) == 0)
		return OPERATOR_CANCELLED;
	v2d= &ac.ar->v2d;
	
	/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
	get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
	
	extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
	v2d->cur.xmin -= extra;
	v2d->cur.xmax += extra;
	
	/* set vertical range */
	v2d->cur.ymax= 0.0f;
	v2d->cur.ymin= (float)-(v2d->mask.ymax - v2d->mask.ymin);
	
	/* do View2D syncing */
	UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
	
	/* just redraw this view */
	ED_area_tag_redraw(CTX_wm_area(C));
	
	return OPERATOR_FINISHED;
}
Beispiel #3
0
static int actkeys_viewall(bContext *C, const bool only_sel)
{
	bAnimContext ac;
	View2D *v2d;
	float extra, min, max;
	bool found;
	
	/* get editor data */
	if (ANIM_animdata_get_context(C, &ac) == 0)
		return OPERATOR_CANCELLED;
	v2d = &ac.ar->v2d;
	
	/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
	found = get_keyframe_extents(&ac, &min, &max, only_sel);

	if (only_sel && (found == false))
		return OPERATOR_CANCELLED;

	v2d->cur.xmin = min;
	v2d->cur.xmax = max;

	extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
	v2d->cur.xmin -= extra;
	v2d->cur.xmax += extra;
	
	/* set vertical range */
	if (only_sel == false) {
		/* view all -> the summary channel is usually the shows everything, and resides right at the top... */
		v2d->cur.ymax = 0.0f;
		v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
	}
	else {
		/* locate first selected channel (or the active one), and frame those */
		float ymin = v2d->cur.ymin;
		float ymax = v2d->cur.ymax;
		
		if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) {
			/* recenter the view so that this range is in the middle */
			float ymid = (ymax - ymin) / 2.0f + ymin;
			float x_center;
			
			UI_view2d_center_get(v2d, &x_center, NULL);
			UI_view2d_center_set(v2d, x_center, ymid);
		}
	}
	
	/* do View2D syncing */
	UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
	
	/* just redraw this view */
	ED_area_tag_redraw(CTX_wm_area(C));
	
	return OPERATOR_FINISHED;
}
Beispiel #4
0
static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xaxis)
{
	bAnimContext ac;
	View2D *v2d;
	float extra;
	bool found;
	
	/* get editor data */
	if (ANIM_animdata_get_context(C, &ac) == 0)
		return OPERATOR_CANCELLED;
	v2d = &ac.ar->v2d;
	
	/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
	found = get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, only_sel);

	if (only_sel && (found == false))
		return OPERATOR_CANCELLED;
	
	extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
	v2d->cur.xmin -= extra;
	v2d->cur.xmax += extra;
	
	/* set vertical range */
	if (only_xaxis == false) {
		v2d->cur.ymax = 0.0f;
		v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
	}
	
	/* do View2D syncing */
	UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
	
	/* just redraw this view */
	ED_area_tag_redraw(CTX_wm_area(C));
	
	return OPERATOR_FINISHED;
}