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>
11 #include "side-position-interface.hh"
12 #include "global-context.hh"
13 #include "engraver.hh"
15 class Measure_grouping_engraver : public Engraver
18 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver);
22 Rational stop_grouping_mom_;
24 virtual void process_music ();
25 virtual void finalize ();
26 virtual void acknowledge_grob (Grob_info);
30 Measure_grouping_engraver::finalize ()
34 grouping_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
35 typeset_grob (grouping_);
36 grouping_->suicide ();
43 Measure_grouping_engraver::acknowledge_grob (Grob_info gi)
47 Side_position_interface::add_support (grouping_, gi.grob_);
52 Measure_grouping_engraver::process_music ()
54 Moment now = now_mom ();
55 if (grouping_ && now.main_part_ >= stop_grouping_mom_ && !now.grace_part_)
57 grouping_->set_bound (RIGHT,
58 unsmob_grob (get_property ("currentMusicalColumn")));
59 typeset_grob (grouping_);
66 SCM grouping = get_property ("beatGrouping");
67 if (gh_pair_p (grouping))
69 Moment *measpos = unsmob_moment (get_property ("measurePosition"));
70 Rational mp = measpos->main_part_;
72 Moment * beatlen = unsmob_moment (get_property ("beatLength"));
73 Rational bl = beatlen->main_part_;
76 for (SCM s = grouping; gh_pair_p (s);
77 where += Rational (gh_scm2int (gh_car (s))) * bl,
81 int grouplen = gh_scm2int (gh_car (s));
86 programming_error ("Huh, last grouping not finished yet.");
90 grouping_ = make_spanner ("MeasureGrouping");
91 grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
92 announce_grob (grouping_, SCM_EOL);
95 stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * bl ;
96 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
99 grouping_->set_property ("style", ly_symbol2scm ("triangle"));
101 grouping_->set_property ("style", ly_symbol2scm ("bracket"));
108 Measure_grouping_engraver::Measure_grouping_engraver ()
113 ENTER_DESCRIPTION (Measure_grouping_engraver,
114 /* descr */ "Creates Measure_grouping objects using beatGrouping property",
115 /* creats*/ "MeasureGrouping",
117 /* acks */ "note-column-interface",
118 /* reads */ "beatGrouping beatLength measurePosition currentMusicalColumn",