2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2002--2015 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"
26 #include "translator.icc"
28 class Measure_grouping_engraver : public Engraver
31 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver);
35 Rational stop_grouping_mom_;
37 void process_music ();
38 virtual void finalize ();
39 void acknowledge_note_column (Grob_info);
43 Measure_grouping_engraver::finalize ()
47 grouping_->set_bound (RIGHT, unsmob<Grob> (get_property ("currentCommandColumn")));
48 grouping_->suicide ();
54 Measure_grouping_engraver::acknowledge_note_column (Grob_info gi)
57 Side_position_interface::add_support (grouping_, gi.grob ());
61 Measure_grouping_engraver::process_music ()
63 Moment now = now_mom ();
64 if (grouping_ && now.main_part_ >= stop_grouping_mom_ && !now.grace_part_)
66 grouping_->set_bound (RIGHT,
67 unsmob<Grob> (get_property ("currentMusicalColumn")));
75 SCM grouping = get_property ("beatStructure");
76 if (scm_is_pair (grouping))
78 Moment *measpos = unsmob<Moment> (get_property ("measurePosition"));
79 Rational mp = measpos->main_part_;
81 Moment *base_mom = unsmob<Moment> (get_property ("baseMoment"));
82 Rational base_moment = base_mom->main_part_;
85 for (SCM s = grouping; scm_is_pair (s);
86 where += Rational ((int) scm_to_int (scm_car (s))) * base_moment,
89 int grouplen = scm_to_int (scm_car (s));
94 programming_error ("last grouping not finished yet");
99 grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
100 grouping_->set_bound (LEFT, unsmob<Grob> (get_property ("currentMusicalColumn")));
102 stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * base_moment;
103 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
106 grouping_->set_property ("style", ly_symbol2scm ("triangle"));
108 grouping_->set_property ("style", ly_symbol2scm ("bracket"));
117 Measure_grouping_engraver::Measure_grouping_engraver (Context *c)
124 Measure_grouping_engraver::boot ()
126 ADD_ACKNOWLEDGER (Measure_grouping_engraver, note_column);
129 ADD_TRANSLATOR (Measure_grouping_engraver,
131 "Create @code{MeasureGrouping} to indicate beat subdivision.",
139 "currentMusicalColumn "