lilypond-1.3.130
[lilypond.git] / lily / walk-regs.cc
blob328fa177cd7d25421a591034c9543415f0a97892
1 /*
2 walkregs.cc -- implement Walker_registers
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "debug.hh"
9 #include "walk-regs.hh"
10 #include "staff-regs.hh"
11 #include "score-elem.hh"
12 #include "staff.hh"
13 #include "complex-walker.hh"
14 #include "staff-column.hh"
15 #include "score-walker.hh"
16 #include "bar.hh" // needed for Bar::static_name
17 #include "input-register.hh"
18 #include "staffline.hh"
20 Walker_registers::Walker_registers(Complex_walker *w)
22 walk_l_ = w;
23 Input_register * ireg_l = w->staff_l_->ireg_p_;
24 if (ireg_l->name_str_ == "Staff_registers")
25 add(new Staff_registers(ireg_l));
26 else {
27 add(ireg_l->get_nongroup_p_arr());
31 void
32 Walker_registers::announce_element(Score_elem_info info)
34 if (info.elem_l_->name() == Bar::static_name()) {
35 walk_l_->allow_break();
37 announce_info_arr_.push(info);
40 void
41 Walker_registers::acknowledge_element(Score_elem_info )
43 assert(false);
46 void
47 Walker_registers::do_announces()
49 Request dummy_req;
50 for (int i = 0; i < announce_info_arr_.size(); i++){
51 Score_elem_info info = announce_info_arr_[i];
52 mtor << "Announcing " << info.elem_l_->name()<<"\n";
54 if (!info.req_l_)
55 info.req_l_ = &dummy_req;
56 Register_group_register::acknowledge_element(info);
58 announce_info_arr_.set_size(0);
61 void
62 Walker_registers::typeset_element(Score_elem *elem_p)
64 musical_item_p_arr_.push(elem_p);
67 void
68 Walker_registers::typeset_breakable_item(Item * pre_p , Item * nobreak_p,
69 Item * post_p)
71 if (pre_p) {
72 prebreak_item_p_arr_.push(pre_p);
73 walk_l_->staff_l_->staff_line_l_->add_element(pre_p);
75 if (nobreak_p) {
76 nobreak_item_p_arr_.push(nobreak_p);
77 walk_l_->staff_l_->staff_line_l_->add_element(nobreak_p);
79 if (post_p) {
80 postbreak_item_p_arr_.push(post_p);
81 walk_l_->staff_l_->staff_line_l_->add_element(post_p);
85 void
86 Walker_registers::pre_move_processing()
88 // this generates all items.
89 Register_group_register::pre_move_processing();
90 walk_l_->ptr()->typeset_breakable_items(prebreak_item_p_arr_,
91 nobreak_item_p_arr_,
92 postbreak_item_p_arr_);
93 for (int i=0; i < musical_item_p_arr_.size(); i++)
94 walk_l_->typeset_element(musical_item_p_arr_[i]);
95 musical_item_p_arr_.set_size(0);
97 void
98 Walker_registers::post_move_processing()
100 Register_group_register::post_move_processing();
104 Staff_info
105 Walker_registers::get_staff_info()
107 Staff_info inf;
108 if (walk_l_->score_walk_l_) // we get called ctors
109 inf.break_allowed_b_ = walk_l_->score_walk_l_->break_allowed_b();
110 inf.walk_l_ = walk_l_;
111 inf.time_C_ = &walk_l_->time_;
112 inf.rhythmic_C_ = walk_l_->default_grouping;
113 return inf;
116 Paper_def*
117 Walker_registers::paper()const
119 return walk_l_->staff_l_->paper();