source file of the GNU LilyPond music typesetter
- (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "note-column.hh"
#include "stem.hh"
#include "paper-column.hh"
-#include "molecule.hh"
+#include "stencil.hh"
#include "warn.hh"
#include "slur-bezier-bow.hh"
#include "main.hh"
return SCM_UNSPECIFIED;
}
set_extremities (me);
- set_control_points (me);
+ if (!gh_pair_p (me->get_grob_property ("control-points")))
+ set_control_points (me);
return SCM_UNSPECIFIED;
}
void
Slur::check_slope (Grob *me)
{
-
/*
Avoid too steep slurs.
*/
o[RIGHT] = ly_scm2offset (index_get_cell (a, RIGHT));
o[d][Y_AXIS] -= (limit - slope) * dx * dir / staff_space;
- o[d][Y_AXIS] *= Directional_element_interface::get (me);
+ o[d][Y_AXIS] *= get_grob_direction (me);
me->set_grob_property ("attachment-offset",
gh_cons (ly_offset2scm (o[LEFT]),
SCM
Slur::set_extremities (Grob *me)
{
- if (!Directional_element_interface::get (me))
- Directional_element_interface::set (me, get_default_dir (me));
+ if (!get_grob_direction (me))
+ set_grob_direction (me, get_default_dir (me));
SCM att = me->get_grob_property ("attachment");
/*
Grob **common)
{
SCM s = me->get_grob_property ("attachment");
- if (!gh_symbol_p (index_get_cell (s, dir)))
+ if (!gh_pair_p (s) || !gh_symbol_p (index_get_cell (s, dir)))
{
s = set_extremities (me);
}
- SCM a = dir == LEFT ? ly_car (s) : ly_cdr (s);
+ SCM a = (dir == LEFT) ? ly_car (s) : ly_cdr (s);
Spanner*sp = dynamic_cast<Spanner*> (me);
String str = ly_symbol2string (a);
+
Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
Real hs = staff_space / 2.0;
Offset o;
- int slurdir = gh_scm2int (me->get_grob_property ("direction"));
+ Direction slurdir = to_dir (me->get_grob_property ("direction"));
Grob *stem = 0;
if (Note_column::has_interface (sp->get_bound (dir)))
{
Grob * n =sp->get_bound (dir);
- if ((stem = Note_column::get_stem (n)))
+ stem = Note_column::get_stem (n);
+ if (stem)
{
Real x_extent;
- if (Grob *head = Note_column::first_head (n))
+ Grob *head = Note_column::first_head (n);
+ if (head)
x_extent = head->extent (head, X_AXIS).length ();
else
x_extent = n->extent (n, X_AXIS).length ();
- if (str == "head")
+ if (!head)
+ {
+ o = Offset (0, n->extent (n, Y_AXIS)[slurdir]);
+ }
+ else if (str == "head")
{
o = Offset (0, Stem::head_positions (stem)
- [Directional_element_interface::get (me)] * hs);
+ [slurdir] * hs);
/*
Default position is centered in X, on outer side of head Y
*/
o += Offset (0.5 * x_extent,
0.5 * staff_space
- * Directional_element_interface::get (me));
+ * slurdir);
}
else if (str == "alongside-stem")
{
*/
o += Offset (x_extent * (1 + Stem::get_direction (stem)),
0.5 * staff_space
- * Directional_element_interface::get (me));
+ * slurdir);
}
else if (str == "stem")
{
/*
Default position is on stem X, at stem end Y
*/
- Real stem_thickness =
- gh_scm2double (stem->get_grob_property ("thickness"))
- * stem->get_paper ()->get_var ("linethickness");
+ Real stem_thickness = Stem::thickness (stem);
o += Offset (0.5 *
x_extent * (1 + Stem::get_direction (stem))
- ((dir + 1)/2) * stem_thickness
{
Offset off = ly_scm2offset (ly_cdr (l)) * staff_space;
off[X_AXIS] *= dir;
- off[Y_AXIS] *= Directional_element_interface::get (me);
+ off[Y_AXIS] *= slurdir;
o += off;
}
("attachment-offset"),
dir)) * staff_space;
- off[Y_AXIS] *= Directional_element_interface::get (me);
+ off[Y_AXIS] *= slurdir;
o += off;
return o;
}
Offset o;
Grob* stem = unsmob_grob (col->get_grob_property ("stem"));
- Direction dir = Directional_element_interface::get (me);
+ Direction dir = get_grob_direction (me);
if (!stem)
{
o[Y_AXIS] = col->relative_coordinate (common[Y_AXIS], Y_AXIS);
return o;
}
- Direction stem_dir = Directional_element_interface::get (stem);
+ Direction stem_dir = get_grob_direction (stem);
o[X_AXIS] = stem->relative_coordinate (0, X_AXIS);
/*
o[X_AXIS] -= 0.5 * stem_dir * x_extent;
if ((stem_dir == dir)
- && !stem->extent (stem, Y_AXIS).empty_b ())
+ && !stem->extent (stem, Y_AXIS).is_empty ())
{
o[Y_AXIS] = stem->extent (common[Y_AXIS], Y_AXIS)[dir];
}
/*
leave a gap: slur mustn't touch head/stem
*/
- o[Y_AXIS] += dir * gh_scm2double (me->get_grob_property ("y-free")) *
+ o[Y_AXIS] += dir * robust_scm2double (me->get_grob_property ("y-free"), 0) *
1.0;
return o;
}
Grob * me = unsmob_grob (smob);
assert (a == Y_AXIS);
- SCM mol = me->get_uncached_molecule ();
- return ly_interval2scm (unsmob_molecule (mol)->extent (a));
+ SCM mol = me->get_uncached_stencil ();
+ Interval ext;
+ if (Stencil * m = unsmob_stencil (mol))
+ ext = m->extent (a);
+ return ly_interval2scm (ext);
}
/*
Ugh should have dash-length + dash-period
*/
-MAKE_SCHEME_CALLBACK (Slur, brew_molecule,1);
+MAKE_SCHEME_CALLBACK (Slur, print,1);
SCM
-Slur::brew_molecule (SCM smob)
+Slur::print (SCM smob)
{
Grob * me = unsmob_grob (smob);
if (!scm_ilength (me->get_grob_property ("note-columns")))
return SCM_EOL;
}
- Real thick = me->get_paper ()->get_var ("linethickness") *
- gh_scm2double (me->get_grob_property ("thickness"));
+ Real base_thick = robust_scm2double (me->get_grob_property ("thickness"), 1);
+ Real thick = base_thick * Staff_symbol_referencer::line_thickness (me);
+
+ Real ss = Staff_symbol_referencer::staff_space (me);
Bezier one = get_curve (me);
// get_curve may suicide
if (!scm_ilength (me->get_grob_property ("note-columns")))
return SCM_EOL;
- Molecule a;
+ Stencil a;
SCM d = me->get_grob_property ("dashed");
if (gh_number_p (d))
- a = Lookup::dashed_slur (one, thick, thick * gh_scm2double (d));
+ a = Lookup::dashed_slur (one, thick, thick * robust_scm2double (d, 0));
else
- a = Lookup::slur (one, Directional_element_interface::get (me) * thick, thick);
+ a = Lookup::slur (one, get_grob_direction (me) * base_thick * ss / 10.0,
+ thick);
return a.smobbed_copy ();
}
SCM h_inf_scm = me->get_grob_property ("height-limit");
SCM r_0_scm = me->get_grob_property ("ratio");
- Real r_0 = gh_scm2double (r_0_scm);
+ Real r_0 = robust_scm2double (r_0_scm, 1);
Real h_inf = staff_space * gh_scm2double (h_inf_scm);
Slur_bezier_bow bb (get_encompass_offsets (me),
- Directional_element_interface::get (me),
+ get_grob_direction (me),
h_inf, r_0);
attach = set_extremities(me);
- if (!Directional_element_interface::get (me)
+ if (!get_grob_direction (me)
|| ! gh_symbol_p (index_get_cell (attach, LEFT))
|| ! gh_symbol_p (index_get_cell (attach, RIGHT)))
set_extremities (me);
}
Array<Offset> enc (get_encompass_offsets (me));
- Direction dir = Directional_element_interface::get (me);
+ Direction dir = get_grob_direction (me);
Real x1 = enc[0][X_AXIS];
Real x2 = enc.top ()[X_AXIS];