Correct left text alignment of DynamicTextSpanner.
[lilypond.git] / lily / ligature-bracket-engraver.cc
blob091388f7e66ecc58a8d144dd132da324932f11ff
1 /*
2 ligature-bracket-engraver.cc -- implement Ligature_bracket_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2007 Juergen Reuter <reuter@ipd.uka.de>
7 */
9 #include "international.hh"
11 #include "ligature-engraver.hh"
12 #include "note-column.hh"
13 #include "tuplet-bracket.hh"
14 #include "spanner.hh"
15 #include "stream-event.hh"
16 #include "spanner.hh"
17 #include "item.hh"
19 #include "translator.icc"
21 class Ligature_bracket_engraver : public Engraver
23 protected:
24 virtual void process_music ();
25 virtual void stop_translation_timestep ();
26 DECLARE_ACKNOWLEDGER (rest);
27 DECLARE_ACKNOWLEDGER (note_column);
28 DECLARE_TRANSLATOR_LISTENER (ligature);
29 public:
30 TRANSLATOR_DECLARATIONS (Ligature_bracket_engraver);
32 private:
33 Drul_array<Stream_event *> events_drul_;
34 Spanner *finished_ligature_;
35 Spanner *ligature_;
36 Stream_event *previous_start_event_;
39 IMPLEMENT_TRANSLATOR_LISTENER (Ligature_bracket_engraver, ligature);
40 void
41 Ligature_bracket_engraver::listen_ligature (Stream_event *ev)
43 Direction d = to_dir (ev->get_property ("span-direction"));
44 ASSIGN_EVENT_ONCE (events_drul_[d], ev);
47 Ligature_bracket_engraver::Ligature_bracket_engraver ()
49 ligature_ = 0;
50 finished_ligature_ = 0;
51 events_drul_[LEFT] = events_drul_[RIGHT] = 0;
52 previous_start_event_ = 0;
55 void
56 Ligature_bracket_engraver::process_music()
58 if (events_drul_[STOP])
60 if (!ligature_)
62 events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature"));
63 return;
66 finished_ligature_ = ligature_;
67 ligature_ = 0;
68 previous_start_event_ = 0;
71 if (events_drul_[START])
73 if (ligature_)
75 events_drul_[START]->origin ()->warning (_ ("already have a ligature"));
76 return;
79 previous_start_event_ = events_drul_[START];
80 ligature_ = make_spanner ("LigatureBracket", events_drul_[START]->self_scm ());
84 void
85 Ligature_bracket_engraver::acknowledge_note_column (Grob_info info)
87 if (ligature_)
89 Tuplet_bracket::add_column (ligature_,
90 info.item ());
91 add_bound_item (ligature_, info.item());
95 void
96 Ligature_bracket_engraver::acknowledge_rest (Grob_info info)
98 acknowledge_note_column(info);
102 void
103 Ligature_bracket_engraver::stop_translation_timestep ()
105 events_drul_[LEFT] =
106 events_drul_[RIGHT] = 0;
107 finished_ligature_ = 0;
110 ADD_ACKNOWLEDGER (Ligature_bracket_engraver, rest);
111 ADD_ACKNOWLEDGER (Ligature_bracket_engraver, note_column);
113 ADD_TRANSLATOR (Ligature_bracket_engraver,
114 /* doc */
115 "Handle @code{Ligature_events} by engraving @code{Ligature}"
116 " brackets.",
118 /* create */
119 "LigatureBracket ",
121 /* read */
124 /* write */