2 tie-helper.cc -- implement Tie_configuration, Tie_details
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
14 #include "staff-symbol-referencer.hh"
18 Tie_configuration::compare (Tie_configuration const &a,
19 Tie_configuration const &b)
21 if (a.position_ - b.position_)
22 return sign (a.position_ - b.position_);
23 return sign (a.dir_ - b.dir_);
27 Tie_configuration::Tie_configuration ()
36 Tie_configuration::center_tie_vertically (Tie_details const &details)
38 Bezier b = get_bezier (details);
39 Offset middle = b.curve_point (0.5);
40 Offset edge = b.curve_point (0.0);
42 Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0;
44 delta_y_ = - dir_ * center;
49 Get bezier with left control at (0,0)
52 Tie_configuration::get_bezier (Tie_details const &details) const
54 Real l = attachment_x_.length();
55 if (isnan (l) || isnan (l))
57 programming_error ("Inf or NaN encountered");
61 details.height_limit_,
66 Tie_configuration::distance (Tie_configuration const &a,
67 Tie_configuration const &b)
70 Real d = 3 * (a.position_ - b.position_);
72 return d + (2 + (b.dir_ - a.dir_));
74 return d + (2 + (a.dir_ - b.dir_));
78 Tie_configuration::height (Tie_details const &details) const
80 Real l = attachment_x_.length();
83 details.height_limit_,
84 details.ratio_).curve_point (0.5)[Y_AXIS];
90 Tie_details::init (Grob *me)
92 staff_space_ = Staff_symbol_referencer::staff_space (me);
93 SCM details = me->get_property ("details");
96 height_limit_ = robust_scm2double (ly_assoc_get (ly_symbol2scm ("height-limit"), details, SCM_EOL),
99 ratio_ = robust_scm2double (ly_assoc_get (ly_symbol2scm ("ratio"), details, SCM_EOL),
102 x_gap_ = robust_scm2double (me->get_property ("x-gap"), 0.2);
103 between_length_limit_
104 = robust_scm2double (ly_assoc_get (ly_symbol2scm ("between-length-limit"), details, SCM_EOL),
109 Tie_details::Tie_details ()