* lexer-gcc-3.1.sh: Remove.
[lilypond/patrick.git] / lily / bar-engraver.cc
blob16792eac58adf2306e2b295e61f8b94e2cf250db
1 /*
2 bar-engraver.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #include "bar-line.hh"
11 #include "context.hh"
12 #include "score-engraver.hh"
13 #include "warn.hh"
14 #include "item.hh"
16 #include "translator.icc"
19 generate bars. Either user ("|:"), or default (new measure)
21 class Bar_engraver : public Engraver
23 public:
24 TRANSLATOR_DECLARATIONS (Bar_engraver);
25 void request_bar (string type_string);
27 protected:
28 virtual void finalize ();
29 void stop_translation_timestep ();
30 void process_acknowledged ();
32 private:
33 void typeset_bar ();
34 void create_bar ();
36 Item *bar_;
39 Bar_engraver::Bar_engraver ()
41 bar_ = 0;
44 void
45 Bar_engraver::create_bar ()
47 if (!bar_)
49 bar_ = make_item ("BarLine", SCM_EOL);
50 SCM gl = get_property ("whichBar");
51 if (scm_equal_p (gl, bar_->get_property ("glyph")) != SCM_BOOL_T)
52 bar_->set_property ("glyph", gl);
56 void
57 Bar_engraver::finalize ()
59 typeset_bar ();
63 Bar_engraver should come *after* any engravers that
64 modify whichBar
66 This is a little hairy : whichBar may be set by
67 Repeat_acknowledge_engraver::process_music, which is at score
68 context. This means that grobs could should be created after
69 process_music. We do stuff process_acknowledged (), just to be
70 on the safe side.
73 void
74 Bar_engraver::process_acknowledged ()
76 if (!bar_ && scm_is_string (get_property ("whichBar")))
77 create_bar ();
80 void
81 Bar_engraver::typeset_bar ()
83 bar_ = 0;
87 lines may only be broken if there is a barline in all staves
89 void
90 Bar_engraver::stop_translation_timestep ()
92 if (!bar_)
93 context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
94 else
95 typeset_bar ();
98 ADD_TRANSLATOR (Bar_engraver,
99 /* doc */ "Create barlines. This engraver is controlled through the "
100 "@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point",
101 /* create */ "BarLine",
102 /* accept */ "",
103 /* read */ "whichBar",
104 /* write */ "forbidBreak");