]> git.donarmstrong.com Git - lilypond.git/blob - lily/glissando-engraver.cc
update for the lily-wins.py script.
[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--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7  */
8
9 #include "warn.hh"
10 #include "event.hh"
11 #include "spanner.hh"
12 #include "rhythmic-head.hh"
13 #include "engraver.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   virtual void acknowledge_grob (Grob_info);
26   virtual void finalize ();
27   virtual void stop_translation_timestep ();
28   virtual bool try_music (Music *);
29   virtual void process_music ();
30 private:
31   Spanner *line_; 
32   Spanner *last_line_; 
33   Music* event_;
34 };
35
36 Glissando_engraver::Glissando_engraver ()
37 {
38   last_line_ = line_ = 0;
39   event_ = 0;
40 }
41
42 bool
43 Glissando_engraver::try_music (Music* m)
44 {
45   if (!event_)
46     {
47       event_ = m;
48       return true;
49     }
50   return false;
51 }
52
53 void
54 Glissando_engraver::process_music ()
55 {
56   if (event_)
57     {
58       line_ = make_spanner ("Glissando", event_->self_scm ());
59     }
60 }
61
62
63 void
64 Glissando_engraver::acknowledge_grob (Grob_info info)
65 {
66   if (Rhythmic_head::has_interface (info.grob_))
67     {
68       Grob * g = info.grob_;
69       if (line_)
70         line_->set_bound (LEFT, g);
71
72       if (last_line_)
73         last_line_->set_bound (RIGHT, g);
74     }    
75 }
76
77
78 void
79 Glissando_engraver::stop_translation_timestep ()
80 {
81   if (last_line_ && last_line_->get_bound (RIGHT))
82     {
83       typeset_grob (last_line_);
84       last_line_ =0;
85     }
86   if (line_)
87     {
88       if ( last_line_)
89         programming_error ("Overwriting glissando.");
90       last_line_ = line_;
91     }
92   line_ = 0;
93   event_ = 0;
94 }
95
96 void
97 Glissando_engraver::finalize ()
98 {
99   if (line_)
100     {
101       String msg = _("Unterminated glissando.");
102       
103       if (event_)
104         event_->origin ()->warning (msg);
105       else
106         warning (msg);
107       
108       line_->suicide ();
109       line_ =0;
110     }
111 }
112
113
114
115 ENTER_DESCRIPTION (Glissando_engraver,
116 /* descr */       "Engrave a glissandi",
117 /* creats*/       "Glissando",
118 /* accepts */     "glissando-event",
119 /* acks  */       "rhythmic-head-interface",
120 /* reads */       "followVoice",
121 /* write */       "");