Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2015-10-10 08:26:09 +0300
committerJoshua Leung <aligorith@gmail.com>2015-10-26 10:18:10 +0300
commit65072499c65affaf26e2e6912129387ba54211f1 (patch)
tree9be728f60cb29e26e980123177235a9d022f6250
parent2092056745064f8ce41863f1856d902588dc39f9 (diff)
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.
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c5
-rw-r--r--source/blender/editors/space_graph/graph_ops.c23
-rw-r--r--source/blender/editors/space_graph/space_graph.c31
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_space.c5
5 files changed, 53 insertions, 13 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 713f101accb..1bab7bd349c 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 07c16fa2cc4..0f0a329f87a 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 ea5cd56b1da..7cbd310301c 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 b8f2ce1b2ea..d9d3b5cc37d 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 5338d4b3900..9e660ad01e8 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");