2 measure-grouping-engraver.cc -- implement Measure_grouping_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "side-position-interface.hh"
11 #include "global-context.hh"
12 #include "engraver.hh"
15 #include "translator.icc"
17 class Measure_grouping_engraver
: public Engraver
20 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver
);
24 Rational stop_grouping_mom_
;
26 void process_music ();
27 virtual void finalize ();
28 DECLARE_ACKNOWLEDGER (note_column
);
32 Measure_grouping_engraver::finalize ()
36 grouping_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
37 grouping_
->suicide ();
43 Measure_grouping_engraver::acknowledge_note_column (Grob_info gi
)
46 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_mom
= unsmob_moment (get_property ("beatLength"));
71 Rational beat_length
= beatlen_mom
->main_part_
;
74 for (SCM s
= grouping
; scm_is_pair (s
);
75 where
+= Rational ((int) scm_to_int (scm_car (s
))) * beat_length
,
78 int grouplen
= scm_to_int (scm_car (s
));
83 programming_error ("last grouping not finished yet");
87 grouping_
= make_spanner ("MeasureGrouping", SCM_EOL
);
88 grouping_
->set_bound (LEFT
, unsmob_grob (get_property ("currentMusicalColumn")));
90 stop_grouping_mom_
= now
.main_part_
+ Rational (grouplen
- 1) * beat_length
;
91 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_
));
94 grouping_
->set_property ("style", ly_symbol2scm ("triangle"));
96 grouping_
->set_property ("style", ly_symbol2scm ("bracket"));
104 Measure_grouping_engraver::Measure_grouping_engraver ()
109 ADD_ACKNOWLEDGER (Measure_grouping_engraver
, note_column
);
110 ADD_TRANSLATOR (Measure_grouping_engraver
,
112 "Create @code{MeasureGrouping} to indicate beat subdivision.",
119 "currentMusicalColumn "