X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparenthesis-engraver.cc;h=c9b9ec62a481047adb88ba7c5a432903ad1a5f27;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=7d2a8df8997f52662ba423992403f51885700a96;hpb=e18531db1f79fb685fbd16d6a2a67bf4b6c09915;p=lilypond.git diff --git a/lily/parenthesis-engraver.cc b/lily/parenthesis-engraver.cc index 7d2a8df899..c9b9ec62a4 100644 --- a/lily/parenthesis-engraver.cc +++ b/lily/parenthesis-engraver.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2010 Han-Wen Nienhuys + Copyright (C) 2005--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify @@ -22,7 +22,6 @@ #include "item.hh" #include "pointer-group-interface.hh" -#include "simple-closure.hh" #include "stream-event.hh" #include "warn.hh" @@ -33,10 +32,11 @@ class Parenthesis_engraver : public Engraver TRANSLATOR_DECLARATIONS (Parenthesis_engraver); protected: - DECLARE_ACKNOWLEDGER (grob); + void acknowledge_grob (Grob_info); }; -Parenthesis_engraver::Parenthesis_engraver () +Parenthesis_engraver::Parenthesis_engraver (Context *c) + : Engraver (c) { } @@ -46,45 +46,50 @@ Parenthesis_engraver::acknowledge_grob (Grob_info info) if (Stream_event *ev = info.event_cause ()) { if (to_boolean (ev->get_property ("parenthesize"))) - { - if (Item *victim = dynamic_cast (info.grob ())) - { - Engraver *eng = dynamic_cast (info.origin_translator ()); - Item *paren = eng->make_item ("ParenthesesItem", victim->self_scm ()); - Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim); - - paren->set_parent (victim, Y_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."); - } - } + { + if (Item *victim = dynamic_cast (info.grob ())) + { + Engraver *eng = dynamic_cast (info.origin_translator ()); + Item *paren = eng->make_item ("ParenthesesItem", victim->self_scm ()); + Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim); + + paren->set_parent (victim, Y_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 + { + info.grob ()->warning ("Don't know how to parenthesize spanners."); + } + } } } -ADD_ACKNOWLEDGER (Parenthesis_engraver, grob); +void +Parenthesis_engraver::boot () +{ + ADD_ACKNOWLEDGER (Parenthesis_engraver, grob); +} + ADD_TRANSLATOR (Parenthesis_engraver, - /* doc */ - "Parenthesize objects whose music cause has the" - " @code{parenthesize} property.", - - /* create */ - "ParenthesesItem ", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "Parenthesize objects whose music cause has the" + " @code{parenthesize} property.", + + /* create */ + "ParenthesesItem ", + + /* read */ + "", + + /* write */ + "" + );