]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur.cc
release: 0.0.64
[lilypond.git] / lily / slur.cc
1 /*
2   slur.cc -- implement  Slur
3
4   source file of the LilyPond music typesetter
5
6   (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 /*
10
11   TODO:
12   
13   think about crossing stems.
14   Begin and end should be treated as a Script.
15   
16  */
17 #include "slur.hh"
18 #include "scalar.hh"
19 #include "lookup.hh"
20 #include "paper-def.hh"
21 #include "note-column.hh"
22 #include "stem.hh"
23 #include "p-col.hh"
24 #include "molecule.hh"
25 #include "debug.hh"
26 #include "boxes.hh"
27
28
29
30 void
31 Slur::add(Note_column*n)
32 {
33     encompass_arr_.push(n);
34     add_dependency(n);
35 }
36
37 void
38 Slur::set_default_dir()
39 {
40     dir_i_ = -1;
41     for (int i=0; i < encompass_arr_.size(); i ++) {
42         if (encompass_arr_[i]->dir_i_ < 0) {
43             dir_i_ =1;
44             break;
45         }
46     }
47 }
48
49 void
50 Slur::do_pre_processing()
51 {
52     right_col_l_  = encompass_arr_.top()->pcol_l_;
53     left_col_l_ = encompass_arr_[0]->pcol_l_;    
54 }
55
56 Spanner*
57 Slur::do_break_at(PCol*l, PCol*r) const
58 {
59     assert(l->line_l_ == r->line_l_);
60     Slur*ret = new Slur(*this);
61
62     ret->encompass_arr_.set_size(0);
63     for (int i =0; i < encompass_arr_.size(); i++) {
64         if (encompass_arr_[i]->pcol_l_->line_l_==l->line_l_)
65             ret->encompass_arr_.push(encompass_arr_[i]);
66     }
67
68     return ret;
69 }
70
71 void
72 Slur::do_post_processing()
73 {
74     if (!dir_i_)
75         set_default_dir();
76     Real inter_f = paper()->internote();
77     if (encompass_arr_[0]->stem_l_)
78         left_pos_i_ = rint(encompass_arr_[0]->stem_l_->height()[dir_i_]/inter_f);
79     else
80         left_pos_i_ = 0;
81     if (encompass_arr_.top()->stem_l_)
82         right_pos_i_ = rint(encompass_arr_.top()->stem_l_->height()[dir_i_]/inter_f);
83     else
84         right_pos_i_ = 0;
85
86     left_pos_i_ += dir_i_;
87     right_pos_i_ += dir_i_;
88 }
89 IMPLEMENT_STATIC_NAME(Slur);