Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / grace-engraver.cc
blob19072ae7ad4358261cede36e5e67c73f2a307e4c
1 /*
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>
7 */
9 #include "engraver.hh"
10 #include "context.hh"
11 #include "warn.hh"
13 class Grace_engraver : public Engraver
15 void consider_change_grace_settings ();
16 protected:
17 void start_translation_timestep ();
18 virtual void derived_mark () const;
19 virtual void initialize ();
21 TRANSLATOR_DECLARATIONS (Grace_engraver);
22 Moment last_moment_;
23 SCM grace_settings_;
24 public:
27 Grace_engraver::Grace_engraver ()
29 grace_settings_ = SCM_EOL;
30 last_moment_ = Moment (Rational (-1, 1));
33 void
34 Grace_engraver::initialize ()
36 consider_change_grace_settings ();
39 void
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 ();
75 if (c)
77 execute_pushpop_property (c,
78 grob, sym, val);
79 grace_settings_
80 = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_);
82 else
83 programming_error ("cannot find context from graceSettings: "
84 + ly_symbol2string (context_name));
88 last_moment_ = now_mom ();
91 void
92 Grace_engraver::derived_mark () const
94 scm_gc_mark (grace_settings_);
95 Engraver::derived_mark ();
98 void
99 Grace_engraver::start_translation_timestep ()
101 consider_change_grace_settings ();
104 #include "translator.icc"
106 ADD_TRANSLATOR (Grace_engraver,
107 /* doc */
108 "Set font size and other properties for grace notes.",
110 /* create */
113 /* read */
114 "graceSettings ",
116 /* write */