lilypond-0.1.14
[lilypond.git] / src / barreg.cc
blobf0b32fd3df53cbfd66ad50232bec9d022705c184
1 /*
2 barreg.cc -- implement Bar_register
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "barreg.hh"
10 #include "bar.hh"
11 #include "commandrequest.hh"
12 #include "complexwalker.hh"
13 #include "scorecolumn.hh"
16 Bar_register::Bar_register(Complex_walker*w)
17 : Request_register(w)
19 do_post_move_process();
22 bool
23 Bar_register::try_request(Request*r_l)
25 if (!r_l->command()->bar())
26 return false;
28 assert(!bar_req_l_);
29 bar_req_l_ = r_l->command()->bar();
31 return true;
34 void
35 Bar_register::process_request()
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("|");
44 if (bar_p_){
45 walk_l_->allow_break();
46 announce_element(Staff_elem_info(bar_p_, bar_req_l_, this) );
50 void
51 Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post)
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);
64 void
65 Bar_register::do_pre_move_process()
67 if (bar_p_) {
68 Bar * post_p =0;
69 Bar * pre_p =0;
70 split_bar(pre_p, bar_p_, post_p);
72 typeset_breakable_item(pre_p, bar_p_, post_p);
73 bar_p_ =0;
77 void
78 Bar_register::do_post_move_process()
80 bar_req_l_ = 0;
81 bar_p_ =0;