* The grand 2005-2006 replace.
[lilypond/patrick.git] / lily / glissando-engraver.cc
blob4bb180ef167e3da13f9cf0b80e203998760fbb6e
1 /*
2 note-head-line-engraver.cc -- implement Note_head_line_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "warn.hh"
10 #include "spanner.hh"
11 #include "rhythmic-head.hh"
12 #include "engraver.hh"
14 /**
15 Create line-spanner grobs for glissandi lines that connect note
16 heads.
18 class Glissando_engraver : public Engraver
20 public:
21 TRANSLATOR_DECLARATIONS (Glissando_engraver);
23 protected:
24 DECLARE_ACKNOWLEDGER (rhythmic_head);
25 virtual void finalize ();
26 void stop_translation_timestep ();
27 virtual bool try_music (Music *);
28 void process_music ();
29 private:
30 Spanner *line_;
31 Spanner *last_line_;
32 Music *event_;
35 Glissando_engraver::Glissando_engraver ()
37 last_line_ = line_ = 0;
38 event_ = 0;
41 bool
42 Glissando_engraver::try_music (Music *m)
44 if (!event_)
46 event_ = m;
47 return true;
49 return false;
52 void
53 Glissando_engraver::process_music ()
55 if (event_)
56 line_ = make_spanner ("Glissando", event_->self_scm ());
59 void
60 Glissando_engraver::acknowledge_rhythmic_head (Grob_info info)
62 Grob *g = info.grob ();
63 if (line_)
64 line_->set_bound (LEFT, g);
66 if (last_line_)
67 last_line_->set_bound (RIGHT, g);
70 void
71 Glissando_engraver::stop_translation_timestep ()
73 if (last_line_ && last_line_->get_bound (RIGHT))
74 last_line_ = 0;
75 if (line_)
77 if (last_line_)
78 programming_error ("overwriting glissando");
79 last_line_ = line_;
81 line_ = 0;
82 event_ = 0;
85 void
86 Glissando_engraver::finalize ()
88 if (line_)
90 String msg = _ ("unterminated glissando");
92 if (event_)
93 event_->origin ()->warning (msg);
94 else
95 warning (msg);
97 line_->suicide ();
98 line_ = 0;
102 #include "translator.icc"
104 ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head);
105 ADD_TRANSLATOR (Glissando_engraver,
106 /* doc */ "Engrave a glissandi",
107 /* create */ "Glissando",
108 /* accept */ "glissando-event",
109 /* read */ "followVoice",
110 /* write */ "");