From: hanwen Date: Sun, 21 Aug 2005 21:47:18 +0000 (+0000) Subject: * lily/tie.cc: remove minimum-length X-Git-Tag: release/2.6.4~17^2~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4f46fcbe7bd47731c7f3e214ad3f3036b0c91445;p=lilypond.git * lily/tie.cc: remove minimum-length * lily/tie.cc (get_control_points): rewrite. Put short ties in staff-spaces, make long ties cross staff lines. Avoid flags and dots. --- diff --git a/lily/include/tie.hh b/lily/include/tie.hh index d7c4312e7b..bb6066a539 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -12,6 +12,24 @@ #include "lily-guile.hh" #include "lily-proto.hh" + +struct Tie_configuration +{ + int position_; + Direction dir_; + Interval attachment_x_; + Real edge_y_; + + Tie_configuration () + { + dir_ = CENTER; + position_ = 0; + } + + static int compare (Tie_configuration const &a, + Tie_configuration const &b); +}; + class Tie { public: @@ -24,8 +42,10 @@ public: static Real get_position (Grob *); static Direction get_default_dir (Grob *); static SCM get_control_points (SCM); + static SCM get_configuration (SCM); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); }; + #endif // TIE_HH diff --git a/lily/tie-column.cc b/lily/tie-column.cc index 082cc619df..31e1daf1f8 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -51,6 +51,7 @@ tie_compare (Grob *const &s1, return sign (Tie::get_position (s1) - Tie::get_position (s2)); } +#if 0 /* Werner: @@ -133,6 +134,7 @@ Tie_column::werner_directions (Grob *me) return; } +#endif MAKE_SCHEME_CALLBACK (Tie_column, after_line_breaking, 1); SCM @@ -169,3 +171,4 @@ ADD_INTERFACE (Tie_column, "tie-column-interface", "Object that sets directions of multiple ties in a tied chord", "direction"); + diff --git a/lily/tie.cc b/lily/tie.cc index f596a7c71e..0a968718c1 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -126,9 +126,12 @@ Tie::set_direction (Grob *me) SCM -Tie::get_control_points (SCM smob) +Tie::get_configuration (Grob *me_grob, + Grob **common, + Tie_configuration *conf) { - Spanner *me = unsmob_spanner (smob); + Spanner *me = dynamic_cast (me_grob); + if (!head (me, LEFT) && !head (me, RIGHT)) { programming_error ("tie without heads"); @@ -144,16 +147,6 @@ Tie::get_control_points (SCM smob) Real staff_space = Staff_symbol_referencer::staff_space (me); Real staff_position = tie_position; - Grob *common[NO_AXES]; - for (int a = X_AXIS; a < NO_AXES; a++) - { - Axis ax ((Axis) a); - common[ax] = me->get_bound (LEFT)->common_refpoint (me, ax); - common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); - } - - Interval attachments; - Direction d = LEFT; Real gap = robust_scm2double (me->get_property ("x-gap"), 0.2); do @@ -296,15 +289,15 @@ Tie::get_control_points (SCM smob) Offset edge = b.curve_point (0.0); Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0; - b.translate (Offset (0, - staff_position * staff_space * 0.5 - - center)); + + conf->edge_y_ = staff_position * staff_space * 0.5 + - center; } else { - b.translate (Offset (0, - (staff_position - dir) * staff_space * 0.5 - + dir * 0.2 * staff_space)); + conf->edge_y_ = + (staff_position - dir) * staff_space * 0.5 + + dir * 0.2 * staff_space; } } else @@ -312,20 +305,59 @@ Tie::get_control_points (SCM smob) Real where = 0.5 * dir; Real rounding_dy = (where - middle[Y_AXIS]); - b.translate (Offset (0, - 0.5 * staff_position * staff_space + rounding_dy)); + conf->edge_y_ = 0.5 * staff_position * staff_space + rounding_dy; if (dir * b.curve_point (0.0)[Y_AXIS] < dir * tie_position * 0.5 * staff_space) - b.translate (Offset (0, staff_space * dir)); + conf->edge_y_ += staff_space * dir; } + + conf->position_ = staff_position; + conf->dir_ = dir; + conf->attachment_x_ = attachments; +} + + +SCM +Tie::get_control_points (SCM smob) +{ + Spanner *me = unsmob_spanner (smob); + + Grob *common[NO_AXES] = { + 0, 0 + }; + for (int a = X_AXIS; a < NO_AXES; a++) + { + Axis ax ((Axis) a); + common[ax] = me->get_bound (LEFT)->common_refpoint (me, ax); + common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); + } + + Tie_configuration conf; + get_configuration (me, common, &conf); - b.translate (Offset (attachments[LEFT] + SCM details = me->get_property ("details"); + SCM limit + = scm_assq (ly_symbol2scm ("height-limit"), details); + + Real h_inf = robust_scm2double (scm_cdr (limit), 0.75) * staff_space; + Real r_0 = robust_scm2double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), + details)), + .333); + + Bezier b = slur_shape (conf->attachment_x_.length(), + h_inf, r_0); + b.scale (1, conf->dir_); + + Bezier b; + + b.translate (Offset (conf->attachment_x_[LEFT] - me->relative_coordinate (common[X_AXIS], X_AXIS), 0)); SCM controls = SCM_EOL; for (int i = 4; i--;) controls = scm_cons (ly_offset2scm (b.control_[i]), controls); + return controls; } @@ -388,3 +420,6 @@ ADD_INTERFACE (Tie, "head-pair " "thickness " "x-gap "); + + +