Docs: NR expressive: clarify \fermata and \fermataMarkup
[lilypond/mpolesky.git] / lily / grace-engraver.cc
blobc7d8e33ed2e2e7850f48c671676837431b4c7bc2
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "context.hh"
22 #include "warn.hh"
24 class Grace_engraver : public Engraver
26 void consider_change_grace_settings ();
27 protected:
28 void start_translation_timestep ();
29 virtual void derived_mark () const;
30 virtual void initialize ();
32 TRANSLATOR_DECLARATIONS (Grace_engraver);
33 Moment last_moment_;
34 SCM grace_settings_;
35 public:
38 Grace_engraver::Grace_engraver ()
40 grace_settings_ = SCM_EOL;
41 last_moment_ = Moment (Rational (-1, 1));
44 void
45 Grace_engraver::initialize ()
47 consider_change_grace_settings ();
50 void
51 Grace_engraver::consider_change_grace_settings ()
53 Moment now = now_mom ();
54 if (last_moment_.grace_part_ && !now.grace_part_)
56 for (SCM s = grace_settings_; scm_is_pair (s); s = scm_cdr (s))
58 SCM context = scm_caar (s);
59 SCM entry = scm_cdar (s);
60 SCM grob = scm_cadr (entry);
61 SCM sym = scm_caddr (entry);
63 execute_pushpop_property (unsmob_context (context),
64 grob, sym, SCM_UNDEFINED);
67 grace_settings_ = SCM_EOL;
69 else if (!last_moment_.grace_part_ && now.grace_part_)
71 SCM settings = get_property ("graceSettings");
73 grace_settings_ = SCM_EOL;
74 for (SCM s = settings; scm_is_pair (s); s = scm_cdr (s))
76 SCM entry = scm_car (s);
77 SCM context_name = scm_car (entry);
78 SCM grob = scm_cadr (entry);
79 SCM sym = scm_caddr (entry);
80 SCM val = scm_cadr (scm_cddr (entry));
82 Context *c = context ();
83 while (c && !c->is_alias (context_name))
84 c = c->get_parent_context ();
86 if (c)
88 execute_pushpop_property (c,
89 grob, sym, val);
90 grace_settings_
91 = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_);
93 else
94 programming_error ("cannot find context from graceSettings: "
95 + ly_symbol2string (context_name));
99 last_moment_ = now_mom ();
102 void
103 Grace_engraver::derived_mark () const
105 scm_gc_mark (grace_settings_);
106 Engraver::derived_mark ();
109 void
110 Grace_engraver::start_translation_timestep ()
112 consider_change_grace_settings ();
115 #include "translator.icc"
117 ADD_TRANSLATOR (Grace_engraver,
118 /* doc */
119 "Set font size and other properties for grace notes.",
121 /* create */
124 /* read */
125 "graceSettings ",
127 /* write */