lilypond-0.0.50
[lilypond.git] / lily / bar-reg.cc
blob8450b6bf7e8ab5687c62d9a74f9ddc0fb5fc986c
1 /*
2 bar-reg.cc -- implement Bar_register
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "bar-reg.hh"
10 #include "bar.hh"
11 #include "command-request.hh"
12 //#include "score-column.hh"
13 #include "time-description.hh"
15 Bar_register::Bar_register()
17 post_move_processing();
20 bool
21 Bar_register::try_request(Request*r_l)
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;
30 bar_req_l_ = b;
32 return true;
35 void
36 Bar_register::process_requests()
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("|");
44 if (bar_p_){
45 announce_element(Staff_elem_info(bar_p_, bar_req_l_) );
51 void
52 Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post)
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);
65 void
66 Bar_register::pre_move_processing()
68 if (bar_p_) {
69 Bar * post_p =0;
70 Bar * pre_p =0;
71 split_bar(pre_p, bar_p_, post_p);
73 typeset_breakable_item(pre_p, bar_p_, post_p);
74 bar_p_ =0;
78 void
79 Bar_register::post_move_processing()
81 bar_req_l_ = 0;
82 bar_p_ =0;
85 IMPLEMENT_STATIC_NAME(Bar_register);
86 ADD_THIS_REGISTER(Bar_register);