]> git.donarmstrong.com Git - lilypond.git/blob - src/barreg.cc
release: 0.0.34
[lilypond.git] / src / barreg.cc
1 /*
2   barreg.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 "barreg.hh"
10 #include "bar.hh"
11 #include "commandrequest.hh"
12 #include "complexwalker.hh"
13 #include "sccol.hh"
14
15
16 Bar_register::Bar_register(Complex_walker*w)
17     : Request_register(w)
18 {
19     do_post_move_process();
20 }
21
22 bool
23 Bar_register::try_request(Request*r_l)
24 {
25     if (!r_l->nonmus()->bar()) 
26         return false;
27
28     assert(!bar_req_l_);
29     bar_req_l_ = r_l->nonmus()->bar();
30
31     return true;
32 }
33
34 void
35 Bar_register::process_request()
36 {
37
38     if (bar_req_l_ ) {
39         bar_p_ = new Bar(bar_req_l_->type_str_);
40     } else if (!walk_l_->time_.whole_in_measure_) {
41         bar_p_ = new Bar("|");
42     }
43     
44     if (bar_p_){
45         walk_l_->allow_break();         
46         announce_element(Staff_elem_info(bar_p_, bar_req_l_, this) );
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::do_pre_move_process()
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::do_post_move_process()
79 {
80     bar_req_l_ = 0;
81     bar_p_ =0;
82 }