]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie-grav.cc
partial: 1.0.1.jcn
[lilypond.git] / lily / tie-grav.cc
1 /*
2   tie-reg.cc -- implement Tie_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "tie-grav.hh"
10 #include "tie.hh"
11 #include "note-head.hh"
12 #include "musical-request.hh"
13 #include "music-list.hh"
14
15 Tie_engraver::Tie_engraver()
16 {
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;
25 }
26
27 void
28 Tie_engraver::do_post_move_processing()
29 {
30   if (tie_p_ && now_moment () == end_mom_)
31     {
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;
38     }
39 }
40
41 bool
42 Tie_engraver::do_try_request (Request*r)
43 {
44   if (! (r->musical() && r->musical ()->tie ()))
45     return false;
46   
47   if (req_l_)
48     {
49       return false;
50     }
51   req_l_ = r->musical()->tie ();
52   end_mom_ = r->parent_music_l_->time_int().length ()
53     + now_moment ();
54   return true;
55 }
56
57 void
58 Tie_engraver::do_process_requests()
59 {
60   dir_ = (Direction) int (get_property ("ydirection"));
61   if (req_l_ && ! tie_p_)
62     {
63       tie_p_ = new Tie;
64       Scalar prop = get_property ("slurdash");
65       if (prop.isnum_b ()) 
66         tie_p_->dash_i_ = prop;
67     }
68 }
69
70 void
71 Tie_engraver::acknowledge_element (Score_elem_info i)
72 {
73   if (i.elem_l_->is_type_b (Note_head::static_name ()))
74     {
75       if (tie_p_)
76         {
77           tie_p_->set_head (LEFT, (Note_head*)i.elem_l_->item());
78           melodic_req_l_ = i.req_l_->musical()->melodic ();
79         }
80
81       if (end_tie_p_)
82         {
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_));
87         }
88     }
89 }
90
91 void
92 Tie_engraver::do_pre_move_processing()
93 {
94   if (end_tie_p_)
95     {
96       if (dir_)
97         end_tie_p_->dir_ =  dir_;
98
99       typeset_element (end_tie_p_);
100       end_tie_p_ =0;
101       end_req_l_ =0;
102     }
103 }
104
105 void
106 Tie_engraver::do_removal_processing ()
107 {
108   do_pre_move_processing ();
109   if (tie_p_)
110     {
111       req_l_->warning (_("unended Tie"));
112       tie_p_->unlink ();
113       delete tie_p_;
114     }
115 }
116
117
118
119 IMPLEMENT_IS_TYPE_B1(Tie_engraver,Engraver);
120 ADD_THIS_TRANSLATOR(Tie_engraver);