lilypond-0.1.11
[lilypond.git] / lily / tie-grav.cc
blob660d1da9488fa05a8ec8c518e956e4e5c5876587
1 /*
2 tie-reg.cc -- implement Tie_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "tie-grav.hh"
10 #include "tie.hh"
11 #include "note-head.hh"
12 #include "musical-request.hh"
13 #include "music-list.hh"
15 Tie_engraver::Tie_engraver()
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_engraver::sync_features()
30 dir_i_ = get_feature ("vdir");
34 void
35 Tie_engraver::do_post_move_processing()
37 if (tie_p_ && get_staff_info().when () == end_mom_)
39 end_tie_p_ = tie_p_;
40 end_req_l_ = req_l_;
41 end_melodic_req_l_ = melodic_req_l_;
42 tie_p_ =0;
43 req_l_ =0;
44 end_mom_ = -1;
48 bool
49 Tie_engraver::acceptable_request_b (Request*r)
51 return r->musical() && r->musical ()->tie ();
54 bool
55 Tie_engraver::do_try_request (Request*r)
57 if (!acceptable_request_b (r))
58 return false;
59 if (req_l_)
61 return false;
63 req_l_ = r->musical()->tie ();
64 end_mom_ = r->parent_music_l_->time_int().length ()
65 + get_staff_info().when ();
66 return true;
69 void
70 Tie_engraver::do_process_requests()
72 if (req_l_ && ! tie_p_)
74 tie_p_ = new Tie;
78 void
79 Tie_engraver::acknowledge_element (Score_elem_info i)
81 if (i.elem_l_->name() == Note_head::static_name ())
83 if (tie_p_)
85 tie_p_->set_head (-1, (Note_head*)i.elem_l_->item());
86 melodic_req_l_ = i.req_l_->musical()->melodic ();
89 if (end_tie_p_)
91 end_tie_p_->set_head (1, (Note_head*)i.elem_l_->item());
92 if (!Melodic_req::compare ( *end_melodic_req_l_, *melodic_req_l_))
93 end_tie_p_->same_pitch_b_ = true;
94 announce_element (Score_elem_info (end_tie_p_,end_req_l_));
99 void
100 Tie_engraver::do_pre_move_processing()
102 if (end_tie_p_)
104 if (dir_i_)
105 end_tie_p_->dir_i_ = dir_i_;
107 typeset_element (end_tie_p_);
108 end_tie_p_ =0;
109 end_req_l_ =0;
114 Tie_engraver::~Tie_engraver()
116 if (tie_p_)
118 req_l_->warning ("unended Tie");
119 delete tie_p_;
123 void
124 Tie_engraver::set_feature (Feature f)
126 if (f.type_ == "vdir")
127 dir_i_ = f.value_;
131 IMPLEMENT_IS_TYPE_B1(Tie_engraver,Engraver);
132 ADD_THIS_ENGRAVER(Tie_engraver);