LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2011 Mike Solomon <mike@apollinemike.com> | 4 Copyright (C) 2011 Mike Solomon <mike@apollinemike.com> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 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 | 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 | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 class Footnote_engraver : public Engraver | 30 class Footnote_engraver : public Engraver |
31 { | 31 { |
32 TRANSLATOR_DECLARATIONS (Footnote_engraver); | 32 TRANSLATOR_DECLARATIONS (Footnote_engraver); |
33 | 33 |
34 DECLARE_TRANSLATOR_LISTENER (footnote); | 34 DECLARE_TRANSLATOR_LISTENER (footnote); |
35 DECLARE_ACKNOWLEDGER (grob); | 35 DECLARE_ACKNOWLEDGER (grob); |
36 DECLARE_END_ACKNOWLEDGER (grob); | 36 DECLARE_END_ACKNOWLEDGER (grob); |
37 vector<Stream_event *> events_; | 37 vector<Stream_event *> events_; |
38 vector<Drul_array<Spanner *> > annotated_spanners_; | 38 vector<Drul_array<Spanner *> > annotated_spanners_; |
39 vector<Grob *> footnotes_; | |
40 | 39 |
41 void stop_translation_timestep (); | 40 void stop_translation_timestep (); |
42 void finalize (); | 41 void finalize (); |
43 | 42 |
44 void footnotify (Grob *, Stream_event *); | 43 void footnotify (Grob *, Stream_event *); |
45 }; | 44 }; |
46 | 45 |
47 IMPLEMENT_TRANSLATOR_LISTENER (Footnote_engraver, footnote); | 46 IMPLEMENT_TRANSLATOR_LISTENER (Footnote_engraver, footnote); |
48 void | 47 void |
49 Footnote_engraver::listen_footnote (Stream_event *ev) | 48 Footnote_engraver::listen_footnote (Stream_event *ev) |
50 { | 49 { |
51 events_.push_back (ev); | 50 events_.push_back (ev); |
52 } | 51 } |
53 | 52 |
54 void | 53 void |
55 Footnote_engraver::stop_translation_timestep () | 54 Footnote_engraver::stop_translation_timestep () |
56 { | 55 { |
57 events_.clear (); | 56 events_.clear (); |
58 } | 57 } |
59 | 58 |
60 void | 59 void |
61 Footnote_engraver::finalize () | 60 Footnote_engraver::finalize () |
62 { | 61 { |
63 if (!footnotes_.size ()) | 62 annotated_spanners_.resize (0); |
64 return; | |
65 System *sys = Grob::get_system (footnotes_[0]); | |
66 if (!sys) | |
67 { | |
68 footnotes_[0]->programming_error ("Cannot assign footnotes to system"); | |
69 return; | |
70 } | |
71 for (vsize i = 0; i < footnotes_.size (); i++) | |
72 Pointer_group_interface::add_grob (sys, ly_symbol2scm ("footnotes"), footnot
es_[i]); | |
73 } | 63 } |
74 | 64 |
75 Footnote_engraver::Footnote_engraver () | 65 Footnote_engraver::Footnote_engraver () |
76 { | 66 { |
77 } | 67 } |
78 | 68 |
79 void | 69 void |
80 Footnote_engraver::footnotify (Grob *g, Stream_event *event) | 70 Footnote_engraver::footnotify (Grob *g, Stream_event *event) |
81 { | 71 { |
82 Spanner *s = dynamic_cast<Spanner *>(g); | 72 Spanner *s = dynamic_cast<Spanner *>(g); |
83 | 73 |
84 if (s) | 74 if (s) |
85 { | 75 { |
86 Spanner *b = make_spanner ("FootnoteSpanner", event->self_scm ()); | 76 Spanner *b = make_spanner ("FootnoteSpanner", event->self_scm ()); |
87 b->set_parent (s, Y_AXIS); | 77 b->set_parent (s, Y_AXIS); |
88 b->set_parent (s, X_AXIS); | 78 b->set_parent (s, X_AXIS); |
89 Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); | 79 Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); |
90 b->set_bound (LEFT, bound); | 80 b->set_bound (LEFT, bound); |
91 annotated_spanners_.push_back (Drul_array<Spanner *> (s, b)); | 81 annotated_spanners_.push_back (Drul_array<Spanner *> (s, b)); |
92 footnotes_.push_back (b); | |
93 } | 82 } |
94 else | 83 else |
95 { | 84 { |
96 Grob *b = make_item ("FootnoteItem", event->self_scm ()); | 85 Grob *b = make_item ("FootnoteItem", event->self_scm ()); |
97 b->set_parent (g, Y_AXIS); | 86 b->set_parent (g, Y_AXIS); |
98 b->set_parent (g, X_AXIS); | 87 b->set_parent (g, X_AXIS); |
99 footnotes_.push_back (b); | |
100 } | 88 } |
101 } | 89 } |
102 | 90 |
103 void | 91 void |
104 Footnote_engraver::acknowledge_grob (Grob_info info) | 92 Footnote_engraver::acknowledge_grob (Grob_info info) |
105 { | 93 { |
106 Stream_event *cause = info.event_cause (); | 94 Stream_event *cause = info.event_cause (); |
107 | 95 |
108 SCM arts = cause ? cause->get_property ("articulations") : SCM_EOL; | 96 SCM arts = cause ? cause->get_property ("articulations") : SCM_EOL; |
109 for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s)) | 97 for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s)) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 /* create */ | 135 /* create */ |
148 "FootnoteItem " | 136 "FootnoteItem " |
149 "FootnoteSpanner ", | 137 "FootnoteSpanner ", |
150 | 138 |
151 /*read*/ | 139 /*read*/ |
152 "currentMusicalColumn ", | 140 "currentMusicalColumn ", |
153 | 141 |
154 /*write*/ | 142 /*write*/ |
155 "" | 143 "" |
156 ); | 144 ); |
LEFT | RIGHT |