{
TRANSLATOR_DECLARATIONS (Footnote_engraver);
- DECLARE_TRANSLATOR_LISTENER (footnote);
DECLARE_ACKNOWLEDGER (grob);
DECLARE_END_ACKNOWLEDGER (grob);
- vector<Stream_event *> events_;
+
vector<Drul_array<Spanner *> > annotated_spanners_;
- void stop_translation_timestep ();
void finalize ();
- virtual void derived_mark () const;
void footnotify (Grob *, SCM);
};
-IMPLEMENT_TRANSLATOR_LISTENER (Footnote_engraver, footnote);
-void
-Footnote_engraver::listen_footnote (Stream_event *ev)
-{
- events_.push_back (ev);
-}
-
-void
-Footnote_engraver::stop_translation_timestep ()
-{
- events_.clear ();
-}
-
void
Footnote_engraver::finalize ()
{
annotated_spanners_.clear ();
}
-void
-Footnote_engraver::derived_mark () const
-{
- for (vsize i = 0; i < events_.size (); ++i)
- scm_gc_mark (events_[i]->self_scm ());
-}
-
Footnote_engraver::Footnote_engraver ()
{
}
// This grob has exhausted its footnote
info.grob ()->set_property ("footnote-music", SCM_EOL);
- return;
- }
- if (!events_.empty ())
- {
- string grobname = info.grob ()->name ();
-
- for (vsize i = 0; i < events_.size (); i++)
- {
- SCM name = events_[i]->get_property ("symbol");
- if (scm_is_symbol (name)
- && grobname == ly_symbol2string (name))
- {
- footnotify (info.grob (), events_[i]->self_scm ());
- // Event has exhausted its footnote
- events_[i]->set_property ("symbol", SCM_EOL);
- }
- }
+ return;
}
}
\consists "Figured_bass_position_engraver"
\consists "Script_row_engraver"
\consists "Cue_clef_engraver"
- \consists "Footnote_engraver"
localKeySignature = #'()
createSpacing = ##t
argument))
footnote =
-#(define-music-function (parser location mark offset grob-name footnote music)
- ((markup?) number-pair? (symbol?) markup? (ly:music?))
- (_i "Make the markup @var{footnote} a footnote on @var{music}. The
+#(define-music-function (parser location mark offset footnote item)
+ ((markup?) number-pair? markup? symbol-list-or-music?)
+ (_i "Make the markup @var{footnote} a footnote on @var{item}. The
footnote is marked with a markup @var{mark} moved by @var{offset} with
respect to the marked music.
If @var{mark} is not given or specified as @var{\\default}, it is
-replaced by an automatically generated sequence number. If a symbol
-@var{grob-name} is specified, then grobs of that type will be marked
-if they have @var{music} as their ultimate cause; by default all grobs
-having @var{music} as their @emph{direct} cause will be marked,
-similar to the way @code{\\tweak} works.
-
-If @var{music} is given as @code{\\default}, a footnote event
-affecting @emph{all} grobs matching @var{grob-name} at a given time
-step is generated. This may be required for creating footnotes on
-time signatures, clefs, and other items not cooperating with
-@code{\\tweak}.
+replaced by an automatically generated sequence number. If @var{item}
+is a symbol list of form @samp{Grob} or @samp{Context.Grob}, then
+grobs of that type will be marked at the current time step in the
+given context (default @code{Bottom}).
+
+If @var{item} is music, the music will get a footnote attached to a
+grob immediately attached to the event, like @var{\\tweak} does. For
+attaching a footnote to an @emph{indirectly} caused grob, write
+@code{\\single\\footnote}, use @var{item} to specify the grob, and
+follow it with the music to annotate.
Like with @code{\\tweak}, if you use a footnote on a following
post-event, the @code{\\footnote} command itself needs to be attached
'Y-offset (cdr offset)
'automatically-numbered (not mark)
'text (or mark (make-null-markup))
- 'footnote-text footnote
- 'symbol (or grob-name '()))))
- (cond (music
- (set! (ly:music-property music 'tweaks)
- (acons (if grob-name
- (cons grob-name 'footnote-music)
- 'footnote-music)
- mus
- (ly:music-property music 'tweaks)))
- music)
- (grob-name mus)
- (else
- (ly:input-warning location
- (_ "\\footnote requires music or grob-name"))
- (make-music 'Music)))))
+ 'footnote-text footnote)))
+ (if (ly:music? item)
+ #{ \tweak #'footnote-music #mus #item #}
+ #{ \once\override $item #'footnote-music = #mus #})))
grace =
#(def-grace-function startGraceMusic stopGraceMusic
str = re.sub (barstring + r'"empty"', '\\1\\2"-"', str)
return str
+symbol_list = (r"#'(?:" + wordsyntax + r"|\(\s*(?:" + wordsyntax + r"\s+)*"
+ + wordsyntax + r"\s*\))")
+
@rule ((2, 17, 6), r"""\accidentalStyle #'Context "style" -> \accidentalStyle Context.style
\alterBroken "Context.grob" -> \alterBroken Context.grob
\overrideProperty "Context.grob" -> \overrideProperty Context.grob
\tweak Grob #'symbol -> \tweak Grob.symbol""")
def conv (str):
+ def patrep (m):
+ def fn_path_replace (m):
+ x = string.join (re.findall (wordsyntax, m.group (2)), ".")
+ if x in ["TimeSignature", "KeySignature", "BarLine",
+ "Clef", "StaffSymbol", "OttavaBracket",
+ "LedgerLineSpanner"]:
+ x = "Staff." + x
+ return m.group (1) + x
+ if m.group (1):
+ return m.group (0)
+ x = m.group (2) + m.group (4)
+
+ if m.group (3):
+ x = x + re.sub (r"(\s*)(" + symbol_list + ")", fn_path_replace,
+ m.group (3))
+
+ if not m.group (5):
+ x = r"\single" + x
+ return x
+
str = re.sub (r'''(\\accidentalStyle\s+)#?"([-A-Za-z]+)"''',
r"\1\2", str)
str = re.sub (r'''(\\accidentalStyle\s+)#'([A-Za-z]+)\s+#?"?([-A-Za-z]+)"?''',
r"\1\2.\3", str)
str = re.sub (r'''(\\tweak\s+)#?"?([A-Za-z]+)"?\s+?#'([-A-Za-z]+)''',
r"\1\2.\3", str)
+ str = re.sub ("(" + matchmarkup + ")|"
+ + r"(\\footnote(?:\s*"
+ + matchmarkup + ")?" + matcharg + ")(" + matcharg
+ + r")?(\s+" + matchmarkup + r")(\s+\\default)?",
+ patrep, str)
return str
# Guidelines to write rules (please keep this at the end of this file)