AnimEditors: Draw start/end frame ranges on all timelines by default

This uses the global scene range, with styling matching the sequencer's start/end
frame drawing.

(The graph editor's "drivers" mode is exempt, as that doesn't really display time
in a linear way, so the start/end frames don't apply)
This commit is contained in:
2018-04-19 18:03:15 +02:00
parent 0f77060ebc
commit c9fc11a314
6 changed files with 69 additions and 5 deletions

View File

@@ -184,6 +184,48 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
}
}
/* *************************************************** */
/* SCENE FRAME RANGE */
/* Draw frame range guides (for scene frame range) in background */
// TODO: Should we still show these when preview range is enabled?
void ANIM_draw_framerange(Scene *scene, View2D *v2d)
{
/* draw darkened area outside of active timeline frame range */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
if (SFRA < EFRA) {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
immRectf(pos, (float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
glDisable(GL_BLEND);
/* thin lines where the actual frames are */
immUniformThemeColorShade(TH_BACK, -60);
immBegin(GWN_PRIM_LINES, 4);
immVertex2f(pos, (float)SFRA, v2d->cur.ymin);
immVertex2f(pos, (float)SFRA, v2d->cur.ymax);
immVertex2f(pos, (float)EFRA, v2d->cur.ymin);
immVertex2f(pos, (float)EFRA, v2d->cur.ymax);
immEnd();
immUnbindProgram();
}
/* *************************************************** */
/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes) */

View File

@@ -551,6 +551,12 @@ void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
/* main call to draw preview range curtains */
void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d, int end_frame_width);
/* -------------- Frame Range Drawing --------------- */
/* main call to draw normal frame range indicators */
void ANIM_draw_framerange(struct Scene *scene, struct View2D *v2d);
/* ************************************************* */
/* F-MODIFIER TOOLS */

View File

@@ -39,6 +39,7 @@ struct SpaceAction;
struct ScrArea;
struct ARegion;
struct ARegionType;
struct View2D;
struct wmOperatorType;
/* internal exports only */

View File

@@ -34,6 +34,7 @@
#include "DNA_action_types.h"
#include "DNA_group_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
@@ -212,6 +213,8 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceAction *saction = CTX_wm_space_action(C);
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DGrid *grid;
@@ -231,7 +234,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_free(grid);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
/* start and end frame */
ANIM_draw_framerange(scene, v2d);
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
draw_channel_strips(&ac, saction, ar);
@@ -250,11 +256,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
/* caches */
if (saction->mode == SACTCONT_TIMELINE) {
timeline_draw_cache(saction, ac.obact, ac.scene);
timeline_draw_cache(saction, obact, scene);
}
/* preview range */
// XXX: we should always draw the range
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 0);

View File

@@ -226,6 +226,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceIpo *sipo = CTX_wm_space_graph(C);
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DGrid *grid;
@@ -246,7 +247,12 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
/* start and end frame (in F-Curve mode only) */
if (sipo->mode != SIPO_MODE_DRIVERS) {
ANIM_draw_framerange(scene, v2d);
}
/* draw data */
if (ANIM_animdata_get_context(C, &ac)) {
/* draw ghost curves */

View File

@@ -268,6 +268,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceNla *snla = CTX_wm_space_nla(C);
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DGrid *grid;
@@ -287,7 +288,10 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_free(grid);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
/* start and end frame */
ANIM_draw_framerange(scene, v2d);
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
/* strips and backdrops */