]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tuplet-engraver.cc
Imported Upstream version 2.14.2
[lilypond.git] / lily / tuplet-engraver.cc
index 17eed00f35c11bde96d043c9b1603cc5161e912f..39c120dd751be00ac4b640a45ae960c165d1ff66 100644 (file)
@@ -1,9 +1,20 @@
 /*
-  tuplet-engraver.cc -- implement Tuplet_engraver
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 1998--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 1998--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "beam.hh"
@@ -78,7 +89,7 @@ Tuplet_engraver::listen_tuplet_span (Stream_event *ev)
        {
          /*
            discard duplicates.
-          */
+         */
          if (new_tuplets_[i].stop_moment_ == d.stop_moment_)
            return;
        }
@@ -87,13 +98,13 @@ Tuplet_engraver::listen_tuplet_span (Stream_event *ev)
     }
   else if (dir == STOP)
     {
-    if (tuplets_.size ())
-    {
-      stopped_tuplets_.push_back (tuplets_.back ());
-      tuplets_.pop_back ();
-    }
-    else
-      ev->origin ()->warning (_f ("No tuplet to end"));
+      if (tuplets_.size ())
+       {
+         stopped_tuplets_.push_back (tuplets_.back ());
+         tuplets_.pop_back ();
+       }
+      else if (!to_boolean (get_property ("skipTypesetting"))) 
+       ev->origin ()->warning (_ ("No tuplet to end"));
     }
   else 
     ev->origin ()->programming_error ("direction tuplet-span-event_ invalid.");
@@ -133,12 +144,16 @@ Tuplet_engraver::process_music ()
            }
          else if (!bracket->get_bound (RIGHT))
            {
-             bracket->set_bound (RIGHT,
-                                 bracket->get_bound (LEFT));
-             number->set_bound (RIGHT,
-                                stopped_tuplets_[i].bracket_->get_bound (LEFT));
-           }
-         
+             if (bracket->get_bound (LEFT))
+               {
+                 bracket->set_bound (RIGHT,
+                                     bracket->get_bound (LEFT));
+                 number->set_bound (RIGHT,
+                                    stopped_tuplets_[i].bracket_->get_bound (LEFT));
+               }
+             else
+               programming_error ("stopped tuplet bracket has neither left nor right bound");
+           }     
          // todo: scrap last_tuplets_, use stopped_tuplets_ only.
          // clear stopped_tuplets_ at start_translation_timestep
          last_tuplets_.push_back (bracket);
@@ -196,6 +211,10 @@ void
 Tuplet_engraver::start_translation_timestep ()
 {
   last_tuplets_.clear ();
+  /*
+    May seem superfluous, but necessary for skipTypesetting.
+   */
+  new_tuplets_.clear ();       
 }
 
 void
@@ -215,11 +234,17 @@ Tuplet_engraver::Tuplet_engraver ()
 
 ADD_ACKNOWLEDGER (Tuplet_engraver, note_column);
 ADD_TRANSLATOR (Tuplet_engraver,
-               /* doc */ "Catch TupletSpannerEvent and generate appropriate bracket  ",
+               /* doc */
+               "Catch tuplet events and generate appropriate bracket.",
+               
                /* create */
                "TupletBracket "
                "TupletNumber ",
+
                /* read */
                "tupletFullLength "
                "tupletFullLengthNote ",
-               /* write */ "");
+
+               /* write */
+               ""
+               );