Ensure scripts inside chords obey manual directions.
[lilypond/mpolesky.git] / lily / parenthesis-engraver.cc
blob7d2a8df8997f52662ba423992403f51885700a96
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "engraver.hh"
23 #include "item.hh"
24 #include "pointer-group-interface.hh"
25 #include "simple-closure.hh"
26 #include "stream-event.hh"
27 #include "warn.hh"
29 #include "translator.icc"
31 class Parenthesis_engraver : public Engraver
33 TRANSLATOR_DECLARATIONS (Parenthesis_engraver);
35 protected:
36 DECLARE_ACKNOWLEDGER (grob);
39 Parenthesis_engraver::Parenthesis_engraver ()
43 void
44 Parenthesis_engraver::acknowledge_grob (Grob_info info)
46 if (Stream_event *ev = info.event_cause ())
48 if (to_boolean (ev->get_property ("parenthesize")))
50 if (Item *victim = dynamic_cast<Item*> (info.grob ()))
52 Engraver *eng = dynamic_cast<Engraver*> (info.origin_translator ());
53 Item *paren = eng->make_item ("ParenthesesItem", victim->self_scm ());
54 Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim);
56 paren->set_parent (victim, Y_AXIS);
58 Real size = robust_scm2double (paren->get_property ("font-size"), 0.0)
59 + robust_scm2double (victim->get_property ("font-size"), 0.0);
60 paren->set_property ("font-size", scm_from_double (size));
63 TODO?
65 enlarge victim to allow for parentheses space?
68 else
70 programming_error ("Don't know how to parenthesize spanners.");
76 ADD_ACKNOWLEDGER (Parenthesis_engraver, grob);
77 ADD_TRANSLATOR (Parenthesis_engraver,
78 /* doc */
79 "Parenthesize objects whose music cause has the"
80 " @code{parenthesize} property.",
82 /* create */
83 "ParenthesesItem ",
85 /* read */
86 "",
88 /* write */