]> git.donarmstrong.com Git - lilypond.git/blob - lily/script-reg.cc
release: 0.0.46.jcn1
[lilypond.git] / lily / script-reg.cc
1 /*
2   script-reg.cc -- implement Script_register
3
4   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6
7 #include "script-reg.hh"
8 #include "script.hh"
9 #include "musical-request.hh"
10 #include "complex-walker.hh"
11 #include "stem.hh"
12
13 Script_register::Script_register()
14 {
15     script_p_ = 0;
16     post_move_processing();
17 }
18
19 bool
20 Script_register::try_request(Request *r_l)
21 {
22     if (!r_l->script())
23         return false ;
24
25     if (script_req_l_
26         && Script_req::compare(*script_req_l_, *r_l->script()))
27         
28         return false;
29
30     script_req_l_ = r_l->script();
31     
32     return true;
33 }
34
35 void
36 Script_register::process_requests()
37 {
38     if (script_req_l_) {
39         script_p_ = new Script(script_req_l_, 10);
40         announce_element(
41             Staff_elem_info(script_p_, script_req_l_));
42     }
43 }
44
45 void
46 Script_register::acknowledge_element(Staff_elem_info info)
47 {
48     if (!script_p_)
49         return;
50     if (info.elem_p_->name() == Stem::static_name())
51         script_p_->set_stem((Stem*)info.elem_p_);
52     else if (info.req_l_->rhythmic())
53         script_p_->set_support(info.elem_p_->item());
54 }
55
56 void
57 Script_register::pre_move_processing()
58 {
59     if (script_p_){
60         script_p_->dir = dir_i_;
61         typeset_element(script_p_);
62         script_p_ = 0;
63     }
64 }
65 void
66 Script_register::post_move_processing()
67 {
68     script_req_l_ = 0;
69 }
70
71 void
72 Script_register::set_feature(Features i)
73 {
74     if (i.direction_i_|| i.initialiser_b_)
75         dir_i_ = i.direction_i_;
76 }
77 IMPLEMENT_STATIC_NAME(Script_register);
78 ADD_THIS_REGISTER(Script_register);