lilypond-1.3.8
[lilypond.git] / src / scriptreg.cc
blobbff07f54d21c4a717b8a148efc2ed55b0616984b
1 /*
2 scriptreg.cc -- implement Script_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
7 #include "scriptreg.hh"
8 #include "script.hh"
9 #include "musicalrequest.hh"
10 #include "complexwalker.hh"
12 Script_register::Script_register(Complex_walker*w)
13 : Request_register(w)
15 script_p_ = 0;
18 bool
19 Script_register::try_request(Request *r_l)
21 if (!r_l->script())
22 return false ;
24 if (accepted_req_arr_.size()
25 && Script_req::compare(*accepted_req_arr_[0]->script(), *r_l->script()))
27 return false;
29 accepted_req_arr_.push(r_l);
31 return true;
34 void
35 Script_register::process_request()
37 if (accepted_req_arr_.size() ) {
38 script_p_ = new Script(accepted_req_arr_[0]->script(), 10);
39 announce_element(
40 Staff_elem_info(script_p_, accepted_req_arr_[0], this));
44 void
45 Script_register::acknowledge_element(Staff_elem_info info)
47 if (!script_p_)
48 return;
49 if (info.elem_p_->name() == String("Stem"))
50 script_p_->set_stem((Stem*)info.elem_p_);
51 else if (info.req_l_->rhythmic())
52 script_p_->set_support(info.elem_p_->item());
55 void
56 Script_register::do_pre_move_process()
58 if (script_p_){
59 script_p_->dir = dir_i_;
60 typeset_element(script_p_);
61 script_p_ = 0;
65 void
66 Script_register::set_dir(int i)
68 dir_i_ = i;