2 note-spacing-engraver.cc -- implement Note_spacing_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2006--2007 Han-Wen Nienhuys <hanwen@lilypond.org>
10 #include "engraver.hh"
12 #include "grob-array.hh"
15 #include "pointer-group-interface.hh"
17 #include "translator.icc"
19 class Note_spacing_engraver : public Engraver
22 Context *last_spacing_parent_context_;
26 void add_spacing_item (Grob *);
27 TRANSLATOR_DECLARATIONS (Note_spacing_engraver);
30 DECLARE_ACKNOWLEDGER (rhythmic_grob);
31 DECLARE_ACKNOWLEDGER (note_column);
32 void stop_translation_timestep ();
33 virtual void finalize ();
34 virtual void derived_mark () const;
38 Note_spacing_engraver::derived_mark () const
40 if (last_spacing_parent_context_)
41 scm_gc_mark (last_spacing_parent_context_->self_scm ());
44 Note_spacing_engraver::Note_spacing_engraver ()
46 last_spacing_parent_context_ = 0;
52 Note_spacing_engraver::add_spacing_item (Grob *g)
56 spacing_ = make_item ("NoteSpacing", g->self_scm ());
61 Pointer_group_interface::add_grob (spacing_,
62 ly_symbol2scm ("left-items"),
66 Pointer_group_interface::add_grob (last_spacing_,
67 ly_symbol2scm ("right-items"),
74 Note_spacing_engraver::acknowledge_note_column (Grob_info gi)
76 add_spacing_item (gi.grob ());
80 Note_spacing_engraver::acknowledge_rhythmic_grob (Grob_info gi)
82 add_spacing_item (gi.grob ());
86 Note_spacing_engraver::finalize ()
89 && last_spacing_parent_context_
90 && last_spacing_parent_context_ == context ()->get_parent_context ()
91 && !unsmob_grob_array (last_spacing_->get_object ("right-items")))
93 SCM ccol = get_property ("currentCommandColumn");
94 Grob *column = unsmob_grob (ccol);
96 Pointer_group_interface::add_grob (last_spacing_,
97 ly_symbol2scm ("right-items"),
103 Note_spacing_engraver::stop_translation_timestep ()
106 && last_spacing_parent_context_
107 && last_spacing_parent_context_ == context ()->get_parent_context ())
109 Grob *sep = unsmob_grob (get_property ("breakableSeparationItem"));
111 Pointer_group_interface::add_grob (last_spacing_,
112 ly_symbol2scm ("right-items"),
118 last_spacing_ = spacing_;
119 last_spacing_parent_context_ = context ()->get_parent_context ();
125 ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column);
126 ADD_ACKNOWLEDGER (Note_spacing_engraver, rhythmic_grob);
128 ADD_TRANSLATOR (Note_spacing_engraver,
129 /* doc */ "Generates NoteSpacing, an object linking horizontal lines for use in spacing.",
130 /* create */ "NoteSpacing",