]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-engraver.cc
patch::: 1.1.6.jcn1: pats
[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 #include "repeated-music.hh"
17
18 Bar_engraver::Bar_engraver()
19 {
20   bar_p_ =0;
21   do_post_move_processing();
22 }
23
24 bool
25 Bar_engraver::do_try_music (Music*r_l)
26 {
27   if (Bar_req  * b= dynamic_cast <Bar_req *> (r_l))
28     {
29       if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
30         return false;
31       
32       bar_req_l_ = b;
33
34       return true;
35     }
36   else if (Repeated_music * m = dynamic_cast<Repeated_music *> (r_l))
37     {
38       if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
39         return false;
40       bar_req_l_ = new Bar_req ("|:");
41         return true;
42     }
43   
44   return false;
45
46 }
47
48 void
49 Bar_engraver::create_bar ()
50 {
51   if (!bar_p_)
52     {
53       bar_p_ = new Bar;
54       bar_p_->break_priority_i_  = 0;
55       String default_type = get_property ("defaultBarType");
56       if (default_type.length_i ())
57         {
58           bar_p_->type_str_ = default_type;
59         }
60       announce_element (Score_element_info (bar_p_, bar_req_l_));
61     }
62 }
63
64
65 void 
66 Bar_engraver::do_creation_processing ()
67 {
68   create_bar ();
69   bar_p_->type_str_ = "";
70 }
71
72 void
73 Bar_engraver::do_removal_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_process_requests()
84 {  
85   if (bar_req_l_) 
86     {
87       if (!bar_p_)
88         create_bar ();    
89
90       bar_p_->type_str_ = bar_req_l_->type_str_;
91     }
92   else 
93     {
94       Time_description const *time = get_staff_info().time_C_;
95       String always = get_property ("barAlways");
96       if ((time && !time->whole_in_measure_) || always.length_i ()) 
97         create_bar ();
98     }
99
100   
101   
102   if (!bar_p_)
103     {
104       Break_req r;
105       r.penalty_i_ = Break_req::DISALLOW;
106       daddy_grav_l ()->try_music (&r);
107     }
108 }
109
110
111 void 
112 Bar_engraver::do_pre_move_processing()
113 {
114   if (bar_p_) 
115     {
116       typeset_element (bar_p_);
117       bar_p_ =0;
118     }
119 }
120
121 void
122 Bar_engraver::do_post_move_processing()
123 {
124   bar_req_l_ = 0;
125 }
126
127
128
129 ADD_THIS_TRANSLATOR(Bar_engraver);
130
131