2 measure-grouping-engraver.cc -- implement Measure_grouping_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "side-position-interface.hh"
11 #include "global-context.hh"
12 #include "engraver.hh"
14 #include "translator.icc"
16 class Measure_grouping_engraver : public Engraver
19 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver);
23 Rational stop_grouping_mom_;
25 void process_music ();
26 virtual void finalize ();
27 DECLARE_ACKNOWLEDGER (note_column);
31 Measure_grouping_engraver::finalize ()
35 grouping_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
36 grouping_->suicide ();
42 Measure_grouping_engraver::acknowledge_note_column (Grob_info gi)
45 Side_position_interface::add_support (grouping_, gi.grob ());
49 Measure_grouping_engraver::process_music ()
51 Moment now = now_mom ();
52 if (grouping_ && now.main_part_ >= stop_grouping_mom_ && !now.grace_part_)
54 grouping_->set_bound (RIGHT,
55 unsmob_grob (get_property ("currentMusicalColumn")));
63 SCM grouping = get_property ("beatGrouping");
64 if (scm_is_pair (grouping))
66 Moment *measpos = unsmob_moment (get_property ("measurePosition"));
67 Rational mp = measpos->main_part_;
69 Moment *beatlen_mom = unsmob_moment (get_property ("beatLength"));
70 Rational beat_length = beatlen_mom->main_part_;
73 for (SCM s = grouping; scm_is_pair (s);
74 where += Rational ((int) scm_to_int (scm_car (s))) * beat_length,
77 int grouplen = scm_to_int (scm_car (s));
82 programming_error ("last grouping not finished yet");
86 grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
87 grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
89 stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * beat_length;
90 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
93 grouping_->set_property ("style", ly_symbol2scm ("triangle"));
95 grouping_->set_property ("style", ly_symbol2scm ("bracket"));
103 Measure_grouping_engraver::Measure_grouping_engraver ()
108 ADD_ACKNOWLEDGER (Measure_grouping_engraver, note_column);
109 ADD_TRANSLATOR (Measure_grouping_engraver,
111 "Creates MeasureGrouping to indicate beat subdivision.",
118 "currentMusicalColumn "