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"
14 #include "group-interface.hh"
20 Tie::set_head (Direction d, Note_head * head_l)
24 gh_set_car_x (get_elt_property ("heads"), head_l->self_scm_ );
26 gh_set_cdr_x (get_elt_property ("heads"), head_l->self_scm_ );
28 set_bounds (d, head_l);
30 add_dependency (head_l);
35 set_elt_property ("heads", gh_cons (SCM_EOL, SCM_EOL));
39 Tie::head (Direction d) const
41 SCM c = get_elt_property ("heads");
42 c = index_cell (c, d);
44 return dynamic_cast<Note_head*> (unsmob_element (c));
49 ugh: direction of the Tie is more complicated. See [Ross] p136 and further
52 Tie::get_default_dir () const
54 int m = int (head (LEFT)->position_f ()
55 + head (RIGHT)->position_f ()) /2;
58 If dir is not determined: inverse of stem: down
59 (see stem::get_default_dir ())
61 Direction neutral_dir = (Direction)(int)paper_l ()->get_var ("stem_default_neutral_direction");
62 return (m == 0) ? other_dir (neutral_dir) : (m < 0) ? DOWN : UP;
66 Tie::do_add_processing()
68 if (!(head (LEFT) && head (RIGHT)))
69 warning (_ ("lonely tie"));
72 Drul_array<Note_head *> new_head_drul;
73 new_head_drul[LEFT] = head(LEFT);
74 new_head_drul[RIGHT] = head(RIGHT);
77 new_head_drul[d] = head((Direction)-d);
78 } while (flip(&d) != LEFT);
80 gh_set_car_x (get_elt_property ("heads"), new_head_drul[LEFT]->self_scm_ );
81 gh_set_cdr_x (get_elt_property ("heads"), new_head_drul[RIGHT]->self_scm_ );
85 Tie::do_post_processing()
87 assert (head (LEFT) || head (RIGHT));
89 Real interline_f = paper_l ()->get_var ("interline");
90 Real internote_f = interline_f / 2;
91 Real x_gap_f = paper_l ()->get_var ("tie_x_gap");
92 Real y_gap_f = paper_l ()->get_var ("tie_y_gap");
95 Slur and tie placement [OSU]
99 * x = inner vertical tangent - d * gap
105 OSU: not different for outer notes, so why all this code?
106 ie, can we drop this, or should it be made switchable.
112 Real head_width_f = head (d)
113 ? head (d)->extent (X_AXIS).length ()
116 side attached to outer (upper or lower) notehead of chord
123 to second tie, middle notehead seems not extremal
125 Getting scared a bit by score-element's comment:
126 // is this a good idea?
128 && (head (d)->get_elt_property ("extremal")
132 dx_f_drul_[d] += head_width_f;
133 dx_f_drul_[d] += -d * x_gap_f;
136 side attached to inner notehead
140 dx_f_drul_[d] += -d * head_width_f;
142 } while (flip (&d) != LEFT);
147 dx_f_drul_[LEFT] = head (LEFT)->extent (X_AXIS).length ();
149 dx_f_drul_[LEFT] = get_broken_left_end_align ();
150 dx_f_drul_[LEFT] += x_gap_f;
151 dx_f_drul_[RIGHT] -= x_gap_f;
156 Slur and tie placement [OSU] -- check this
160 * y = dx < 5ss: horizontal tangent
161 y = dx >= 5ss: y next interline - d * 0.25 ss
163 which probably means that OSU assumes that
170 Real ypos = head (LEFT) ? head (LEFT)->position_f ()
171 : head (RIGHT)->position_f ();
173 Real y_f = internote_f * ypos;
174 int ypos_i = int (ypos);
176 Real dx_f = extent (X_AXIS).length () + dx_f_drul_[RIGHT] - dx_f_drul_[LEFT];
177 if (dx_f < paper_l ()->get_var ("tie_staffspace_length"))
179 if (abs (ypos_i) % 2)
180 y_f += get_direction () * internote_f;
181 y_f += get_direction () * y_gap_f;
185 if (! (abs (ypos_i) % 2))
186 y_f += get_direction () * internote_f;
187 y_f += get_direction () * internote_f;
188 y_f -= get_direction () * y_gap_f;
191 dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = y_f;
197 Tie::get_rods () const
201 r.item_l_drul_ = spanned_drul_;
202 r.distance_f_ = paper_l ()->get_var ("tie_x_minimum");