]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie.cc
release: 0.0.60
[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 }
45
46 void
47 Tie::set_default_dir()
48 {
49     int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
50     dir_i_ =  (m < 5)? -1:1;                    // ugh
51 }
52     
53
54 void
55 Tie::do_add_processing()
56 {
57     assert(left_head_l_ && right_head_l_);
58     left_col_l_ = left_head_l_ -> pcol_l_;
59     right_col_l_ = right_head_l_ -> pcol_l_;
60 }
61
62 void
63 Tie::do_post_processing()
64 {
65     assert(left_head_l_ || right_head_l_);
66     left_pos_i_ =  (left_head_l_)? 
67         left_head_l_->position_i_ : right_head_l_->position_i_;
68     right_pos_i_ = (right_head_l_) ? 
69         right_head_l_->position_i_ : left_head_l_->position_i_;
70  
71     if ( right_head_l_ && right_head_l_->extremal_i_) {
72         right_pos_i_ += 2*dir_i_;
73         right_dx_f_ -= 0.25;
74     } else
75         right_dx_f_ -= 0.5;
76
77     if (left_head_l_ && left_head_l_->extremal_i_) {
78         left_pos_i_ += 2*dir_i_;
79         left_dx_f_ += 0.25;
80     } else
81         left_dx_f_ += 0.5;
82 }
83
84