2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2002--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "side-position-interface.hh"
22 #include "global-context.hh"
23 #include "engraver.hh"
25 #include "beam-settings.hh"
27 #include "translator.icc"
29 class Measure_grouping_engraver : public Engraver
32 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver);
36 Rational stop_grouping_mom_;
38 void process_music ();
39 virtual void finalize ();
40 DECLARE_ACKNOWLEDGER (note_column);
44 Measure_grouping_engraver::finalize ()
48 grouping_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
49 grouping_->suicide ();
55 Measure_grouping_engraver::acknowledge_note_column (Grob_info gi)
58 Side_position_interface::add_support (grouping_, gi.grob ());
62 Measure_grouping_engraver::process_music ()
64 Moment now = now_mom ();
65 if (grouping_ && now.main_part_ >= stop_grouping_mom_ && !now.grace_part_)
67 grouping_->set_bound (RIGHT,
68 unsmob_grob (get_property ("currentMusicalColumn")));
76 SCM settings = get_property ("beamSettings");
77 SCM grouping = SCM_EOL;
78 if (scm_is_pair (settings))
80 SCM time_signature_fraction = get_property ("timeSignatureFraction");
81 grouping = ly_beam_grouping (settings,
82 time_signature_fraction,
83 ly_symbol2scm ("end"),
86 if (scm_is_pair (grouping))
88 Moment *measpos = unsmob_moment (get_property ("measurePosition"));
89 Rational mp = measpos->main_part_;
91 Moment *beatlen_mom = unsmob_moment (get_property ("beatLength"));
92 Rational beat_length = beatlen_mom->main_part_;
95 for (SCM s = grouping; scm_is_pair (s);
96 where += Rational ((int) scm_to_int (scm_car (s))) * beat_length,
99 int grouplen = scm_to_int (scm_car (s));
104 programming_error ("last grouping not finished yet");
109 grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
110 grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
112 stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * beat_length;
113 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
116 grouping_->set_property ("style", ly_symbol2scm ("triangle"));
118 grouping_->set_property ("style", ly_symbol2scm ("bracket"));
127 Measure_grouping_engraver::Measure_grouping_engraver ()
132 ADD_ACKNOWLEDGER (Measure_grouping_engraver, note_column);
133 ADD_TRANSLATOR (Measure_grouping_engraver,
135 "Create @code{MeasureGrouping} to indicate beat subdivision.",
142 "currentMusicalColumn "