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"
14 #include "rhythmic-head.hh"
15 #include "side-position-interface.hh"
16 #include "staff-symbol-referencer.hh"
17 #include "translator-group.hh"
18 #include "protected-scm.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_;
45 Note_head_line_engraver::Note_head_line_engraver ()
55 Note_head_line_engraver::try_music (Music* m)
59 if (Glissando_req *r = dynamic_cast<Glissando_req*> (m))
69 Note_head_line_engraver::acknowledge_grob (Grob_info info)
71 if (Rhythmic_head::has_interface (info.elem_l_))
74 heads_ = gh_cons (info.elem_l_->self_scm (), heads_);
75 else if (to_boolean (get_property ("followThread")))
77 Translator* staff = daddy_trans_l_ && daddy_trans_l_->daddy_trans_l_
78 ? daddy_trans_l_->daddy_trans_l_->daddy_trans_l_ : 0;
79 if (staff != last_staff_)
82 heads_ = gh_list (info.elem_l_->self_scm (),
83 last_head_->self_scm (), SCM_UNDEFINED);
86 last_head_ = info.elem_l_;
92 Note_head_line_engraver::create_grobs ()
94 if (!line_ && scm_ilength (heads_) > 1)
97 line_ = new Spanner (get_property ("NoteHeadLine"));
98 line_->set_bound (LEFT, unsmob_grob (gh_car (heads_)));
99 line_->set_bound (RIGHT, unsmob_grob (ly_last (heads_)));
101 line_->set_parent (unsmob_grob (gh_car (heads_)), X_AXIS);
102 line_->set_parent (unsmob_grob (gh_car (heads_)), Y_AXIS);
104 line_->set_parent (unsmob_grob (ly_last (heads_)), X_AXIS);
105 line_->set_parent (unsmob_grob (ly_last (heads_)), Y_AXIS);
107 announce_grob (line_, req_);
114 Note_head_line_engraver::stop_translation_timestep ()
118 typeset_grob (line_);
124 ADD_THIS_TRANSLATOR (Note_head_line_engraver);