]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie.cc
release: 0.0.77.jcn1
[lilypond.git] / lily / tie.cc
1 /*
2   tie.cc -- implement Tie
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "paper-def.hh"
10 #include "tie.hh"
11 #include "note-head.hh"
12 #include "p-col.hh"
13
14
15 void
16 Tie::set_head(int x_pos, Note_head * head_l)
17 {
18     if (x_pos >0) {
19         assert(!right_head_l_);
20         right_head_l_ = head_l;
21     } else {
22         assert(!left_head_l_);
23         left_head_l_ = head_l;
24     }
25     add_dependency(head_l);
26 }
27
28 Tie::Tie()
29 {
30     right_head_l_ =0;
31     left_head_l_ =0;
32     same_pitch_b_ =false;
33 }
34
35 void
36 Tie::set_default_dir()
37 {
38     int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
39     dir_i_ =  (m < 5)? -1:1;                    // ugh
40 }
41     
42
43 void
44 Tie::do_add_processing()
45 {
46     assert(left_head_l_ && right_head_l_);
47     left_col_l_ = left_head_l_ -> pcol_l_;
48     right_col_l_ = right_head_l_ -> pcol_l_;
49 }
50
51 /**
52   This is already getting hairy. Should use Note_head *heads[2]
53  */
54 void
55 Tie::do_post_processing()
56 {
57     assert(left_head_l_ || right_head_l_);
58     left_pos_i_ =  (left_head_l_)? 
59         left_head_l_->position_i_ : right_head_l_->position_i_;
60     right_pos_i_ = (right_head_l_) ? 
61         right_head_l_->position_i_ : left_head_l_->position_i_;
62  
63     if ( right_head_l_ && right_head_l_->extremal_i_) {
64         right_pos_i_ += 2*dir_i_;
65         right_dx_f_ -= 0.25;
66     } else
67         right_dx_f_ -= 0.5;
68
69     if (left_head_l_ && left_head_l_->extremal_i_) {
70         left_pos_i_ += 2*dir_i_;
71         left_dx_f_ += 0.25;
72     } else
73         left_dx_f_ += 0.5;
74     
75     if (!right_head_l_)
76         right_pos_i_ = left_pos_i_;
77     if (! left_head_l_)
78         left_pos_i_ = right_pos_i_;
79 }
80
81
82
83 void
84 Tie::do_substitute_dependency(Score_elem*o, Score_elem*n)
85 {
86     Note_head *new_l =n?(Note_head*)n->item():0;
87     if (o->item() == left_head_l_)
88         left_head_l_ = new_l;
89     else if (o->item() == right_head_l_)
90         right_head_l_ = new_l;
91 }
92
93
94
95 IMPLEMENT_IS_TYPE_B1(Tie,Bow);