]> git.donarmstrong.com Git - lilypond.git/blob - lily/glissando-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / glissando-engraver.cc
1 /*
2   note-head-line-engraver.cc -- implement Note_head_line_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "engraver.hh"
10 #include "international.hh"
11 #include "rhythmic-head.hh"
12 #include "spanner.hh"
13 #include "warn.hh"
14
15 /**
16    Create line-spanner grobs for glissandi lines that connect note
17    heads.
18 */
19 class Glissando_engraver : public Engraver
20 {
21 public:
22   TRANSLATOR_DECLARATIONS (Glissando_engraver);
23
24 protected:
25   DECLARE_ACKNOWLEDGER (rhythmic_head);
26   virtual void finalize ();
27   virtual bool try_music (Music *);
28
29   void stop_translation_timestep ();
30   void process_music ();
31 private:
32   Spanner *line_;
33   Spanner *last_line_;
34   Music *event_;
35 };
36
37 Glissando_engraver::Glissando_engraver ()
38 {
39   last_line_ = line_ = 0;
40   event_ = 0;
41 }
42
43 bool
44 Glissando_engraver::try_music (Music *m)
45 {
46   if (!event_)
47     {
48       event_ = m;
49       return true;
50     }
51   return false;
52 }
53
54 void
55 Glissando_engraver::process_music ()
56 {
57   if (event_)
58     line_ = make_spanner ("Glissando", event_->self_scm ());
59 }
60
61 void
62 Glissando_engraver::acknowledge_rhythmic_head (Grob_info info)
63 {
64   Grob *g = info.grob ();
65   if (line_)
66     line_->set_bound (LEFT, g);
67
68   if (last_line_)
69     last_line_->set_bound (RIGHT, g);
70 }
71
72 void
73 Glissando_engraver::stop_translation_timestep ()
74 {
75   if (last_line_ && last_line_->get_bound (RIGHT))
76     last_line_ = 0;
77   if (line_)
78     {
79       if (last_line_)
80         programming_error ("overwriting glissando");
81       last_line_ = line_;
82     }
83   line_ = 0;
84   event_ = 0;
85 }
86
87 void
88 Glissando_engraver::finalize ()
89 {
90   if (line_)
91     {
92       string msg = _ ("unterminated glissando");
93
94       if (event_)
95         event_->origin ()->warning (msg);
96       else
97         warning (msg);
98
99       line_->suicide ();
100       line_ = 0;
101     }
102 }
103
104 #include "translator.icc"
105
106 ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head);
107 ADD_TRANSLATOR (Glissando_engraver,
108                 /* doc */ "Engrave a glissandi",
109                 /* create */ "Glissando",
110                 /* accept */ "glissando-event",
111                 /* read */ "followVoice",
112                 /* write */ "");