]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/music-functions.scm (descend-to-context): new
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 19 Mar 2004 00:49:58 +0000 (00:49 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 19 Mar 2004 00:49:58 +0000 (00:49 +0000)
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.

ChangeLog
lily/context-specced-music-iterator.cc
lily/include/music-iterator.hh
lily/music-iterator.cc
lily/translator-scheme.cc
scm/define-music-properties.scm
scm/music-functions.scm

index f6f898137c0f2e3e698f7113e12f3b7021b00d1a..8b2871aff8ebd39bae1968dc4123f263f7a4dab9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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. 
 
index dc4992e36c94517bead13de2e0761b7a0521ed1a..2f7445fd6760fa34bf96b8f65f93df2eab471d30 100644 (file)
@@ -32,9 +32,15 @@ Context_specced_music_iterator::construct_children ()
   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);
index 14f4aad5d15ff7ab9958773dc8025493a1eb4fc7..d35f58cac59568e3fb00b341fdd9fc46869f3212 100644 (file)
@@ -117,6 +117,7 @@ private:
   Music  * music_;
 };
 
+bool is_child_context (Context *me, Context *child);
 
 #define IMPLEMENT_CTOR_CALLBACK(Class)         \
 LY_DEFINE_MEMBER_FUNCTION(Class,constructor, #Class "::constructor",\
index 9fc288866e809fcee74294d2207d9c13bb71476e..43e28e3ebde725b92cdeefe065d1410acc2aca41 100644 (file)
@@ -237,6 +237,18 @@ Music_iterator::run_always ()const
   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.
@@ -245,13 +257,6 @@ void
 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);
 }
index 1129a7b99abfcba9d33a625e1e6ebf573c5cf0a3..c32b13b017cf7b22000a405418198f6be5f40ca0 100644 (file)
@@ -36,9 +36,11 @@ LY_DEFINE (ly_translator_description, "ly:translator-description",
 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;
 }
index e7cc07e34fb9c40ef59ac0c447446ff13bc8e218..6252131af50a65b2574337b91066a8d2fef6e4b9 100644 (file)
@@ -43,6 +43,8 @@ TODO: consider making type into symbol ")
      (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?")
index c366fbd5e3a7778a4392dea081ef4ca1da50ccdc..64dde86fc75328a27b6915cedcb4ab667f0b82c0 100644 (file)
@@ -211,6 +211,13 @@ i.e.  this is not an override"
        (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))
@@ -304,9 +311,7 @@ OTTAVATION to `8va', or whatever appropriate."
 
 (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))
@@ -316,7 +321,7 @@ Rest can contain a list of beat groupings
                                                    (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)