2 walkregs.cc -- implement Walker_registers
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "clef-reg.hh"
11 #include "local-key-reg.hh"
13 #include "meter-reg.hh"
16 #include "walk-regs.hh"
17 #include "staff-elem.hh"
19 #include "complex-walker.hh"
20 #include "staff-column.hh"
21 #include "voice-group-regs.hh"
22 #include "voice-regs.hh"
23 #include "commandrequest.hh"
26 Walker_registers::Walker_registers(Complex_walker
*w
)
29 add( new Bar_register
);
30 add( new Clef_register
);
31 add( new Key_register
);
32 add( new Meter_register
);
33 add( new Local_key_register
);
37 Walker_registers::announce_element(Staff_elem_info info
)
39 if (info
.elem_p_
->name() == Bar::static_name()) {
40 walk_l_
->allow_break();
42 announce_info_arr_
.push(info
);
46 Walker_registers::acknowledge_element(Staff_elem_info
)
52 Walker_registers::do_announces()
55 for (int i
= 0; i
< announce_info_arr_
.size(); i
++){
56 Staff_elem_info info
= announce_info_arr_
[i
];
59 info
.req_l_
= &dummy_req
;
60 Register_group_register::acknowledge_element(info
);
62 announce_info_arr_
.set_size(0);
66 Walker_registers::typeset_element(Staff_elem
*elem_p
)
68 typeset_musical_item(elem_p
);
72 Walker_registers::typeset_musical_item(Staff_elem
* elem_p
)
74 walk_l_
->typeset_element(elem_p
);
78 Walker_registers::typeset_breakable_item(Item
* pre_p
, Item
* nobreak_p
,
82 prebreak_item_p_arr_
.push(pre_p
);
84 nobreak_item_p_arr_
.push(nobreak_p
);
86 postbreak_item_p_arr_
.push(post_p
);
90 Walker_registers::pre_move_processing()
92 // this generates all items.
93 Register_group_register::pre_move_processing();
94 walk_l_
->ptr()->typeset_breakable_items(prebreak_item_p_arr_
,
96 postbreak_item_p_arr_
);
99 Walker_registers::post_move_processing()
101 Register_group_register::post_move_processing();
105 Walker_registers::change_group(Group_change_req
* greq_l
,
106 Voice_registers
*voice_regs_l
,
107 Voice_group_registers
* old_group
)
109 Voice_registers
*regs_p
= (old_group
)
110 ? (Voice_registers
*) old_group
->get_register_p(voice_regs_l
)
111 : new Voice_registers(greq_l
->voice_l());
112 Voice_group_registers
* new_group_l
= get_group(greq_l
->newgroup_str_
);
113 new_group_l
->add(regs_p
);
115 mtor
<< "processed change request";
119 Voice_group_registers
*
120 Walker_registers::get_group(String id
)
122 for (int i
=0; i
< group_l_arr_
.size(); i
++) {
123 if (group_l_arr_
[i
]->group_id_str_
== id
)
124 return group_l_arr_
[i
];
126 Voice_group_registers
*group_p
= new Voice_group_registers(id
);
127 group_l_arr_
.push(group_p
);
133 Walker_registers::terminate_register(Request_register
* reg
)
135 for (int i
=0; i
< group_l_arr_
.size(); i
++) {
136 if (group_l_arr_
[i
] == reg
) {
138 Register_group_register::terminate_register(reg
);
146 Walker_registers::try_request(Request
* r
)
148 bool b
= Register_group_register::try_request(r
);
150 Command_req
* cr_l
= r
->command() ;
152 if (cr_l
&& cr_l
->groupchange()) {
153 change_group(cr_l
->groupchange(), 0, 0);
155 warning("junking request: " + String(r
->name()),
163 Walker_registers::get_staff_info() return inf
;
165 inf
.c0_position_i_
= &walk_l_
->c0_position_i_
;
166 inf
.walk_l_
= walk_l_
;
167 inf
.time_c_l_
= &walk_l_
->time_
;
168 inf
.rhythmic_c_l_
= walk_l_
->default_grouping
;
171 Walker_registers::paper()const
173 return walk_l_
->staff_l_
->paper();