// now, make the footnote stencils with the numbering function
SCM numbers = SCM_EOL;
SCM in_text_numbers = SCM_EOL;
- bool do_numbering = to_boolean (paper->c_variable ("footnote-auto-numbering"));
- // if there's no numbering, skip all this
/*
TODO: This recalculates numbering every time this function is called, including once
after the balloon prints are called. Although it is not a huge computational drain,
in duplicated work, either by making this process less complicated or (preferably)
by passing its results downstream.
*/
- if (do_numbering)
+ vector<SCM> footnote_number_markups; // Holds the numbering markups.
+ vector<Stencil *> footnote_number_stencils; // Holds translated versions of the stencilized numbering markups.
+ for (vsize i = 0; i < fn_count; i++)
{
- vector<SCM> footnote_number_markups; // Holds the numbering markups.
- vector<Stencil *> footnote_number_stencils; // Holds translated versions of the stencilized numbering markups.
- for (vsize i = 0; i < fn_count; i++)
+ SCM markup = scm_call_1 (numbering_function, scm_from_int (counter));
+ Stencil *s = unsmob_stencil (Text_interface::interpret_markup (layout, props, markup));
+ if (!s)
{
- SCM markup = scm_call_1 (numbering_function, scm_from_int (counter));
- Stencil *s = unsmob_stencil (Text_interface::interpret_markup (layout, props, markup));
- if (!s)
- {
- programming_error ("Your numbering function needs to return a stencil.");
- markup = SCM_EOL;
- s = new Stencil (Box (Interval (0, 0), Interval (0, 0)), SCM_EOL);
- }
- footnote_number_markups.push_back (markup);
- footnote_number_stencils.push_back (s);
- counter++;
+ programming_error ("Your numbering function needs to return a stencil.");
+ markup = SCM_EOL;
+ s = new Stencil (Box (Interval (0, 0), Interval (0, 0)), SCM_EOL);
}
+ footnote_number_markups.push_back (markup);
+ footnote_number_stencils.push_back (s);
+ counter++;
+ }
- // find the maximum X_AXIS length
- Real max_length = -infinity_f;
- for (vsize i = 0; i < fn_count; i++)
- max_length = max (max_length, footnote_number_stencils[i]->extent (X_AXIS).length ());
+ // find the maximum X_AXIS length
+ Real max_length = -infinity_f;
+ for (vsize i = 0; i < fn_count; i++)
+ max_length = max (max_length, footnote_number_stencils[i]->extent (X_AXIS).length ());
- /*
- translate each stencil such that it attains the correct maximum length and bundle the
- footnotes into a scheme object.
- */
- SCM *tail = &numbers;
- SCM *in_text_tail = &in_text_numbers;
+ /*
+ translate each stencil such that it attains the correct maximum length and bundle the
+ footnotes into a scheme object.
+ */
+ SCM *tail = &numbers;
+ SCM *in_text_tail = &in_text_numbers;
- for (vsize i = 0; i < fn_count; i++)
- {
- *in_text_tail = scm_cons (footnote_number_markups[i], SCM_EOL);
- in_text_tail = SCM_CDRLOC (*in_text_tail);
- footnote_number_stencils[i]->translate_axis (max_length - footnote_number_stencils[i]->extent (X_AXIS).length (), X_AXIS);
- *tail = scm_cons (footnote_number_stencils[i]->smobbed_copy (), SCM_EOL);
- tail = SCM_CDRLOC (*tail);
- }
+ for (vsize i = 0; i < fn_count; i++)
+ {
+ *in_text_tail = scm_cons (footnote_number_markups[i], SCM_EOL);
+ in_text_tail = SCM_CDRLOC (*in_text_tail);
+ footnote_number_stencils[i]->translate_axis (max_length - footnote_number_stencils[i]->extent (X_AXIS).length (), X_AXIS);
+ *tail = scm_cons (footnote_number_stencils[i]->smobbed_copy (), SCM_EOL);
+ tail = SCM_CDRLOC (*tail);
}
// build the footnotes
props, footnote_markup);
Stencil *footnote_stencil = unsmob_stencil (footnote_stl);
+ bool do_numbering = to_boolean (footnote->get_property ("automatically-numbered"));
+ if (Spanner *orig = dynamic_cast<Spanner *>(footnote))
+ {
+ if (orig->is_broken ())
+ for (vsize i = 0; i < orig->broken_intos_.size (); i++)
+ do_numbering = do_numbering || to_boolean (orig->broken_intos_[i]->get_property ("automatically-numbered"));
+ }
if (do_numbering)
{
SCM annotation_scm = scm_car (in_text_numbers);
for (SCM st = stencils; scm_is_pair (st); st = scm_cdr (st))
{
Stencil mol;
- Stencil *footnote = unsmob_stencil (scm_cadar (st));
+ Stencil *footnote = unsmob_stencil (scm_caddar (st));
mol.add_stencil (*footnote);
+ bool do_numbering = to_boolean (scm_cadar (st));
+ SCM in_text_stencil = Stencil ().smobbed_copy ();
if (do_numbering)
{
Stencil *annotation = unsmob_stencil (scm_car (numbers));
SCM in_text_annotation = scm_car (in_text_numbers);
- SCM in_text_stencil = Text_interface::interpret_markup (layout, props, in_text_annotation);
+ in_text_stencil = Text_interface::interpret_markup (layout, props, in_text_annotation);
if (!unsmob_stencil (in_text_stencil))
in_text_stencil = SCM_EOL;
- number_footnote_table = scm_cons (scm_cons (scm_caar (st), in_text_stencil), number_footnote_table);
annotation->translate_axis (mol.extent (Y_AXIS)[UP] + number_raise - annotation->extent (Y_AXIS)[UP], Y_AXIS);
mol.add_at_edge (X_AXIS, LEFT, *annotation, 0.0);
numbers = scm_cdr (numbers);
in_text_numbers = scm_cdr (in_text_numbers);
}
+ number_footnote_table = scm_cons (scm_cons (scm_caar (st), in_text_stencil), number_footnote_table);
footnote_stencil.add_at_edge (Y_AXIS, DOWN, mol, padding);
}
footnotes = scm_cons (footnote_stencil.smobbed_copy (), footnotes);
(_i "Attach @var{text} to @var{grob-name} at offset @var{offset},
with @var{text} referring to @var{footnote} (use like @code{\\once})")
(make-music 'FootnoteEvent
+ 'automatically-numbered #f
'symbol grob-name
'X-offset (car offset)
'Y-offset (cdr offset)
the number appears at @var{offset}. Note that, for this to take effect,
auto-numbering must be turned on in the paper block. Otherwise, no
number will appear. Use like @code{\\once})")
- #{
- \footnoteGrob $grob-name $offset \markup { \null } $footnote
- #})
+ (make-music 'FootnoteEvent
+ 'automatically-numbered #t
+ 'symbol grob-name
+ 'X-offset (car offset)
+ 'Y-offset (cdr offset)
+ 'text (make-null-markup)
+ 'footnote-text footnote))
+
footnote =
#(define-music-function (parser location offset text footnote)
(_i "Attach @var{text} at @var{offset} with @var{text} referring
to @var{footnote} (use like @code{\\tweak})")
(make-music 'FootnoteEvent
+ 'automatically-numbered #f
'X-offset (car offset)
'Y-offset (cdr offset)
'text text
'footnote-text footnote))
-% this function can't be a simple copy and past of the above because
-% it needs to be encapsulated in a Sequential Music.
-% so, there's a code dup of above :-(
autoFootnote =
#(define-music-function (parser location offset footnote)
(number-pair? markup?)
take effect, auto-numbering must be turned on in the paper block.
Otherwise, no number will appear. Use like @code{\\tweak})")
(make-music 'FootnoteEvent
+ 'automatically-numbered #t
'X-offset (car offset)
'Y-offset (cdr offset)
'text (make-null-markup)
(interpret-markup layout props (list anonymous-with-signature arg))))
(define-markup-command (footnote layout props mkup note)
+ (markup? markup?)
+ #:category other
+ "Have footnote @var{note} act as an annotation to the markup @var{mkup}.
+
+@lilypond[verbatim,quote]
+\\markup {
+ \\auto-footnote a b
+ \\override #'(padding . 0.2)
+ \\auto-footnote c d
+}
+@end lilypond
+The footnote will not be annotated automatically."
+ (ly:stencil-combine-at-edge
+ (interpret-markup layout props mkup)
+ X
+ RIGHT
+ (ly:make-stencil
+ `(footnote (gensym "footnote") #f ,(interpret-markup layout props note))
+ '(0 . 0)
+ '(0 . 0))
+ 0.0))
+
+(define-markup-command (auto-footnote layout props mkup note)
(markup? markup?)
#:category other
#:properties ((raise 0.5)
@lilypond[verbatim,quote]
\\markup {
- \\footnote a b
+ \\auto-footnote a b
\\override #'(padding . 0.2)
- \\footnote c d
+ \\auto-footnote c d
}
-@end lilypond"
+@end lilypond
+The footnote will be annotated automatically."
(let* ((markup-stencil (interpret-markup layout props mkup))
(auto-numbering (ly:output-def-lookup layout
'footnote-auto-numbering))
(ly:stencil-add
main-stencil
(ly:make-stencil
- `(footnote ,footnote-hash ,(interpret-markup layout props note))
+ `(footnote ,footnote-hash #t ,(interpret-markup layout props note))
'(0 . 0)
'(0 . 0)))))