]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 1111: Break dynamic line spanner if different direction is explicitly given
authorReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 22 Jul 2011 14:35:41 +0000 (16:35 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 28 Jul 2011 11:59:02 +0000 (13:59 +0200)
input/regression/dynamics-alignment-autobreak.ly [new file with mode: 0644]
lily/dynamic-align-engraver.cc

diff --git a/input/regression/dynamics-alignment-autobreak.ly b/input/regression/dynamics-alignment-autobreak.ly
new file mode 100644 (file)
index 0000000..85e27f0
--- /dev/null
@@ -0,0 +1,17 @@
+\version "2.15.6"
+
+\header {
+  texidoc = "If a dynamic has an explicit direction that differs from the 
+dynamic line spanner's direction, automatically break the dynamic line spanner.
+"
+}
+
+\relative c' {
+  c1^\<
+  c1_\>
+  f,1\p
+
+  c'1^\<
+  c1_\p^\>
+  c1\!
+}
index 591ffee7332cab4c3e8b432d28581dfb77b96807..766b63ed545591bd1087295aa7044ff9d58ea147 100644 (file)
@@ -116,6 +116,23 @@ void
 Dynamic_align_engraver::acknowledge_dynamic (Grob_info info)
 {
   Stream_event *cause = info.event_cause ();
+  // Check whether an existing line spanner has the same direction
+  if (line_ && cause)
+    {
+      Direction line_dir = get_grob_direction (line_);
+      Direction grob_dir = to_dir (cause->get_property ("direction"));
+
+      // If we have an explicit direction for the new dynamic grob
+      // that differs from the current line spanner, break the spanner
+      if (grob_dir && (line_dir != grob_dir))
+        {
+          if (!ended_line_)
+            ended_line_ = line_;
+          line_ = 0;
+          current_dynamic_spanner_ = 0;
+        }
+    }
+
   create_line_spanner (cause);
   if (Spanner::has_interface (info.grob ()))
     {
@@ -131,9 +148,6 @@ Dynamic_align_engraver::acknowledge_dynamic (Grob_info info)
 
   if (cause)
     {
-      // TODO: Compare the direction of the existing spanner with
-      //       the new one and if they differ, create a new line
-      //       spanner.
       if (Direction d = to_dir (cause->get_property ("direction")))
        set_grob_direction (line_, d);
     }