]> git.donarmstrong.com Git - lilypond.git/blob - src/bar-reg.cc
release: 0.0.38
[lilypond.git] / src / bar-reg.cc
1 /*
2   bar-reg.cc -- implement Bar_register
3
4   source file of the 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 "commandrequest.hh"
12 #include "score-column.hh"
13 #include "time-description.hh"
14
15 Bar_register::Bar_register()
16 {
17     post_move_processing();
18 }
19
20 bool
21 Bar_register::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
27     assert(!bar_req_l_);
28     bar_req_l_ = c_l->bar();
29
30     return true;
31 }
32
33 void
34 Bar_register::process_requests()
35 {
36     if (bar_req_l_ ) {
37         bar_p_ = new Bar(bar_req_l_->type_str_);
38     } else if (!get_staff_info().time_c_l_->whole_in_measure_) {
39         bar_p_ = new Bar("|");
40     }
41     
42     if (bar_p_){
43         announce_element(Staff_elem_info(bar_p_, bar_req_l_) );
44     }
45 }
46
47 void
48 Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post)
49 {
50     String s= no->type;
51     if (s == ":|:") {
52         pre = new Bar(":|");
53         post = new Bar("|:");
54     }else if (s=="|:") {
55         post = new Bar(s);
56     } else {
57         pre = new Bar(*no);
58     }
59 }
60
61 void 
62 Bar_register::pre_move_processing()
63 {
64       if (bar_p_) {
65           Bar * post_p =0;
66           Bar * pre_p =0;
67           split_bar(pre_p, bar_p_, post_p);
68           
69           typeset_breakable_item(pre_p, bar_p_, post_p);
70           bar_p_ =0;
71       }
72 }
73
74 void
75 Bar_register::post_move_processing()
76 {
77     bar_req_l_ = 0;
78     bar_p_ =0;
79 }