]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/include/music.hh (class Music): replace Music::start_mom()
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 14 Jan 2005 13:07:58 +0000 (13:07 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 14 Jan 2005 13:07:58 +0000 (13:07 +0000)
by start-callback property

* lily/include/grace-music.hh: remove file.

* lily/time-scaled-music.cc: remove file.

* lily/include/music.hh (class Music): include SCM init argument.
(class Music): replace Music::get_length() virtual by
length-callback property everywhere.

17 files changed:
ChangeLog
lily/grace-iterator.cc
lily/grace-music.cc
lily/include/grace-music.hh [deleted file]
lily/include/music-iterator.hh
lily/include/music-list.hh
lily/include/music-sequence.hh
lily/include/music-wrapper.hh
lily/include/music.hh
lily/music-sequence.cc
lily/music-wrapper.cc
lily/music.cc
lily/repeated-music.cc
lily/sequential-music.cc
lily/simultaneous-music.cc
scm/define-music-properties.scm
scm/define-music-types.scm

index df15f42c6e5663727a980b2bfd7b08d0c8704159..849ade778e455930e56a5c094c1ab799ba3fa7fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-01-14  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/include/music.hh (class Music): replace Music::start_mom()
+       by start-callback property
+
+       * lily/include/grace-music.hh: remove file. 
+
        * lily/stem.cc (height): robustness fix.
 
        * lily/time-scaled-music.cc: remove file.
index daa81375487ee0141b14954bc03301ac3abb69d5..e9e6259acbffefe6b83462dd41c077af8b2fde00 100644 (file)
@@ -8,8 +8,6 @@
  */
 
 #include "grace-iterator.hh"
-
-#include "grace-music.hh"
 #include "global-context.hh"
 #include "warn.hh"
 
index 02abe88c6046575af8250607f835ebcb9ed76d05..358efcdd3aa7fa616c1fe8794aeeb27f8e9ef98a 100644 (file)
@@ -7,21 +7,21 @@
   
 */
 
-#include "grace-music.hh"
-#include "grace-iterator.hh"
+#include "music.hh"
+#include "music-wrapper.hh"
 
-Moment
-Grace_music::start_mom () const
+class Grace_music
 {
-  Moment *l = unsmob_moment (Music_wrapper::length_callback (self_scm ()));
-  Moment gl;
-  gl.grace_part_ = -(l->main_part_ + l->grace_part_ );
-  return gl;
-}
+public:
+  DECLARE_SCHEME_CALLBACK(start_callback, (SCM));
+};
 
-Grace_music::Grace_music (SCM x)
-  : Music_wrapper (x)
+MAKE_SCHEME_CALLBACK(Grace_music,start_callback,1);
+SCM
+Grace_music::start_callback (SCM m) 
 {
+  Moment *l = unsmob_moment (Music_wrapper::length_callback (m));
+  Moment gl;
+  gl.grace_part_ = -(l->main_part_ + l->grace_part_ );
+  return gl.smobbed_copy ();
 }
-
-ADD_MUSIC (Grace_music);
diff --git a/lily/include/grace-music.hh b/lily/include/grace-music.hh
deleted file mode 100644 (file)
index 9ddb705..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*   
-  grace-music.hh -- declare Grace_music
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#ifndef GRACE_MUSIC_HH
-#define GRACE_MUSIC_HH
-
-#include "music-wrapper.hh"
-
-class Grace_music : public Music_wrapper
-{
-public:
-  VIRTUAL_COPY_CONSTRUCTOR (Music, Grace_music);
-  Grace_music (SCM);
-protected:
-  virtual Moment start_mom () const;
-};
-
-#endif /* GRACE_MUSIC_HH */
-
index c5fdfe912c99cf3b855008cb8fd23e09a605c896..9429273ca4af6a4a242a45d2f89a71c860fb015c 100644 (file)
@@ -60,7 +60,7 @@ protected:
 public:
   
   Moment music_get_length () const;
-  virtual Moment music_start_mom () const;
+  Moment music_start_mom () const;
   Music_iterator ();
 
   /**
index fcbcb78e934e4375c74a2426d2bd6788ef00b15d..b16e573476fd9f98049c4eca05ffedbd2b321394 100644 (file)
@@ -20,9 +20,7 @@ class Simultaneous_music : public Music_sequence
 public:
   Simultaneous_music (SCM);
   VIRTUAL_COPY_CONSTRUCTOR (Music, Simultaneous_music);
-
   virtual Pitch to_relative_octave (Pitch);
-  virtual Moment start_mom () const;
 };
 
 /*
@@ -43,8 +41,6 @@ class Sequential_music : public Music_sequence
 {
 public:
   VIRTUAL_COPY_CONSTRUCTOR (Music, Sequential_music);
-  virtual Moment start_mom () const;
-  
   Sequential_music (SCM);
 };
 
index 34e69c16b98641aa85bef9d44381eebb40c26556..46ee4507ee2ce9fa3769d8952e9910407e93c4a7 100644 (file)
@@ -19,6 +19,8 @@ public:
   VIRTUAL_COPY_CONSTRUCTOR (Music, Music_sequence);
   DECLARE_SCHEME_CALLBACK(cumulative_length_callback, (SCM));
   DECLARE_SCHEME_CALLBACK(maximum_length_callback, (SCM));
+  DECLARE_SCHEME_CALLBACK(minimum_start_callback, (SCM));
+  DECLARE_SCHEME_CALLBACK(first_start_callback, (SCM));
   SCM music_list () const;
   
   Pitch do_relative_octave (Pitch p, bool b);
index 74030955624b98c9384d4aef6d89a318511dbd12..d2aa3556760a64504f764c59321e768bd13835ea 100644 (file)
@@ -25,8 +25,9 @@ public:
   Music_wrapper (SCM);
   VIRTUAL_COPY_CONSTRUCTOR (Music, Music_wrapper);
   DECLARE_SCHEME_CALLBACK(length_callback,(SCM));
+  DECLARE_SCHEME_CALLBACK(start_callback, (SCM));
+  
   Music *element () const;
-  virtual Moment start_mom () const;
 };
 
 #endif /* MUSIC_WRAPPER_HH */
index 82de70454b5c5ee21055b136f1789a3bbf7eaf57..0eefbc3b71ec4adb977b410b3da2f41d63c29830 100644 (file)
@@ -47,7 +47,7 @@ public:
   virtual Pitch to_relative_octave (Pitch);
   String name () const;
   Moment get_length () const;
-  virtual Moment start_mom () const;
+  Moment start_mom () const;
   void print () const;
   /// Transpose, with the interval central C to #p#
   virtual void transpose (Pitch p);
@@ -61,6 +61,7 @@ protected:
   SCM mutable_property_alist_;
 protected:
   SCM length_callback_;
+  SCM start_callback_;
   friend SCM ly_extended_make_music (SCM, SCM);
 };
 
index 3051f48e6729111d8f9b8cb0048a7e45a5fa63a1..150cc9cba4fd0d569d6f0202f036caf9596aff35 100644 (file)
@@ -82,6 +82,23 @@ Music_sequence::cumulative_length_callback (SCM m)
   return cumulative_length (me->get_property ("elements")).smobbed_copy();
 }
 
+
+MAKE_SCHEME_CALLBACK(Music_sequence,minimum_start_callback,1);
+SCM
+Music_sequence::minimum_start_callback (SCM m)
+{
+  Music* me = unsmob_music (m);
+  return minimum_start (me->get_property ("elements")).smobbed_copy();
+}
+
+MAKE_SCHEME_CALLBACK(Music_sequence,first_start_callback,1);
+SCM
+Music_sequence::first_start_callback (SCM m)
+{
+  Music* me = unsmob_music (m);
+  return first_start (me->get_property ("elements")).smobbed_copy();
+}
+
 Pitch
 music_list_to_relative (SCM l,Pitch p, bool ret_first)
 {
index a8dbf95bff293f9472c17d68e6956c8f86bc7048..0a1650f991015660b3f4c4bb1a5446034ccb6cdb 100644 (file)
@@ -14,8 +14,18 @@ Music_wrapper::Music_wrapper (SCM x)
 {
   if (!ly_c_procedure_p (length_callback_))
     length_callback_ = length_callback_proc; 
+  if (!ly_c_procedure_p (start_callback_))
+    start_callback_ = length_callback_proc; 
 }
 
+MAKE_SCHEME_CALLBACK(Music_wrapper,start_callback,1);
+SCM
+Music_wrapper::start_callback (SCM m)
+{
+  Music *me = unsmob_music (m);
+  Music *elt = unsmob_music (me->get_property ("element"));
+  return elt->start_mom ().smobbed_copy ();
+}
 
 MAKE_SCHEME_CALLBACK(Music_wrapper,length_callback,1);
 SCM
@@ -35,9 +45,3 @@ Music_wrapper::element () const
 
 ADD_MUSIC (Music_wrapper);
 
-
-Moment
-Music_wrapper::start_mom () const
-{
-  return element ()->start_mom ();
-}
index f0622a731ed6b0b8f77b55b8bc796107bdcf7bd1..edaed5e3f3abf1670fab5f6f90bccdc5fa924a21 100644 (file)
@@ -47,6 +47,7 @@ Music::Music (SCM init)
   smobify_self ();
 
   length_callback_ = get_property ("length-callback");
+  start_callback_ = get_property ("start-callback");
 }
 
 Music::Music (Music const &m)
@@ -61,6 +62,7 @@ Music::Music (Music const &m)
   smobify_self ();
   mutable_property_alist_ = ly_music_deep_copy (m.mutable_property_alist_);
   length_callback_ = m.length_callback_;
+  start_callback_ = m.start_callback_;
   set_spot (*m.origin ());
 }
 
@@ -104,7 +106,7 @@ Music::get_length () const
 Moment
 Music::start_mom () const
 {
-  SCM lst = get_property ("start-moment-function");
+  SCM lst = get_property ("start-callback");
   if (ly_c_procedure_p (lst))
     {
       SCM res = scm_call_1 (lst, self_scm ());
index f145ecfe36c1e108498d31a63271239362e2ae94..90764d987e72cbcd7e020266dc18e7368466e600 100644 (file)
@@ -156,8 +156,6 @@ Repeated_music::Repeated_music (SCM x)
 
 
 MAKE_SCHEME_CALLBACK (Repeated_music,minimum_start, 1);
-MAKE_SCHEME_CALLBACK (Repeated_music,first_start, 1);
-
 SCM
 Repeated_music::minimum_start (SCM m)
 {
@@ -172,6 +170,7 @@ Repeated_music::minimum_start (SCM m)
     }
 }
 
+MAKE_SCHEME_CALLBACK (Repeated_music,first_start, 1);
 SCM
 Repeated_music::first_start (SCM m)
 {
index ada814deb0c737b23882ebcbebd2a2dac1f2b08b..dee78e2e28adab18b860e6c1a9bae88e5ae087c1 100644 (file)
@@ -7,9 +7,3 @@ Sequential_music::Sequential_music (SCM x)
 }
 
 ADD_MUSIC (Sequential_music);
-
-Moment
-Sequential_music::start_mom () const
-{
-  return Music_sequence::first_start (get_property ("elements"));
-}
index 04f0506c2beb157e464c10583157fae4898a130f..7d82cc7660bec49fe95d94c37af9938d7fc4305f 100644 (file)
 #include "music-list.hh"
 #include "scm-option.hh"
 
-Moment
-Simultaneous_music::start_mom () const
-{
-  return Music_sequence::minimum_start (get_property ("elements"));
-}
-
 Simultaneous_music::Simultaneous_music (SCM x)
   : Music_sequence (x)
 {
index b8aba452ff8364dfb4d67fd5649ee71c9be4a8af..8b730ef2ab92ff87dfc834917470ce83b1364deb 100644 (file)
@@ -98,7 +98,7 @@ processed.")
      (repeat-count  ,integer? "do a @code{\repeat} how ofen?")
      (span-direction ,ly:dir? "Does this start or stop a spanner?")
      (split-list ,list? "splitting moments for part combiner.")
-     (start-moment-function ,procedure? "Function to compute the negative length of
+     (start-callback ,procedure? "Function to compute the negative length of
 starting grace notes.")
      (string-number ,integer? "The number of the string in a String_number_req")
      (symbol ,symbol? "Grob name to perform an override/revert on.")
index 4578a7a481c8ab2037fa79d301a7c3557e90b2bd..fe790ec6a2ae0a02a1351a846d4a95ee388e28c9 100644 (file)
@@ -198,7 +198,8 @@ Syntax: @var{note}\\cr
     (GraceMusic
      . (
        (description .  "Interpret the argument as grace notes. ")
-       (internal-class-name . "Grace_music")
+       (internal-class-name . "Music_wrapper")
+       (start-callback . ,Grace_music::start_callback)
        (length . ,(ly:make-moment 0 1))
        (iterator-ctor . ,Grace_iterator::constructor)
        (types . (grace-music music-wrapper-music general-music))
@@ -352,6 +353,8 @@ SYNTAX
        (description .  "Combine two parts on a staff, either merged or
 as separate voices.")
        (internal-class-name . "Simultaneous_music")
+       (length-callback . ,Music_sequence::maximum_length_callback)
+       (start-callback . ,Music_sequence::minimum_start_callback)
        (types . (general-music part-combine-music))
        (iterator-ctor . ,Part_combine_iterator::constructor)
        ))
@@ -368,15 +371,12 @@ Syntax NOTE \\(  and \\) NOTE")
      . (
        (description .  "Set a context property.
 
-
-
 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
        (internal-class-name . "Music")
        (types . (layout-instruction general-music))
        (iterator-ctor . ,Property_iterator::constructor)
-       )
-     )
-    
+       ))
+
     (PropertyUnset
      . (
        (description .  "Remove the definition of a context @code{\\property}.")
@@ -384,8 +384,7 @@ Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
        (internal-class-name . "Music")
        (types . (layout-instruction general-music))
        (iterator-ctor . ,Property_unset_iterator::constructor)
-       )
-     )
+       ))
     
     (PesOrFlexaEvent
      . (
@@ -454,6 +453,7 @@ Syntax \\sequential @{..@} or simply @{..@} .")
 
        (internal-class-name . "Sequential_music")
        (length-callback . ,Music_sequence::cumulative_length_callback)
+       (start-callback . ,Music_sequence::first_start_callback)
        (iterator-ctor . ,Sequential_music_iterator::constructor)
        (types . (general-music sequential-music))
        ))
@@ -466,6 +466,7 @@ to group start-mmrest, skip, stop-mmrest sequence.
 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
        (internal-class-name . "Sequential_music")
        (length-callback . ,Music_sequence::cumulative_length_callback)
+       (start-callback . ,Music_sequence::first_start_callback)
        (iterator-ctor . ,Sequential_music_iterator::constructor)
        (types . (general-music sequential-music))
        ))
@@ -500,6 +501,7 @@ SYNTAX
 
        (internal-class-name . "Simultaneous_music")
        (iterator-ctor . ,Simultaneous_music_iterator::constructor)
+       (start-callback . ,Music_sequence::minimum_start_callback)
        (length-callback . ,Music_sequence::maximum_length_callback)
        
        (types . (general-music simultaneous-music))
@@ -715,7 +717,7 @@ Syntax: @code{\\\\}")
        (iterator-ctor . ,Volta_repeat_iterator::constructor)
        (internal-class-name . "Repeated_music")
        (description . "")
-       (start-moment-function .  ,Repeated_music::first_start)
+       (start-callback .  ,Repeated_music::first_start)
        (length-callback . ,Repeated_music::volta_music_length)
        (types . (general-music repeated-music volta-repeated-music))
        ))
@@ -724,7 +726,7 @@ Syntax: @code{\\\\}")
      . (
        (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
        (description .  "")
-       (start-moment-function .  ,Repeated_music::first_start)
+       (start-callback .  ,Repeated_music::first_start)
        (internal-class-name . "Repeated_music")
        (types . (general-music repeated-music unfolded-repeated-music))
        (length-callback . ,Repeated_music::unfolded_music_length)
@@ -734,7 +736,7 @@ Syntax: @code{\\\\}")
        (internal-class-name . "Repeated_music")
        (description .  "Repeats encoded by percents.")
        (iterator-ctor . ,Percent_repeat_iterator::constructor)
-       (start-moment-function .  ,Repeated_music::first_start)
+       (start-callback .  ,Repeated_music::first_start)
        (length-callback . ,Repeated_music::unfolded_music_length)
        (types . (general-music repeated-music percent-repeated-music))
        ))
@@ -744,7 +746,7 @@ Syntax: @code{\\\\}")
        (iterator-ctor . ,Chord_tremolo_iterator::constructor)
        (description .  "Repeated notes denoted by tremolo beams.")
        (internal-class-name . "Repeated_music")
-       (start-moment-function .  ,Repeated_music::first_start)
+       (start-callback .  ,Repeated_music::first_start)
 
        ;; the length of the repeat is handled by shifting the note logs
        (length-callback . ,Repeated_music::folded_music_length)
@@ -757,7 +759,7 @@ Syntax: @code{\\\\}")
        (internal-class-name . "Repeated_music")
        (description .  "Repeats with alternatives placed in parallel. ")
        (iterator-ctor  . ,Folded_repeat_iterator::constructor)
-       (start-moment-function .  ,Repeated_music::minimum_start)
+       (start-callback .  ,Repeated_music::minimum_start)
        (length-callback . ,Repeated_music::folded_music_length)
        (types . (general-music repeated-music folded-repeated-music))
        ))