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"
19 #include "translator.icc"
21 class Note_spacing_engraver : public Engraver
23 typedef map <Context*, Grob*> Last_spacing_map;
24 Last_spacing_map last_spacings_;
28 void add_spacing_item (Grob *);
29 TRANSLATOR_DECLARATIONS (Note_spacing_engraver);
32 DECLARE_ACKNOWLEDGER (rhythmic_grob);
33 DECLARE_ACKNOWLEDGER (note_column);
34 void stop_translation_timestep ();
35 virtual void finalize ();
36 virtual void derived_mark () const;
40 Note_spacing_engraver::derived_mark () const
42 for (Last_spacing_map::const_iterator i = last_spacings_.begin ();
43 i != last_spacings_.end (); i++)
44 scm_gc_mark (i->first->self_scm ());
47 Note_spacing_engraver::Note_spacing_engraver ()
53 Note_spacing_engraver::add_spacing_item (Grob *g)
57 spacing_ = make_item ("NoteSpacing", g->self_scm ());
62 Pointer_group_interface::add_grob (spacing_,
63 ly_symbol2scm ("left-items"),
66 Grob *last_spacing = last_spacings_[context ()->get_parent_context ()];
68 Pointer_group_interface::add_grob (last_spacing,
69 ly_symbol2scm ("right-items"),
76 Note_spacing_engraver::acknowledge_note_column (Grob_info gi)
78 add_spacing_item (gi.grob ());
82 Note_spacing_engraver::acknowledge_rhythmic_grob (Grob_info gi)
84 add_spacing_item (gi.grob ());
88 Note_spacing_engraver::finalize ()
90 Context *parent = context ()->get_parent_context ();
91 Grob *last_spacing = last_spacings_[parent];
94 && !unsmob_grob_array (last_spacing->get_object ("right-items")))
96 Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
98 Pointer_group_interface::add_grob (last_spacing,
99 ly_symbol2scm ("right-items"),
105 Note_spacing_engraver::stop_translation_timestep ()
107 Context *parent = context ()->get_parent_context ();
108 Grob *last_spacing = last_spacings_[parent];
111 && to_boolean (get_property ("hasStaffSpacing")))
113 Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
114 Pointer_group_interface::add_grob (last_spacing,
115 ly_symbol2scm ("right-items"),
121 last_spacings_[parent] = spacing_;
127 ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column);
128 ADD_ACKNOWLEDGER (Note_spacing_engraver, rhythmic_grob);
130 ADD_TRANSLATOR (Note_spacing_engraver,
131 /* doc */ "Generates NoteSpacing, an object linking horizontal lines for use in spacing.",
132 /* create */ "NoteSpacing",