2 measure-grouping-engraver.cc -- implement Measure_grouping_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "side-position-interface.hh"
11 #include "global-context.hh"
12 #include "engraver.hh"
14 class Measure_grouping_engraver : public Engraver
17 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver);
21 Rational stop_grouping_mom_;
23 virtual void process_music ();
24 virtual void finalize ();
25 virtual void acknowledge_grob (Grob_info);
29 Measure_grouping_engraver::finalize ()
33 grouping_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
34 grouping_->suicide ();
41 Measure_grouping_engraver::acknowledge_grob (Grob_info gi)
45 Side_position_interface::add_support (grouping_, gi.grob_);
50 Measure_grouping_engraver::process_music ()
52 Moment now = now_mom ();
53 if (grouping_ && now.main_part_ >= stop_grouping_mom_ && !now.grace_part_)
55 grouping_->set_bound (RIGHT,
56 unsmob_grob (get_property ("currentMusicalColumn")));
64 SCM grouping = get_property ("beatGrouping");
65 if (scm_is_pair (grouping))
67 Moment *measpos = unsmob_moment (get_property ("measurePosition"));
68 Rational mp = measpos->main_part_;
70 Moment * beatlen = unsmob_moment (get_property ("beatLength"));
71 Rational bl = beatlen->main_part_;
74 for (SCM s = grouping; scm_is_pair (s);
75 where += Rational ((int) scm_to_int (scm_car (s))) * bl,
79 int grouplen = scm_to_int (scm_car (s));
84 programming_error ("Huh, last grouping not finished yet.");
88 grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
89 grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
93 stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * bl ;
94 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
97 grouping_->set_property ("style", ly_symbol2scm ("triangle"));
99 grouping_->set_property ("style", ly_symbol2scm ("bracket"));
106 Measure_grouping_engraver::Measure_grouping_engraver ()
111 ADD_TRANSLATOR (Measure_grouping_engraver,
112 /* descr */ "Creates MeasureGrouping to indicate beat subdivision.",
113 /* creats*/ "MeasureGrouping",
115 /* acks */ "note-column-interface",
116 /* reads */ "beatGrouping beatLength measurePosition currentMusicalColumn",