]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie-specification.cc
Web-ja: update introduction
[lilypond.git] / lily / tie-specification.cc
1 #include "tie-formatting-problem.hh"
2 #include "grob.hh"
3 #include "item.hh"
4 #include "semi-tie.hh"
5 #include "spanner.hh"
6 #include "tie.hh"
7 #include "libc-extension.hh"
8 #include "tie-specification.hh"
9
10 Tie_specification::Tie_specification ()
11 {
12   tie_grob_ = 0;
13   has_manual_position_ = false;
14   has_manual_dir_ = false;
15   has_manual_delta_y_ = false;
16   position_ = 0;
17   manual_position_ = 0;
18   manual_dir_ = CENTER;
19   note_head_drul_[LEFT]
20     = note_head_drul_[RIGHT] = 0;
21   column_ranks_[RIGHT]
22     = column_ranks_[LEFT] = 0;
23 }
24
25 void
26 Tie_specification::from_grob (Grob *tie)
27 {
28   // In this method, Tie and Semi_tie require the same logic with different
29   // types.  It might be clearer to use a template.
30   tie_grob_ = tie;
31   if (scm_is_number (tie->get_property_data ("direction")))
32     {
33       manual_dir_ = to_dir (tie->get_property ("direction"));
34       has_manual_dir_ = true;
35     }
36
37   if (Spanner *spanner = dynamic_cast<Spanner *> (tie))
38     position_ = Tie::get_position (spanner);
39   else if (Item *item = dynamic_cast<Item *> (tie))
40     position_ = Semi_tie::get_position (item);
41   else
42     {
43       programming_error ("grob is neither a tie nor a semi-tie");
44       position_ = 0;
45     }
46
47   SCM pos_scm = tie->get_property ("staff-position");
48   if (scm_is_number (pos_scm))
49     {
50       has_manual_delta_y_ = !ly_is_rational (pos_scm);
51       manual_position_ = scm_to_double (tie->get_property ("staff-position"));
52       has_manual_position_ = true;
53     }
54 }
55
56 int
57 Tie_specification::column_span () const
58 {
59   return column_ranks_[RIGHT] - column_ranks_[LEFT];
60 }