2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2011--2014 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 DECLARE_ACKNOWLEDGER (grob);
37 DECLARE_END_ACKNOWLEDGER (grob);
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 ()
57 Footnote_engraver::footnotify (Grob *g, SCM cause)
59 Spanner *s = dynamic_cast<Spanner *>(g);
63 Spanner *b = make_spanner ("FootnoteSpanner", cause);
64 b->set_parent (s, Y_AXIS);
65 b->set_parent (s, X_AXIS);
66 Grob *bound = Grob::unsmob (get_property ("currentMusicalColumn"));
67 b->set_bound (LEFT, bound);
68 annotated_spanners_.push_back (Drul_array<Spanner *> (s, b));
72 Grob *b = make_item ("FootnoteItem", cause);
73 b->set_parent (g, Y_AXIS);
74 b->set_parent (g, X_AXIS);
79 Footnote_engraver::acknowledge_grob (Grob_info info)
81 Music *mus = Music::unsmob (info.grob ()->get_property ("footnote-music"));
85 if (!mus->is_mus_type ("footnote-event"))
87 mus->origin ()->programming_error (_ ("Must be footnote-event."));
91 footnotify (info.grob (), mus->to_event ()->unprotect ());
93 // This grob has exhausted its footnote
94 info.grob ()->set_property ("footnote-music", SCM_EOL);
101 Footnote_engraver::acknowledge_end_grob (Grob_info info)
103 Spanner *s = dynamic_cast<Spanner *>(info.grob ());
106 for (vsize i = 0; i < annotated_spanners_.size (); i++)
108 if (annotated_spanners_[i][LEFT] == s)
110 Grob *bound = Grob::unsmob (get_property ("currentMusicalColumn"));
111 annotated_spanners_[i][RIGHT]->set_bound (RIGHT, bound);
117 ADD_ACKNOWLEDGER (Footnote_engraver, grob);
118 ADD_END_ACKNOWLEDGER (Footnote_engraver, grob);
120 ADD_TRANSLATOR (Footnote_engraver,
122 "Create footnote texts.",
129 "currentMusicalColumn ",