]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-engraver.cc
release: 1.3.83
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "bar.hh"
11 #include "score-engraver.hh"
12 #include "bar-engraver.hh"
13 #include "musical-request.hh"
14 #include "multi-measure-rest.hh"
15 #include "command-request.hh"
16
17 #include "engraver-group-engraver.hh"
18 #include "warn.hh"
19 #include "item.hh"
20
21 Bar_engraver::Bar_engraver()
22 {
23   bar_p_ =0;
24   do_post_move_processing();
25 }
26
27 void
28 Bar_engraver::create_bar ()
29 {
30   if (!bar_p_)
31     {
32       bar_p_ = new Item (get_property ("basicBarProperties"));
33       announce_element (bar_p_, 0);
34     }
35 }
36
37 void 
38 Bar_engraver::do_creation_processing ()
39 {
40 }
41
42 void
43 Bar_engraver::do_removal_processing ()
44 {
45   typeset_bar ();
46 }
47
48 /*
49   Bar_engraver should come *after* any engravers that expect bars to
50   modify whichBar in do_process_music () be typeset
51 */
52 void
53 Bar_engraver::do_process_music()
54 {
55   SCM b =get_property ("whichBar");
56   if (gh_string_p (b))
57     {
58       create_bar ();
59     }
60 }
61
62 void
63 Bar_engraver::typeset_bar ()
64 {
65   if (bar_p_) 
66     {
67       SCM gl = get_property ("whichBar");
68       if (scm_equal_p (gl, bar_p_->get_elt_property ("glyph")) != SCM_BOOL_T)
69           bar_p_->set_elt_property ("glyph", gl);
70       typeset_element (bar_p_);
71       bar_p_ =0;
72     }
73 }
74
75 /*
76   lines may only be broken if there is a barline in all staffs 
77 */
78 void 
79 Bar_engraver::do_pre_move_processing()
80 {
81   if (!bar_p_)
82     {
83       Score_engraver * e = 0;
84       Translator * t  =  daddy_grav_l ();
85       for (; !e && t;  t = t->daddy_trans_l_)
86         {
87           e = dynamic_cast<Score_engraver*> (t);
88         }
89
90       if (!e)
91         programming_error ("No score engraver!");
92       else
93         e->forbid_breaks ();    // guh. Use properties!
94     }
95   else
96     typeset_bar ();
97 }
98
99 ADD_THIS_TRANSLATOR(Bar_engraver);
100
101
102