From: Han-Wen Nienhuys Date: Sun, 21 Jul 2002 21:40:40 +0000 (+0000) Subject: * lily/accidental-placement.cc (stagger_apes): try to arrange accs X-Git-Tag: release/1.5.69~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=03450b2aa4d991de72a9ce57aff429c66f2172cc;p=lilypond.git * lily/accidental-placement.cc (stagger_apes): try to arrange accs in a C form, with the top accidental closet to the chord. * lily/stem.cc (get_default_stem_end_position): don't crash if lengths not set. (get_default_stem_end_position): idem for stem-shorten. * mf/feta-toevallig.mf: enlarge flat bbox. * input/regression/lyrics-extender.ly: new file. --- diff --git a/ChangeLog b/ChangeLog index cc86db65d5..b86cb4caca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2002-07-21 Han-Wen + * lily/accidental-placement.cc (stagger_apes): try to arrange accs + in a C form, with the top accidental closet to the chord. + + * lily/stem.cc (get_default_stem_end_position): don't crash if + lengths not set. + (get_default_stem_end_position): idem for stem-shorten. + + * mf/feta-toevallig.mf: enlarge flat bbox. + + * input/regression/lyrics-extender.ly: new file. + * lily/lyric-extender.cc (brew_molecule): don't add right-trim-amount if extender is broken. diff --git a/input/regression/accidental-placement.ly b/input/regression/accidental-placement.ly index 3653addaef..6011fcc201 100644 --- a/input/regression/accidental-placement.ly +++ b/input/regression/accidental-placement.ly @@ -1,11 +1,21 @@ \header { texidoc ="Accidentals are placed as closely as possible. -Accidentals in corresponding octaves are aligned." +Accidentals in corresponding octaves are aligned. +The top accidental should be nearest to the chord. The +flats in a sixth shoudl be staggered. " } \score { \notes \context Voice \relative c' { cis4 + c4 + \transpose c'' { + + + + + +} diff --git a/input/regression/lyrics-extender.ly b/input/regression/lyrics-extender.ly new file mode 100644 index 0000000000..42966ad69e --- /dev/null +++ b/input/regression/lyrics-extender.ly @@ -0,0 +1,27 @@ +\header{ + texidoc = + + "Extenders that end a staff should not extend past the staff. +Also shown: a trick to get an extender at the end of the staff. +" + +} + +sopran = \notes \relative c'' { +\time 3/4 a2.( | \break +)g2 < g4 { s8 s8 } > | +} + +text = \lyrics { +vielt __ Zeit. __ " " +} + +\score { +< +\addlyrics + \context Staff \sopran + \context Lyrics \text +> +\paper { linewidth = 5.0\cm +} +} diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index 9a0ab1fec3..1f102415c5 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -104,16 +104,7 @@ struct Accidental_placement_entry static Interval all_accidental_vertical_extent; Real ape_priority (Accidental_placement_entry const * a) { - Real c = a->vertical_extent_.center(); - - /* - far from center means we can fold more. Hopefully. - */ - Real center_distance = - fabs(c - all_accidental_vertical_extent[LEFT]) >? - fabs(c - all_accidental_vertical_extent[RIGHT]); - - return 20 * a->vertical_extent_.length () + center_distance; + return a->vertical_extent_[UP]; } @@ -124,6 +115,52 @@ int ape_compare (Accidental_placement_entry *const &a, return sign (ape_priority (a) - ape_priority(b)); } +int ape_rcompare (Accidental_placement_entry *const &a, + Accidental_placement_entry *const &b) +{ + return -sign (ape_priority (a) - ape_priority(b)); +} + + +/* + +TODO: should favor + + b + b + +placement + +*/ +void +stagger_apes (Link_array *apes) +{ + Link_array asc = *apes; + + + asc.sort (&ape_compare); + + apes->clear(); + + int i =0; + int parity = 1; + while (i < asc.size()) + { + Accidental_placement_entry * a = 0; + if (parity) + a = asc.pop(); + else + a = asc[i++]; + + apes->push (a); + parity = !parity; + } + + apes->reverse(); +} + + + /* Return: width as SCM interval. @@ -265,7 +302,7 @@ Accidental_placement::position_accidentals (Grob * me) total.unite (y); } all_accidental_vertical_extent = total; - apes.sort (&ape_compare); + stagger_apes (&apes); Accidental_placement_entry * head_ape = new Accidental_placement_entry; Grob *commonx = common_refpoint_of_array (heads, me, X_AXIS); diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 8245965f3d..53328a23d7 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -156,8 +156,6 @@ Interval ly_scm2interval (SCM); Slice int_list_to_slice (SCM l); SCM ly_interval2scm (Drul_array); -void taint (SCM *); - SCM ly_parse_scm (char const* s, int* n); SCM ly_quote_scm (SCM s); @@ -167,6 +165,8 @@ String print_scm_val (SCM val); SCM ly_number2string (SCM s); SCM parse_symbol_list (char const *); +SCM robust_list_ref(int i, SCM l); + inline SCM ly_cdr (SCM x) { return SCM_CDR (x); } inline SCM ly_car (SCM x) { return SCM_CAR (x); } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 69990c82b1..6f8bcbe4c0 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -812,3 +812,19 @@ int_list_to_slice (SCM l) return s; } + + + +/* + return I-th element, or last elt L + + PRE: length (L) > 0 + */ +SCM +robust_list_ref(int i, SCM l) +{ + while (i-- && gh_pair_p (gh_cdr(l))) + l = gh_cdr (l); + + return gh_car(l); +} diff --git a/lily/stem.cc b/lily/stem.cc index 8589fc0295..32ccc700b8 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -294,24 +294,22 @@ Stem::get_default_stem_end_position (Grob*me) else { s = me->get_grob_property ("lengths"); - for (SCM q = s; q != SCM_EOL; q = ly_cdr (q)) - a.push (gh_scm2double (ly_car (q))); - - // stem uses half-spaces - length_f = a[ ((duration_log (me) - 2) >? 0) get_grob_property ("stem-shorten"); - for (SCM q = s; gh_pair_p (q); q = ly_cdr (q)) - a.push (gh_scm2double (ly_car (q))); - - - // stem uses half-spaces - - // fixme: use scm_list_n_ref () iso. array[] - Real shorten_f = a[ ((duration_log (me) - 2) >? 0) get_grob_property ("stem-shorten"); + if (gh_pair_p (sshorten)) + { + shorten_f = 2* gh_scm2double (robust_list_ref ((duration_log (me) - 2) >? 0, sshorten)); + } /* On boundary: shorten only half */ if (abs (chord_start_y (me)) == 0.5) @@ -760,20 +758,6 @@ Stem::beam_l (Grob*me) return unsmob_grob (b); } -/* - return I-th element, or last elt L - - PRE: length (L) > 0 - */ -SCM -robust_list_ref(int i, SCM l) -{ - while (i-- && gh_pair_p (gh_cdr(l))) - l = gh_cdr (l); - - return gh_car(l); -} - // ugh still very long. Stem_info Stem::calc_stem_info (Grob*me) diff --git a/mf/feta-toevallig.mf b/mf/feta-toevallig.mf index 4d6dd61996..3363568582 100644 --- a/mf/feta-toevallig.mf +++ b/mf/feta-toevallig.mf @@ -251,7 +251,7 @@ enddef; % unfortunately, 600dpi is not enough to show the brush of the stem. % fet_beginchar("Flat", "-1", "flat") - set_char_box(1.2 stafflinethickness#, .8 staff_space#, .5 staff_space#, 2 staff_space#); + set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 2 staff_space#); draw_meta_flat(0, w, 1/3 staff_space); fet_endchar; diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 61934849a6..27aca00c77 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -247,7 +247,10 @@ For barline, space after a thick line.") (grob-property-description 'left-widen boolean? "Whether the left edge of a piano pedal bracket should be widened by the first element of edge-widen.") (grob-property-description 'length number? "Stem length for unbeamed stems, only for user override.") -(grob-property-description 'lengths list? "Stem length given multiplicity of flag.") +(grob-property-description 'lengths list? "Stem length given +multiplicity of flag. The Nth element of the list gives the stem +length of a note with N flags. +") (grob-property-description 'line-count integer? "Number of staff lines. If you want to override this for staffs individually, you must use @code{\outputproperty}. @code{\property .. \override} will not @@ -379,7 +382,9 @@ being the style. It returns a (X . Y) pair, specifying location in terms of note head bounding box.") (grob-property-description 'stem-end-position number? "Where does the stem end (the end is opposite to the support-head.") -(grob-property-description 'stem-shorten list? "shorten stems in forced directions given flag multiplicity.") +(grob-property-description 'stem-shorten list? "shorten stems in forced directions given flag multiplicity: +the Nth element of the list gives the amount stem shortening of a note with N flags. +") (grob-property-description 'stem-spacing-correction number? "optical correction amount. [TODO: doco] ") (grob-property-description 'stems grob-list? "list of stem objects, corresponding to the notes that the arpeggio has to be before.") (grob-property-description 'style symbol? "a string determining what style of glyph is typeset. Valid choices depend on the function that is reading this property. .")