Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / glissando-engraver.cc
blob99eb6bc515b2aa5675483de2d498c5f0792a556e
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2011 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
22 #include "international.hh"
23 #include "rhythmic-head.hh"
24 #include "spanner.hh"
25 #include "stream-event.hh"
26 #include "warn.hh"
27 #include "item.hh"
29 #include "translator.icc"
31 class Glissando_engraver : public Engraver
33 public:
34 TRANSLATOR_DECLARATIONS (Glissando_engraver);
36 protected:
37 DECLARE_TRANSLATOR_LISTENER (glissando);
38 DECLARE_ACKNOWLEDGER (rhythmic_head);
39 virtual void finalize ();
41 void stop_translation_timestep ();
42 void process_music ();
43 private:
44 Spanner *line_;
45 Spanner *last_line_;
46 Stream_event *event_;
49 Glissando_engraver::Glissando_engraver ()
51 last_line_ = line_ = 0;
52 event_ = 0;
55 IMPLEMENT_TRANSLATOR_LISTENER (Glissando_engraver, glissando);
56 void
57 Glissando_engraver::listen_glissando (Stream_event *ev)
59 ASSIGN_EVENT_ONCE (event_, ev);
62 void
63 Glissando_engraver::process_music ()
65 if (event_)
66 line_ = make_spanner ("Glissando", event_->self_scm ());
69 void
70 Glissando_engraver::acknowledge_rhythmic_head (Grob_info info)
72 Grob *g = info.grob ();
73 if (line_)
74 line_->set_bound (LEFT, g);
76 if (last_line_)
78 last_line_->set_bound (RIGHT, g);
79 announce_end_grob (last_line_, g->self_scm ());
83 void
84 Glissando_engraver::stop_translation_timestep ()
86 if (last_line_ && last_line_->get_bound (RIGHT))
88 last_line_ = 0;
90 if (line_)
92 if (last_line_)
93 programming_error ("overwriting glissando");
94 last_line_ = line_;
96 line_ = 0;
97 event_ = 0;
100 void
101 Glissando_engraver::finalize ()
103 if (line_)
105 string msg = _ ("unterminated glissando");
107 if (event_)
108 event_->origin ()->warning (msg);
109 else
110 warning (msg);
112 line_->suicide ();
113 line_ = 0;
117 ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head);
118 ADD_TRANSLATOR (Glissando_engraver,
119 /* doc */
120 "Engrave glissandi.",
122 /* create */
123 "Glissando ",
125 /* read */
128 /* write */