lilypond-1.5.37
[lilypond.git] / lily / bar-engraver.cc
blob864caaa82762ee9def1a835085f83ecc5db986e4
1 /*
2 bar-engraver.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #include "bar-line.hh"
11 #include "score-engraver.hh"
12 #include "musical-request.hh"
13 #include "engraver-group-engraver.hh"
14 #include "warn.hh"
15 #include "item.hh"
16 #include "engraver.hh"
19 generate bars. Either user ("|:"), or default (new measure)
22 class Bar_engraver : public Engraver
24 public:
25 TRANSLATOR_DECLARATIONS( Bar_engraver );
26 void request_bar (String type_str);
28 protected:
29 virtual void finalize ();
30 virtual void stop_translation_timestep ();
31 virtual void create_grobs ();
33 private:
34 void typeset_bar ();
35 void create_bar ();
37 Item * bar_p_;
40 Bar_engraver::Bar_engraver ()
42 bar_p_ =0;
45 void
46 Bar_engraver::create_bar ()
48 if (!bar_p_)
50 bar_p_ = new Item (get_property ("BarLine"));
52 SCM gl = get_property ("whichBar");
53 if (scm_equal_p (gl, bar_p_->get_grob_property ("glyph")) != SCM_BOOL_T)
54 bar_p_->set_grob_property ("glyph", gl);
56 announce_grob(bar_p_, SCM_EOL);
60 void
61 Bar_engraver::finalize ()
63 typeset_bar ();
67 Bar_engraver should come *after* any engravers that
68 modify whichBar
70 void
71 Bar_engraver::create_grobs ()
73 if (!bar_p_ && gh_string_p (get_property ("whichBar")))
75 create_bar ();
79 void
80 Bar_engraver::typeset_bar ()
82 if (bar_p_)
84 typeset_grob (bar_p_);
85 bar_p_ =0;
90 lines may only be broken if there is a barline in all staves
92 void
93 Bar_engraver::stop_translation_timestep ()
95 if (!bar_p_)
97 top_engraver ()->forbid_breaks (); // guh. Use properties!
99 else
100 typeset_bar ();
104 ENTER_DESCRIPTION(Bar_engraver,
105 /* descr */ "Create barlines. This engraver is controlled through the
106 @code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point",
107 /* creats*/ "BarLine",
108 /* acks */ "",
109 /* reads */ "whichBar",
110 /* write */ "");