Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-02-26 19:24:36 +0300
committerJacques Lucke <mail@jlucke.com>2019-02-26 19:24:36 +0300
commitd54143078562fbf7780f0da8ab5c6da79a9c21b1 (patch)
tree58c6d033aa82c8d64c173dd827283f6928325969 /source/blender/editors
parent2b3553eff2a01cf3d1655183de9ebd416abde9c1 (diff)
UI: Show marker lines in remaining animation spaces
This also includes fixed/slighly refactored drawing code for marker lines. The old code used the wrong height. Reviewers: brecht Differential Revision: https://developer.blender.org/D4411
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_markers.c57
-rw-r--r--source/blender/editors/space_action/space_action.c1
-rw-r--r--source/blender/editors/space_nla/space_nla.c4
3 files changed, 37 insertions, 25 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 2669cf89225..5d85a78905b 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -368,11 +368,35 @@ static void draw_marker_name(
UI_fontstyle_draw_simple(fstyle, x, y, name, text_col);
}
+static void draw_marker_line(const float color[4], float x, float ymin, float ymax)
+{
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
+
+ float viewport_size[4];
+ GPU_viewport_size_get_f(viewport_size);
+ immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
+
+ immUniformColor4fv(color);
+ immUniform1i("colors_len", 0); /* "simple" mode */
+ immUniform1f("dash_width", 6.0f);
+ immUniform1f("dash_factor", 0.5f);
+
+ immBegin(GPU_PRIM_LINES, 2);
+ immVertex2f(pos, x, ymin);
+ immVertex2f(pos, x, ymax);
+ immEnd();
+
+ immUnbindProgram();
+}
+
/* function to draw markers */
static void draw_marker(
- View2D *v2d, const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int flag,
+ const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int flag,
/* avoid re-calculating each time */
- const float ypixels, const float xscale, const float yscale)
+ const float ypixels, const float xscale, int height)
{
const float xpos = marker->frame * xscale;
#ifdef DURIAN_CAMERA_SWITCH
@@ -392,31 +416,15 @@ static void draw_marker(
if (flag & DRAW_MARKERS_LINES)
#endif
{
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
-
- float viewport_size[4];
- GPU_viewport_size_get_f(viewport_size);
- immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
-
+ float color[4];
if (marker->flag & SELECT) {
- immUniformColor4f(1.0f, 1.0f, 1.0f, 0.38f);
+ copy_v4_fl4(color, 1.0f, 1.0f, 1.0f, 0.38f);
}
else {
- immUniformColor4f(0.0f, 0.0f, 0.0f, 0.38f);
+ copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f);
}
- immUniform1i("colors_len", 0); /* "simple" mode */
- immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_factor", 0.5f);
-
- immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, xpos + 0.5f, 12.0f);
- immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
- immEnd();
- immUnbindProgram();
+ draw_marker_line(color, xpos, yoffs + 1.5f * UI_DPI_ICON_SIZE, height);
}
/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
@@ -477,6 +485,7 @@ void ED_markers_draw(const bContext *C, int flag)
scene = CTX_data_scene(C);
v2d = UI_view2d_fromcontext(C);
+ int height = v2d->mask.ymax - v2d->mask.ymin;
if (flag & DRAW_MARKERS_MARGIN) {
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -515,8 +524,8 @@ void ED_markers_draw(const bContext *C, int flag)
if ((marker->frame >= v2d_clip_range_x[0]) &&
(marker->frame <= v2d_clip_range_x[1]))
{
- draw_marker(v2d, fstyle, marker, scene->r.cfra, flag,
- ypixels, xscale, yscale);
+ draw_marker(fstyle, marker, scene->r.cfra, flag,
+ ypixels, xscale, height);
}
}
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index ac82fb2888a..3dffa6afb55 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -243,6 +243,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_orthoSpecial(ar, v2d, 1);
marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
+ if (saction->flag & SACTION_SHOW_MARKER_LINES) marker_flag |= DRAW_MARKERS_LINES;
ED_markers_draw(C, marker_flag);
/* caches */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 232e4e9ce0f..84b8a64bc62 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -301,7 +301,9 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
- ED_markers_draw(C, DRAW_MARKERS_MARGIN);
+ int marker_draw_flag = DRAW_MARKERS_MARGIN;
+ if (snla->flag & SNLA_SHOW_MARKER_LINES) marker_draw_flag |= DRAW_MARKERS_LINES;
+ ED_markers_draw(C, marker_draw_flag);
/* preview range */
UI_view2d_view_ortho(v2d);