]> git.donarmstrong.com Git - lilypond.git/blob - lily/grace-spacing-engraver.cc
(Two-pass vertical spacing): add documentation for two-pass spacing
[lilypond.git] / lily / grace-spacing-engraver.cc
1 /*
2   grace-spacing-engraver.cc -- implement Grace_spacing_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2006 Han-Wen <hanwen@lilypond.org>
7
8 */
9
10 #include "engraver.hh"
11 #include "moment.hh"
12 #include "pointer-group-interface.hh"
13 #include "spanner.hh"
14
15 #include "translator.icc"
16
17 class Grace_spacing_engraver : public Engraver
18 {
19   TRANSLATOR_DECLARATIONS (Grace_spacing_engraver);
20
21 protected:
22
23   Moment last_moment_;
24   Spanner *grace_spacing_;
25   
26   void process_music ();
27   void stop_translation_timestep ();
28 };
29
30
31 Grace_spacing_engraver::Grace_spacing_engraver ()
32 {
33   grace_spacing_ = 0;
34 }
35
36 void
37 Grace_spacing_engraver::process_music ()
38 {
39   Moment now = now_mom ();
40   if (!last_moment_.grace_part_ and now.grace_part_)
41     {
42       grace_spacing_ = make_spanner ("GraceSpacing", SCM_EOL);
43     }
44
45
46   if (grace_spacing_ && (now.grace_part_ || last_moment_.grace_part_))
47     {
48       Grob *column = unsmob_grob (get_property ("currentMusicalColumn"));
49       Pointer_group_interface::add_grob (grace_spacing_,
50                                          ly_symbol2scm ("columns"),
51                                          column);
52
53       column->set_object ("grace-spacing", grace_spacing_->self_scm ());
54     }
55 }
56
57 void
58 Grace_spacing_engraver::stop_translation_timestep ()
59 {
60   last_moment_ = now_mom ();
61
62   if (!last_moment_.grace_part_)
63     grace_spacing_ = 0;
64 }
65
66
67 ADD_TRANSLATOR (Grace_spacing_engraver,
68                 "Bookkeeping of shortest starting and playing notes in grace note runs.",
69
70                 /* create */
71                 "GraceSpacing ",
72                 
73                 /* accept */
74                 "",
75
76                 /* read */
77                 "currentMusicalColumn ",
78                 
79                 /* write */ "");