Commit: 65072499c65affaf26e2e6912129387ba54211f1 Author: Joshua Leung Date: Sat Oct 10 18:26:09 2015 +1300 Branches: master https://developer.blender.org/rB65072499c65affaf26e2e6912129387ba54211f1
Graph Editor: Allow "cursor x" to have fractional values when working with Drivers (T46004) When working is the Graph Editor it can be very important to be able to work with fractions (sub integers), especially when working with Drivers. Currently the "Cursor Y" is hooked up to "cursor_position_y" which allows fractions but "Cursor X" is directly hooked up to "frame_current" which is an integer. This commit adds initial support for this feature. * When in Drivers mode, the x-part of the cursor is mapped to a new "cursor_position_x" value which can have fractional values. Animation mode however remains mapped to frame_current * This commit only adds the UI/property/drawing tweaks needed to support this. Many operators still need to be modified to consider this value instead of the current frame, for this to be more useful. =================================================================== M source/blender/editors/space_graph/graph_buttons.c M source/blender/editors/space_graph/graph_ops.c M source/blender/editors/space_graph/space_graph.c M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c =================================================================== diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 713f101..1bab7bd 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -133,7 +133,10 @@ static void graph_panel_view(const bContext *C, Panel *pa) 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); + if (sipo->mode == SIPO_MODE_DRIVERS) + uiItemR(row, &spaceptr, "cursor_position_x", 0, IFACE_("Cursor X"), ICON_NONE); + else + 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); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 07c16fa..0f0a329 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -83,13 +83,20 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op) 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"); - FRAMENUMBER_MIN_CLAMP(CFRA); - SUBFRA = 0.f; - BKE_sound_seek_scene(bmain, scene); + /* adjust the frame or the cursor x-value */ + if (sipo->mode == SIPO_MODE_DRIVERS) { + /* adjust cursor x-value */ + sipo->cursorTime = (float)RNA_int_get(op->ptr, "frame"); // XXX: need new prop + } + else { + /* adjust the frame + * NOTE: sync this part of the code with ANIM_OT_change_frame + */ + CFRA = RNA_int_get(op->ptr, "frame"); + FRAMENUMBER_MIN_CLAMP(CFRA); + SUBFRA = 0.f; + BKE_sound_seek_scene(bmain, scene); + } /* set the cursor value */ sipo->cursorVal = RNA_float_get(op->ptr, "value"); @@ -200,7 +207,7 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Cursor"; ot->idname = "GRAPH_OT_cursor_set"; - ot->description = "Interactively set the current frame number and value cursor"; + ot->description = "Interactively set the current frame and value cursor"; /* api callbacks */ ot->exec = graphview_cursor_exec; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index ea5cd56..7cbd310 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -286,10 +286,33 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) glDisable(GL_BLEND); } - /* current frame */ - if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((sipo->flag & SIPO_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; - ANIM_draw_cfra(C, v2d, flag); + /* current frame or vertical component of vertical component of the cursor */ + if (sipo->mode == SIPO_MODE_DRIVERS) { + /* cursor x-value */ + float vec[2]; + + vec[0] = sipo->cursorTime; + + /* to help differentiate this from the current frame, draw slightly darker like the horizontal one */ + UI_ThemeColorShadeAlpha(TH_CFRAME, -40, -50); + glLineWidth(2.0); + + glEnable(GL_BLEND); + glBegin(GL_LINE_STRIP); + vec[1] = v2d->cur.ymin; + glVertex2fv(vec); + + vec[1] = v2d->cur.ymax; + glVertex2fv(vec); + glEnd(); // GL_LINE_STRIP + glDisable(GL_BLEND); + } + else { + /* current frame */ + if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((sipo->flag & SIPO_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; + ANIM_draw_cfra(C, v2d, flag); + } /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index b8f2ce1..d9d3b5c 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -327,8 +327,10 @@ typedef struct SpaceIpo { short autosnap; /* time-transform autosnapping settings for Graph editor (eAnimEdit_AutoSnap in DNA_action_types.h) */ int flag; /* settings for Graph editor (eGraphEdit_Flag) */ + float cursorTime; /* time value for cursor (when in drivers mode; animation uses current frame) */ float cursorVal; /* cursor value (y-value, x-value is current frame) */ int around; /* pivot point for transforms */ + int pad; } SpaceIpo; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5338d4b..9e660ad 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3504,6 +3504,11 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Cursor", "Show 2D cursor"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + prop = RNA_def_property(srna, "cursor_position_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "cursorTime"); + RNA_def_property_ui_text(prop, "Cursor X-Value", "Graph Editor 2D-Value cursor - X-Value component"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + prop = RNA_def_property(srna, "cursor_position_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "cursorVal"); RNA_def_property_ui_text(prop, "Cursor Y-Value", "Graph Editor 2D-Value cursor - Y-Value component"); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs