function. Similar to context-spec-music.
(make-time-signature-set): specify Score as descend-only. This
fixes the polymetric.ly example.
* lily/context-specced-music-iterator.cc (construct_children): add
support for descend-only context spec.
2004-03-19 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * scm/music-functions.scm (descend-to-context): new
+ function. Similar to context-spec-music.
+ (make-time-signature-set): specify Score as descend-only. This
+ fixes the polymetric.ly example.
+
+ * lily/context-specced-music-iterator.cc (construct_children): add
+ support for descend-only context spec.
+
* lily/note-head.cc (brew_ez_stencil): read vector note-names to
determine ez-notation letter.
Context * a
= get_outlet ()->find_create_context (ct, c_id, ops);
+ if (a
+ && to_boolean (get_music ()->get_property ("descend-only"))
+ && !is_child_context (get_outlet (), a))
+ a = 0;
+
if (a)
set_translator (a);
Music_wrapper_iterator::construct_children ();
}
+
IMPLEMENT_CTOR_CALLBACK (Context_specced_music_iterator);
Music * music_;
};
+bool is_child_context (Context *me, Context *child);
#define IMPLEMENT_CTOR_CALLBACK(Class) \
LY_DEFINE_MEMBER_FUNCTION(Class,constructor, #Class "::constructor",\
return false;
}
+
+bool
+is_child_context (Context *me, Context *child)
+{
+ while (child && child != me)
+ {
+ child = child->daddy_context_;
+ }
+
+ return child == me;
+}
+
/*
move to context of child iterator if it is deeper down in the
hierarchy.
Music_iterator::descend_to_child (Context * child_report)
{
Context * me_report = get_outlet ();
-
- Context * c = child_report;
- while (c && c != me_report)
- {
- c = c->daddy_context_;
- }
-
- if (c == me_report)
+ if (is_child_context (me_report, child_report))
set_translator (child_report);
}
int
Translator::print_smob (SCM s, SCM port, scm_print_state *)
{
- Translator *sc = (Translator*) ly_cdr (s);
+ Translator *me = (Translator*) ly_cdr (s);
scm_puts ("#<Translator ", port);
- scm_puts (classname (sc), port);
+ scm_puts (classname (me), port);
+ scm_display (me->simple_trans_list_, port);
+
scm_puts (" >", port);
return 1;
}
(compress-procedure ,procedure? "compress this music expression. Argument 1: the music, arg 2: factor")
(context-id ,string? "name of context")
(context-type ,symbol? "type of context")
+ (descend-only ,boolean? "If set, this @code{\\context} will only
+descend in the context tree.")
(denominator ,integer? "denominator in a time signature")
(digit ,integer? "digit for fingering")
(direction ,ly:dir? "Print this up or down?")
(set! (ly:music-property cm 'context-id) id))
cm))
+
+(define*-public (descend-to-context m context)
+ "Like context-spec-music, but only descending. "
+ (let ((cm (context-spec-music m context)))
+ (ly:music-set-property! cm 'descend-only #t)
+ cm))
+
(define-public (make-apply-context func)
(make-music 'ApplyContext
'procedure func))
(define-public (make-time-signature-set num den . rest)
" Set properties for time signature NUM/DEN.
-Rest can contain a list of beat groupings
-
-"
+Rest can contain a list of beat groupings "
(let* ((set1 (make-property-set 'timeSignatureFraction (cons num den)))
(beat (ly:make-moment 1 den))
(len (ly:make-moment num den))
(car rest)
'())))
(basic (list set1 set2 set3 set4)))
- (context-spec-music
+ (descend-to-context
(context-spec-music (make-sequential-music basic) 'Timing) 'Score)))
(define-public (make-mark-set label)