* Documentation/user/tutorial.itely (A lead sheet): remove
[lilypond.git] / lily / note-head-line-engraver.cc
blob84e8af265201aec998793328b8b3c5b3f5ad8b06
1 /*
2 note-head-line-engraver.cc -- implement Note_head_line_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "engraver.hh"
10 #include "group-interface.hh"
11 #include "item.hh"
12 #include "event.hh"
13 #include "spanner.hh"
14 #include "stem.hh"
15 #include "rhythmic-head.hh"
16 #include "side-position-interface.hh"
17 #include "staff-symbol-referencer.hh"
18 #include "translator-group.hh"
20 /**
21 Create line-spanner grobs for lines that connect note heads.
23 TODO: have the line commit suicide if the notes are connected with
24 either slur or beam.
27 class Note_head_line_engraver : public Engraver
29 public:
30 TRANSLATOR_DECLARATIONS(Note_head_line_engraver);
32 protected:
33 virtual void acknowledge_grob (Grob_info);
34 virtual void process_acknowledged_grobs ();
35 virtual void stop_translation_timestep ();
37 private:
38 Spanner* line_;
39 Translator* last_staff_;
40 bool follow_;
41 Grob* head_;
42 Grob* last_head_;
45 Note_head_line_engraver::Note_head_line_engraver ()
47 line_ = 0;
48 follow_ = false;
49 head_ = 0;
50 last_head_ = 0;
51 last_staff_ = 0;
54 void
55 Note_head_line_engraver::acknowledge_grob (Grob_info info)
57 if (Rhythmic_head::has_interface (info.grob_))
59 head_ = info.grob_;
60 if (to_boolean (get_property ("followVoice")))
62 Translator_group * tr = daddy_trans_;
63 while (tr && !tr->is_alias_b (ly_symbol2scm ( "Staff")))
64 tr = tr->daddy_trans_ ;
66 if (tr && tr->is_alias_b (ly_symbol2scm ("Staff")) && tr != last_staff_)
68 if (last_head_)
69 follow_ = true;
70 last_staff_ = tr;
77 void
78 Note_head_line_engraver::process_acknowledged_grobs ()
80 if (!line_ && follow_ && last_head_ && head_)
82 /* TODO: Don't follow if there's a beam.
84 We can't do beam-stuff here, since beam doesn't exist yet.
85 Should probably store follow_ in line_, and suicide at some
86 later point */
87 if (follow_)
88 line_ = new Spanner (get_property ("VoiceFollower"));
90 line_->set_bound (LEFT, last_head_);
91 line_->set_bound (RIGHT, head_);
93 announce_grob(line_, head_->self_scm ());
95 follow_ = false;
99 void
100 Note_head_line_engraver::stop_translation_timestep ()
102 if (line_)
104 typeset_grob (line_);
105 line_ = 0;
107 if (head_)
108 last_head_ = head_;
109 head_ = 0;
115 ENTER_DESCRIPTION(Note_head_line_engraver,
116 /* descr */ "Engrave a line between two note heads, for example a glissando. If "
117 " followVoice is set, staff switches also generate a line.",
118 /* creats*/ "Glissando VoiceFollower",
119 /* accepts */ "glissando-event",
120 /* acks */ "rhythmic-head-interface",
121 /* reads */ "followVoice",
122 /* write */ "");