2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2011 Mike Solomon <mike@apollinemike.com>
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"
22 #include "stream-event.hh"
24 #include "pointer-group-interface.hh"
27 #include "translator.icc"
29 class Footnote_engraver
: public Engraver
31 TRANSLATOR_DECLARATIONS (Footnote_engraver
);
33 DECLARE_TRANSLATOR_LISTENER (footnote
);
34 DECLARE_ACKNOWLEDGER (grob
);
35 DECLARE_END_ACKNOWLEDGER (grob
);
36 vector
<Stream_event
*> events_
;
37 vector
<Drul_array
<Spanner
*> > annotated_spanners_
;
39 void stop_translation_timestep ();
41 void footnotify (Grob
*, Stream_event
*);
44 IMPLEMENT_TRANSLATOR_LISTENER (Footnote_engraver
, footnote
);
46 Footnote_engraver::listen_footnote (Stream_event
*ev
)
48 events_
.push_back (ev
);
52 Footnote_engraver::stop_translation_timestep ()
57 Footnote_engraver::Footnote_engraver ()
62 Footnote_engraver::footnotify (Grob
*g
, Stream_event
*event
)
64 Spanner
*s
= dynamic_cast<Spanner
*>(g
);
68 Spanner
*b
= make_spanner ("FootnoteSpanner", event
->self_scm ());
69 b
->set_parent (s
, Y_AXIS
);
70 b
->set_parent (s
, X_AXIS
);
71 Grob
*bound
= unsmob_grob (get_property ("currentMusicalColumn"));
72 b
->set_bound (LEFT
, bound
);
73 annotated_spanners_
.push_back (Drul_array
<Spanner
*> (s
,b
));
77 Grob
*b
= make_item ("FootnoteItem", event
->self_scm ());
78 b
->set_parent (g
, Y_AXIS
);
79 b
->set_parent (g
, X_AXIS
);
84 Footnote_engraver::acknowledge_grob (Grob_info info
)
86 Stream_event
*cause
= info
.event_cause ();
88 SCM arts
= cause
? cause
->get_property ("articulations") : SCM_EOL
;
89 for (SCM s
= arts
; scm_is_pair (s
); s
= scm_cdr (s
))
91 Stream_event
*e
= unsmob_stream_event (scm_car (s
));
92 if (e
->in_event_class ("footnote-event"))
93 footnotify (info
.grob (), e
);
96 for (vsize i
= 0; i
< events_
.size (); i
++)
98 if (info
.grob ()->name () == ly_symbol2string (events_
[i
]->get_property ("symbol")))
99 footnotify (info
.grob (), events_
[i
]);
104 Footnote_engraver::acknowledge_end_grob (Grob_info info
)
106 Spanner
*s
= dynamic_cast<Spanner
*>(info
.grob ());
109 for (vsize i
= 0; i
< annotated_spanners_
.size (); i
++)
111 if (annotated_spanners_
[i
][LEFT
] == s
)
113 Grob
*bound
= unsmob_grob (get_property ("currentMusicalColumn"));
114 annotated_spanners_
[i
][RIGHT
]->set_bound (RIGHT
, bound
);
120 ADD_ACKNOWLEDGER (Footnote_engraver
, grob
);
121 ADD_END_ACKNOWLEDGER (Footnote_engraver
, grob
);
123 ADD_TRANSLATOR (Footnote_engraver
,
125 "Create footnote texts.",
132 "currentMusicalColumn ",