]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie.cc
ba7d75a3b8fcc523428a61eec775e122f1152bff
[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     {
20         assert (!right_head_l_);
21         right_head_l_ = head_l;
22     }
23   else 
24     {
25         assert (!left_head_l_);
26         left_head_l_ = head_l;
27     }
28   add_dependency (head_l);
29 }
30
31 Tie::Tie()
32 {
33   right_head_l_ =0;
34   left_head_l_ =0;
35   same_pitch_b_ =false;
36 }
37
38 void
39 Tie::set_default_dir()
40 {
41   int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
42   dir_i_ =  (m < 5)? -1:1;                      // ugh
43 }
44   
45
46 void
47 Tie::do_add_processing()
48 {
49   assert (left_head_l_ && right_head_l_);
50   left_col_l_ = left_head_l_ -> pcol_l_;
51   right_col_l_ = right_head_l_ -> pcol_l_;
52 }
53
54 /**
55   This is already getting hairy. Should use Note_head *heads[2]
56  */
57 void
58 Tie::do_post_processing()
59 {
60   assert (left_head_l_ || right_head_l_);
61   left_pos_i_ =  (left_head_l_)? 
62         left_head_l_->position_i_ : right_head_l_->position_i_;
63   right_pos_i_ = (right_head_l_) ? 
64         right_head_l_->position_i_ : left_head_l_->position_i_;
65  
66   if ( right_head_l_ && right_head_l_->extremal_i_) 
67     {
68         right_pos_i_ += 2*dir_i_;
69         right_dx_f_ -= 0.25;
70     }
71   else
72         right_dx_f_ -= 0.5;
73
74   if (left_head_l_ && left_head_l_->extremal_i_) 
75     {
76         left_pos_i_ += 2*dir_i_;
77         left_dx_f_ += 0.25;
78     }
79   else
80         left_dx_f_ += 0.5;
81   
82   if (!right_head_l_)
83         right_pos_i_ = left_pos_i_;
84   if (! left_head_l_)
85         left_pos_i_ = right_pos_i_;
86 }
87
88
89
90 void
91 Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
92 {
93   Note_head *new_l =n?(Note_head*)n->item():0;
94   if (o->item() == left_head_l_)
95         left_head_l_ = new_l;
96   else if (o->item() == right_head_l_)
97         right_head_l_ = new_l;
98 }
99
100
101
102 IMPLEMENT_IS_TYPE_B1(Tie,Bow);