]> git.donarmstrong.com Git - lilypond.git/blob - lily/ligature-bracket-engraver.cc
Doc [nl]: Translation update.
[lilypond.git] / lily / ligature-bracket-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2002--2011 Juergen Reuter <reuter@ipd.uka.de>
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 "international.hh"
21
22 #include "engraver.hh"
23 #include "note-column.hh"
24 #include "tuplet-bracket.hh"
25 #include "spanner.hh"
26 #include "stream-event.hh"
27 #include "item.hh"
28
29 #include "translator.icc"
30
31 class Ligature_bracket_engraver : public Engraver
32 {
33 protected:
34   virtual void process_music ();
35   virtual void stop_translation_timestep ();
36   DECLARE_ACKNOWLEDGER (rest);
37   DECLARE_ACKNOWLEDGER (note_column);
38   DECLARE_TRANSLATOR_LISTENER (ligature);
39 public:
40   TRANSLATOR_DECLARATIONS (Ligature_bracket_engraver);
41
42 private:
43   Drul_array<Stream_event *> events_drul_;
44   Spanner *finished_ligature_;
45   Spanner *ligature_;
46   Stream_event *previous_start_event_;
47 };
48
49 IMPLEMENT_TRANSLATOR_LISTENER (Ligature_bracket_engraver, ligature);
50 void
51 Ligature_bracket_engraver::listen_ligature (Stream_event *ev)
52 {
53   Direction d = to_dir (ev->get_property ("span-direction"));
54   ASSIGN_EVENT_ONCE (events_drul_[d], ev);
55 }
56
57 Ligature_bracket_engraver::Ligature_bracket_engraver ()
58 {
59   ligature_ = 0;
60   finished_ligature_ = 0;
61   events_drul_[LEFT] = events_drul_[RIGHT] = 0;
62   previous_start_event_ = 0;
63 }
64
65 void
66 Ligature_bracket_engraver::process_music()
67 {
68   if (events_drul_[STOP])
69     {
70       if (!ligature_)
71         {
72           events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature"));
73           return;
74         }
75
76       finished_ligature_ = ligature_;
77       ligature_ = 0;
78       previous_start_event_ = 0;
79     }
80
81   if (events_drul_[START])
82     {
83       if (ligature_)
84         {
85           events_drul_[START]->origin ()->warning (_ ("already have a ligature"));
86           return;
87         }
88
89       previous_start_event_ = events_drul_[START];
90       ligature_ = make_spanner ("LigatureBracket", events_drul_[START]->self_scm ());
91     }
92 }
93
94 void
95 Ligature_bracket_engraver::acknowledge_note_column (Grob_info info)
96 {
97   if (ligature_)
98     {
99       Tuplet_bracket::add_column (ligature_,
100                                   info.item ());
101       add_bound_item (ligature_, info.item());
102     }
103 }
104
105 void
106 Ligature_bracket_engraver::acknowledge_rest (Grob_info info)
107 {
108   acknowledge_note_column(info);
109 }
110
111
112 void
113 Ligature_bracket_engraver::stop_translation_timestep ()
114 {
115   events_drul_[LEFT] =  
116     events_drul_[RIGHT] = 0;
117   finished_ligature_ = 0;
118 }
119
120 ADD_ACKNOWLEDGER (Ligature_bracket_engraver, rest);
121 ADD_ACKNOWLEDGER (Ligature_bracket_engraver, note_column);
122
123 ADD_TRANSLATOR (Ligature_bracket_engraver,
124                 /* doc */
125                 "Handle @code{Ligature_events} by engraving @code{Ligature}"
126                 " brackets.",
127
128                 /* create */
129                 "LigatureBracket ",
130
131                 /* read */
132                 "",
133
134                 /* write */
135                 ""
136                 );