Commit: b05fd95f8aaf3eecb88dbb87744fec7bda30fa1f
Author: Joshua Leung
Date: Tue Apr 24 19:18:22 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb05fd95f8aaf3eecb88dbb87744fec7bda30fa1f
Current Frame Indicator tweaks
* Draw the frame/time number box over the scrollbar instead of above it,
to reduce the clutter/clashes with markers.
* Draw the box centered around the line instead of off to one side,
making it clearer that the frame shown is the one being affected.
* Make the box larger than the scrollbar + use white text to make it
stand out from the neighbouring frame numbers (otherwise, it's easy
to misread that it's just another one of those)
===================================================================
M source/blender/editors/animation/anim_draw.c
M source/blender/editors/include/ED_anim_api.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_draw.c
b/source/blender/editors/animation/anim_draw.c
index c70d3133c29..ff39a3baee5 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -69,14 +69,20 @@
/* CURRENT FRAME DRAWING */
/* Draw current frame number in a little green box beside the current frame
indicator */
-static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra,
const bool time)
+void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
{
+ Scene *scene = CTX_data_scene(C);
+ const float time = scene->r.cfra + scene->r.subframe;
+ const float cfra = (float)(time * scene->r.framelen);
+ const bool show_time = (flag & DRAWCFRA_UNIT_SECONDS) != 0;
+
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32,
2, GWN_FETCH_FLOAT);
unsigned char col[4];
float xscale, x, y;
- char numstr[32] = " t"; /* t is the character to start replacing
from */
+ char numstr[32] = " t "; /* t is the character to start replacing
from */
+ float hlen;
int slen;
/* because the frame number text is subject to the same scaling as the
contents of the view */
@@ -86,33 +92,39 @@ static void draw_cfra_number(Scene *scene, View2D *v2d,
const float cfra, const
/* get timecode string
* - padding on str-buf passed so that it doesn't sit on the frame
indicator
- * - power = 0, gives 'standard' behavior for time
- * but power = 1 is required for frames (to get integer frames)
*/
- if (time) {
- BLI_timecode_string_from_time(&numstr[4], sizeof(numstr) - 4,
0, FRA2TIME(cfra), FPS, U.timecode_style);
+ if (show_time) {
+ BLI_timecode_string_from_time(&numstr[2], sizeof(numstr) - 2,
0, FRA2TIME(cfra), FPS, U.timecode_style);
}
else {
- BLI_timecode_string_from_time_seconds(&numstr[4],
sizeof(numstr) - 4, 1, cfra);
+ BLI_timecode_string_from_time_seconds(&numstr[2],
sizeof(numstr) - 2, 1, cfra);
}
slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
+ hlen = slen * 0.5f;
/* get starting coordinates for drawing */
x = cfra * xscale;
- y = 0.9f * U.widget_unit;
+ y = 0.02f * U.widget_unit;
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* draw green box around/behind text */
immUniformThemeColorShade(TH_CFRAME, 0);
- immRectf(pos, x, y, x + slen, y + 0.75f * U.widget_unit);
+ immRectf(pos,
+ x - hlen - 0.20f * U.widget_unit,
+ y,
+ x + hlen + 0.2f * U.widget_unit,
+ y + U.widget_unit);
immUnbindProgram();
/* draw current frame number */
- UI_GetThemeColor4ubv(TH_TEXT, col);
- UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f *
U.widget_unit, numstr, col);
+ UI_GetThemeColor4ubv(TH_TEXT_HI, col);
+ UI_fontstyle_draw_simple(fstyle,
+ x - hlen - 0.15f * U.widget_unit,
+ y + 0.28f * U.widget_unit,
+ numstr, col);
/* restore view transform */
gpuPopMatrix();
@@ -141,12 +153,6 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short
flag)
immVertex2f(pos, x, v2d->cur.ymax);
immEnd();
immUnbindProgram();
-
- /* Draw current frame number in a little box */
- if (flag & DRAWCFRA_SHOW_NUMBOX) {
- UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
- draw_cfra_number(scene, v2d, x, (flag & DRAWCFRA_UNIT_SECONDS)
!= 0);
- }
}
/* *************************************************** */
diff --git a/source/blender/editors/include/ED_anim_api.h
b/source/blender/editors/include/ED_anim_api.h
index 888e9e04636..2165402b6d3 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -535,17 +535,18 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac,
struct AnimData *adt, st
enum eAnimEditDraw_CurrentFrame {
/* plain time indicator with no special indicators */
DRAWCFRA_PLAIN = 0,
- /* draw box indicating current frame number */
- DRAWCFRA_SHOW_NUMBOX = (1 << 0),
/* time indication in seconds or frames */
- DRAWCFRA_UNIT_SECONDS = (1 << 1),
+ DRAWCFRA_UNIT_SECONDS = (1 << 0),
/* draw indicator extra wide (for timeline) */
- DRAWCFRA_WIDE = (1 << 2)
+ DRAWCFRA_WIDE = (1 << 1)
};
/* main call to draw current-frame indicator in an Animation Editor */
void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
+/* main call to draw "number box" in scrollbar for current frame indicator */
+void ANIM_draw_cfra_number(const struct bContext *C, struct View2D *v2d, short
flag);
+
/* ------------- Preview Range Drawing -------------- */
/* main call to draw preview range curtains */
diff --git a/source/blender/editors/space_action/space_action.c
b/source/blender/editors/space_action/space_action.c
index f749cce69e3..5353c250d1e 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -217,7 +217,9 @@ static void action_main_region_draw(const bContext *C,
ARegion *ar)
View2D *v2d = &ar->v2d;
View2DGrid *grid;
View2DScrollers *scrollers;
- short unit = 0, flag = 0;
+ short marker_flag = 0;
+ short cfra_flag = 0;
+ short unit = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -242,15 +244,14 @@ static void action_main_region_draw(const bContext *C,
ARegion *ar)
}
/* current frame */
- if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS;
- if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) flag |=
DRAWCFRA_SHOW_NUMBOX;
- ANIM_draw_cfra(C, v2d, flag);
+ if (saction->flag & SACTION_DRAWTIME) cfra_flag |=
DRAWCFRA_UNIT_SECONDS;
+ ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
- flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ?
DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
- ED_markers_draw(C, flag);
+ marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ?
DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
+ ED_markers_draw(C, marker_flag);
/* caches */
if (saction->mode == SACTCONT_TIMELINE) {
@@ -272,6 +273,12 @@ static void action_main_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);
+
+ /* draw current frame number-indicator on top of scrollers */
+ if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) {
+ UI_view2d_view_orthoSpecial(ar, v2d, 1);
+ ANIM_draw_cfra_number(C, v2d, cfra_flag);
+ }
}
/* add handlers, stuff you only do once or on area/region changes */
diff --git a/source/blender/editors/space_graph/space_graph.c
b/source/blender/editors/space_graph/space_graph.c
index 381cb1d9e6e..f59d70d97c7 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -234,7 +234,7 @@ static void graph_main_region_draw(const bContext *C,
ARegion *ar)
View2DGrid *grid;
View2DScrollers *scrollers;
float col[3];
- short unitx = 0, unity = V2D_UNIT_VALUES, flag = 0;
+ short unitx = 0, unity = V2D_UNIT_VALUES, cfra_flag = 0;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
@@ -281,7 +281,6 @@ static void graph_main_region_draw(const bContext *C,
ARegion *ar)
/* horizontal component of value-cursor (value line before the
current frame line) */
if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) {
-
float y = sipo->cursorVal;
/* Draw a green line to indicate the cursor value */
@@ -320,9 +319,8 @@ static void graph_main_region_draw(const bContext *C,
ARegion *ar)
if (sipo->mode != SIPO_MODE_DRIVERS) {
/* 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);
+ if (sipo->flag & SIPO_DRAWTIME) cfra_flag |=
DRAWCFRA_UNIT_SECONDS;
+ ANIM_draw_cfra(C, v2d, cfra_flag);
}
/* markers */
@@ -345,6 +343,12 @@ static void graph_main_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);
+
+ /* draw current frame number-indicator on top of scrollers */
+ if ((sipo->mode != SIPO_MODE_DRIVERS) && ((sipo->flag &
SIPO_NODRAWCFRANUM) == 0)) {
+ UI_view2d_view_orthoSpecial(ar, v2d, 1);
+ ANIM_draw_cfra_number(C, v2d, cfra_flag);
+ }
}
static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar)
diff --git a/source/blender/editors/space_nla/space_nla.c
b/source/blender/editors/space_nla/space_nla.c
index 616d85f7d9d..331fae606af 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -274,7 +274,7 @@ static void nla_main_region_draw(const bContext *C, ARegion
*ar)
View2D *v2d = &ar->v2d;
View2DGrid *grid;
View2DScrollers *scrollers;
- short unit = 0, flag = 0;
+ short unit = 0, cfra_flag = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -305,9 +305,8 @@ static void nla_main_region_draw(const bContext *C, ARegion
*ar)
UI_view2d_view_ortho(v2d);
/* current frame */
- if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS;
- if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) flag |=
DRAWCFRA_SHOW_NUMBOX;
- ANIM_draw_cfra(C, v2d, flag);
+ if (snla->flag & SNLA_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -328,6 +327,12 @@ static void nla_main_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);
+
+ /* draw current frame number-indicator on top of scrollers */
+ if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) {
+ UI_view2d_view_orthoSpecial(ar, v2d, 1);
+ ANIM_draw_cfra_number(C, v2d,
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs