2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2011--2015 Mike Solomon <mike@mikesolomon.org>
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.
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.
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/>.
20 #include "engraver.hh"
23 #include "stream-event.hh"
24 #include "international.hh"
26 #include "pointer-group-interface.hh"
30 #include "translator.icc"
32 class Footnote_engraver : public Engraver
34 TRANSLATOR_DECLARATIONS (Footnote_engraver);
36 void acknowledge_grob (Grob_info);
37 void acknowledge_end_grob (Grob_info);
39 vector<Drul_array<Spanner *> > annotated_spanners_;
43 void footnotify (Grob *, SCM);
47 Footnote_engraver::finalize ()
49 annotated_spanners_.clear ();
52 Footnote_engraver::Footnote_engraver (Context *c)
58 Footnote_engraver::footnotify (Grob *g, SCM cause)
60 Spanner *s = dynamic_cast<Spanner *>(g);
64 Spanner *b = make_spanner ("FootnoteSpanner", cause);
65 b->set_parent (s, Y_AXIS);
66 b->set_parent (s, X_AXIS);
67 Grob *bound = unsmob<Grob> (get_property ("currentMusicalColumn"));
68 b->set_bound (LEFT, bound);
69 annotated_spanners_.push_back (Drul_array<Spanner *> (s, b));
73 Grob *b = make_item ("FootnoteItem", cause);
74 b->set_parent (g, Y_AXIS);
75 b->set_parent (g, X_AXIS);
80 Footnote_engraver::acknowledge_grob (Grob_info info)
82 Music *mus = unsmob<Music> (info.grob ()->get_property ("footnote-music"));
86 if (!mus->is_mus_type ("footnote-event"))
88 mus->origin ()->programming_error (_ ("Must be footnote-event."));
92 footnotify (info.grob (), mus->to_event ()->unprotect ());
94 // This grob has exhausted its footnote
95 info.grob ()->set_property ("footnote-music", SCM_EOL);
102 Footnote_engraver::acknowledge_end_grob (Grob_info info)
104 Spanner *s = dynamic_cast<Spanner *>(info.grob ());
107 for (vsize i = 0; i < annotated_spanners_.size (); i++)
109 if (annotated_spanners_[i][LEFT] == s)
111 Grob *bound = unsmob<Grob> (get_property ("currentMusicalColumn"));
112 annotated_spanners_[i][RIGHT]->set_bound (RIGHT, bound);
120 Footnote_engraver::boot ()
122 ADD_ACKNOWLEDGER (Footnote_engraver, grob);
123 ADD_END_ACKNOWLEDGER (Footnote_engraver, grob);
126 ADD_TRANSLATOR (Footnote_engraver,
128 "Create footnote texts.",
135 "currentMusicalColumn ",