You can now use something akin to
\tweak Accidental #'color #red cis'
for tweaking a grob created indirectly from the given music expression.
void
Tweak_engraver::acknowledge_grob (Grob_info info)
{
void
Tweak_engraver::acknowledge_grob (Grob_info info)
{
- if (Stream_event *ev = info.event_cause ())
+ Stream_event *ev = info.event_cause ();
+ bool direct = ev;
+ SCM grobname = SCM_UNDEFINED;
+ if (!direct)
+ ev = info.ultimate_event_cause ();
+ if (ev)
{
for (SCM s = ev->get_property ("tweaks");
scm_is_pair (s); s = scm_cdr (s))
{
{
for (SCM s = ev->get_property ("tweaks");
scm_is_pair (s); s = scm_cdr (s))
{
- info.grob ()->set_property (scm_caar (s), scm_cdar (s));
+ if (scm_is_pair (scm_caar (s))) {
+ if (SCM_UNBNDP (grobname))
+ grobname = scm_from_locale_symbol (info.grob ()->name ().c_str ());
+ if (scm_is_eq (scm_caaar (s), grobname))
+ info.grob ()->set_property (scm_cdaar (s), scm_cdar (s));
+ } else if (direct)
+ info.grob ()->set_property (scm_caar (s), scm_cdar (s));
-#(define-music-function (parser location sym val arg)
- (symbol? scheme? ly:music?)
- (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
-
- (if (equal? (object-property sym 'backend-type?) #f)
+#(define-music-function (parser location grob prop value music)
+ ((string?) symbol? scheme? ly:music?)
+ (_i "Add a tweak to the following @var{music}.
+Layout objects created by @var{music} get their property @var{prop}
+set to @var{value}. If @var{grob} is specified, like with
+@example
+\\tweak Accidental #'color #red cis'
+@end example
+an indirectly created grob (@samp{Accidental} is caused by
+@samp{NoteHead}) can be tweaked; otherwise only directly created grobs
+are affected.")
+ (if (not (object-property prop 'backend-type?))
- (ly:input-warning location (_ "cannot find property type-check for ~a") sym)
+ (ly:input-warning location (_ "cannot find property type-check for ~a") prop)
(ly:warning (_ "doing assignment anyway"))))
(set!
(ly:warning (_ "doing assignment anyway"))))
(set!
- (ly:music-property arg 'tweaks)
- (acons sym val
- (ly:music-property arg 'tweaks)))
- arg)
-
-
+ (ly:music-property music 'tweaks)
+ (acons (if grob (cons (string->symbol grob) prop) prop)
+ value
+ (ly:music-property music 'tweaks)))
+ music)
unfoldRepeats =
#(define-music-function (parser location music) (ly:music?)
unfoldRepeats =
#(define-music-function (parser location music) (ly:music?)