2 grace-engraver.cc -- implement Grace_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
13 class Grace_engraver : public Engraver
15 void consider_change_grace_settings ();
17 virtual 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))
74 c = c->get_parent_context ();
79 execute_pushpop_property (c,
82 = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_);
86 programming_error ("can't find context");
87 scm_display (context_name, scm_current_error_port ());
92 last_moment_ = now_mom();
96 Grace_engraver::derived_mark () const
98 scm_gc_mark (grace_settings_);
99 Engraver::derived_mark ();
103 Grace_engraver::start_translation_timestep ()
105 consider_change_grace_settings ();
108 ADD_TRANSLATOR (Grace_engraver,
109 /* descr */ "Set font size and other properties for grace notes.",
113 /* reads */ "graceSettings",