source file of the GNU LilyPond music typesetter
- (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include <math.h>
SCM
Tie::get_control_points (SCM smob)
{
- Spanner*me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner*me = unsmob_spanner (smob);
Direction headdir = CENTER;
if (head (me,LEFT))
headdir = LEFT;
*/
Real lambda = 0.5;
- if (Note_head::has_interface (me->get_bound (LEFT)))
+ if (Note_head::has_interface (l))
left_x = l->extent (l, X_AXIS)[RIGHT] + x_gap_f;
else
left_x = l->extent (l, X_AXIS).linear_combination (lambda);
Real width;
- if (Note_head::has_interface (me->get_bound (LEFT))
- && Note_head::has_interface (me->get_bound (RIGHT)))
+ if (Note_head::has_interface (l) && Note_head::has_interface (r))
{
width =
+ r->extent (commonx,X_AXIS)[LEFT]
}
else
{
- if (Note_head::has_interface (me->get_bound (LEFT)))
+ if (Note_head::has_interface (l))
width = r->relative_coordinate (commonx, X_AXIS)
- l->extent (commonx, X_AXIS)[RIGHT]
- 2 * x_gap_f;
SCM lim // groetjes aan de chirurgendochter.
= scm_assq (ly_symbol2scm ("height-limit"),details);
- Real h_inf = gh_scm2double (gh_cdr (lim)) * staff_space;
- Real r_0 = gh_scm2double (gh_cdr (scm_assq (ly_symbol2scm ("ratio"),details)));
+ Real h_inf = gh_scm2double (ly_cdr (lim)) * staff_space;
+ Real r_0 = gh_scm2double (ly_cdr (scm_assq (ly_symbol2scm ("ratio"),details)));
Bezier b = slur_shape (width, h_inf, r_0);
- Offset leave_dir = b.control_[1] - b.control_[0];
-
- Grob *hed =head (me, headdir);
- Real dx = (hed->extent (hed, X_AXIS).length () + x_gap_f)/2.0;
- Real max_gap = leave_dir[Y_AXIS] * dx / leave_dir[X_AXIS];
-
/*
- for small ties (t small) we want to start in the Y-center (so dy = 0), for
- large ties, the tie should appear to come from the center of the
- head, so dy = max_gap
-
- maybe use a different formula?
+ I think this better, particularly for small ties. It always allows the user to move ties if
+ they seem in the wrong place
TODO: what if 2 heads have different size.
- TODO: for small ties, it is better to start over the heads
- iso. next to the heads.
*/
- Real t = (width / staff_space - 5.0); // ugh.
- Real dy = t > 0 ? max_gap * sqr (t / (1 + t)) : 0.0;
- Real ypos = Tie::position_f (me) * staff_space/2 + dir * dy;
+ Real ypos = Tie::position_f (me) * staff_space/2
+ + dir * gh_scm2double (me->get_grob_property ("y-offset"));;
+ /*
+ Make sure we don't start on a dots
+ */
+ if (Note_head::has_interface (l) && Rhythmic_head::dots_l (l))
+ {
+ Grob* dots = Rhythmic_head::dots_l(l);
+ if(fabs (staff_space * Staff_symbol_referencer::position_f (dots) /2
+ - ypos) < 0.5)
+ {
+ ypos += 0.5 * dir ;
+ }
+ }
+
+
/*
todo: prevent ending / staffline collision.
Real clear = staff_space * gh_scm2double (me->get_grob_property ("staffline-clearance"));
- if (fabs (y) <= Staff_symbol_referencer::staff_radius (me)
+ if (fabs (y) <= Staff_symbol_referencer::staff_radius (me)
&& fabs (diff) < clear)
{
Real y1 = ry + clear;
newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2;
- // newy = ry - 0.5 * staff_space * sign (diff) ;
+ // newy = ry - 0.5 * staff_space * sign (diff) ;
/*
we don't want horizontal ties
Bezier b;
int i = 0;
- for (SCM s= cp; s != SCM_EOL; s = gh_cdr (s))
+ for (SCM s= cp; s != SCM_EOL; s = ly_cdr (s))
{
- b.control_[i] = ly_scm2offset (gh_car (s));
+ b.control_[i] = ly_scm2offset (ly_car (s));
i++;
}