X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fscore-engraver.cc;h=88ea4af86f34003dd605dad337c56d7e7f1174b1;hb=b872748c6aa8bb721ced458691b38ac2fac5dfc8;hp=55becfef5eeb94be8de7ac784374f7b745414ddf;hpb=41e45dd730c075e78065dfa78e5e54be664d905e;p=lilypond.git diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 55becfef5e..88ea4af86f 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -1,9 +1,20 @@ /* - score-engraver.cc -- implement Score_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1997--2015 Han-Wen Nienhuys - (c) 1997--2007 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "score-engraver.hh" @@ -13,6 +24,7 @@ #include "context-def.hh" #include "dispatcher.hh" #include "global-context.hh" +#include "grob-properties.hh" #include "international.hh" #include "main.hh" #include "open-type-font.hh" @@ -37,20 +49,20 @@ Score_engraver::derived_mark () const Engraver_group::derived_mark (); } -IMPLEMENT_LISTENER (Score_engraver, prepare); void Score_engraver::prepare (SCM) { precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, DOWN); } -IMPLEMENT_LISTENER (Score_engraver, finish); void Score_engraver::finish (SCM) { - recurse_over_translators (context (), &Translator::finalize, - &Translator_group::finalize, - UP); + recurse_over_translators + (context (), + Callback0_wrapper::make_smob (), + Callback0_wrapper::make_smob (), + UP); } #define MUSIC_FONT "emmentaler-20" @@ -65,22 +77,22 @@ Score_engraver::initialize () if (!fm) { error (_f ("cannot find `%s'", MUSIC_FONT ".otf") - + "\n" - + _ ("Music font has not been installed properly.") - + "\n" - + _f ("Search path `%s'", global_path.to_string ().c_str ()) - + "\n" - + _ ("Aborting")); + + "\n" + + _ ("Music font has not been installed properly.") + + "\n" + + _f ("Search path `%s'", global_path.to_string ().c_str ()) + + "\n" + + _ ("Aborting")); } pscore_ = new Paper_score (dynamic_cast (context ()->get_output_def ())); pscore_->unprotect (); context ()->set_property ("output", pscore_->self_scm ()); - SCM props = updated_grob_properties (context (), ly_symbol2scm ("System")); + SCM props = Grob_property_info (context (), ly_symbol2scm ("System")).updated (); pscore_->typeset_system (new System (props)); - + system_ = pscore_->root_system (); context ()->set_property ("rootSystem", system_->self_scm ()); @@ -91,34 +103,34 @@ void Score_engraver::connect_to_context (Context *c) { Engraver_group::connect_to_context (c); - + Dispatcher *d = c->get_global_context ()->event_source (); - d->add_listener (GET_LISTENER (one_time_step), ly_symbol2scm ("OneTimeStep")); - d->add_listener (GET_LISTENER (prepare), ly_symbol2scm ("Prepare")); - d->add_listener (GET_LISTENER (finish), ly_symbol2scm ("Finish")); + d->add_listener (GET_LISTENER (Score_engraver, one_time_step), ly_symbol2scm ("OneTimeStep")); + d->add_listener (GET_LISTENER (Score_engraver, prepare), ly_symbol2scm ("Prepare")); + d->add_listener (GET_LISTENER (Score_engraver, finish), ly_symbol2scm ("Finish")); } /* uncovered: - - check_removal always returns false for Score contexts, it has been that way -since I joined the project. There is a reason for this: The typeset score is -stored in the Score_engraver, which in turn is accessed through the -Global_context returned by ly:run-translator. So the score-translator must be + + check_removal always returns false for Score contexts, it has been that way +since I joined the project. There is a reason for this: The typeset score is +stored in the Score_engraver, which in turn is accessed through the +Global_context returned by ly:run-translator. So the score-translator must be connected to the score-context after run-translator finishes. -I plan to change this: we should junk run-translator, and instead keep track -of both context and translator in the SCM code, and access the typeset score -directly via the created global-translator. Then it would be possible to +I plan to change this: we should junk run-translator, and instead keep track +of both context and translator in the SCM code, and access the typeset score +directly via the created global-translator. Then it would be possible to disconnect score-translators at iteration time. -es */ void Score_engraver::disconnect_from_context () { Dispatcher *d = context ()->get_global_context ()->event_source (); - d->remove_listener (GET_LISTENER (one_time_step), ly_symbol2scm ("OneTimeStep")); - d->remove_listener (GET_LISTENER (prepare), ly_symbol2scm ("Prepare")); - d->remove_listener (GET_LISTENER (finish), ly_symbol2scm ("Finish")); + d->remove_listener (GET_LISTENER (Score_engraver, one_time_step), ly_symbol2scm ("OneTimeStep")); + d->remove_listener (GET_LISTENER (Score_engraver, prepare), ly_symbol2scm ("Prepare")); + d->remove_listener (GET_LISTENER (Score_engraver, finish), ly_symbol2scm ("Finish")); Engraver_group::disconnect_from_context (); } @@ -131,7 +143,6 @@ Score_engraver::finalize () typeset_all (); } -IMPLEMENT_LISTENER (Score_engraver, one_time_step); void Score_engraver::one_time_step (SCM) { @@ -146,10 +157,10 @@ Score_engraver::one_time_step (SCM) } void -Score_engraver::announce_grob (Grob_info info) +Score_engraver::announce_grob (Grob_info info, Direction start_end, Context *reroute_context) { - Engraver_group::announce_grob (info); - if (info.start_end () == START) + Engraver_group::announce_grob (info, start_end, reroute_context); + if (start_end == START) { pscore_->root_system ()->typeset_grob (info.grob ()); elems_.push_back (info.grob ()); @@ -164,34 +175,33 @@ Score_engraver::typeset_all () Grob *elem = elems_[i]; if (!elem->get_parent (Y_AXIS)) - Axis_group_interface::add_element (system_, elem); + Axis_group_interface::add_element (system_, elem); } elems_.clear (); } ADD_TRANSLATOR_GROUP (Score_engraver, - /* doc */ - "The top-level engraver. Takes care of generating" - " columns and the complete system (i.e.," - " @code{System}).\n" - "\n" - "This engraver decides whether a column is breakable." - " The default is that a column is always breakable." - " However, every @code{Bar_engraver} that does not have" - " a bar line at a certain point sets @code{forbidBreaks}" - " to stop line breaks. In practice, this means that you" - " can make a break point by creating a bar line" - " (assuming that there are no beams or notes that" - " prevent a break point).", - - /* create */ - "System ", - - /* read */ - "currentMusicalColumn " - "currentCommandColumn " - "verticallySpacedContexts ", - - /* write */ - "" - ); + /* doc */ + "The top-level engraver. Takes care of generating" + " columns and the complete system (i.e.," + " @code{System}).\n" + "\n" + "This engraver decides whether a column is breakable." + " The default is that a column is always breakable." + " However, every @code{Bar_engraver} that does not have" + " a bar line at a certain point sets @code{forbidBreaks}" + " to stop line breaks. In practice, this means that you" + " can make a break point by creating a bar line" + " (assuming that there are no beams or notes that" + " prevent a break point).", + + /* create */ + "System ", + + /* read */ + "currentMusicalColumn " + "currentCommandColumn ", + + /* write */ + "" + );