]> git.donarmstrong.com Git - lilypond.git/blob - src/scriptreg.cc
release: 0.0.31
[lilypond.git] / src / scriptreg.cc
1 /*
2   scriptreg.cc -- implement Script_register
3
4   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6
7 #include "scriptreg.hh"
8 #include "script.hh"
9 #include "request.hh"
10 #include "complexwalker.hh"
11
12 Script_register::Script_register(Complex_walker*w)
13     : Request_register(w)
14 {
15     script_p_ = 0;
16 }
17
18 bool
19 Script_register::try_request(Request *r_l)
20 {
21     if (!r_l->script())
22         return false ;
23
24     if (accepted_req_arr_.size()
25         && Script_req::compare(*accepted_req_arr_[0]->script(), *r_l->script()))
26         
27         return false;
28
29     accepted_req_arr_.push(r_l);
30     
31     return true;
32 }
33
34 void
35 Script_register::process_request()
36 {
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));
41     }
42 }
43
44 void
45 Script_register::acknowledge_element(Staff_elem_info info)
46 {
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());
53 }
54
55 void
56 Script_register::do_pre_move_process()
57 {
58     if (script_p_){
59         script_p_->dir = dir_i_;
60         typeset_element(script_p_);
61         script_p_ = 0;
62     }
63 }
64
65 void
66 Script_register::set_dir(int i)
67 {
68     dir_i_ = i;
69 }