source file of the GNU LilyPond music typesetter
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "paper-def.hh"
#include "debug.hh"
+
void
Tie::set_head (Direction d, Note_head * head_l)
{
Tie::do_add_processing()
{
if (!(head_l_drul_[LEFT] && head_l_drul_[RIGHT]))
- warning (_("Lonely tie.. "));
+ warning (_ ("lonely tie"));
Direction d = LEFT;
Drul_array<Note_head *> new_head_drul = head_l_drul_;
do {
if (!head_l_drul_[d])
new_head_drul[d] = head_l_drul_[(Direction)-d];
- } while ((d *= -1) != LEFT);
+ } while (flip(&d) != LEFT);
head_l_drul_ = new_head_drul;
}
void
Tie::do_post_processing()
{
- Real nw_f = paper()->note_width ();
+ // URG: share code with slur!
assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
+ // URG
+ Real notewidth = paper ()->note_width () * 0.8;
+ Real interline_f = paper ()->interline_f ();
+
+ /*
+ [OSU]: slur and tie placement
+
+ ties:
+ * x = inner raakpunt - d * gap
+
+ * y = length < 5ss : horizontal raakpunt
+ y = length >= 5ss : y next interline - d * 0.25 ss
+ --> height <= 5 length ?? we use <= 3 length, now...
+ */
+
+ Real gap_f = paper ()->get_var ("slur_x_gap");
+
Direction d = LEFT;
do
{
- pos_i_drul_[d] = (head_l_drul_[d])?
- head_l_drul_[d]->position_i_ : head_l_drul_[(Direction)-d]->position_i_;
+ dy_f_drul_[d] = .5 * interline_f * (head_l_drul_[d]
+ ? head_l_drul_[d]->position_i_
+ : head_l_drul_[(Direction)-d]->position_i_);
}
- while ((d *= -1) != LEFT);
+ while (flip(&d) != LEFT);
do
{
+ // tie attached to outer notehead
if (head_l_drul_[d] && head_l_drul_[d]->extremal_i_)
{
- pos_i_drul_[d] += 2*dir_;
- dx_f_drul_[d] += d * 0.25;
+ if (d == LEFT)
+ dx_f_drul_[d] += notewidth;
+ dx_f_drul_[d] += -d * gap_f;
+ /* attach to outer 3/4 end of head */
+ dy_f_drul_[d] += dir_ * 0.25 * interline_f;
}
- else if (head_l_drul_[d])
- dx_f_drul_[d] += d*0.5;
+ // tie attached to inner notehead
+ else if (head_l_drul_[d] && d == LEFT)
+ {
+ dx_f_drul_[d] += -d * notewidth;
+ }
+ // uhm? loose end of tie // tie attached to stem
else
{
- pos_i_drul_[d] = pos_i_drul_[(Direction) -d];
- dx_f_drul_[d] = -d
- *(spanned_drul_[d]->width ().length ()/nw_f -0.5);
+ dx_f_drul_[d] = -d * (spanned_drul_[d]->extent (X_AXIS).length ()
+ -0.5 * notewidth);
}
}
- while ((d *= -1) != LEFT);
-}
-
+ while (flip(&d) != LEFT);
+ // now that both are set, do dependent
+ do
+ {
+ // tie attached to outer notehead
+ if (!head_l_drul_[d])
+ {
+ dy_f_drul_[d] = dy_f_drul_[(Direction) -d];
+ }
+ }
+ while (flip(&d) != LEFT);
+
+ /*
+ Avoid too steep ties
+ * slur from notehead to stemend: c''()b''
+ */
+ Real damp_f = paper ()->get_var ("tie_slope_damping");
+ Offset d_off = Offset (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT],
+ dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]);
+ d_off.x () += extent (X_AXIS).length ();
+
+ Real ratio_f = abs (d_off.y () / d_off.x ());
+ if (ratio_f > damp_f)
+ dy_f_drul_[(Direction)(- dir_ * sign (d_off.y ()))] +=
+ dir_ * (ratio_f - damp_f) * d_off.x ();
+}
void
-Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
+Tie::do_substitute_element_pointer (Score_element*o, Score_element*n)
{
- Note_head *new_l =n?(Note_head*)n->item():0;
- if (o->item() == head_l_drul_[LEFT])
+ Note_head *new_l =n?dynamic_cast<Note_head *> (n):0;
+ if (dynamic_cast <Item *> (o) == head_l_drul_[LEFT])
head_l_drul_[LEFT] = new_l;
- else if (o->item() == head_l_drul_[RIGHT])
+ else if (dynamic_cast <Item *> (o) == head_l_drul_[RIGHT])
head_l_drul_[RIGHT] = new_l;
}
-IMPLEMENT_IS_TYPE_B1(Tie,Bow);
+#if 0
+Interval
+Tie::do_width () const
+{
+ Real min_f =
+ Interval width_int = Bow::do_width ();
+ return width_int.length () < min_f ? Interval (0, min_f) : width_int;
+}
+#endif
+
+Array<Rod>
+Tie::get_rods () const
+{
+ Array<Rod> a;
+ Rod r;
+ r.item_l_drul_ = spanned_drul_;
+ r.distance_f_ = paper ()->get_var ("tie_x_minimum");
+ a.push (r);
+ return a;
+}