1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3 
4   Copyright (C) 2011--2021 Mike Solomon <mike@mikesolomon.org>
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 "engraver.hh"
21 
22 #include "music.hh"
23 #include "stream-event.hh"
24 #include "international.hh"
25 #include "item.hh"
26 #include "pointer-group-interface.hh"
27 #include "spanner.hh"
28 #include "system.hh"
29 
30 #include "translator.icc"
31 
32 class Footnote_engraver : public Engraver
33 {
34   TRANSLATOR_DECLARATIONS (Footnote_engraver);
35 
36   void acknowledge_grob (Grob_info) override;
37 };
38 
Footnote_engraver(Context * c)39 Footnote_engraver::Footnote_engraver (Context *c)
40   : Engraver (c)
41 {
42 }
43 
44 void
acknowledge_grob(Grob_info info)45 Footnote_engraver::acknowledge_grob (Grob_info info)
46 {
47   Music *mus = unsmob<Music> (get_property (info.grob (), "footnote-music"));
48 
49   if (mus)
50     {
51       if (!mus->is_mus_type ("footnote-event"))
52         {
53           mus->programming_error (_ ("Must be footnote-event."));
54           return;
55         }
56 
57       make_sticky ("Footnote", info.grob (), mus->to_event ()->unprotect ());
58 
59       // This grob has exhausted its footnote
60       set_property (info.grob (), "footnote-music", SCM_EOL);
61     }
62 }
63 
64 void
boot()65 Footnote_engraver::boot ()
66 {
67   ADD_ACKNOWLEDGER (Footnote_engraver, grob);
68 }
69 
70 ADD_TRANSLATOR (Footnote_engraver,
71                 /* doc */
72                 "Create footnote texts.",
73 
74                 /* create */
75                 "Footnote",
76 
77                 /*read*/
78                 "",
79 
80                 /*write*/
81                 ""
82                );
83