]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie.cc
release: 0.0.61
[lilypond.git] / lily / tie.cc
1 /*
2   tie.cc -- implement Tie
3
4   source file of the 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 "notehead.hh"
12 #include "p-col.hh"
13
14 Spanner*
15 Tie::do_break_at(PCol*l, PCol*r) const
16 {
17     Tie * tie_p = new Tie(*this);
18     Line_of_score const  *line_C=l->line_l_;
19     tie_p->left_head_l_ = (left_head_l_->line_l()== line_C) ?
20         left_head_l_ : 0;
21     tie_p->right_head_l_  = (right_head_l_->line_l() == line_C)?
22         right_head_l_ : 0;
23     
24     return tie_p;
25 }
26
27 void
28 Tie::set_head(int x_pos, Notehead * head_l)
29 {
30     if (x_pos >0) {
31         assert(!right_head_l_);
32         right_head_l_ = head_l;
33     } else {
34         assert(!left_head_l_);
35         left_head_l_ = head_l;
36     }
37     add_dependency(head_l);
38 }
39
40 Tie::Tie()
41 {
42     right_head_l_ =0;
43     left_head_l_ =0;
44     same_pitch_b_ =false;
45 }
46
47 void
48 Tie::set_default_dir()
49 {
50     int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
51     dir_i_ =  (m < 5)? -1:1;                    // ugh
52 }
53     
54
55 void
56 Tie::do_add_processing()
57 {
58     assert(left_head_l_ && right_head_l_);
59     left_col_l_ = left_head_l_ -> pcol_l_;
60     right_col_l_ = right_head_l_ -> pcol_l_;
61 }
62
63 void
64 Tie::do_post_processing()
65 {
66     assert(left_head_l_ || right_head_l_);
67     left_pos_i_ =  (left_head_l_)? 
68         left_head_l_->position_i_ : right_head_l_->position_i_;
69     right_pos_i_ = (right_head_l_) ? 
70         right_head_l_->position_i_ : left_head_l_->position_i_;
71  
72     if ( right_head_l_ && right_head_l_->extremal_i_) {
73         right_pos_i_ += 2*dir_i_;
74         right_dx_f_ -= 0.25;
75     } else
76         right_dx_f_ -= 0.5;
77
78     if (left_head_l_ && left_head_l_->extremal_i_) {
79         left_pos_i_ += 2*dir_i_;
80         left_dx_f_ += 0.25;
81     } else
82         left_dx_f_ += 0.5;
83 }
84
85