]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-engraver.cc
remove unnecessary code
[lilypond.git] / lily / bar-engraver.cc
1 /*
2   bar-engraver.cc -- implement Bar_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "bar-line.hh"
11 #include "context.hh"
12 #include "score-engraver.hh"
13 #include "warn.hh"
14 #include "item.hh"
15
16 #include "translator.icc"
17
18 /*
19   generate bars. Either user ("|:"), or default (new measure)
20 */
21 class Bar_engraver : public Engraver
22 {
23 public:
24   TRANSLATOR_DECLARATIONS (Bar_engraver);
25   void request_bar (string type_string);
26
27 protected:
28   void stop_translation_timestep ();
29   void process_acknowledged ();
30
31 private:
32   void create_bar ();
33
34   Item *bar_;
35 };
36
37 Bar_engraver::Bar_engraver ()
38 {
39   bar_ = 0;
40 }
41
42 void
43 Bar_engraver::create_bar ()
44 {
45   if (!bar_)
46     {
47       bar_ = make_item ("BarLine", SCM_EOL);
48       SCM gl = get_property ("whichBar");
49       if (scm_equal_p (gl, bar_->get_property ("glyph")) != SCM_BOOL_T)
50         bar_->set_property ("glyph", gl);
51     }
52 }
53
54 /*
55   Bar_engraver should come *after* any engravers that
56   modify whichBar
57
58   This is a little hairy : whichBar may be set by
59   Repeat_acknowledge_engraver::process_music, which is at score
60   context. This means that grobs could should be created after
61   process_music. We do stuff process_acknowledged (), just to be
62   on the safe side.
63 */
64
65 void
66 Bar_engraver::process_acknowledged ()
67 {
68   if (!bar_ && scm_is_string (get_property ("whichBar")))
69     create_bar ();
70 }
71
72 /*
73   lines may only be broken if there is a barline in all staves
74 */
75 void
76 Bar_engraver::stop_translation_timestep ()
77 {
78   if (!bar_)
79     context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
80
81   bar_ = 0;
82 }
83
84 ADD_TRANSLATOR (Bar_engraver,
85                 /* doc */ "Create barlines. This engraver is controlled through the "
86                 "@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point",
87                 /* create */ "BarLine",
88                 /* read */ "whichBar",
89                 /* write */ "forbidBreak");