]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-reg.cc
release: 0.0.65
[lilypond.git] / lily / bar-reg.cc
1 /*
2   bar-reg.cc -- implement Bar_register
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-reg.hh"
10 #include "bar.hh"
11 #include "command-request.hh"
12 #include "time-description.hh"
13
14 Bar_register::Bar_register()
15 {
16     post_move_processing();
17 }
18
19 bool
20 Bar_register::try_request(Request*r_l)
21 {
22     Command_req* c_l = r_l->command();
23     if (!c_l|| !c_l->bar()) 
24         return false;
25     Bar_req  * b= c_l->bar();
26     if (bar_req_l_ && bar_req_l_->compare(*b))
27         return false;
28     
29     bar_req_l_ = b;
30
31     return true;
32 }
33
34 void
35 Bar_register::process_requests()
36 {
37     if (bar_req_l_ ) {
38         bar_p_ = new Bar(bar_req_l_->type_str_);
39     } else if (!get_staff_info().time_C_->whole_in_measure_) {
40         bar_p_ = new Bar("|");
41     }
42     
43     if (bar_p_){
44         announce_element(Score_elem_info(bar_p_, bar_req_l_) );
45     }
46 }
47
48
49
50 void
51 Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post)
52 {
53     String s= no->type;
54     if (s == ":|:") {
55         pre = new Bar(":|");
56         post = new Bar("|:");
57     }else if (s=="|:") {
58         post = new Bar(s);
59     } else {
60         pre = new Bar(*no);
61     }
62 }
63
64 void 
65 Bar_register::pre_move_processing()
66 {
67       if (bar_p_) {
68           Bar * post_p =0;
69           Bar * pre_p =0;
70           split_bar(pre_p, bar_p_, post_p);
71           
72           typeset_breakable_item(pre_p, bar_p_, post_p);
73           bar_p_ =0;
74       }
75 }
76
77 void
78 Bar_register::post_move_processing()
79 {
80     bar_req_l_ = 0;
81     bar_p_ =0;
82 }
83
84 IMPLEMENT_STATIC_NAME(Bar_register);
85 ADD_THIS_REGISTER(Bar_register);
86
87