2 tie.cc -- implement Tie
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "paper-def.hh"
11 #include "note-head.hh"
12 #include "paper-column.hh"
18 Tie::set_head (Direction d, Note_head * head_l)
20 assert (!head_l_drul_[d]);
21 head_l_drul_[d] = head_l;
22 set_bounds (d, head_l);
24 add_dependency (head_l);
29 head_l_drul_[RIGHT] =0;
30 head_l_drul_[LEFT] =0;
35 ugh: direction of the Tie is more complicated. See [Ross] p136 and further
38 Tie::get_default_dir () const
40 int m = int (head_l_drul_[LEFT]->position_f ()
41 + head_l_drul_[RIGHT]->position_f ()) /2;
44 If dir is not determined: inverse of stem: down
45 (see stem::get_default_dir ())
47 Direction neutral_dir = (Direction)(int)paper_l ()->get_var ("stem_default_neutral_direction");
48 return (m == 0) ? other_dir (neutral_dir) : (m < 0) ? DOWN : UP;
52 Tie::do_add_processing()
54 if (!(head_l_drul_[LEFT] && head_l_drul_[RIGHT]))
55 warning (_ ("lonely tie"));
58 Drul_array<Note_head *> new_head_drul = head_l_drul_;
61 new_head_drul[d] = head_l_drul_[(Direction)-d];
62 } while (flip(&d) != LEFT);
63 head_l_drul_ = new_head_drul;
67 Tie::do_post_processing()
69 assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
71 Real interline_f = paper_l ()->get_var ("interline");
72 Real internote_f = interline_f / 2;
73 Real x_gap_f = paper_l ()->get_var ("tie_x_gap");
74 Real y_gap_f = paper_l ()->get_var ("tie_y_gap");
77 Slur and tie placement [OSU]
81 * x = inner vertical tangent - d * gap
87 OSU: not different for outer notes, so why all this code?
88 ie, can we drop this, or should it be made switchable.
94 Real head_width_f = head_l_drul_[d]
95 ? head_l_drul_[d]->extent (X_AXIS).length ()
98 side attached to outer (upper or lower) notehead of chord
105 to second tie, middle notehead seems not extremal
107 Getting scared a bit by score-element's comment:
108 // is this a good idea?
110 && (head_l_drul_[d]->get_elt_property ("extremal")
114 dx_f_drul_[d] += head_width_f;
115 dx_f_drul_[d] += -d * x_gap_f;
118 side attached to inner notehead
122 dx_f_drul_[d] += -d * head_width_f;
124 } while (flip (&d) != LEFT);
128 if (head_l_drul_[LEFT])
129 dx_f_drul_[LEFT] = head_l_drul_[LEFT]->extent (X_AXIS).length ();
131 dx_f_drul_[LEFT] = get_broken_left_end_align ();
132 dx_f_drul_[LEFT] += x_gap_f;
133 dx_f_drul_[RIGHT] -= x_gap_f;
138 Slur and tie placement [OSU] -- check this
142 * y = dx < 5ss: horizontal tangent
143 y = dx >= 5ss: y next interline - d * 0.25 ss
145 which probably means that OSU assumes that
152 Real ypos = head_l_drul_[LEFT] ? head_l_drul_[LEFT]->position_f ()
153 : head_l_drul_[RIGHT]->position_f ();
155 Real y_f = internote_f * ypos;
156 int ypos_i = int (ypos);
158 Real dx_f = extent (X_AXIS).length () + dx_f_drul_[RIGHT] - dx_f_drul_[LEFT];
159 if (dx_f < paper_l ()->get_var ("tie_staffspace_length"))
161 if (abs (ypos_i) % 2)
162 y_f += get_direction () * internote_f;
163 y_f += get_direction () * y_gap_f;
167 if (! (abs (ypos_i) % 2))
168 y_f += get_direction () * internote_f;
169 y_f += get_direction () * internote_f;
170 y_f -= get_direction () * y_gap_f;
173 dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = y_f;
177 Tie::do_substitute_element_pointer (Score_element*o, Score_element*n)
179 Note_head *new_l = n ? dynamic_cast<Note_head *> (n) : 0;
180 if (dynamic_cast <Item *> (o) == head_l_drul_[LEFT])
181 head_l_drul_[LEFT] = new_l;
182 else if (dynamic_cast <Item *> (o) == head_l_drul_[RIGHT])
183 head_l_drul_[RIGHT] = new_l;
188 Tie::get_rods () const
192 r.item_l_drul_ = spanned_drul_;
193 r.distance_f_ = paper_l ()->get_var ("tie_x_minimum");