Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(244)

Side by Side Diff: lily/footnote-engraver.cc

Issue 6635050: Make arguments like Context.GrobName accessible as symbol lists (Closed) Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Patch Set: Change \footnote user interface to match the rest (though pre-2.16 German docs fail) Created 12 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
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--2012 Mike Solomon <mike@mikesolomon.org> 4 Copyright (C) 2011--2012 Mike Solomon <mike@mikesolomon.org>
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 15 matching lines...) Expand all
26 #include "pointer-group-interface.hh" 26 #include "pointer-group-interface.hh"
27 #include "spanner.hh" 27 #include "spanner.hh"
28 #include "system.hh" 28 #include "system.hh"
29 29
30 #include "translator.icc" 30 #include "translator.icc"
31 31
32 class Footnote_engraver : public Engraver 32 class Footnote_engraver : public Engraver
33 { 33 {
34 TRANSLATOR_DECLARATIONS (Footnote_engraver); 34 TRANSLATOR_DECLARATIONS (Footnote_engraver);
35 35
36 DECLARE_TRANSLATOR_LISTENER (footnote);
37 DECLARE_ACKNOWLEDGER (grob); 36 DECLARE_ACKNOWLEDGER (grob);
38 DECLARE_END_ACKNOWLEDGER (grob); 37 DECLARE_END_ACKNOWLEDGER (grob);
39 vector<Stream_event *> events_; 38
40 vector<Drul_array<Spanner *> > annotated_spanners_; 39 vector<Drul_array<Spanner *> > annotated_spanners_;
41 40
42 void stop_translation_timestep ();
43 void finalize (); 41 void finalize ();
44 virtual void derived_mark () const;
45 42
46 void footnotify (Grob *, SCM); 43 void footnotify (Grob *, SCM);
47 }; 44 };
48 45
49 IMPLEMENT_TRANSLATOR_LISTENER (Footnote_engraver, footnote);
Keith 2012/10/13 05:16:00 I don't see now the new syntax avoids the need for
dak 2012/10/13 07:04:08 The new syntax allows a grob specification _with_
50 void
51 Footnote_engraver::listen_footnote (Stream_event *ev)
52 {
53 events_.push_back (ev);
54 }
55
56 void
57 Footnote_engraver::stop_translation_timestep ()
58 {
59 events_.clear ();
60 }
61
62 void 46 void
63 Footnote_engraver::finalize () 47 Footnote_engraver::finalize ()
64 { 48 {
65 annotated_spanners_.clear (); 49 annotated_spanners_.clear ();
66 } 50 }
67 51
68 void
69 Footnote_engraver::derived_mark () const
70 {
71 for (vsize i = 0; i < events_.size (); ++i)
72 scm_gc_mark (events_[i]->self_scm ());
73 }
74
75 Footnote_engraver::Footnote_engraver () 52 Footnote_engraver::Footnote_engraver ()
76 { 53 {
77 } 54 }
78 55
79 void 56 void
80 Footnote_engraver::footnotify (Grob *g, SCM cause) 57 Footnote_engraver::footnotify (Grob *g, SCM cause)
81 { 58 {
82 Spanner *s = dynamic_cast<Spanner *>(g); 59 Spanner *s = dynamic_cast<Spanner *>(g);
83 60
84 if (s) 61 if (s)
(...skipping 23 matching lines...) Expand all
108 if (!mus->is_mus_type ("footnote-event")) 85 if (!mus->is_mus_type ("footnote-event"))
109 { 86 {
110 mus->origin ()->programming_error (_ ("Must be footnote-event.")); 87 mus->origin ()->programming_error (_ ("Must be footnote-event."));
111 return; 88 return;
112 } 89 }
113 90
114 footnotify (info.grob (), mus->to_event (context ())->unprotect ()); 91 footnotify (info.grob (), mus->to_event (context ())->unprotect ());
115 92
116 // This grob has exhausted its footnote 93 // This grob has exhausted its footnote
117 info.grob ()->set_property ("footnote-music", SCM_EOL); 94 info.grob ()->set_property ("footnote-music", SCM_EOL);
95
118 return; 96 return;
119 } 97 }
120
121 if (!events_.empty ())
122 {
123 string grobname = info.grob ()->name ();
124
125 for (vsize i = 0; i < events_.size (); i++)
126 {
127 SCM name = events_[i]->get_property ("symbol");
128 if (scm_is_symbol (name)
129 && grobname == ly_symbol2string (name))
130 {
131 footnotify (info.grob (), events_[i]->self_scm ());
132 // Event has exhausted its footnote
133 events_[i]->set_property ("symbol", SCM_EOL);
134 }
135 }
136 }
137 } 98 }
138 99
139 void 100 void
140 Footnote_engraver::acknowledge_end_grob (Grob_info info) 101 Footnote_engraver::acknowledge_end_grob (Grob_info info)
141 { 102 {
142 Spanner *s = dynamic_cast<Spanner *>(info.grob ()); 103 Spanner *s = dynamic_cast<Spanner *>(info.grob ());
143 104
144 if (s) 105 if (s)
145 for (vsize i = 0; i < annotated_spanners_.size (); i++) 106 for (vsize i = 0; i < annotated_spanners_.size (); i++)
146 { 107 {
(...skipping 16 matching lines...) Expand all
163 /* create */ 124 /* create */
164 "FootnoteItem " 125 "FootnoteItem "
165 "FootnoteSpanner ", 126 "FootnoteSpanner ",
166 127
167 /*read*/ 128 /*read*/
168 "currentMusicalColumn ", 129 "currentMusicalColumn ",
169 130
170 /*write*/ 131 /*write*/
171 "" 132 ""
172 ); 133 );
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b