Fix Drivers Editor showing playhead on the X Axis

Currently the Drivers Editor shows this (the blue thing can be dragged
to change frame):
{F10647661}

But the Drivers Editors X axis is the output of the driver [which can be
further tweaked by the curve] not time(frame).
So it seems better to not mix them here, it is just confusing to have
two different units on one axis.
Especially since what we really want to look at in X (the drivers output
value) can be in a totally unrelated range compared to frames, so e.g.
we might be interested in a drivers range from 0.0 to 1.0 and a
framerange of 100 to 200, so putting this on one axis just does not make
sense. Better to use a separate timeline for this.

Note 2.79 also did not do this.

Maniphest Tasks: T91157

Differential Revision: https://developer.blender.org/D12392
This commit is contained in:
Philipp Oeser 2021-09-03 16:04:01 +02:00
parent 6f29801f1b
commit b3431a8846
Notes: blender-bot 2023-05-03 10:14:48 +02:00
Referenced by commit 6b8dde93b0, Fix T95531: Draw y axis values in Driver Editor
Referenced by commit ea3b2e8736, Fix T95531: Draw y axis values in Driver Editor
Referenced by issue #95531, Driver Editor UI - Y-axis numbers missing
Referenced by issue #91157, Drivers Editor : Frame indicator/controller & cursor problem
7 changed files with 35 additions and 27 deletions

View File

@ -74,9 +74,16 @@ static bool change_frame_poll(bContext *C)
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
if (area) {
if (ELEM(area->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP, SPACE_GRAPH)) {
if (ELEM(area->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
return true;
}
if (area->spacetype == SPACE_GRAPH) {
const SpaceGraph *sipo = area->spacedata.first;
/* Driver Editor's X axis is not time. */
if (sipo->mode != SIPO_MODE_DRIVERS) {
return true;
}
}
}
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");

View File

@ -91,8 +91,7 @@ static void draw_current_frame(const Scene *scene,
bool display_seconds,
const View2D *v2d,
const rcti *scrub_region_rect,
int current_frame,
bool draw_line)
int current_frame)
{
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
int frame_x = UI_view2d_view_to_region_x(v2d, current_frame);
@ -106,21 +105,19 @@ static void draw_current_frame(const Scene *scene,
float bg_color[4];
UI_GetThemeColorShade4fv(TH_CFRAME, -5, bg_color);
if (draw_line) {
/* Draw vertical line to from the bottom of the current frame box to the bottom of the screen.
*/
const float subframe_x = UI_view2d_view_to_region_x(v2d, BKE_scene_ctime_get(scene));
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_CFRAME);
immRectf(pos,
subframe_x - U.pixelsize,
scrub_region_rect->ymax - box_padding,
subframe_x + U.pixelsize,
0.0f);
immUnbindProgram();
}
/* Draw vertical line to from the bottom of the current frame box to the bottom of the screen.
*/
const float subframe_x = UI_view2d_view_to_region_x(v2d, BKE_scene_ctime_get(scene));
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_CFRAME);
immRectf(pos,
subframe_x - U.pixelsize,
scrub_region_rect->ymax - box_padding,
subframe_x + U.pixelsize,
0.0f);
immUnbindProgram();
UI_draw_roundbox_corner_set(UI_CNR_ALL);
@ -152,8 +149,7 @@ static void draw_current_frame(const Scene *scene,
void ED_time_scrub_draw_current_frame(const ARegion *region,
const Scene *scene,
bool display_seconds,
bool draw_line)
bool display_seconds)
{
const View2D *v2d = &region->v2d;
GPU_matrix_push_projection();
@ -162,7 +158,7 @@ void ED_time_scrub_draw_current_frame(const ARegion *region,
rcti scrub_region_rect;
get_time_scrub_region_rect(region, &scrub_region_rect);
draw_current_frame(scene, display_seconds, v2d, &scrub_region_rect, scene->r.cfra, draw_line);
draw_current_frame(scene, display_seconds, v2d, &scrub_region_rect, scene->r.cfra);
GPU_matrix_pop_projection();
}

View File

@ -33,8 +33,7 @@ struct wmEvent;
void ED_time_scrub_draw_current_frame(const struct ARegion *region,
const struct Scene *scene,
bool display_seconds,
bool draw_line);
bool display_seconds);
void ED_time_scrub_draw(const struct ARegion *region,
const struct Scene *scene,

View File

@ -247,7 +247,7 @@ static void action_main_region_draw_overlay(const bContext *C, ARegion *region)
View2D *v2d = &region->v2d;
/* scrubbing region */
ED_time_scrub_draw_current_frame(region, scene, saction->flag & SACTION_DRAWTIME, true);
ED_time_scrub_draw_current_frame(region, scene, saction->flag & SACTION_DRAWTIME);
/* scrollers */
UI_view2d_scrollers_draw(v2d, NULL);

View File

@ -309,12 +309,18 @@ static void graph_main_region_draw_overlay(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
const SpaceGraph *sipo = CTX_wm_space_graph(C);
/* Driver Editor's X axis is not time. */
if (sipo->mode == SIPO_MODE_DRIVERS) {
return;
}
const Scene *scene = CTX_data_scene(C);
const bool draw_vert_line = sipo->mode != SIPO_MODE_DRIVERS;
View2D *v2d = &region->v2d;
/* scrubbing region */
ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME, draw_vert_line);
ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME);
/* scrollers */
/* FIXME: args for scrollers depend on the type of data being shown. */

View File

@ -289,7 +289,7 @@ static void nla_main_region_draw_overlay(const bContext *C, ARegion *region)
View2D *v2d = &region->v2d;
/* scrubbing region */
ED_time_scrub_draw_current_frame(region, scene, snla->flag & SNLA_DRAWTIME, true);
ED_time_scrub_draw_current_frame(region, scene, snla->flag & SNLA_DRAWTIME);
/* scrollers */
UI_view2d_scrollers_draw(v2d, NULL);

View File

@ -3294,6 +3294,6 @@ void draw_timeline_seq_display(const bContext *C, ARegion *region)
UI_view2d_view_restore(C);
}
ED_time_scrub_draw_current_frame(region, scene, !(sseq->flag & SEQ_DRAWFRAMES), true);
ED_time_scrub_draw_current_frame(region, scene, !(sseq->flag & SEQ_DRAWFRAMES));
UI_view2d_scrollers_draw(v2d, NULL);
}