lilypond-0.1.16
[lilypond.git] / lily / tie-grav.cc
blob385de4ab05533934aed1df4bdef0e03ae8ff7913
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_ = CENTER;
27 void
28 Tie_engraver::do_post_move_processing()
30 if (tie_p_ && now_moment () == end_mom_)
32 end_tie_p_ = tie_p_;
33 end_req_l_ = req_l_;
34 end_melodic_req_l_ = melodic_req_l_;
35 tie_p_ =0;
36 req_l_ =0;
37 end_mom_ = -1;
41 bool
42 Tie_engraver::acceptable_request_b (Request*r)
44 return r->musical() && r->musical ()->tie ();
47 bool
48 Tie_engraver::do_try_request (Request*r)
50 if (!acceptable_request_b (r))
51 return false;
52 if (req_l_)
54 return false;
56 req_l_ = r->musical()->tie ();
57 end_mom_ = r->parent_music_l_->time_int().length ()
58 + now_moment ();
59 return true;
62 void
63 Tie_engraver::do_process_requests()
65 dir_ = (Direction) int (get_property ("ydirection"));
66 if (req_l_ && ! tie_p_)
68 tie_p_ = new Tie;
72 void
73 Tie_engraver::acknowledge_element (Score_elem_info i)
75 if (i.elem_l_->name() == Note_head::static_name ())
77 if (tie_p_)
79 tie_p_->set_head (LEFT, (Note_head*)i.elem_l_->item());
80 melodic_req_l_ = i.req_l_->musical()->melodic ();
83 if (end_tie_p_)
85 end_tie_p_->set_head (RIGHT, (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_engraver::do_pre_move_processing()
96 if (end_tie_p_)
98 if (dir_)
99 end_tie_p_->dir_ = dir_;
101 typeset_element (end_tie_p_);
102 end_tie_p_ =0;
103 end_req_l_ =0;
107 void
108 Tie_engraver::do_removal_processing ()
110 do_pre_move_processing ();
111 if (tie_p_)
113 req_l_->warning ("unended Tie");
114 tie_p_->unlink ();
115 delete tie_p_;
121 IMPLEMENT_IS_TYPE_B1(Tie_engraver,Engraver);
122 ADD_THIS_TRANSLATOR(Tie_engraver);