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) 2009--2011 Joe Neeman <joeneeman@gmail.com> | 4 Copyright (C) 2009--2011 Joe Neeman <joeneeman@gmail.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (stencils == SCM_EOL) | 60 if (stencils == SCM_EOL) |
61 continue; | 61 continue; |
62 for (SCM st = stencils; scm_is_pair (st); st = scm_cdr (st)) | 62 for (SCM st = stencils; scm_is_pair (st); st = scm_cdr (st)) |
63 fn_count++; | 63 fn_count++; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 return fn_count; | 67 return fn_count; |
68 } | 68 } |
69 | 69 |
70 | |
71 SCM | 70 SCM |
72 Page_layout_problem::get_footnotes_from_lines (SCM lines) | 71 Page_layout_problem::get_footnotes_from_lines (SCM lines) |
73 { | 72 { |
74 if (!scm_is_pair (lines)) | 73 if (!scm_is_pair (lines)) |
75 return SCM_EOL; | 74 return SCM_EOL; |
76 | 75 |
77 bool footnotes_added; | 76 bool footnotes_added; |
78 if (Grob *g = unsmob_grob (scm_car (lines))) | 77 if (Grob *g = unsmob_grob (scm_car (lines))) |
79 footnotes_added = g->get_property ("footnote-stencil") != SCM_EOL; | 78 footnotes_added = !scm_is_null (g->get_property ("footnote-stencil")); |
80 else if (Prob *p = unsmob_prob (scm_car (lines))) | 79 else if (Prob *p = unsmob_prob (scm_car (lines))) |
81 footnotes_added = p->get_property ("footnote-stencil") != SCM_EOL; | 80 footnotes_added = !scm_is_null (p->get_property ("footnote-stencil")); |
82 else | 81 else |
83 { | 82 { |
84 programming_error ("Systems on a page must be a prob or grob."); | 83 programming_error ("Systems on a page must be a prob or grob."); |
85 return SCM_EOL; | 84 return SCM_EOL; |
86 } | 85 } |
87 if (!footnotes_added) | 86 if (!footnotes_added) |
88 { | 87 { |
89 programming_error ("Footnotes must be added to lines before they're retrie
ved."); | 88 programming_error ("Footnotes must be added to lines before they are retri
eved."); |
90 return SCM_EOL; | 89 return SCM_EOL; |
91 } | 90 } |
92 | 91 |
93 SCM out = SCM_EOL; | 92 SCM out = SCM_EOL; |
94 for (SCM s = lines; scm_is_pair (s); s = scm_cdr (s)) | 93 for (SCM s = lines; scm_is_pair (s); s = scm_cdr (s)) |
95 { | 94 { |
96 if (Grob *g = unsmob_grob (scm_car (s))) | 95 if (Grob *g = unsmob_grob (scm_car (s))) |
97 out = scm_cons (g->get_property ("footnote-stencil"), out); | 96 out = scm_cons (g->get_property ("footnote-stencil"), out); |
98 else if (Prob *p = unsmob_prob (scm_car (s))) | 97 else if (Prob *p = unsmob_prob (scm_car (s))) |
99 out = scm_cons (p->get_property ("footnote-stencil"), out); | 98 out = scm_cons (p->get_property ("footnote-stencil"), out); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 translate each stencil such that it attains the correct maximum length and b
undle the | 178 translate each stencil such that it attains the correct maximum length and b
undle the |
180 footnotes into a scheme object. | 179 footnotes into a scheme object. |
181 */ | 180 */ |
182 SCM *tail = &numbers; | 181 SCM *tail = &numbers; |
183 SCM *in_text_tail = &in_text_numbers; | 182 SCM *in_text_tail = &in_text_numbers; |
184 | 183 |
185 for (vsize i = 0; i < fn_count; i++) | 184 for (vsize i = 0; i < fn_count; i++) |
186 { | 185 { |
187 *in_text_tail = scm_cons (footnote_number_markups[i], SCM_EOL); | 186 *in_text_tail = scm_cons (footnote_number_markups[i], SCM_EOL); |
188 in_text_tail = SCM_CDRLOC (*in_text_tail); | 187 in_text_tail = SCM_CDRLOC (*in_text_tail); |
189 footnote_number_stencils[i]->translate_axis (max_length - footnote_number_
stencils[i]->extent (X_AXIS).length (), X_AXIS); | 188 footnote_number_stencils[i]->translate_axis ((max_length |
| 189 - footnote_number_stencils[i
]->extent (X_AXIS).length ()), |
| 190 X_AXIS); |
190 *tail = scm_cons (footnote_number_stencils[i]->smobbed_copy (), SCM_EOL); | 191 *tail = scm_cons (footnote_number_stencils[i]->smobbed_copy (), SCM_EOL); |
191 tail = SCM_CDRLOC (*tail); | 192 tail = SCM_CDRLOC (*tail); |
192 } | 193 } |
193 // build the footnotes | 194 // build the footnotes |
194 | 195 |
195 for (SCM s = lines; scm_is_pair (s); s = scm_cdr (s)) | 196 for (SCM s = lines; scm_is_pair (s); s = scm_cdr (s)) |
196 { | 197 { |
197 // Take care of musical systems. | 198 // Take care of musical systems. |
198 if (Grob *g = unsmob_grob (scm_car (s))) | 199 if (Grob *g = unsmob_grob (scm_car (s))) |
199 { | 200 { |
(...skipping 18 matching lines...) Expand all Loading... |
218 | 219 |
219 SCM footnote_stl = Text_interface::interpret_markup (paper->self_s
cm (), | 220 SCM footnote_stl = Text_interface::interpret_markup (paper->self_s
cm (), |
220 props, footno
te_markup); | 221 props, footno
te_markup); |
221 | 222 |
222 Stencil *footnote_stencil = unsmob_stencil (footnote_stl); | 223 Stencil *footnote_stencil = unsmob_stencil (footnote_stl); |
223 bool do_numbering = to_boolean (footnote->get_property ("automatic
ally-numbered")); | 224 bool do_numbering = to_boolean (footnote->get_property ("automatic
ally-numbered")); |
224 if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) | 225 if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) |
225 { | 226 { |
226 if (orig->is_broken ()) | 227 if (orig->is_broken ()) |
227 for (vsize i = 0; i < orig->broken_intos_.size (); i++) | 228 for (vsize i = 0; i < orig->broken_intos_.size (); i++) |
228 do_numbering = do_numbering || to_boolean (orig->broken_in
tos_[i]->get_property ("automatically-numbered")); | 229 do_numbering = do_numbering |
| 230 || to_boolean (orig->broken_intos_[i]->get_p
roperty ("automatically-numbered")); |
229 } | 231 } |
230 if (do_numbering) | 232 if (do_numbering) |
231 { | 233 { |
232 SCM annotation_scm = scm_car (in_text_numbers); | 234 SCM annotation_scm = scm_car (in_text_numbers); |
233 footnote->set_property ("text", annotation_scm); | 235 footnote->set_property ("text", annotation_scm); |
234 if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) | 236 if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) |
235 { | 237 { |
236 orig->set_property ("text", annotation_scm); | 238 orig->set_property ("text", annotation_scm); |
237 if (orig->is_broken ()) | 239 if (orig->is_broken ()) |
238 for (vsize i = 0; i < orig->broken_intos_.size (); i++) | 240 for (vsize i = 0; i < orig->broken_intos_.size (); i++) |
239 orig->broken_intos_[i]->set_property ("text", annotati
on_scm); | 241 orig->broken_intos_[i]->set_property ("text", annotati
on_scm); |
240 } | 242 } |
241 | 243 |
242 Stencil *annotation = unsmob_stencil (scm_car (numbers)); | 244 Stencil *annotation = unsmob_stencil (scm_car (numbers)); |
243 annotation->translate_axis (footnote_stencil->extent (Y_AXIS)[
UP] + number_raise - annotation->extent (Y_AXIS)[UP], Y_AXIS); | 245 annotation->translate_axis ((footnote_stencil->extent (Y_AXIS)
[UP] |
| 246 + number_raise |
| 247 - annotation->extent (Y_AXIS)[UP]
), |
| 248 Y_AXIS); |
244 footnote_stencil->add_at_edge (X_AXIS, LEFT, *annotation, 0.0)
; | 249 footnote_stencil->add_at_edge (X_AXIS, LEFT, *annotation, 0.0)
; |
245 numbers = scm_cdr (numbers); | 250 numbers = scm_cdr (numbers); |
246 in_text_numbers = scm_cdr (in_text_numbers); | 251 in_text_numbers = scm_cdr (in_text_numbers); |
247 } | 252 } |
248 if (to_boolean (footnote->get_property ("footnote"))) | 253 if (!footnote_stencil->is_empty ()) |
249 mol.add_at_edge (Y_AXIS, DOWN, *footnote_stencil, padding); | 254 { |
250 else | 255 if (to_boolean (footnote->get_property ("footnote"))) |
251 in_note_mol.add_at_edge (Y_AXIS, DOWN, *footnote_stencil, paddin
g); | 256 mol.add_at_edge (Y_AXIS, DOWN, *footnote_stencil, padding); |
| 257 else |
| 258 in_note_mol.add_at_edge (Y_AXIS, DOWN, *footnote_stencil, pa
dding); |
| 259 } |
252 } | 260 } |
253 sys->set_property ("in-note-stencil", in_note_mol.smobbed_copy ()); | 261 sys->set_property ("in-note-stencil", in_note_mol.smobbed_copy ()); |
254 sys->set_property ("footnote-stencil", mol.smobbed_copy ()); | 262 sys->set_property ("footnote-stencil", mol.smobbed_copy ()); |
255 } | 263 } |
256 // Take care of top-level markups | 264 // Take care of top-level markups |
257 else if (Prob *p = unsmob_prob (scm_car (s))) | 265 else if (Prob *p = unsmob_prob (scm_car (s))) |
258 { | 266 { |
259 SCM stencils = p->get_property ("footnotes"); | 267 SCM stencils = p->get_property ("footnotes"); |
260 Stencil footnote_stencil; | 268 Stencil mol; |
261 | 269 |
262 for (SCM st = stencils; scm_is_pair (st); st = scm_cdr (st)) | 270 for (SCM st = stencils; scm_is_pair (st); st = scm_cdr (st)) |
263 { | 271 { |
264 Stencil mol; | 272 Stencil footnote_stencil; |
265 Stencil *footnote = unsmob_stencil (scm_caddar (st)); | 273 Stencil *footnote = unsmob_stencil (scm_caddar (st)); |
266 mol.add_stencil (*footnote); | 274 footnote_stencil.add_stencil (*footnote); |
267 bool do_numbering = to_boolean (scm_cadar (st)); | 275 bool do_numbering = to_boolean (scm_cadar (st)); |
268 SCM in_text_stencil = Stencil ().smobbed_copy (); | 276 SCM in_text_stencil = Stencil ().smobbed_copy (); |
269 if (do_numbering) | 277 if (do_numbering) |
270 { | 278 { |
271 Stencil *annotation = unsmob_stencil (scm_car (numbers)); | 279 Stencil *annotation = unsmob_stencil (scm_car (numbers)); |
272 SCM in_text_annotation = scm_car (in_text_numbers); | 280 SCM in_text_annotation = scm_car (in_text_numbers); |
273 in_text_stencil = Text_interface::interpret_markup (layout, pr
ops, in_text_annotation); | 281 in_text_stencil = Text_interface::interpret_markup (layout, |
| 282 props, |
| 283 in_text_an
notation); |
274 if (!unsmob_stencil (in_text_stencil)) | 284 if (!unsmob_stencil (in_text_stencil)) |
275 in_text_stencil = SCM_EOL; | 285 in_text_stencil = SCM_EOL; |
276 annotation->translate_axis (mol.extent (Y_AXIS)[UP] + number_r
aise - annotation->extent (Y_AXIS)[UP], Y_AXIS); | 286 annotation->translate_axis ((footnote_stencil.extent (Y_AXIS)[
UP] |
277 mol.add_at_edge (X_AXIS, LEFT, *annotation, 0.0); | 287 + number_raise |
| 288 - annotation->extent (Y_AXIS)[UP]
), |
| 289 Y_AXIS); |
| 290 footnote_stencil.add_at_edge (X_AXIS, LEFT, *annotation, 0.0); |
278 numbers = scm_cdr (numbers); | 291 numbers = scm_cdr (numbers); |
279 in_text_numbers = scm_cdr (in_text_numbers); | 292 in_text_numbers = scm_cdr (in_text_numbers); |
280 } | 293 } |
281 number_footnote_table = scm_cons (scm_cons (scm_caar (st), in_text
_stencil), number_footnote_table); | 294 number_footnote_table = scm_cons (scm_cons (scm_caar (st), |
282 footnote_stencil.add_at_edge (Y_AXIS, DOWN, mol, padding); | 295 in_text_stencil), |
| 296 number_footnote_table); |
| 297 if (!footnote_stencil.is_empty ()) |
| 298 mol.add_at_edge (Y_AXIS, DOWN, footnote_stencil, padding); |
283 } | 299 } |
284 p->set_property ("footnote-stencil", footnote_stencil.smobbed_copy ())
; | 300 p->set_property ("footnote-stencil", mol.smobbed_copy ()); |
285 } | 301 } |
286 } | 302 } |
287 | 303 |
288 // note that this line of code doesn't do anything if numbering isn't turned o
n | 304 // note that this line of code doesn't do anything if numbering isn't turned o
n |
289 pb->top_paper ()->set_variable (ly_symbol2scm ("number-footnote-table"), numbe
r_footnote_table); | 305 pb->top_paper ()->set_variable (ly_symbol2scm ("number-footnote-table"), numbe
r_footnote_table); |
290 } | 306 } |
291 | 307 |
292 Stencil * | 308 Stencil * |
293 Page_layout_problem::get_footnote_separator_stencil (Output_def *paper) | 309 Page_layout_problem::get_footnote_separator_stencil (Output_def *paper) |
294 { | 310 { |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 { | 1154 { |
1139 if (Hara_kiri_group_spanner::has_interface (input[i])) | 1155 if (Hara_kiri_group_spanner::has_interface (input[i])) |
1140 Hara_kiri_group_spanner::consider_suicide (input[i]); | 1156 Hara_kiri_group_spanner::consider_suicide (input[i]); |
1141 | 1157 |
1142 if (input[i]->is_live ()) | 1158 if (input[i]->is_live ()) |
1143 output.push_back (input[i]); | 1159 output.push_back (input[i]); |
1144 } | 1160 } |
1145 | 1161 |
1146 return output; | 1162 return output; |
1147 } | 1163 } |
LEFT | RIGHT |