예제 #1
0
/* Graph Editor View Settings */
static void graph_panel_view(const bContext *C, Panel *pa)
{
	bScreen *sc = CTX_wm_screen(C);
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	Scene *scene = CTX_data_scene(C);
	PointerRNA spaceptr, sceneptr;
	uiLayout *col, *sub, *row;
	
	/* get RNA pointers for use when creating the UI elements */
	RNA_id_pointer_create(&scene->id, &sceneptr);
	RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);

	/* 2D-Cursor */
	col = uiLayoutColumn(pa->layout, FALSE);
	uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
		
	sub = uiLayoutColumn(col, TRUE);
	uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
	uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");

	sub = uiLayoutColumn(col, TRUE);
	uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
	row = uiLayoutSplit(sub, 0.7f, TRUE);
	uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
	uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
	row = uiLayoutSplit(sub, 0.7f, TRUE);
	uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
	uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
}
예제 #2
0
/* drivers panel poll */
static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
{
	SpaceIpo *sipo = CTX_wm_space_graph(C);

	if (sipo->mode != SIPO_MODE_DRIVERS)
		return 0;

	return graph_panel_context(C, NULL, NULL);
}
예제 #3
0
/* update callback for active keyframe properties - base updates stuff */
static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr))
{
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
	FCurve *fcu = (FCurve *)fcu_ptr;
	
	/* make sure F-Curve and its handles are still valid after this editing */
	sort_time_fcurve(fcu);
	testhandles_fcurve(fcu, use_handle);
}
예제 #4
0
static int toggle_time_exec(bContext *C, wmOperator *UNUSED(op))
{
    ScrArea *curarea= CTX_wm_area(C);

    if (curarea == NULL)
        return OPERATOR_CANCELLED;

    /* simply toggle draw frames flag in applicable spaces */
    // XXX or should relevant spaces define their own version of this?
    switch (curarea->spacetype) {
    case SPACE_TIME: /* TimeLine */
    {
        SpaceTime *stime= CTX_wm_space_time(C);
        stime->flag ^= TIME_DRAWFRAMES;
    }
    break;
    case SPACE_ACTION: /* Action Editor */
    {
        SpaceAction *saction= CTX_wm_space_action(C);
        saction->flag ^= SACTION_DRAWTIME;
    }
    break;
    case SPACE_IPO: /* Graph Editor */
    {
        SpaceIpo *sipo= CTX_wm_space_graph(C);
        sipo->flag ^= SIPO_DRAWTIME;
    }
    break;
    case SPACE_NLA: /* NLA Editor */
    {
        SpaceNla *snla= CTX_wm_space_nla(C);
        snla->flag ^= SNLA_DRAWTIME;
    }
    break;
    case SPACE_SEQ: /* Sequencer */
    {
        SpaceSeq *sseq= CTX_wm_space_seq(C);
        sseq->flag ^= SEQ_DRAWFRAMES;
    }
    break;

    default: /* editor doesn't show frames */
        return OPERATOR_CANCELLED; // XXX or should we pass through instead?
    }

    ED_area_tag_redraw(curarea);

    return OPERATOR_FINISHED;
}
예제 #5
0
static int view_toggle_handles_exec (bContext *C, wmOperator *UNUSED(op))
{
	SpaceIpo *sipo= CTX_wm_space_graph(C);
	ARegion *ar= CTX_wm_region(C);
	
	if (sipo == NULL)
		return OPERATOR_CANCELLED;
	
	/* toggle flag to hide handles */
	sipo->flag ^= SIPO_NOHANDLES;
	
	/* request refresh of keys area */
	ED_region_tag_redraw(ar);
	
	return OPERATOR_FINISHED;
}
예제 #6
0
/* Set the new frame number */
static void graphview_cursor_apply(bContext *C, wmOperator *op)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	
	/* adjust the frame 
	 * NOTE: sync this part of the code with ANIM_OT_change_frame
	 */
	CFRA = RNA_int_get(op->ptr, "frame");
	SUBFRA = 0.f;
	sound_seek_scene(bmain, scene);
	
	/* set the cursor value */
	sipo->cursorVal = RNA_float_get(op->ptr, "value");
	
	/* send notifiers - notifiers for frame should force an update for both vars ok... */
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
예제 #7
0
/* Set the new frame number */
static void graphview_cursor_apply(bContext *C, wmOperator *op)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	float frame = RNA_float_get(op->ptr, "frame"); /* this isn't technically "frame", but it'll do... */
	
	/* adjust the frame or the cursor x-value */
	if (sipo->mode == SIPO_MODE_DRIVERS) {
		/* adjust cursor x-value */
		sipo->cursorTime = frame;
	}
	else {
		/* adjust the frame 
		 * NOTE: sync this part of the code with ANIM_OT_change_frame
		 */
		/* 1) frame is rounded to the nearest int, since frames are ints */
		CFRA = round_fl_to_int(frame);
		
		if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
			/* Clip to preview range
			 * NOTE: Preview range won't go into negative values,
			 *       so only clamping once should be fine.
			 */
			CLAMP(CFRA, PSFRA, PEFRA);
		}
		else {
			/* Prevent negative frames */
			FRAMENUMBER_MIN_CLAMP(CFRA);
		}
		
		SUBFRA = 0.0f;
		BKE_sound_seek_scene(bmain, scene);
	}
	
	/* set the cursor value */
	sipo->cursorVal = RNA_float_get(op->ptr, "value");
	
	/* send notifiers - notifiers for frame should force an update for both vars ok... */
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}