2 staff-regs.cc -- implement Staff_registers
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 #include "staff-sym.hh"
9 #include "voice-group-regs.hh"
10 #include "voice-regs.hh"
11 #include "staff-regs.hh"
12 #include "command-request.hh"
15 #include "input-register.hh"
18 Staff_registers::get_staff_info()
21 inf = Request_register::get_staff_info();
22 inf.staff_sym_l_=staff_sym_l_;
23 inf.c0_position_i_l_ = &c0_position_i_;
27 Staff_registers::Staff_registers(Input_register const*ireg_C)
32 add( ireg_C->get_nongroup_p_arr());
36 /** Magic function which takes a Voice_registers out of one of its own
37 children, and puts it in another. This also handles the push and
40 Staff_registers::change_group(Group_change_req * greq_l,
41 Voice_registers *voice_regs_l,
42 Voice_group_registers * old_group)
45 Voice_registers *regs_p = (old_group)
46 ? (Voice_registers*) old_group->get_register_p(
48 : new Voice_registers(
49 greq_l->voice_l(), ireg_C_->get_ireg_l("Voice_group_registers")
50 ->get_ireg_l("Voice_registers"));
52 String new_str = greq_l->newgroup_str_;
55 old_str = old_group->group_id_str_;
56 if ( new_str[0] == '+') {
57 new_str = old_str + new_str;
58 } else if (new_str[0] == '-') {
59 int idx = old_str.index_last_i('+');
61 new_str = old_str.left_str ( idx );
63 Voice_group_registers * new_group_l = get_group(new_str);
64 new_group_l->add(regs_p);
65 regs_p->sync_features();
66 mtor << "processed change_group " << get_staff_info().when()<<"\n";
70 Voice_group_registers *
71 Staff_registers::get_group(String id)
73 for (int i=0; i < group_l_arr_.size(); i++) {
74 if (group_l_arr_[i]->group_id_str_ == id)
75 return group_l_arr_[i];
77 Voice_group_registers *group_p =
78 new Voice_group_registers(id, ireg_C_->get_ireg_l("Voice_group_registers"));
79 group_l_arr_.push(group_p);
86 Staff_registers::terminate_register(Request_register * reg)
88 for (int i=0; i < group_l_arr_.size(); i++) {
89 if (group_l_arr_[i] == reg) {
91 Register_group_register::terminate_register(reg);
99 Staff_registers::try_request(Request * r)
101 bool b = Register_group_register::try_request(r);
103 Command_req * cr_l = r->command() ;
105 if (cr_l && cr_l->groupchange()) {
106 change_group(cr_l->groupchange(), 0, 0);
114 IMPLEMENT_STATIC_NAME(Staff_registers);
117 Staff_registers::acceptable_request_b(Request*r)const
119 return Register_group_register::acceptable_request_b(r) ||
120 (r->command() && r->command()->groupchange());
124 Staff_registers::acknowledge_element(Score_elem_info i)
126 Register_group_register::acknowledge_element(i);
127 if ( i.elem_l_->name() == Staff_symbol::static_name())
128 staff_sym_l_ = (Staff_symbol*)i.elem_l_->item();