2 note-spacing-engraver.cc -- implement Note_spacing_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
10 #include "engraver.hh"
14 #include "pointer-group-interface.hh"
16 #include "translator.icc"
18 class Note_spacing_engraver : public Engraver
21 Context *last_spacing_parent_context_;
25 void add_spacing_item (Grob *);
26 TRANSLATOR_DECLARATIONS (Note_spacing_engraver);
29 DECLARE_ACKNOWLEDGER (rhythmic_grob);
30 DECLARE_ACKNOWLEDGER (note_column);
31 void stop_translation_timestep ();
32 virtual void finalize ();
33 virtual void derived_mark () const;
37 Note_spacing_engraver::derived_mark () const
39 if (last_spacing_parent_context_)
40 scm_gc_mark (last_spacing_parent_context_->self_scm ());
43 Note_spacing_engraver::Note_spacing_engraver ()
45 last_spacing_parent_context_ = 0;
51 Note_spacing_engraver::add_spacing_item (Grob *g)
55 spacing_ = make_item ("NoteSpacing", g->self_scm ());
60 Pointer_group_interface::add_grob (spacing_,
61 ly_symbol2scm ("left-items"),
65 Pointer_group_interface::add_grob (last_spacing_,
66 ly_symbol2scm ("right-items"),
73 Note_spacing_engraver::acknowledge_note_column (Grob_info gi)
75 add_spacing_item (gi.grob ());
79 Note_spacing_engraver::acknowledge_rhythmic_grob (Grob_info gi)
81 add_spacing_item (gi.grob ());
85 Note_spacing_engraver::finalize ()
88 && last_spacing_parent_context_
89 && last_spacing_parent_context_ == context ()->get_parent_context ())
91 SCM ccol = get_property ("currentCommandColumn");
92 Grob *column = unsmob_grob (ccol);
94 Pointer_group_interface::add_grob (last_spacing_,
95 ly_symbol2scm ("right-items"),
101 Note_spacing_engraver::stop_translation_timestep ()
104 && last_spacing_parent_context_
105 && last_spacing_parent_context_ == context ()->get_parent_context ())
107 Grob *sep = unsmob_grob (get_property ("breakableSeparationItem"));
109 Pointer_group_interface::add_grob (last_spacing_,
110 ly_symbol2scm ("right-items"),
116 last_spacing_ = spacing_;
117 last_spacing_parent_context_ = context ()->get_parent_context ();
123 ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column);
124 ADD_ACKNOWLEDGER (Note_spacing_engraver, rhythmic_grob);
126 ADD_TRANSLATOR (Note_spacing_engraver,
127 /* doc */ "Generates NoteSpacing, an object linking horizontal lines for use in spacing.",
128 /* create */ "NoteSpacing",