lilypond-1.3.11
[lilypond.git] / lily / tie-reg.cc
blob725c02c277d1ce2125f21c5077f28afc8da2616a
1 /*
2 tie-reg.cc -- implement Tie_register
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "tie-reg.hh"
10 #include "tie.hh"
11 #include "note-head.hh"
12 #include "musical-request.hh"
13 #include "music-list.hh"
15 Tie_register::Tie_register()
17 end_tie_p_ = 0;
18 tie_p_ = 0;
19 req_l_ =0;
20 end_req_l_ =0;
21 end_mom_ = -1;
22 melodic_req_l_ = 0;
23 end_melodic_req_l_ =0;
24 dir_i_ = 0;
27 void
28 Tie_register::sync_features()
30 dir_i_ = get_feature("vdir");
34 void
35 Tie_register::do_post_move_processing()
37 if (tie_p_ && get_staff_info().when() == end_mom_) {
38 end_tie_p_ = tie_p_;
39 end_req_l_ = req_l_;
40 end_melodic_req_l_ = melodic_req_l_;
41 tie_p_ =0;
42 req_l_ =0;
43 end_mom_ = -1;
47 bool
48 Tie_register::acceptable_request_b(Request*r)
50 return r->musical() && r->musical()->tie();
53 bool
54 Tie_register::do_try_request(Request*r)
56 if(!acceptable_request_b(r))
57 return false;
58 if (req_l_ ) {
59 return false;
61 req_l_ = r->musical()->tie();
62 end_mom_ = r->parent_music_l_->time_int().length()
63 + get_staff_info().when();
64 return true;
67 void
68 Tie_register::do_process_requests()
70 if (req_l_ && ! tie_p_) {
71 tie_p_ = new Tie;
75 void
76 Tie_register::acknowledge_element(Score_elem_info i)
78 if (i.elem_l_->name() == Note_head::static_name()) {
79 if (tie_p_) {
80 tie_p_->set_head(-1, (Note_head*)i.elem_l_->item());
81 melodic_req_l_ = i.req_l_->musical()->melodic();
84 if (end_tie_p_) {
85 end_tie_p_->set_head(1, (Note_head*)i.elem_l_->item());
86 if (!Melodic_req::compare ( *end_melodic_req_l_, *melodic_req_l_))
87 end_tie_p_->same_pitch_b_ = true;
88 announce_element(Score_elem_info(end_tie_p_,end_req_l_));
93 void
94 Tie_register::do_pre_move_processing()
96 if (end_tie_p_) {
97 if (dir_i_)
98 end_tie_p_->dir_i_ = dir_i_;
100 typeset_element(end_tie_p_);
101 end_tie_p_ =0;
102 end_req_l_ =0;
107 Tie_register::~Tie_register()
109 if (tie_p_) {
110 req_l_->warning("unended Tie");
111 delete tie_p_;
115 void
116 Tie_register::set_feature(Feature f)
118 if (f.type_ == "vdir")
119 dir_i_ = f.value_;
122 IMPLEMENT_STATIC_NAME(Tie_register);
123 IMPLEMENT_IS_TYPE_B1(Tie_register,Request_register);
124 ADD_THIS_REGISTER(Tie_register);