From: Han-Wen Nienhuys Date: Thu, 17 Nov 2005 15:11:19 +0000 (+0000) Subject: * lily/stem.cc (calc_stem_info): trigger beaming calculation. X-Git-Tag: release/2.7.18~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=970817926622df67c370c0566b65a8484e05ab5a;p=lilypond.git * lily/stem.cc (calc_stem_info): trigger beaming calculation. * 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. --- diff --git a/ChangeLog b/ChangeLog index 39ce04051c..dee05a0421 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2005-11-17 Han-Wen Nienhuys + * 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. diff --git a/THANKS b/THANKS index 434b25a294..7483c5586f 100644 --- a/THANKS +++ b/THANKS @@ -47,6 +47,7 @@ Bob Broadus Chris Sawer Darius Blasband Donald Axel +Edward Neeman Eduardo Vieira Erlend Aasland Matevž Jekovec diff --git a/lily/beam.cc b/lily/beam.cc index 19b69fe15b..4b6bfa3024 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -160,13 +160,13 @@ Beam::calc_direction (SCM smob) 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 @@ -209,9 +209,12 @@ position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming, 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; @@ -269,6 +272,8 @@ Beam::connect_beams (Grob *me) last_dir = this_dir; } } + + return SCM_BOOL_T; } /* @@ -692,14 +697,44 @@ scmify forced-fraction 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); @@ -708,7 +743,7 @@ Beam::set_stem_shorten (Grob *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); @@ -718,33 +753,14 @@ Beam::set_stem_shorten (Grob *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. diff --git a/lily/include/beam.hh b/lily/include/beam.hh index a044a1fd8c..6025cd1e12 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -57,6 +57,8 @@ public: 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)); diff --git a/lily/include/stem.hh b/lily/include/stem.hh index ee66ec15fa..dbbb3e8438 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -42,6 +42,7 @@ public: 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)); diff --git a/lily/stem.cc b/lily/stem.cc index 9cdaaa2568..62f9c8669b 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -448,8 +448,6 @@ Stem::calc_positioning_done (SCM smob) return SCM_BOOL_T; } - - MAKE_SCHEME_CALLBACK(Stem, calc_direction, 1); SCM Stem::calc_direction (SCM smob) @@ -809,31 +807,38 @@ Stem::calc_stem_info (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 @@ -893,7 +898,8 @@ Stem::calc_stem_info (SCM smob) 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 diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 6d96746247..9188337440 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -300,6 +300,8 @@ (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.