Real beam_thickness = get_beam_thickness (me);
Real fract = robust_scm2double (me->get_property ("length-fraction"), 1.0);
- Real beam_translation = beam_count < 4
- ? (2 * staff_space + line - beam_thickness) / 2.0
- : (3 * staff_space + line - beam_thickness) / 3.0;
-
- return fract * beam_translation;
+ /*
+ if fract != 1.0, as is the case for grace notes, we want the gap
+ to decrease too. To achieve this, we divide the thickness by
+ fract */
+ return (beam_count < 4
+ ? (2 * staff_space * fract + line * fract - beam_thickness) / 2.0
+ : (3 * staff_space * fract + line * fract - beam_thickness) / 3.0);
}
/* Maximum beam_count. */
SCM
Beam::calc_normal_stems (SCM smob)
{
- Grob *me = Grob::unsmob (smob);
+ Grob *me = unsmob<Grob> (smob);
extract_grob_set (me, "stems", stems);
SCM val = Grob_array::make_array ();
- Grob_array *ga = Grob_array::unsmob (val);
+ Grob_array *ga = unsmob<Grob_array> (val);
for (vsize i = 0; i < stems.size (); i++)
if (Stem::is_normal_stem (stems[i]))
ga->add (stems[i]);
SCM
Beam::calc_direction (SCM smob)
{
- Grob *me = Grob::unsmob (smob);
+ Grob *me = unsmob<Grob> (smob);
/* Beams with less than 2 two stems don't make much sense, but could happen
when you do
for (SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s))
{
int k = -right_dir * scm_to_int (scm_car (s)) + i;
- if (scm_is_true (scm_c_memq (scm_from_int (k), left_beaming)))
+ if (scm_is_true (ly_memv (scm_from_int (k), left_beaming)))
count++;
}
SCM
Beam::calc_beaming (SCM smob)
{
- Grob *me = Grob::unsmob (smob);
+ Grob *me = unsmob<Grob> (smob);
extract_grob_set (me, "stems", stems);
{
/* ugh, this has a side-effect that we need to ensure that
Stem #'beaming is correct */
- Grob *me_grob = Grob::unsmob (smob);
+ Grob *me_grob = unsmob<Grob> (smob);
(void) me_grob->get_property ("beaming");
Spanner *me = dynamic_cast<Spanner *> (me_grob);
SCM
Beam::calc_x_positions (SCM smob)
{
- Spanner *me = Spanner::unsmob (smob);
+ Spanner *me = unsmob<Spanner> (smob);
SCM segments = me->get_property ("beam-segments");
Interval x_positions;
x_positions.set_empty ();
SCM
Beam::print (SCM grob)
{
- Spanner *me = Spanner::unsmob (grob);
+ Spanner *me = unsmob<Spanner> (grob);
/*
TODO - mild code dup for all the commonx calls.
Some use just common_refpoint_of_array, some (in print and
Direction stem_dir = stems.size () ? to_dir (stems[0]->get_property ("direction")) : UP;
- Stencil score = *Stencil::unsmob (Text_interface::interpret_markup
+ Stencil score = *unsmob<Stencil> (Text_interface::interpret_markup
(me->layout ()->self_scm (), properties, annotation));
if (!score.is_empty ())
SCM
Beam::calc_stem_shorten (SCM smob)
{
- Grob *me = Grob::unsmob (smob);
+ Grob *me = unsmob<Grob> (smob);
/*
shortening looks silly for x staff beams
SCM
Beam::quanting (SCM smob, SCM ys_scm, SCM align_broken_intos)
{
- Grob *me = Grob::unsmob (smob);
+ Grob *me = unsmob<Grob> (smob);
Drul_array<Real> ys = robust_scm2drul (ys_scm, Drul_array<Real> (infinity_f, -infinity_f));
bool cbs = to_boolean (align_broken_intos);
for (SCM s = scm_car (beaming); scm_is_pair (s); s = scm_cdr (s))
{
- if (scm_is_true (scm_c_memq (scm_car (s), scm_cdr (beaming))))
+ if (scm_is_true (ly_memv (scm_car (s), scm_cdr (beaming))))
l.add_point (scm_to_int (scm_car (s)));
}
SCM
Beam::set_stem_lengths (SCM smob)
{
- Grob *me = Grob::unsmob (smob);
+ Grob *me = unsmob<Grob> (smob);
/* trigger callbacks. */
(void) me->get_property ("direction");
SCM
Beam::rest_collision_callback (SCM smob, SCM prev_offset)
{
- Grob *rest = Grob::unsmob (smob);
+ if (!scm_is_number (prev_offset))
+ prev_offset = SCM_INUM0;
+
+ Grob *rest = unsmob<Grob> (smob);
if (scm_is_number (rest->get_property ("staff-position")))
- return scm_from_int (0);
+ return prev_offset;
- Real offset = robust_scm2double (prev_offset, 0.0);
+ Grob *stem = unsmob<Grob> (rest->get_object ("stem"));
- Grob *st = Grob::unsmob (rest->get_object ("stem"));
- Grob *stem = st;
if (!stem)
- return scm_from_double (0.0);
- Grob *beam = Grob::unsmob (stem->get_object ("beam"));
+ return prev_offset;
+
+ Grob *beam = unsmob<Grob> (stem->get_object ("beam"));
if (!beam
- || !Beam::has_interface (beam)
+ || !has_interface<Beam> (beam)
|| !Beam::normal_stem_count (beam))
- return scm_from_double (0.0);
+ return prev_offset;
Grob *common_y = rest->common_refpoint (beam, Y_AXIS);
+ (beam_count - 1) * beam_translation;
Real beam_y = stem_y - d * height_of_my_beams;
+ Real offset = robust_scm2double (prev_offset, 0.0);
Interval rest_extent = rest->extent (rest, Y_AXIS);
- rest_extent.translate (offset + rest->get_parent (Y_AXIS)->relative_coordinate (common_y, Y_AXIS));
+ rest_extent.translate (offset + rest->parent_relative (common_y, Y_AXIS));
Real rest_dim = rest_extent[d];
Real minimum_distance
SCM, /* end */
SCM prev_offset)
{
- Real previous = robust_scm2double (prev_offset, 0.0);
+ if (!scm_is_number (prev_offset))
+ prev_offset = SCM_INUM0;
- Grob *me = Grob::unsmob (smob);
- Grob *stem = Grob::unsmob (me->get_object ("stem"));
+ Grob *me = unsmob<Grob> (smob);
+ Grob *stem = unsmob<Grob> (me->get_object ("stem"));
if (!stem)
- return scm_from_double (previous);
- Grob *beam = Grob::unsmob (stem->get_object ("beam"));
+ return prev_offset;
+ Grob *beam = unsmob<Grob> (stem->get_object ("beam"));
if (!beam
|| !Beam::normal_stem_count (beam)
|| !is_direction (beam->get_property_data ("direction")))
- return scm_from_double (previous);
+ return prev_offset;
Real ss = Staff_symbol_referencer::staff_space (me);
Grob *right;
if (idx == (vsize) - 1 || my_stems.size () == 1)
- return scm_from_double (previous);
+ return prev_offset;
else if (idx == 0)
left = right = my_stems[1];
else if (idx == my_stems.size () - 1)
Real offset = beam_pos * ss / 2.0
- minimum_distance * beamdir
- me->extent (me, Y_AXIS)[beamdir];
+ Real previous = robust_scm2double (prev_offset, 0.0);
/* Always move by a whole number of staff spaces, always away from the beam */
offset = floor (min (0.0, (offset - previous) / ss * beamdir))
SCM
Beam::calc_cross_staff (SCM smob)
{
- return scm_from_bool (is_cross_staff (Grob::unsmob (smob)));
+ return scm_from_bool (is_cross_staff (unsmob<Grob> (smob)));
}
int