]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/measure-grouping-engraver.cc
Don't let lyrics interfere with StaffGrouper.
[lilypond.git] / lily / measure-grouping-engraver.cc
index 03192a1defd611e1895b2e53cbe614a0437540bc..c61dd74c45f2188b4eb52ced9d435dd8284e8b1d 100644 (file)
@@ -1,9 +1,20 @@
 /*
-  measure-grouping-engraver.cc -- implement Measure_grouping_engraver
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 2002--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 2002--2009 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 "warn.hh"
@@ -11,6 +22,7 @@
 #include "global-context.hh"
 #include "engraver.hh"
 #include "spanner.hh"
+#include "beam-settings.hh"
 
 #include "translator.icc"
 
@@ -61,7 +73,16 @@ Measure_grouping_engraver::process_music ()
   if (now.grace_part_)
     return;
 
-  SCM grouping = get_property ("beatGrouping");
+  SCM settings = get_property ("beamSettings");
+  SCM grouping = SCM_EOL;
+  if (scm_is_pair (settings))
+    {
+      SCM time_signature_fraction = get_property ("timeSignatureFraction");
+      grouping = ly_beam_grouping (settings,
+                                   time_signature_fraction,
+                                   ly_symbol2scm ("end"),
+                                   ly_symbol2scm ("*"));
+    }
   if (scm_is_pair (grouping))
     {
       Moment *measpos = unsmob_moment (get_property ("measurePosition"));
@@ -83,19 +104,21 @@ Measure_grouping_engraver::process_music ()
                  programming_error ("last grouping not finished yet");
                  continue;
                }
+              if (grouplen > 1)
+               {
+                grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
+                grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
 
-             grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
-             grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
-
-             stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * beat_length;
-             get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
+                stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * beat_length;
+                get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
 
-             if (grouplen == 3)
-               grouping_->set_property ("style", ly_symbol2scm ("triangle"));
-             else
-               grouping_->set_property ("style", ly_symbol2scm ("bracket"));
+                if (grouplen == 3)
+                  grouping_->set_property ("style", ly_symbol2scm ("triangle"));
+                else
+                  grouping_->set_property ("style", ly_symbol2scm ("bracket"));
 
-             break;
+                break;
+               }
            }
        }
     }
@@ -118,7 +141,7 @@ ADD_TRANSLATOR (Measure_grouping_engraver,
                "beatLength "
                "currentMusicalColumn "
                "measurePosition "
-               "beatGrouping ",
+               "beamSettings ",
 
                /* write */
                ""