* lily/beam.cc (calc_beaming): new function.
(calc_shorten): new function.
* THANKS: add Edward Neeman.
* scm/define-grobs.scm (all-grob-descriptions): add Y-offset property.
2005-11-17 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/stem.cc (calc_stem_info): trigger beaming calculation.
+
+ * lily/beam.cc (calc_beaming): new function.
+ (calc_shorten): new function.
+
+ * THANKS: add Edward Neeman.
+
* input/regression/accidental-clef-change.ly: new file.
* lily/note-collision.cc (check_meshing_chords): don't merge fa heads.
Chris Sawer
Darius Blasband
Donald Axel
+Edward Neeman
Eduardo Vieira
Erlend Aasland
Matevž Jekovec
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_dir = this_dir;
}
}
+
+ return SCM_BOOL_T;
}
/*
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));
-}
-
-
+ return scm_from_double (shorten);
-void
-set_minimum_dy (Grob *me, Real *dy)
-{
- if (*dy)
- {
- /*
- If dy is smaller than the smallest quant, we
- get absurd direction-sign penalties.
- */
+ return scm_from_double (0.0);
+}
- 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.
DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element));
DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
DECLARE_SCHEME_CALLBACK (calc_length, (SCM));
DECLARE_SCHEME_CALLBACK (calc_stem_end_position, (SCM));
DECLARE_SCHEME_CALLBACK (calc_stem_info, (SCM));
return SCM_BOOL_T;
}
-
-
MAKE_SCHEME_CALLBACK(Stem, calc_direction, 1);
SCM
Stem::calc_direction (SCM smob)
Real staff_space = Staff_symbol_referencer::staff_space (me);
Grob *beam = get_beam (me);
+
+ if (beam)
+ {
+ (void) beam->get_property ("beaming");
+ }
+
Real beam_translation = Beam::get_beam_translation (beam);
Real beam_thickness = Beam::get_thickness (beam);
int beam_count = Beam::get_direction_beam_count (beam, my_dir);
+ Real length_fraction
+ = robust_scm2double (me->get_property ("length-fraction"), 1.0);
/* Simple standard stem length */
SCM details = me->get_property ("details");
SCM lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-lengths"), details));
-
Real ideal_length
= scm_to_double (robust_list_ref (beam_count - 1, lengths))
-
* staff_space
+ * length_fraction
+
/* stem only extends to center of beam
*/
- 0.5 * beam_thickness;
/* Condition: sane minimum free stem length (chord to beams) */
lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-minimum-free-lengths"), details));
- Real length_fraction
- = robust_scm2double (me->get_property ("length-fraction"), 1.0);
Real ideal_minimum_free
= scm_to_double (robust_list_ref (beam_count - 1, lengths))
- * staff_space * length_fraction;
+ * staff_space
+ * length_fraction;
/* UGH
It seems that also for ideal minimum length, we must use
Real minimum_free
= scm_to_double (robust_list_ref (beam_count - 1, bemfl))
- * staff_space;
+ * staff_space
+ * length_fraction;
Real minimum_length = minimum_free
+ height_of_my_beams
(quantized-positions . ,Beam::set_stem_lengths)
(concaveness . ,Beam::calc_concaveness)
(direction . ,Beam::calc_direction)
+ (shorten . ,Beam::calc_stem_shorten)
+ (beaming . ,Beam::calc_beaming)
(stencil . ,Beam::print)
;; TODO: should be in SLT.