]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-reg.cc
release: 0.0.46.jcn1
[lilypond.git] / lily / 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 "command-request.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     Bar_req  * b= c_l->bar();
27     if (bar_req_l_ && bar_req_l_->compare(*b))
28         return false;
29     
30     bar_req_l_ = b;
31
32     return true;
33 }
34
35 void
36 Bar_register::process_requests()
37 {
38     if (bar_req_l_ ) {
39         bar_p_ = new Bar(bar_req_l_->type_str_);
40     } else if (!get_staff_info().time_C_->whole_in_measure_) {
41         bar_p_ = new Bar("|");
42     }
43     
44     if (bar_p_){
45         announce_element(Staff_elem_info(bar_p_, bar_req_l_) );
46     }
47 }
48
49
50
51 void
52 Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post)
53 {
54     String s= no->type;
55     if (s == ":|:") {
56         pre = new Bar(":|");
57         post = new Bar("|:");
58     }else if (s=="|:") {
59         post = new Bar(s);
60     } else {
61         pre = new Bar(*no);
62     }
63 }
64
65 void 
66 Bar_register::pre_move_processing()
67 {
68       if (bar_p_) {
69           Bar * post_p =0;
70           Bar * pre_p =0;
71           split_bar(pre_p, bar_p_, post_p);
72           
73           typeset_breakable_item(pre_p, bar_p_, post_p);
74           bar_p_ =0;
75       }
76 }
77
78 void
79 Bar_register::post_move_processing()
80 {
81     bar_req_l_ = 0;
82     bar_p_ =0;
83 }
84
85 IMPLEMENT_STATIC_NAME(Bar_register);
86 ADD_THIS_REGISTER(Bar_register);
87
88