[Bf-blender-cvs] [d5414307856] master: UI: Show marker lines in remaining animation spaces

Jacques Lucke noreply at git.blender.org
Tue Feb 26 17:25:23 CET 2019


Commit: d54143078562fbf7780f0da8ab5c6da79a9c21b1
Author: Jacques Lucke
Date:   Tue Feb 26 17:24:36 2019 +0100
Branches: master
https://developer.blender.org/rBd54143078562fbf7780f0da8ab5c6da79a9c21b1

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

===================================================================

M	release/scripts/startup/bl_ui/space_dopesheet.py
M	release/scripts/startup/bl_ui/space_nla.py
M	release/scripts/startup/bl_ui/space_time.py
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 5a75ddffd23..3db7bca510a 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -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")
diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py
index 121490b3fcd..b51a42a04cb 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -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")
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index 0ae28ae38e7..726081b2bf5 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -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")
 
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);
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 196d4108d93..a52145a0416 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -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;
 
 
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index e3d4337634e..efa1c0e5010 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -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;
 
 /** \} */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 6782f253717..ccc18b49850 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -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);



More information about the Bf-blender-cvs mailing list