+2005-11-04 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/beam.cc (set_stem_lengths): force direction callback.
+ (print): read quantized-positions, so we can force
+ Beam::set_stem_lengths to occur.
+ (rest_collision_callback): use common X parent.
+
2005-11-03 Jan Nieuwenhuizen <janneke@gnu.org>
* flower/file-path.cc (find): Bugfix: Return name of file found.
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++)
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))
{
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];
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));
+
+ Grob *common = visible_stems[RIGHT]
+ ->common_refpoint (visible_stems[LEFT], 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);
DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM));
+ DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM));
/* position callbacks */
DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (slope_damping, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM));
- DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM,SCM));
static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *);
if (!head_count (me))
return scm_from_double (0.0);
-
+
Real ss = Staff_symbol_referencer::staff_space (me);
int durlog = duration_log (me);
Array<Real> a;
Direction dir = get_grob_direction (me);
Interval hp = head_positions (me);
- Real st = dir ? hp[dir] + dir * length : 0;
+ Real stem_end = dir ? hp[dir] + dir * length : 0;
/* TODO: change name to extend-stems to staff/center/'() */
bool no_extend_b = to_boolean (me->get_property ("no-stem-extend"));
- if (!no_extend_b && dir * st < 0)
- st = 0.0;
+ if (!no_extend_b && dir * stem_end < 0)
+ stem_end = 0.0;
+
/* Make a little room if we have a upflag and there is a dot.
previous approach was to lengthen the stem. This is not
good typesetting practice. */
/* Very gory: add myself to the X-support of the parent,
which should be a dot-column. */
- if (dir * (st + flagy - dp) < 0.5)
+ if (dir * (stem_end + flagy - dp) < 0.5)
{
Grob *par = dots->get_parent (X_AXIS);
}
}
- return scm_from_double (st);
+ return scm_from_double (stem_end);
}
beam->get_property ("positions");
}
- /* FIXME uncached? */
- Interval iv = me->get_stencil () ? me->get_stencil ()->extent (Y_AXIS) : Interval();
+ /*
+ Can't get_stencil(), since that would cache stencils too early.
+ This causes problems with beams.
+ */
+ Stencil *stencil = unsmob_stencil (print (smob));
+ Interval iv = stencil ? stencil->extent (Y_AXIS) : Interval();
if (beam)
{
if (dir == CENTER)
Interval stem_y (min (y1, y2), max (y2, y1));
- if (Grob *hed = support_head (me))
+ if (Grob *head = support_head (me))
{
/*
must not take ledgers into account.
*/
- Interval head_height = hed->extent (hed, Y_AXIS);
- Real y_attach = Note_head::stem_attachment_coordinate (hed, Y_AXIS);
+ Interval head_height = head->extent (head, Y_AXIS);
+ Real y_attach = Note_head::stem_attachment_coordinate (head, Y_AXIS);
y_attach = head_height.linear_combination (y_attach);
stem_y[Direction (-d)] += d * y_attach / half_space;
"should be shortened. The list gives an amount depending on the number "
"of flags/beams."
"@end table\n"
-
,
/* properties */
-
"avoid-note-head "
"beam "
"beaming "
Beam::slope_damping
Beam::shift_region_to_valid
Beam::quanting
- Beam::set_stem_lengths
))))
-
+
+ ;; this is a hack to set stem lengths, if positions is set.
+ (quantized-positions . ,Beam::set_stem_lengths)
(concaveness . ,Beam::calc_concaveness)
(direction . ,Beam::calc_direction)
(stencil . ,Beam::print)