Fix InstrumentSwitch grob definition.
[lilypond.git] / lily / grace-spacing-engraver.cc
blob69a42b2d5b727a73690bdd17eea6b8d3598b930d
1 /*
2 grace-spacing-engraver.cc -- implement Grace_spacing_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2006--2007 Han-Wen <hanwen@lilypond.org>
8 */
10 #include "engraver.hh"
11 #include "moment.hh"
12 #include "pointer-group-interface.hh"
13 #include "spanner.hh"
15 #include "translator.icc"
17 class Grace_spacing_engraver : public Engraver
19 TRANSLATOR_DECLARATIONS (Grace_spacing_engraver);
21 protected:
23 Moment last_moment_;
24 Spanner *grace_spacing_;
26 void process_music ();
27 void stop_translation_timestep ();
31 Grace_spacing_engraver::Grace_spacing_engraver ()
33 grace_spacing_ = 0;
36 void
37 Grace_spacing_engraver::process_music ()
39 Moment now = now_mom ();
40 if (!last_moment_.grace_part_ and now.grace_part_)
42 grace_spacing_ = make_spanner ("GraceSpacing", SCM_EOL);
46 if (grace_spacing_ && (now.grace_part_ || last_moment_.grace_part_))
48 Grob *column = unsmob_grob (get_property ("currentMusicalColumn"));
49 Pointer_group_interface::add_grob (grace_spacing_,
50 ly_symbol2scm ("columns"),
51 column);
53 column->set_object ("grace-spacing", grace_spacing_->self_scm ());
55 if (!grace_spacing_->get_bound (LEFT))
56 grace_spacing_->set_bound (LEFT, column);
57 else
58 grace_spacing_->set_bound (RIGHT, column);
62 void
63 Grace_spacing_engraver::stop_translation_timestep ()
65 last_moment_ = now_mom ();
67 if (!last_moment_.grace_part_)
68 grace_spacing_ = 0;
72 ADD_TRANSLATOR (Grace_spacing_engraver,
73 "Bookkeeping of shortest starting and playing notes in grace"
74 " note runs.",
76 /* create */
77 "GraceSpacing ",
79 /* read */
80 "currentMusicalColumn ",
82 /* write */