lilypond-1.1.67
[lilypond.git] / lily / tie-grav.cc
blobae9f6d2961f7001e2b2bcf09b141f51b1d06a2a0
1 /*
2 tie-reg.cc -- implement Tie_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 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::do_try_request (Request*r)
44 if (! (r->musical() && r->musical ()->tie ()))
45 return false;
47 if (req_l_)
49 return false;
51 req_l_ = r->musical()->tie ();
52 end_mom_ = r->parent_music_l_->time_int().length ()
53 + now_moment ();
54 return true;
57 void
58 Tie_engraver::do_process_requests()
60 dir_ = (Direction) int (get_property ("ydirection"));
61 if (req_l_ && ! tie_p_)
63 tie_p_ = new Tie;
64 Scalar prop = get_property ("slurdash");
65 if (prop.isnum_b ())
66 tie_p_->dash_i_ = prop;
70 void
71 Tie_engraver::acknowledge_element (Score_elem_info i)
73 if (i.elem_l_->is_type_b (Note_head::static_name ()))
75 if (tie_p_)
77 tie_p_->set_head (LEFT, (Note_head*)i.elem_l_->item());
78 melodic_req_l_ = i.req_l_->musical()->melodic ();
81 if (end_tie_p_)
83 end_tie_p_->set_head (RIGHT, (Note_head*)i.elem_l_->item());
84 if (!Melodic_req::compare (*end_melodic_req_l_, *melodic_req_l_))
85 end_tie_p_->same_pitch_b_ = true;
86 announce_element (Score_elem_info (end_tie_p_,end_req_l_));
91 void
92 Tie_engraver::do_pre_move_processing()
94 if (end_tie_p_)
96 if (dir_)
97 end_tie_p_->dir_ = dir_;
99 typeset_element (end_tie_p_);
100 end_tie_p_ =0;
101 end_req_l_ =0;
105 void
106 Tie_engraver::do_removal_processing ()
108 do_pre_move_processing ();
109 if (tie_p_)
111 req_l_->warning (_("unended Tie"));
112 tie_p_->unlink ();
113 delete tie_p_;
119 IMPLEMENT_IS_TYPE_B1(Tie_engraver,Engraver);
120 ADD_THIS_TRANSLATOR(Tie_engraver);