source file of the GNU LilyPond music typesetter
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
}
else
{
- /*
- ugh.
-
- can happen in stem-tremolo case.
- TODO: fixme.
- */
- d = Stem::get_default_dir (stems[0]);
+ d = to_dir (stems[0]->get_property ("default-direction"));
}
}
if (d)
{
set_stem_directions (me, d);
- connect_beams (me);
- set_stem_shorten (me);
}
return scm_from_int (d);
}
+
+
/* We want a maximal number of shared beams, but if there is choice, we
* take the one that is closest to the end of the stem. This is for
* situations like
return best_start;
}
-void
-Beam::connect_beams (Grob *me)
+MAKE_SCHEME_CALLBACK(Beam, calc_beaming, 1)
+SCM
+Beam::calc_beaming (SCM smob)
{
+ Grob *me = unsmob_grob (smob);
+
extract_grob_set (me, "stems", stems);
Slice last_int;
last_int.set_empty ();
- // SCM last_beaming = SCM_EOL;
SCM last_beaming = scm_cons (SCM_EOL, scm_list_1 (scm_from_int (0)));
Direction last_dir = CENTER;
for (int i = 0; i < stems.size (); i++)
last_dir = this_dir;
}
}
+
+ return SCM_EOL;
}
/*
dx = stems.top ()->relative_coordinate (xcommon, X_AXIS) - x0;
}
- SCM posns = me->get_property ("positions");
+ SCM posns = me->get_property ("quantized-positions");
Drul_array<Real> pos;
if (!is_number_pair (posns))
{
if (is_direction (stem_dir_scm))
stem_dir = to_dir (stem_dir_scm);
else
- stem_dir = Stem::get_default_dir (s);
+ stem_dir = to_dir (s->get_property ("default-direction"));
+
+ if (!stem_dir)
+ stem_dir = to_dir (s->get_property ("neutral-direction"));
if (stem_dir)
{
}
Direction dir = CENTER;
-
- if (Direction d = (Direction) sign (count[UP] - count[DOWN]))
+ Direction d = CENTER;
+ if ((d = (Direction) sign (count[UP] - count[DOWN])))
dir = d;
- else if (Direction d = (Direction) sign (total[UP] / count[UP] - total[DOWN]/count[DOWN]))
+ else if (count[UP]
+ && count[DOWN]
+ && (d = (Direction) sign (total[UP] / count[UP] - total[DOWN]/count[DOWN])))
dir = d;
- else if (Direction d = (Direction) sign (total[UP] - total[DOWN]))
+ else if ((d = (Direction) sign (total[UP] - total[DOWN])))
dir = d;
else
dir = to_dir (me->get_property ("neutral-direction"));
This is done in beam because the shorten has to be uniform over the
entire beam.
*/
+
+
+
void
-Beam::set_stem_shorten (Grob *me)
+set_minimum_dy (Grob *me, Real *dy)
{
+ if (*dy)
+ {
+ /*
+ If dy is smaller than the smallest quant, we
+ get absurd direction-sign penalties.
+ */
+
+ Real ss = Staff_symbol_referencer::staff_space (me);
+ Real thickness = Beam::get_thickness (me) / ss;
+ Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
+ Real sit = (thickness - slt) / 2;
+ Real inter = 0.5;
+ Real hang = 1.0 - (thickness - slt) / 2;
+
+ *dy = sign (*dy) * max (fabs (*dy),
+ min (min (sit, inter), hang));
+ }
+}
+
+
+
+MAKE_SCHEME_CALLBACK(Beam, calc_stem_shorten, 1)
+SCM
+Beam::calc_stem_shorten (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+
/*
shortening looks silly for x staff beams
*/
if (is_knee (me))
- return;
+ return scm_from_int (0);
Real forced_fraction = 1.0 * forced_stem_count (me)
/ visible_stem_count (me);
SCM shorten_list = me->get_property ("beamed-stem-shorten");
if (shorten_list == SCM_EOL)
- return;
+ return scm_from_int (0);
Real staff_space = Staff_symbol_referencer::staff_space (me);
shorten *= forced_fraction;
- if (shorten)
- me->set_property ("shorten", scm_from_double (shorten));
-}
-
-MAKE_SCHEME_CALLBACK (Beam, calc_positions, 1);
-SCM
-Beam::calc_positions (SCM smob)
-{
- Grob *me = unsmob_grob (smob);
- if (!me->is_live ())
- return SCM_EOL;
-
- (void) me->get_property ("direction");
- SCM posns = scm_cons (SCM_BOOL_F, SCM_BOOL_F);
- me->set_property ("positions", posns);
-
- SCM callbacks = me->get_property ("position-callbacks");
- for (SCM i = callbacks; scm_is_pair (i); i = scm_cdr (i))
- scm_call_1 (scm_car (i), me->self_scm ());
+ if (shorten)
+ return scm_from_double (shorten);
- return SCM_UNSPECIFIED;
+ return scm_from_double (0.0);
}
-void
-set_minimum_dy (Grob *me, Real *dy)
-{
- if (*dy)
- {
- /*
- If dy is smaller than the smallest quant, we
- get absurd direction-sign penalties.
- */
-
- Real ss = Staff_symbol_referencer::staff_space (me);
- Real thickness = Beam::get_thickness (me) / ss;
- Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
- Real sit = (thickness - slt) / 2;
- Real inter = 0.5;
- Real hang = 1.0 - (thickness - slt) / 2;
-
- *dy = sign (*dy) * max (fabs (*dy),
- min (min (sit, inter), hang));
- }
-}
-
/*
Compute a first approximation to the beam slope.
*/
Hmm. At this time, beam position and slope are determined. Maybe,
stem directions and length should set to relative to the chord's
position of the beam. */
-MAKE_SCHEME_CALLBACK(Beam, set_stem_lengths, 2);
+MAKE_SCHEME_CALLBACK(Beam, set_stem_lengths, 1);
SCM
-Beam::set_stem_lengths (SCM smob, SCM posns)
+Beam::set_stem_lengths (SCM smob)
{
Grob *me = unsmob_grob (smob);
+
+ /* trigger callback. */
+ (void) me->get_property ("direction");
+
+ SCM posns = me->get_property ("positions");
extract_grob_set (me, "stems", stems);
if (!stems.size ())
bool gap = false;
Real thick = 0.0;
if (scm_is_number (me->get_property ("gap-count"))
- &&scm_to_int (me->get_property ("gap-count")))
+ && scm_to_int (me->get_property ("gap-count")))
{
gap = true;
thick = get_thickness (me);
}
- // ugh -> use commonx
Grob *fvs = first_visible_stem (me);
Grob *lvs = last_visible_stem (me);
/*
Don't overwrite user settings.
*/
-
do
{
Grob *stem = stems[i];
/* I can imagine counting those boundaries as a half forced stem,
but let's count them full for now. */
+ Direction defdir = to_dir (s->get_property ("default-direction"));
+
if (abs (Stem::chord_start_y (s)) > 0.1
- && (get_grob_direction (s) != Stem::get_default_dir (s)))
+ && defdir
+ && get_grob_direction (s) != defdir)
f++;
}
return f;
Real dy = pos[RIGHT] - pos[LEFT];
- // ugh -> use commonx
- Real x0 = first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
- Real dx = last_visible_stem (beam)->relative_coordinate (0, X_AXIS) - x0;
+ Drul_array<Grob*> visible_stems (first_visible_stem (beam),
+ last_visible_stem (beam));
+ extract_grob_set (beam, "stems", stems);
+
+ Grob *common = common_refpoint_of_array (stems, beam, X_AXIS);
+
+ Real x0 = visible_stems[LEFT]->relative_coordinate (common, X_AXIS);
+ Real dx = visible_stems[RIGHT]->relative_coordinate (common, X_AXIS) - x0;
Real slope = dy && dx ? dy / dx : 0;
Direction d = get_grob_direction (stem);
- Real stem_y = pos[LEFT] + (stem->relative_coordinate (0, X_AXIS) - x0) * slope;
+ Real stem_y = pos[LEFT]
+ + (stem->relative_coordinate (common, X_AXIS) - x0) * slope;
Real beam_translation = get_beam_translation (beam);
Real beam_thickness = Beam::get_thickness (beam);
"A beam. \n\n"
"The @code{thickness} property is the weight of beams, "
- "measured in staffspace. The @code{direction} property is not user-serviceable. Use "
+ "measured in staffspace. The @code{direction} "
+ "property is not user-serviceable. Use "
"the @code{direction} property of @code{Stem} instead. "
,
/* properties */
"auto-knee-gap "
"beamed-stem-shorten "
+ "beaming "
"break-overshoot "
"chord-tremolo "
"concaveness "
"neutral-direction "
"positions "
"quant-score "
+ "quantized-positions "
"shorten "
"stems "
"thickness "