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.
*/
#include "grace-iterator.hh"
-
-#include "grace-music.hh"
#include "global-context.hh"
#include "warn.hh"
*/
-#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);
+++ /dev/null
-/*
- 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 */
-
public:
Moment music_get_length () const;
- virtual Moment music_start_mom () const;
+ Moment music_start_mom () const;
Music_iterator ();
/**
public:
Simultaneous_music (SCM);
VIRTUAL_COPY_CONSTRUCTOR (Music, Simultaneous_music);
-
virtual Pitch to_relative_octave (Pitch);
- virtual Moment start_mom () const;
};
/*
{
public:
VIRTUAL_COPY_CONSTRUCTOR (Music, Sequential_music);
- virtual Moment start_mom () const;
-
Sequential_music (SCM);
};
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);
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 */
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);
SCM mutable_property_alist_;
protected:
SCM length_callback_;
+ SCM start_callback_;
friend SCM ly_extended_make_music (SCM, SCM);
};
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)
{
{
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
ADD_MUSIC (Music_wrapper);
-
-Moment
-Music_wrapper::start_mom () const
-{
- return element ()->start_mom ();
-}
smobify_self ();
length_callback_ = get_property ("length-callback");
+ start_callback_ = get_property ("start-callback");
}
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 ());
}
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 ());
MAKE_SCHEME_CALLBACK (Repeated_music,minimum_start, 1);
-MAKE_SCHEME_CALLBACK (Repeated_music,first_start, 1);
-
SCM
Repeated_music::minimum_start (SCM m)
{
}
}
+MAKE_SCHEME_CALLBACK (Repeated_music,first_start, 1);
SCM
Repeated_music::first_start (SCM m)
{
}
ADD_MUSIC (Sequential_music);
-
-Moment
-Sequential_music::start_mom () const
-{
- return Music_sequence::first_start (get_property ("elements"));
-}
#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)
{
(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.")
(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))
(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)
))
. (
(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}.")
(internal-class-name . "Music")
(types . (layout-instruction general-music))
(iterator-ctor . ,Property_unset_iterator::constructor)
- )
- )
+ ))
(PesOrFlexaEvent
. (
(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))
))
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))
))
(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))
(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))
))
. (
(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)
(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))
))
(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)
(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))
))