]> git.donarmstrong.com Git - lilypond.git/blob - lily/glissando-engraver.cc
Run grand-replace for 2010.
[lilypond.git] / lily / glissando-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2010 Jan Nieuwenhuizen <janneke@gnu.org>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "engraver.hh"
21
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"
28
29 #include "translator.icc"
30
31 class Glissando_engraver : public Engraver
32 {
33 public:
34   TRANSLATOR_DECLARATIONS (Glissando_engraver);
35
36 protected:
37   DECLARE_TRANSLATOR_LISTENER (glissando);
38   DECLARE_ACKNOWLEDGER (rhythmic_head);
39   virtual void finalize ();
40
41   void stop_translation_timestep ();
42   void process_music ();
43 private:
44   Spanner *line_;
45   Spanner *last_line_;
46   Stream_event *event_;
47 };
48
49 Glissando_engraver::Glissando_engraver ()
50 {
51   last_line_ = line_ = 0;
52   event_ = 0;
53 }
54
55 IMPLEMENT_TRANSLATOR_LISTENER (Glissando_engraver, glissando);
56 void
57 Glissando_engraver::listen_glissando (Stream_event *ev)
58 {
59   ASSIGN_EVENT_ONCE (event_, ev);
60 }
61
62 void
63 Glissando_engraver::process_music ()
64 {
65   if (event_)
66     line_ = make_spanner ("Glissando", event_->self_scm ());
67 }
68
69 void
70 Glissando_engraver::acknowledge_rhythmic_head (Grob_info info)
71 {
72   Grob *g = info.grob ();
73   if (line_)
74     line_->set_bound (LEFT, g);
75
76   if (last_line_)
77     {
78       last_line_->set_bound (RIGHT, g);
79       announce_end_grob (last_line_, g->self_scm ());
80     }      
81 }
82
83 void
84 Glissando_engraver::stop_translation_timestep ()
85 {
86   if (last_line_ && last_line_->get_bound (RIGHT))
87     {
88       last_line_ = 0;
89     }
90   if (line_)
91     {
92       if (last_line_)
93         programming_error ("overwriting glissando");
94       last_line_ = line_;
95     }
96   line_ = 0;
97   event_ = 0;
98 }
99
100 void
101 Glissando_engraver::finalize ()
102 {
103   if (line_)
104     {
105       string msg = _ ("unterminated glissando");
106
107       if (event_)
108         event_->origin ()->warning (msg);
109       else
110         warning (msg);
111
112       line_->suicide ();
113       line_ = 0;
114     }
115 }
116
117 ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head);
118 ADD_TRANSLATOR (Glissando_engraver,
119                 /* doc */
120                 "Engrave glissandi.",
121
122                 /* create */
123                 "Glissando ",
124
125                 /* read */
126                 "",
127
128                 /* write */
129                 ""
130                 );