X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftie.cc;h=cc36ab22c0fec51cd04a2ec65029b34bb818a928;hb=7fa94555679e3197028b1ab3fea02c374cd855da;hp=fb929047e6eb2f572d5670c0a7b443fdea11c840;hpb=c24b8835be7d548804a94f6caceadcf914bb8198;p=lilypond.git diff --git a/lily/tie.cc b/lily/tie.cc index fb929047e6..cc36ab22c0 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ #include "paper-def.hh" @@ -12,6 +12,7 @@ #include "p-col.hh" #include "debug.hh" +IMPLEMENT_IS_TYPE_B1(Tie,Bow); void Tie::set_head (Direction d, Note_head * head_l) @@ -46,24 +47,27 @@ void Tie::do_add_processing() { if (!(head_l_drul_[LEFT] && head_l_drul_[RIGHT])) - warning (_("Lonely tie.. ")); + warning (_ ("lonely tie")); Direction d = LEFT; Drul_array 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 (); - Real interline_f = paper ()->interline_f (); + // URG: share code with slur! assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]); + Real notewidth = paper ()->note_width (); + Real interline_f = paper ()->interline_f (); + Real tie_min = paper ()->get_var ("tie_x_minimum"); + /* [OSU]: slur and tie placement @@ -73,11 +77,9 @@ Tie::do_post_processing() * y = length < 5ss : horizontal raakpunt y = length >= 5ss : y next interline - d * 0.25 ss --> height <= 5 length ?? we use <= 3 length, now... - - * suggested gap = ss / 5; */ - // jcn: 1/5 seems so small? - Real gap_f = interline_f / 2; // 5; + + Real gap_f = paper ()->get_var ("slur_x_gap"); Direction d = LEFT; do @@ -86,39 +88,73 @@ Tie::do_post_processing() ? 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_) { - /* normal tie between noteheads, with gap of space */ - dx_f_drul_[d] += -d * (0.5 * nw_f + gap_f); + 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]) + // tie attached to inner notehead + else if (head_l_drul_[d] && d == LEFT) { - dx_f_drul_[d] += d*0.5 * nw_f; + dx_f_drul_[d] += -d * notewidth; } + // uhm? loose end of tie // tie attached to stem else { - dy_f_drul_[d] = dy_f_drul_[(Direction) -d]; dx_f_drul_[d] = -d * (spanned_drul_[d]->width ().length () - -0.5 * nw_f); + -0.5 * notewidth); + } + } + while (flip(&d) != LEFT); + + // now that both are set, do dependent + do + { + // tie attached to outer notehead + if (!head_l_drul_[d]) + { + if (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT] < tie_min) + { + dx_f_drul_[d] -= d * tie_min + - (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]); + dx_f_drul_[d] = dx_f_drul_[(Direction)-d] + d * tie_min; + } + + dy_f_drul_[d] = dy_f_drul_[(Direction) -d]; } } - while ((d *= -1) != LEFT); + 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 () += width ().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_ * (damp_f - ratio_f) * d_off.x (); } void -Tie::do_substitute_dependency (Score_elem*o, Score_elem*n) +Tie::do_substitute_dependency (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?(Note_head*)n->access_Item ():0; + if (o->access_Item () == head_l_drul_[LEFT]) head_l_drul_[LEFT] = new_l; - else if (o->item() == head_l_drul_[RIGHT]) + else if (o->access_Item () == head_l_drul_[RIGHT]) head_l_drul_[RIGHT] = new_l; } -IMPLEMENT_IS_TYPE_B1(Tie,Bow);