[Bf-blender-cvs] [b3431a88465] master: Fix Drivers Editor showing playhead on the X Axis

Philipp Oeser noreply at git.blender.org
Tue Sep 28 11:15:32 CEST 2021


Commit: b3431a88465db2433b46e1f6426c801125d0047d
Author: Philipp Oeser
Date:   Fri Sep 3 16:04:01 2021 +0200
Branches: master
https://developer.blender.org/rBb3431a88465db2433b46e1f6426c801125d0047d

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

===================================================================

M	source/blender/editors/animation/anim_ops.c
M	source/blender/editors/animation/time_scrub_ui.c
M	source/blender/editors/include/ED_time_scrub_ui.h
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_sequencer/sequencer_draw.c

===================================================================

diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index b4ea33920b2..3958c7f9e34 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -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");
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 8aeb6a57124..70a8973864c 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -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();
 }
 
diff --git a/source/blender/editors/include/ED_time_scrub_ui.h b/source/blender/editors/include/ED_time_scrub_ui.h
index 6420aaf5ef0..812cb31c9b0 100644
--- a/source/blender/editors/include/ED_time_scrub_ui.h
+++ b/source/blender/editors/include/ED_time_scrub_ui.h
@@ -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,
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index f59429ba981..738eeb21e2e 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -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);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 86e12714d62..3512db961ab 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -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. */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 987d06cfe5c..8b44c26f07c 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -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);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 146ea970087..04377f02a7f 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -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);
 }



More information about the Bf-blender-cvs mailing list