2 grace-engraver.cc -- implement Grace_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
13 class Grace_engraver
: public Engraver
15 void consider_change_grace_settings ();
17 void start_translation_timestep ();
18 virtual void derived_mark () const;
19 virtual void initialize ();
21 TRANSLATOR_DECLARATIONS (Grace_engraver
);
27 Grace_engraver::Grace_engraver ()
29 grace_settings_
= SCM_EOL
;
30 last_moment_
= Moment (Rational (-1, 1));
34 Grace_engraver::initialize ()
36 consider_change_grace_settings ();
40 Grace_engraver::consider_change_grace_settings ()
42 Moment now
= now_mom ();
43 if (last_moment_
.grace_part_
&& !now
.grace_part_
)
45 for (SCM s
= grace_settings_
; scm_is_pair (s
); s
= scm_cdr (s
))
47 SCM context
= scm_caar (s
);
48 SCM entry
= scm_cdar (s
);
49 SCM grob
= scm_cadr (entry
);
50 SCM sym
= scm_caddr (entry
);
52 execute_pushpop_property (unsmob_context (context
),
53 grob
, sym
, SCM_UNDEFINED
);
56 grace_settings_
= SCM_EOL
;
58 else if (!last_moment_
.grace_part_
&& now
.grace_part_
)
60 SCM settings
= get_property ("graceSettings");
62 grace_settings_
= SCM_EOL
;
63 for (SCM s
= settings
; scm_is_pair (s
); s
= scm_cdr (s
))
65 SCM entry
= scm_car (s
);
66 SCM context_name
= scm_car (entry
);
67 SCM grob
= scm_cadr (entry
);
68 SCM sym
= scm_caddr (entry
);
69 SCM val
= scm_cadr (scm_cddr (entry
));
71 Context
*c
= context ();
72 while (c
&& !c
->is_alias (context_name
))
73 c
= c
->get_parent_context ();
77 execute_pushpop_property (c
,
80 = scm_cons (scm_cons (c
->self_scm (), entry
), grace_settings_
);
83 programming_error ("cannot find context from graceSettings: "
84 + ly_symbol2string (context_name
));
88 last_moment_
= now_mom ();
92 Grace_engraver::derived_mark () const
94 scm_gc_mark (grace_settings_
);
95 Engraver::derived_mark ();
99 Grace_engraver::start_translation_timestep ()
101 consider_change_grace_settings ();
104 #include "translator.icc"
106 ADD_TRANSLATOR (Grace_engraver
,
108 "Set font size and other properties for grace notes.",