summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Solomon <mike@apollinemike.com>2011-08-29 17:08:02 +0200
committerMike Solomon <mike@apollinemike.com>2011-08-29 17:08:02 +0200
commit181366ec566a338c265ff4960724202d0d55ef79 (patch)
tree3520e36ba3629afac355f6d1bfc48c7893bb1777
parent7623fef74bf21fc726a8c60b535e7794f9776700 (diff)
Lets auto numbering of footnotes kick in from commands alone.
This patch gets rid of footnote-auto-numbering in the paper bloc, allowing footnotes to kick in from commands alone. These commands are: auto-footnote (for top-level markups) autoFootnote (for inside chords) autoFootnoteGrob (for normal grob-footnoting grob situations) Their homologues remain the same - to wit: footnote footnote footnoteGrob Currently, if one mixes automatic and non-automatic footnotes, the automatic footnotes skip over the non-automatic ones. So, \auto-footnote foo \footnote 42 bar \auto-footnote hello Will number the items 1, 42, 3: not 1, 42, 2. The option to make it 1, 42, 2 should be the subject of a future patch. The problem of get_footnotes_from_lines being called twice still remains and also should be solved in a separate patch.
-rw-r--r--input/regression/footnote-auto-numbering-page-reset.ly8
-rw-r--r--input/regression/footnote-auto-numbering.ly8
-rw-r--r--input/regression/footnote-break-visibility.ly4
-rw-r--r--input/regression/footnote-footer-padding.ly4
-rw-r--r--input/regression/footnote-spanner.ly1
-rw-r--r--input/regression/footnote.ly4
-rw-r--r--lily/constrained-breaking.cc2
-rw-r--r--lily/page-breaking.cc4
-rw-r--r--lily/page-layout-problem.cc80
-rw-r--r--ly/music-functions-init.ly17
-rw-r--r--ly/paper-defaults-init.ly1
-rw-r--r--scm/define-grob-interfaces.scm2
-rw-r--r--scm/define-grob-properties.scm2
-rw-r--r--scm/define-grobs.scm2
-rw-r--r--scm/define-markup-commands.scm32
-rw-r--r--scm/define-music-properties.scm2
16 files changed, 98 insertions, 75 deletions
diff --git a/input/regression/footnote-auto-numbering-page-reset.ly b/input/regression/footnote-auto-numbering-page-reset.ly
index dc3fa468b5..0663f5e80a 100644
--- a/input/regression/footnote-auto-numbering-page-reset.ly
+++ b/input/regression/footnote-auto-numbering-page-reset.ly
@@ -16,9 +16,9 @@ have been reached.
\book {
\markup {
- a \footnote b c
- \footnote d e
- \footnote f g
+ a \auto-footnote b c
+ \auto-footnote d e
+ \auto-footnote f g
}
\markup { h i }
@@ -29,7 +29,7 @@ a b c d }
\pageBreak
-\markup { k \footnote l m }
+\markup { k \auto-footnote l m }
\relative c' { a1 }
diff --git a/input/regression/footnote-auto-numbering.ly b/input/regression/footnote-auto-numbering.ly
index 3c0b410956..790278288b 100644
--- a/input/regression/footnote-auto-numbering.ly
+++ b/input/regression/footnote-auto-numbering.ly
@@ -15,9 +15,9 @@ footnotes.
\book {
\markup {
- a \footnote b c
- \footnote d e
- \footnote f g
+ a \auto-footnote b c
+ \auto-footnote d e
+ \auto-footnote f g
}
\markup { h i }
@@ -28,7 +28,7 @@ a b c d }
\pageBreak
-\markup { k \footnote l m }
+\markup { k \auto-footnote l m }
\relative c' { a1 }
diff --git a/input/regression/footnote-break-visibility.ly b/input/regression/footnote-break-visibility.ly
index 6159b5dc5f..23e9035a71 100644
--- a/input/regression/footnote-break-visibility.ly
+++ b/input/regression/footnote-break-visibility.ly
@@ -7,10 +7,6 @@ can be overrided."
#(set-default-paper-size "a6")
-\paper {
- footnote-auto-numbering = ##f
-}
-
\book {
\new Staff \with { \consists "Footnote_engraver" }
diff --git a/input/regression/footnote-footer-padding.ly b/input/regression/footnote-footer-padding.ly
index ce37e71426..b0fd84a309 100644
--- a/input/regression/footnote-footer-padding.ly
+++ b/input/regression/footnote-footer-padding.ly
@@ -5,10 +5,6 @@
#(set-default-paper-size "a6")
-\paper {
- footnote-footer-padding = 1\in
-}
-
\book {
\relative c' {
diff --git a/input/regression/footnote-spanner.ly b/input/regression/footnote-spanner.ly
index 8129d6fd4b..ec27ba7f36 100644
--- a/input/regression/footnote-spanner.ly
+++ b/input/regression/footnote-spanner.ly
@@ -8,7 +8,6 @@ annotation goes to the correct page."
\paper {
ragged-last-bottom = ##f
- footnote-auto-numbering = ##f
}
\book {
diff --git a/input/regression/footnote.ly b/input/regression/footnote.ly
index a2b1c65803..f13347d31a 100644
--- a/input/regression/footnote.ly
+++ b/input/regression/footnote.ly
@@ -3,10 +3,6 @@
texidoc = "Lilypond does footnotes."
}
-\paper {
- footnote-auto-numbering = ##f
-}
-
#(set-default-paper-size "a6")
\book {
diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc
index bff8e79df9..d269cff485 100644
--- a/lily/constrained-breaking.cc
+++ b/lily/constrained-breaking.cc
@@ -554,7 +554,7 @@ Line_details::Line_details (Prob *pb, Output_def *paper)
if (scm_is_pair (footnotes))
for (SCM s = footnotes; scm_is_pair (s); s = scm_cdr (s))
- footnotes_.push_back (unsmob_stencil (scm_cadar (s)));
+ footnotes_.push_back (unsmob_stencil (scm_caddar (s)));
last_column_ = 0;
force_ = 0;
diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc
index f81683a257..c46a04efa5 100644
--- a/lily/page-breaking.cc
+++ b/lily/page-breaking.cc
@@ -265,9 +265,7 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break, Prob_bre
footnote_padding_ = robust_scm2double (pb->paper_->c_variable ("footnote-padding"), 0.0);
footnote_footer_padding_ = robust_scm2double (pb->paper_->c_variable ("footnote-footer-padding"), 0.0);
- footnote_number_raise_ = (to_boolean (pb->paper_->c_variable ("footnote-auto-numbering"))
- ? robust_scm2double (pb->paper_->c_variable ("footnote-number-raise"), 0.0)
- : 0.0);
+ footnote_number_raise_ = robust_scm2double (pb->paper_->c_variable ("footnote-number-raise"), 0.0);
if (systems_per_page_ && (max_systems_per_page_ || min_systems_per_page_))
{
diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc
index 2988a091b6..82c0dc7181 100644
--- a/lily/page-layout-problem.cc
+++ b/lily/page-layout-problem.cc
@@ -106,8 +106,6 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo
// 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,
@@ -118,45 +116,42 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo
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
@@ -193,6 +188,13 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo
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);
@@ -226,21 +228,23 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo
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);
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index e6b8a97f58..b3a0098607 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -346,6 +346,7 @@ footnoteGrob =
(_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)
@@ -360,9 +361,14 @@ allowing for the footnote to be automatically numbered such that
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)
@@ -370,14 +376,12 @@ 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?)
@@ -387,6 +391,7 @@ such that 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{\\tweak})")
(make-music 'FootnoteEvent
+ 'automatically-numbered #t
'X-offset (car offset)
'Y-offset (cdr offset)
'text (make-null-markup)
diff --git a/ly/paper-defaults-init.ly b/ly/paper-defaults-init.ly
index c68652d8a4..d08c665f57 100644
--- a/ly/paper-defaults-init.ly
+++ b/ly/paper-defaults-init.ly
@@ -110,7 +110,6 @@
footnote-padding = 0.5\mm
footnote-footer-padding = 0.5\mm
footnote-number-raise = 0.5\mm
- footnote-auto-numbering = ##t
footnote-numbering-function = #numbered-footnotes
reset-footnotes-on-new-page = ##t
diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm
index 735b9c7895..7b6535f1e3 100644
--- a/scm/define-grob-interfaces.scm
+++ b/scm/define-grob-interfaces.scm
@@ -84,7 +84,7 @@ note)."
(ly:add-interface
'footnote-interface
"Make a footnote."
- '(footnote-text))
+ '(automatically-numbered footnote-text))
(ly:add-interface
'footnote-spanner-interface
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index c8619d9afe..cd3fd6ec97 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -58,6 +58,8 @@ arpeggio squiggly line.")
(auto-knee-gap ,ly:dimension? "If a gap is found between note
heads where a horizontal beam fits that is larger than this number,
make a kneed beam.")
+ (automatically-numbered ,boolean? "Should a footnote be automatically
+numbered?")
(average-spacing-wishes ,boolean? "If set, the spacing wishes are
averaged over staves.")
(avoid-note-head ,boolean? "If set, the stem of a chord does not
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 4bbe29beb1..1591d108bb 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -891,6 +891,7 @@
. (
(annotation-balloon . #f)
(annotation-line . #t)
+ (automatically-numbered . ,(grob::calc-property-by-copy 'automatically-numbered))
(break-visibility . ,inherit-y-parent-visibility)
(footnote-text . ,(grob::calc-property-by-copy 'footnote-text))
(stencil . ,ly:balloon-interface::print)
@@ -909,6 +910,7 @@
. (
(annotation-balloon . #f)
(annotation-line . #t)
+ (automatically-numbered . ,(grob::calc-property-by-copy 'automatically-numbered))
(footnote-text . ,(grob::calc-property-by-copy 'footnote-text))
(spanner-placement . ,LEFT)
(stencil . ,ly:balloon-interface::print-spanner)
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index cdfaf1f9f8..18728e57d9 100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -1902,17 +1902,41 @@ returns an empty markup.
(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)
(padding 0.0))
"Have footnote @var{note} act as an annotation to the markup @var{mkup}.
@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))
@@ -1970,7 +1994,7 @@ returns an empty markup.
(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)))))
diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm
index 5e11593636..a6b910c7db 100644
--- a/scm/define-music-properties.scm
+++ b/scm/define-music-properties.scm
@@ -41,6 +41,8 @@ this @code{\\lyricsto} section.")
(with @code{+} sign).")
(augmented-slash ,boolean? "This figure is for an augmented figured bass
(back-slashed number).")
+ (automatically-numbered ,boolean? "Should a footnote be automatically
+numbered?")
(autosplit-end ,boolean? "Duration of event was truncated by automatic
splitting in @code{Completion_heads_engraver}.")