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