forked from bartvdbraak/blender
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
This commit is contained in:
parent
2b3553eff2
commit
d541430785
@ -337,6 +337,7 @@ class DOPESHEET_MT_view(Menu):
|
||||
layout.prop(st, "show_group_colors")
|
||||
layout.prop(st, "show_interpolation")
|
||||
layout.prop(st, "show_extremes")
|
||||
layout.prop(st, "show_marker_lines")
|
||||
layout.prop(st, "use_auto_merge_keyframes")
|
||||
|
||||
layout.prop(st, "show_seconds")
|
||||
|
@ -100,6 +100,7 @@ class NLA_MT_view(Menu):
|
||||
|
||||
layout.prop(st, "show_strip_curves")
|
||||
layout.prop(st, "show_local_markers")
|
||||
layout.prop(st, "show_marker_lines")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("anim.previewrange_set")
|
||||
|
@ -134,6 +134,7 @@ class TIME_MT_view(Menu):
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop(st, "show_marker_lines")
|
||||
layout.prop(st, "show_frame_indicator")
|
||||
layout.prop(scene, "show_keys_from_selected_only")
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -851,6 +851,8 @@ typedef enum eSAction_Flag {
|
||||
SACTION_SHOW_INTERPOLATION = (1 << 12),
|
||||
/* show extremes */
|
||||
SACTION_SHOW_EXTREMES = (1 << 13),
|
||||
/* show vertical line markers */
|
||||
SACTION_SHOW_MARKER_LINES = (1 << 14),
|
||||
} eSAction_Flag;
|
||||
|
||||
|
||||
|
@ -500,6 +500,8 @@ typedef enum eSpaceNla_Flag {
|
||||
SNLA_NOREALTIMEUPDATES = (1 << 6),
|
||||
/* don't show local strip marker indications */
|
||||
SNLA_NOLOCALMARKERS = (1 << 7),
|
||||
/* show vertical line for every marker */
|
||||
SNLA_SHOW_MARKER_LINES = (1 << 8),
|
||||
} eSpaceNla_Flag;
|
||||
|
||||
/** \} */
|
||||
|
@ -4012,6 +4012,12 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
|
||||
"Mark keyframes where the key value flow changes direction, based on comparison with adjacent keys");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_marker_lines", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_SHOW_MARKER_LINES);
|
||||
RNA_def_property_ui_text(prop, "Show Marker Lines",
|
||||
"Show a vertical line for every marker");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
|
||||
|
||||
/* editing */
|
||||
prop = RNA_def_property(srna, "use_auto_merge_keyframes", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NOTRANSKEYCULL);
|
||||
@ -4258,6 +4264,12 @@ static void rna_def_space_nla(BlenderRNA *brna)
|
||||
"Show action-local markers on the strips, useful when synchronizing timing across strips");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NLA, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_marker_lines", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SNLA_SHOW_MARKER_LINES);
|
||||
RNA_def_property_ui_text(prop, "Show Marker Lines",
|
||||
"Show a vertical line for every marker");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
|
||||
|
||||
/* editing */
|
||||
prop = RNA_def_property(srna, "use_realtime_update", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SNLA_NOREALTIMEUPDATES);
|
||||
|
Loading…
Reference in New Issue
Block a user