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"
15 #include "directional-element-interface.hh"
18 Tie::set_head (Direction d
, Item
* head_l
)
21 index_set_cell (get_elt_property ("heads"), d
, head_l
->self_scm_
);
23 set_bounds (d
, head_l
);
24 add_dependency (head_l
);
29 set_elt_property ("heads", gh_cons (SCM_EOL
, SCM_EOL
));
33 Tie::head (Direction d
) const
35 SCM c
= get_elt_property ("heads");
36 c
= index_cell (c
, d
);
38 return dynamic_cast<Note_head
*> (unsmob_element (c
));
43 ugh: direction of the Tie is more complicated. See [Ross] p136 and further
46 Tie::get_default_dir () const
48 Real p1
= Staff_symbol_referencer_interface (head (LEFT
)).position_f () ;
49 Real p2
= Staff_symbol_referencer_interface (head (RIGHT
)).position_f () ;
51 int m
= int (p1
+ p2
);
54 If dir is not determined: inverse of stem: down
55 (see stem::get_default_dir ())
57 Direction neutral_dir
= (Direction
)(int)paper_l ()->get_var ("stem_default_neutral_direction");
58 return (m
== 0) ? other_dir (neutral_dir
) : (m
< 0) ? DOWN
: UP
;
62 Tie::do_add_processing()
64 if (!(head (LEFT
) && head (RIGHT
)))
65 warning (_ ("lonely tie"));
68 Drul_array
<Note_head
*> new_head_drul
;
69 new_head_drul
[LEFT
] = head(LEFT
);
70 new_head_drul
[RIGHT
] = head(RIGHT
);
73 new_head_drul
[d
] = head((Direction
)-d
);
74 } while (flip(&d
) != LEFT
);
76 index_set_cell (get_elt_property ("heads"), LEFT
, new_head_drul
[LEFT
]->self_scm_
);
77 index_set_cell (get_elt_property ("heads"), RIGHT
, new_head_drul
[LEFT
]->self_scm_
);
82 Tie::do_post_processing()
84 if (!head (LEFT
) && !head (RIGHT
))
86 programming_error ("Tie without heads.");
87 set_elt_property ("transparent", SCM_BOOL_T
);
93 Real staff_space
= paper_l ()->get_var ("interline");
94 Real half_staff_space
= staff_space
/ 2;
95 Real x_gap_f
= paper_l ()->get_var ("tie_x_gap");
96 Real y_gap_f
= paper_l ()->get_var ("tie_y_gap");
99 Slur and tie placement [OSU]
103 * x = inner vertical tangent - d * gap
109 OSU: not different for outer notes, so why all this code?
110 ie, can we drop this, or should it be made switchable.
116 Real head_width_f
= head (d
)
117 ? head (d
)->extent (X_AXIS
).length ()
120 side attached to outer (upper or lower) notehead of chord
127 to second tie, middle notehead seems not extremal
129 Getting scared a bit by score-element's comment:
130 // is this a good idea?
132 && (head (d
)->get_elt_property ("extremal")
136 dx_f_drul_
[d
] += head_width_f
;
137 dx_f_drul_
[d
] += -d
* x_gap_f
;
140 side attached to inner notehead
144 dx_f_drul_
[d
] += -d
* head_width_f
;
146 } while (flip (&d
) != LEFT
);
151 dx_f_drul_
[LEFT
] = head (LEFT
)->extent (X_AXIS
).length ();
153 dx_f_drul_
[LEFT
] = get_broken_left_end_align ();
154 dx_f_drul_
[LEFT
] += x_gap_f
;
155 dx_f_drul_
[RIGHT
] -= x_gap_f
;
160 Slur and tie placement [OSU] -- check this
164 * y = dx < 5ss: horizontal tangent
165 y = dx >= 5ss: y next interline - d * 0.25 ss
167 which probably means that OSU assumes that
175 Real ypos
= head (LEFT
)
176 ? Staff_symbol_referencer_interface (head (LEFT
)).position_f ()
177 : Staff_symbol_referencer_interface (head (RIGHT
)).position_f () ;
179 Real y_f
= half_staff_space
* ypos
;
180 int ypos_i
= int (ypos
);
182 Real dx_f
= extent (X_AXIS
).length () + dx_f_drul_
[RIGHT
] - dx_f_drul_
[LEFT
];
183 Direction dir
= directional_element (this).get();
184 if (dx_f
< paper_l ()->get_var ("tie_staffspace_length"))
186 if (abs (ypos_i
) % 2)
187 y_f
+= dir
* half_staff_space
;
188 y_f
+= dir
* y_gap_f
;
192 if (! (abs (ypos_i
) % 2))
193 y_f
+= dir
* half_staff_space
;
194 y_f
+= dir
* half_staff_space
;
195 y_f
-= dir
* y_gap_f
;
198 dy_f_drul_
[LEFT
] = dy_f_drul_
[RIGHT
] = y_f
;
204 Tie::get_rods () const
208 r
.item_l_drul_
= spanned_drul_
;
209 r
.distance_f_
= paper_l ()->get_var ("tie_x_minimum");