From b5d340e5ecb2147e209401f29ffa8984a5a99548 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 9 Feb 2006 15:02:50 +0000 Subject: [PATCH] *** empty log message *** --- lily/parenthesis-engraver.cc | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 lily/parenthesis-engraver.cc diff --git a/lily/parenthesis-engraver.cc b/lily/parenthesis-engraver.cc new file mode 100644 index 0000000000..13aba090bd --- /dev/null +++ b/lily/parenthesis-engraver.cc @@ -0,0 +1,77 @@ +/* + parenthesis-engraver.cc -- implement Parenthesis_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2005--2006 Han-Wen Nienhuys + +*/ + +#include "engraver.hh" + +#include "warn.hh" +#include "simple-closure.hh" +#include "music.hh" +#include "grob.hh" +#include "item.hh" + +#include "translator.icc" + +class Parenthesis_engraver : public Engraver +{ + TRANSLATOR_DECLARATIONS (Parenthesis_engraver); + +protected: + DECLARE_ACKNOWLEDGER (grob); +}; + +Parenthesis_engraver::Parenthesis_engraver() +{ +} + + + +void +Parenthesis_engraver::acknowledge_grob (Grob_info info) +{ + if (Music *music = info.music_cause ()) + { + if (to_boolean (music->get_property ("parenthesize"))) + { + if (Item *victim = dynamic_cast (info.grob ())) + { + Engraver *eng = dynamic_cast (info.origin_translator ()); + Item *paren = make_item_from_properties (eng, + ly_symbol2scm ("ParenthesesItem"), + victim->self_scm (), + "ParenthesesItem"); + + paren->set_parent (victim, Y_AXIS); + paren->set_parent (victim, X_AXIS); + Real size = robust_scm2double (paren->get_property ("font-size"), 0.0) + + robust_scm2double (victim->get_property ("font-size"), 0.0); + paren->set_property ("font-size", scm_from_double (size)); + + /* + TODO? + + enlarge victim to allow for parentheses space? + */ + } + else + { + programming_error ("Don't know how to parenthesize spanners."); + } + } + } +} + +ADD_ACKNOWLEDGER (Parenthesis_engraver, grob); +ADD_TRANSLATOR (Parenthesis_engraver, + /* doc */ "Parenthesize objects whose music cause has the @code{parenthesize} " + "property.", + + /* create */ "ParenthesesItem", + /* accept */ "", + /* read */ "", + /* write */ ""); -- 2.39.5