2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 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"
24 #include "pointer-group-interface.hh"
25 #include "simple-closure.hh"
26 #include "stream-event.hh"
29 #include "translator.icc"
31 class Parenthesis_engraver : public Engraver
33 TRANSLATOR_DECLARATIONS (Parenthesis_engraver);
36 DECLARE_ACKNOWLEDGER (grob);
39 Parenthesis_engraver::Parenthesis_engraver ()
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));
65 enlarge victim to allow for parentheses space?
70 info.grob ()->warning ("Don't know how to parenthesize spanners.");
76 ADD_ACKNOWLEDGER (Parenthesis_engraver, grob);
77 ADD_TRANSLATOR (Parenthesis_engraver,
79 "Parenthesize objects whose music cause has the"
80 " @code{parenthesize} property.",