X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbar-engraver.cc;h=6bf118ae8b31a10ab4b06b6c5877be0adac594c2;hb=5affcbfc2285da731e317dbe32fac312c67b662b;hp=3875c05da0932f76e7794db09664b40eccda77d2;hpb=f2c2c5c43858f323e4708f83fd97e0f38017c275;p=lilypond.git diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index 3875c05da0..6bf118ae8b 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -3,14 +3,16 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2005 Han-Wen Nienhuys + (c) 1997--2009 Han-Wen Nienhuys Jan Nieuwenhuizen */ #include "bar-line.hh" +#include "context.hh" #include "score-engraver.hh" #include "warn.hh" #include "item.hh" +#include "spanner.hh" #include "translator.icc" @@ -21,18 +23,19 @@ class Bar_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Bar_engraver); - void request_bar (String type_string); + void request_bar (string type_string); protected: - virtual void finalize (); - PRECOMPUTED_VIRTUAL void stop_translation_timestep (); - PRECOMPUTED_VIRTUAL void process_acknowledged (); + void stop_translation_timestep (); + void process_acknowledged (); + + DECLARE_END_ACKNOWLEDGER (spanner); private: - void typeset_bar (); void create_bar (); Item *bar_; + vector spanners_; }; Bar_engraver::Bar_engraver () @@ -52,12 +55,6 @@ Bar_engraver::create_bar () } } -void -Bar_engraver::finalize () -{ - typeset_bar (); -} - /* Bar_engraver should come *after* any engravers that modify whichBar @@ -74,12 +71,10 @@ Bar_engraver::process_acknowledged () { if (!bar_ && scm_is_string (get_property ("whichBar"))) create_bar (); -} -void -Bar_engraver::typeset_bar () -{ - bar_ = 0; + if (bar_) + for (vsize i = 0; i < spanners_.size (); i++) + spanners_[i]->set_bound (RIGHT, bar_); } /* @@ -89,16 +84,35 @@ void Bar_engraver::stop_translation_timestep () { if (!bar_) - /* guh. Use properties! */ - get_score_engraver ()->forbid_breaks (); - else - typeset_bar (); + context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T); + + bar_ = 0; + spanners_.clear (); +} + +void +Bar_engraver::acknowledge_end_spanner (Grob_info gi) +{ + Grob *g = gi.grob (); + + if (to_boolean (g->get_property ("to-barline"))) + spanners_.push_back (dynamic_cast (g)); } +ADD_END_ACKNOWLEDGER (Bar_engraver, spanner); + ADD_TRANSLATOR (Bar_engraver, - /* descr */ "Create barlines. This engraver is controlled through the " - "@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point", - /* creats*/ "BarLine", - /* accepts */ "", - /* reads */ "whichBar", - /* write */ ""); + /* doc */ + "Create barlines. This engraver is controlled through the" + " @code{whichBar} property. If it has no bar line to create," + " it will forbid a linebreak at this point.", + + /* create */ + "BarLine ", + + /* read */ + "whichBar ", + + /* write */ + "forbidBreak " + );