]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-grav.cc
release: 0.1.36
[lilypond.git] / lily / bar-grav.cc
1 /*
2   bar-reg.cc -- implement Bar_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "bar-grav.hh"
10 #include "bar.hh"
11 #include "command-request.hh"
12 #include "time-description.hh"
13 #include "engraver-group.hh"
14
15 Bar_engraver::Bar_engraver()
16 {
17   do_post_move_processing();
18 }
19
20 bool
21 Bar_engraver::do_try_request (Request*r_l)
22 {
23   Command_req* c_l = r_l->command();
24   if (!c_l|| !c_l->bar()) 
25     return false;
26   Bar_req  * b= c_l->bar();
27   if (bar_req_l_ && bar_req_l_->equal_b (b))
28     return false;
29   
30   bar_req_l_ = b;
31
32   return true;
33 }
34
35 void
36 Bar_engraver::create_bar ()
37 {
38   if (!bar_p_)
39     {
40       bar_p_ = new Bar;
41       bar_p_->break_priority_i_  = 0;
42       announce_element (Score_elem_info (bar_p_, bar_req_l_));
43     }
44 }
45
46 void
47 Bar_engraver::do_process_requests()
48 {
49   if (bar_p_)
50     return ;
51   
52   if (bar_req_l_) 
53     {
54       create_bar ();
55       bar_p_->type_str_=bar_req_l_->type_str_;
56     }
57   else 
58     {
59       Time_description const *time = get_staff_info().time_C_;
60       if (time && !time->whole_in_measure_) 
61         create_bar ();
62     }
63   
64   if (!bar_p_)
65     {
66       Disallow_break_req r;
67       daddy_grav_l()->try_request (&r);
68     }
69 }
70
71
72 void 
73 Bar_engraver::do_pre_move_processing()
74 {
75   if (bar_p_) 
76     {
77       typeset_element (bar_p_);
78       bar_p_ =0;
79     }
80 }
81
82 void
83 Bar_engraver::do_post_move_processing()
84 {
85   bar_req_l_ = 0;
86   bar_p_ =0;
87 }
88
89
90 IMPLEMENT_IS_TYPE_B1(Bar_engraver,Engraver);
91 ADD_THIS_TRANSLATOR(Bar_engraver);
92
93