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 "staff-symbol-referencer.hh"
17 Tie::set_head (Direction d, Note_head * head_l)
20 index_set_cell (get_elt_property ("heads"), d, head_l->self_scm_);
22 set_bounds (d, head_l);
23 add_dependency (head_l);
28 set_elt_property ("heads", gh_cons (SCM_EOL, SCM_EOL));
32 Tie::head (Direction d) const
34 SCM c = get_elt_property ("heads");
35 c = index_cell (c, d);
37 return dynamic_cast<Note_head*> (unsmob_element (c));
42 ugh: direction of the Tie is more complicated. See [Ross] p136 and further
45 Tie::get_default_dir () const
47 Real p1 = Staff_symbol_referencer_interface (head (LEFT)).position_f () ;
48 Real p2 = Staff_symbol_referencer_interface (head (RIGHT)).position_f () ;
50 int m = int (p1 + p2);
53 If dir is not determined: inverse of stem: down
54 (see stem::get_default_dir ())
56 Direction neutral_dir = (Direction)(int)paper_l ()->get_var ("stem_default_neutral_direction");
57 return (m == 0) ? other_dir (neutral_dir) : (m < 0) ? DOWN : UP;
61 Tie::do_add_processing()
63 if (!(head (LEFT) && head (RIGHT)))
64 warning (_ ("lonely tie"));
67 Drul_array<Note_head *> new_head_drul;
68 new_head_drul[LEFT] = head(LEFT);
69 new_head_drul[RIGHT] = head(RIGHT);
72 new_head_drul[d] = head((Direction)-d);
73 } while (flip(&d) != LEFT);
75 index_set_cell (get_elt_property ("heads"), LEFT, new_head_drul[LEFT]->self_scm_ );
76 index_set_cell (get_elt_property ("heads"), RIGHT, new_head_drul[LEFT]->self_scm_ );
81 Tie::do_post_processing()
83 if (!head (LEFT) && !head (RIGHT))
85 programming_error ("Tie without heads.");
86 set_elt_property ("transparent", SCM_BOOL_T);
92 Real interline_f = paper_l ()->get_var ("interline");
93 Real internote_f = interline_f / 2;
94 Real x_gap_f = paper_l ()->get_var ("tie_x_gap");
95 Real y_gap_f = paper_l ()->get_var ("tie_y_gap");
98 Slur and tie placement [OSU]
102 * x = inner vertical tangent - d * gap
108 OSU: not different for outer notes, so why all this code?
109 ie, can we drop this, or should it be made switchable.
115 Real head_width_f = head (d)
116 ? head (d)->extent (X_AXIS).length ()
119 side attached to outer (upper or lower) notehead of chord
126 to second tie, middle notehead seems not extremal
128 Getting scared a bit by score-element's comment:
129 // is this a good idea?
131 && (head (d)->get_elt_property ("extremal")
135 dx_f_drul_[d] += head_width_f;
136 dx_f_drul_[d] += -d * x_gap_f;
139 side attached to inner notehead
143 dx_f_drul_[d] += -d * head_width_f;
145 } while (flip (&d) != LEFT);
150 dx_f_drul_[LEFT] = head (LEFT)->extent (X_AXIS).length ();
152 dx_f_drul_[LEFT] = get_broken_left_end_align ();
153 dx_f_drul_[LEFT] += x_gap_f;
154 dx_f_drul_[RIGHT] -= x_gap_f;
159 Slur and tie placement [OSU] -- check this
163 * y = dx < 5ss: horizontal tangent
164 y = dx >= 5ss: y next interline - d * 0.25 ss
166 which probably means that OSU assumes that
174 Real ypos = head (LEFT)
175 ? Staff_symbol_referencer_interface (head (LEFT)).position_f ()
176 : Staff_symbol_referencer_interface (head (RIGHT)).position_f () ;
178 Real y_f = internote_f * ypos;
179 int ypos_i = int (ypos);
181 Real dx_f = extent (X_AXIS).length () + dx_f_drul_[RIGHT] - dx_f_drul_[LEFT];
182 if (dx_f < paper_l ()->get_var ("tie_staffspace_length"))
184 if (abs (ypos_i) % 2)
185 y_f += get_direction () * internote_f;
186 y_f += get_direction () * y_gap_f;
190 if (! (abs (ypos_i) % 2))
191 y_f += get_direction () * internote_f;
192 y_f += get_direction () * internote_f;
193 y_f -= get_direction () * y_gap_f;
196 dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = y_f;
202 Tie::get_rods () const
206 r.item_l_drul_ = spanned_drul_;
207 r.distance_f_ = paper_l ()->get_var ("tie_x_minimum");