2 note-head-line-engraver.cc -- implement Note_head_line_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "group-interface.hh"
12 #include "musical-request.hh"
15 #include "rhythmic-head.hh"
16 #include "side-position-interface.hh"
17 #include "staff-symbol-referencer.hh"
18 #include "translator-group.hh"
21 Create line-spanner grobs for glissandi (and possibly other) lines
22 that connect note heads.
25 class Note_head_line_engraver : public Engraver
28 VIRTUAL_COPY_CONS (Translator);
29 Note_head_line_engraver ();
32 virtual void acknowledge_grob (Grob_info);
33 virtual void create_grobs ();
34 virtual void stop_translation_timestep ();
35 virtual bool try_music (Music *);
41 Translator* last_staff_;
47 Note_head_line_engraver::Note_head_line_engraver ()
59 Note_head_line_engraver::try_music (Music* m)
63 if (Glissando_req *r = dynamic_cast<Glissando_req*> (m))
73 Note_head_line_engraver::acknowledge_grob (Grob_info info)
75 if (Rhythmic_head::has_interface (info.elem_l_))
79 if (to_boolean (get_property ("followThread")))
81 Translator* staff = daddy_trans_l_ && daddy_trans_l_->daddy_trans_l_
82 ? daddy_trans_l_->daddy_trans_l_->daddy_trans_l_ : 0;
83 if (staff != last_staff_)
96 if (Grob *s = Rhythmic_head::stem_l (h))
97 return Stem::beam_l (s);
102 Note_head_line_engraver::create_grobs ()
104 if (!line_ && (follow_ || last_req_) && last_head_ && head_
105 && (last_head_ != head_))
107 /* Don't follow if there's a beam.
109 Hmm, this doesn't work, as head_ does not yet have a beam.
110 Should probably store follow_ in line_, and suicide at some
113 && beam_l (last_head_) && beam_l (last_head_) == beam_l (head_)))
116 line_ = new Spanner (get_property ("FollowThread"));
118 line_ = new Spanner (get_property ("Glissando"));
120 line_->set_bound (LEFT, last_head_);
121 line_->set_bound (RIGHT, head_);
123 /* Note, mustn't set y-parent of breakable symbol to simple item:
124 one of the two broken parts won't have an y-parent! */
125 /* X parent is set by set_bound */
126 line_->set_parent (Staff_symbol_referencer::staff_symbol_l (last_head_),
129 announce_grob (line_, last_req_);
139 Note_head_line_engraver::stop_translation_timestep ()
143 typeset_grob (line_);
151 ADD_THIS_TRANSLATOR (Note_head_line_engraver);