source file of the GNU LilyPond music typesetter
- (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include <math.h>
#include "rhythmic-head.hh"
#include "bezier.hh"
#include "paper-column.hh"
-#include "debug.hh"
+#include "warn.hh"
#include "staff-symbol-referencer.hh"
#include "directional-element-interface.hh"
#include "molecule.hh"
void
-Tie::set_head (Grob*me,Direction d, Item * head_l)
+Tie::set_head (Grob*me,Direction d, Grob * h)
{
assert (!head (me,d));
- index_set_cell (me->get_grob_property ("heads"), d, head_l->self_scm ());
+ index_set_cell (me->get_grob_property ("heads"), d, h->self_scm ());
- dynamic_cast<Spanner*> (me)->set_bound (d, head_l);
- me->add_dependency (head_l);
+ dynamic_cast<Spanner*> (me)->set_bound (d, h);
+ me->add_dependency (h);
}
void
Tie::head (Grob*me, Direction d)
{
SCM c = me->get_grob_property ("heads");
- c = index_cell (c, d);
+ c = index_get_cell (c, d);
return unsmob_grob (c);
}
Real
-Tie::position_f (Grob*me)
+Tie::get_position (Grob*me)
{
Direction d = head (me,LEFT) ? LEFT:RIGHT;
- return Staff_symbol_referencer::position_f (head (me,d));
+ return Staff_symbol_referencer::get_position (head (me,d));
}
Direction
Tie::get_default_dir (Grob*me)
{
- Item * sl = head (me,LEFT) ? Rhythmic_head::stem_l (head (me,LEFT)) :0;
- Item * sr = head (me,RIGHT) ? Rhythmic_head::stem_l (head (me,RIGHT)) :0;
+ Item * sl = head (me,LEFT) ? Rhythmic_head::get_stem (head (me,LEFT)) :0;
+ Item * sr = head (me,RIGHT) ? Rhythmic_head::get_stem (head (me,RIGHT)) :0;
if (sl && sr)
{
me->suicide ();
return SCM_UNSPECIFIED;
}
+
if (!Directional_element_interface::get (me))
Directional_element_interface::set (me, Tie::get_default_dir (me));
+ Direction dir = Directional_element_interface::get (me);
Real staff_space = Staff_symbol_referencer::staff_space (me);
Real left_x;
/*
- this is a kludge: the tie has to be long enough to be
- visible, but should not go through key sigs.
-
- (please fixme)
+ the tie has to be long enough to be visible, but should not go
+ through key sigs. In the 1.5 series the pref.matter - note
+ distance is fixed , so this won't be a problem anymore.
*/
- Real lambda = 0.5;
+ Real lambda = 0.9;
if (Note_head::has_interface (l))
- left_x = l->extent (l, X_AXIS)[RIGHT] + x_gap_f;
+ {
+ Real where = RIGHT;
+
+ /*
+ This correction is due te the shape of the black note head.
+ */
+ if (Rhythmic_head::duration_log (l) == 2)
+ where += dir* 0.2;
+ left_x = l->extent (l, X_AXIS).linear_combination (where)
+ + x_gap_f;
+ }
else
left_x = l->extent (l, X_AXIS).linear_combination (lambda);
- 2 * x_gap_f;
}
- Direction dir = Directional_element_interface::get (me);
+
SCM details = me->get_grob_property ("details");
*/
- Real ypos = Tie::position_f (me) * staff_space/2
+ Real ypos = Tie::get_position (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))
+ if (Note_head::has_interface (l) && Rhythmic_head::get_dots (l))
{
- Grob* dots = Rhythmic_head::dots_l(l);
- if(fabs (staff_space * Staff_symbol_referencer::position_f (dots) /2
+ Grob* dots = Rhythmic_head::get_dots (l);
+ if(fabs (staff_space * Staff_symbol_referencer::get_position (dots) /2
- ypos) < 0.5)
{
ypos += 0.5 * dir ;
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) * staff_space + clear
&& fabs (diff) < clear)
{
Real y1 = ry + clear;
Real y2 = ry - clear;
+
+ /*
+ ugh, we shove the 0.5 out of our sleeves.
+
+ Any way. This test is to make sure that staffline
+ collision avoidance does not result in completely flat
+ ties.
+ */
+ if (fabs (y1 - ypos) < 0.5)
+ y1 = y2;
+ else if (fabs (y2 - ypos) < 0.5)
+ y2 = y1;
newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2;
Real thick =
gh_scm2double (me->get_grob_property ("thickness"))
- * me->paper_l ()->get_var ("linethickness");
+ * me->get_paper ()->get_var ("linethickness");
Bezier b;
int i = 0;