From be400a0789d9eac2afaa929834ea70aa5d2a39a3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 10 May 2018 17:56:12 +0200 Subject: UI: Fix time cursor number box styling for Clip Editor's Dopesheet/Graph views --- .../editors/space_clip/clip_dopesheet_draw.c | 3 -- .../blender/editors/space_clip/clip_graph_draw.c | 3 -- source/blender/editors/space_clip/clip_intern.h | 1 - source/blender/editors/space_clip/clip_utils.c | 33 ---------------------- source/blender/editors/space_clip/space_clip.c | 21 +++++++++++++- 5 files changed, 20 insertions(+), 41 deletions(-) diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 631d891ce02..7ff7ea73628 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -281,9 +281,6 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) glDisable(GL_BLEND); } - - /* current frame */ - clip_draw_cfra(sc, ar, scene); } void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 1bd1ad69d64..8d29cb73a68 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -349,7 +349,4 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) /* frame range */ clip_draw_sfra_efra(v2d, scene); - - /* current frame */ - clip_draw_cfra(sc, ar, scene); } diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index b0d00744558..ab8a7add009 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -143,7 +143,6 @@ void clip_delete_plane_track(struct bContext *C, struct MovieClip *clip, struct void clip_view_center_to_point(SpaceClip *sc, float x, float y); -void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); /* tracking_ops.c */ diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 9f79e8ffd6b..eeb2526921f 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -264,39 +264,6 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y) sc->yof = (y - 0.5f) * height * aspy; } -void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) -{ - /* Draw a light green line to indicate current frame */ - View2D *v2d = &ar->v2d; - float x = (float)(sc->user.framenr * scene->r.framelen); - - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformThemeColor(TH_CFRAME); - glLineWidth(2.0f); - - immBegin(GWN_PRIM_LINES, 2); - immVertex2f(pos, x, v2d->cur.ymin); - immVertex2f(pos, x, v2d->cur.ymax); - immEnd(); - - immUnbindProgram(); - - UI_view2d_view_orthoSpecial(ar, v2d, 1); - - /* because the frame number text is subject to the same scaling as the contents of the view */ - float xscale; - UI_view2d_scale_get(v2d, &xscale, NULL); - gpuPushMatrix(); - gpuScale2f(1.0f / xscale, 1.0f); - - ED_region_cache_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18); - - /* restore view transform */ - gpuPopMatrix(); -} - void clip_draw_sfra_efra(View2D *v2d, Scene *scene) { UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index e416acf0e58..77ebbd990d8 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -51,6 +51,7 @@ #include "IMB_imbuf_types.h" +#include "ED_anim_api.h" /* for timeline cursor drawing */ #include "ED_mask.h" #include "ED_space_api.h" #include "ED_screen.h" @@ -1245,6 +1246,7 @@ static void graph_region_draw(const bContext *C, ARegion *ar) SpaceClip *sc = CTX_wm_space_clip(C); Scene *scene = CTX_data_scene(C); short unitx, unity; + short cfra_flag = 0; if (sc->flag & SC_LOCK_TIMECURSOR) ED_clip_graph_center_current_frame(scene, ar); @@ -1258,6 +1260,10 @@ static void graph_region_draw(const bContext *C, ARegion *ar) /* data... */ clip_draw_graph(sc, ar, scene); + /* current frame indicator line */ + if (sc->flag & SC_SHOW_SECONDS) cfra_flag |= DRAWCFRA_UNIT_SECONDS; + ANIM_draw_cfra(C, v2d, cfra_flag); + /* reset view matrix */ UI_view2d_view_restore(C); @@ -1267,6 +1273,11 @@ static void graph_region_draw(const bContext *C, ARegion *ar) scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); + + /* currnt frame indicator */ + if (sc->flag & SC_SHOW_SECONDS) cfra_flag |= DRAWCFRA_UNIT_SECONDS; + UI_view2d_view_orthoSpecial(ar, v2d, 1); + ANIM_draw_cfra_number(C, v2d, cfra_flag); } static void dopesheet_region_draw(const bContext *C, ARegion *ar) @@ -1277,7 +1288,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - short unit = 0; + short unit = 0, cfra_flag = 0; if (clip) BKE_tracking_dopesheet_update(&clip->tracking); @@ -1298,6 +1309,10 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) /* data... */ clip_draw_dopesheet_main(sc, ar, scene); + /* current frame indicator line */ + if (sc->flag & SC_SHOW_SECONDS) cfra_flag |= DRAWCFRA_UNIT_SECONDS; + ANIM_draw_cfra(C, v2d, cfra_flag); + /* reset view matrix */ UI_view2d_view_restore(C); @@ -1305,6 +1320,10 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); + + /* currnt frame number indicator */ + UI_view2d_view_orthoSpecial(ar, v2d, 1); + ANIM_draw_cfra_number(C, v2d, cfra_flag); } static void clip_preview_region_draw(const bContext *C, ARegion *ar) -- cgit v1.2.3