From 6f457bd257c3d9bd5e2065e182860a2073b3ecc9 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 30 Aug 2003 20:14:54 +0000 Subject: [PATCH] * scripts/convert-ly.py (FatalConversionError.conv): fingering convert rule. * Documentation/user/refman.itely (Fingering instructions): adjust manual. * lily/new-fingering-engraver.cc (position_scripts): don't crash for borderline cases (e.g. 1 fingering.) (position_scripts): revise interface, use fingerOrientations to set fingering positions. --- ChangeLog | 7 +++++ Documentation/user/refman.itely | 12 ++++---- input/regression/finger-chords.ly | 33 ++++++++++++---------- lily/new-fingering-engraver.cc | 42 ++++++++++++++++++---------- ly/engraver-init.ly | 4 +-- scm/define-translator-properties.scm | 6 ++-- scripts/convert-ly.py | 11 +++++++- 7 files changed, 73 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8b0bcf739..26df67e1a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,14 @@ 2003-08-30 Han-Wen Nienhuys + * scripts/convert-ly.py (FatalConversionError.conv): fingering + convert rule. + + * Documentation/user/refman.itely (Fingering instructions): adjust manual. + * lily/new-fingering-engraver.cc (position_scripts): don't crash for borderline cases (e.g. 1 fingering.) + (position_scripts): revise interface, use fingerOrientations to + set fingering positions. * scm/document-translation.scm (context-doc): add aliases to automated documentation. diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 1a1d93fe9b..8423e5c64e 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -2114,14 +2114,14 @@ of the chord by adding them after the pitches: << c-1 e-2 g-3 b-5 >> 4 @end lilypond -Setting @code{fingerHorizontalDirection} will put the fingerings next -to the note head: +Setting @code{fingeringOrientations} will put fingerings next +to note heads: @lilypond[verbatim,singleline,fragment,relative=1] - \property Voice.fingerHorizontalDirection = #LEFT - << c-1 es-2 g-4 bes-5 >> 4 - \property Voice.fingerHorizontalDirection = #RIGHT - << c-1 es-2 g-4 bes-5 >> 4 + \property Voice.fingeringOrientations = #'(left down) + <> 4 + \property Voice.fingeringOrientations = #'(up right down) + <> 4 @end lilypond @seealso diff --git a/input/regression/finger-chords.ly b/input/regression/finger-chords.ly index de50af379f..c803ff9fdb 100644 --- a/input/regression/finger-chords.ly +++ b/input/regression/finger-chords.ly @@ -12,21 +12,24 @@ easier to process." \score { \notes \relative c'{ - <> 4 - <> 4 - <> 4 - <> 4 - <> 4 - << c-1 e-3>> 4 - <> 4 - <> 4 - <> 4 - \property Voice.fingerHorizontalDirection = #LEFT - << c-1 es-3 g-5 >> 4 - \property Voice.fingerHorizontalDirection = #RIGHT - << c-1 e-2 g-3 b-5 >> 4\arpeggio - \property Voice.fingerHorizontalDirection = #LEFT - << c_1 e-2 g-3 b^5 >> 4 + <> 4 + + \property Voice.fingeringOrientations = #'(left) + << c-1 e-2 g-3 b-5 >> 4 + + \property Voice.fingeringOrientations = #'(down left) + << c-1 e-2 g-3 b-5 >> 4 + + \property Voice.fingeringOrientations = #'(down left up) + << c-1 e-2 g-3 b-5 >> 4 + + \property Voice.fingeringOrientations = #'(up left) + << c-1 e-2 g-3 b-5 >> 4 + + \property Voice.fingeringOrientations = #'(right) + << c-1 e-2 g-3 b-5 >> 4 + + } diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 94b0614dde..b58b6c962f 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -169,8 +169,6 @@ New_fingering_engraver::position_scripts () fingerings_[i].position_ = gh_scm2int (fingerings_[i].head_ -> get_grob_property( "staff-position")); } - SCM fhd = get_property ("fingerHorizontalDirection"); - for (int i = fingerings_.size(); i--;) for (int j = heads_.size() ; j--;) Side_position_interface::add_support (fingerings_[i].script_, heads_[j]); @@ -181,23 +179,25 @@ New_fingering_engraver::position_scripts () SCM d = fingerings_[i].finger_event_->get_mus_property ("direction"); if (to_dir (d)) { - if (to_dir (d) == UP) - { - up.push (fingerings_[i]); - } - else - down.push (fingerings_[i]); + ((to_dir (d) == UP) ? up : down ).push (fingerings_[i]); fingerings_.del (i); } } fingerings_.sort (&Finger_tuple::compare); - - if (ly_dir_p (fhd)) + SCM orientations = get_property ("fingeringOrientations"); + + bool up_p = scm_memq (ly_symbol2scm ("up"), orientations) != SCM_BOOL_F; + bool down_p = scm_memq (ly_symbol2scm ("down"), orientations) != SCM_BOOL_F; + bool left_p = scm_memq (ly_symbol2scm ("left"), orientations) != SCM_BOOL_F; + bool right_p = scm_memq (ly_symbol2scm ("right"), orientations) != SCM_BOOL_F; + Direction hordir = (right_p) ? RIGHT : LEFT; + if (left_p || right_p) { - if (!up.size()) + if (up_p && !up.size () && fingerings_.size ()) up.push (fingerings_.pop()); - if (fingerings_.size () && !down.size()) + + if (down_p && !down.size () && fingerings_.size()) { down.push (fingerings_[0]); fingerings_.del(0); @@ -205,13 +205,25 @@ New_fingering_engraver::position_scripts () horiz.concat (fingerings_); } - else + else if (up_p && down_p) { int center = fingerings_.size() / 2; down.concat (fingerings_.slice (0,center)); up.concat (fingerings_.slice (center, fingerings_.size())); } - + else if (up_p) + { + up.concat (fingerings_); + fingerings_ .clear (); + } + else + { + if (!down_p) + warning(_ ("Fingerings are also not down?! Putting them down anyway.")); + down.concat (fingerings_); + fingerings_.clear(); + } + for (int i = 0; i < horiz.size(); i++) { Finger_tuple ft = horiz[i]; @@ -222,7 +234,7 @@ New_fingering_engraver::position_scripts () f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, Y_AXIS); f->add_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS); - f->set_grob_property ("direction", fhd); + f->set_grob_property ("direction", gh_int2scm (hordir)); typeset_grob (f); } diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index a7c1d73b26..3081189ee9 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -468,7 +468,7 @@ ScoreContext = \translator { pedalSostenutoStrings = #'("Sost. Ped." "*Sost. Ped." "*") pedalSostenutoStyle = #'mixed - + fingeringOrientations = #'(up down) tupletNumberFormatFunction = #denominator-tuplet-formatter subdivideBeams = ##f @@ -495,7 +495,7 @@ ScoreContext = \translator { custos ) barCheckSynchronize = ##t - + %% chord names: chordNameFunction = #ignatzek-chord-names majorSevenSymbol = #whiteTriangleMarkup diff --git a/scm/define-translator-properties.scm b/scm/define-translator-properties.scm index c027af6268..f343076f0b 100644 --- a/scm/define-translator-properties.scm +++ b/scm/define-translator-properties.scm @@ -262,9 +262,9 @@ another non-natural. "Used to set the relative size of all grobs in a context. This is done using the @code{Font_size_engraver}.") -(translator-property-description 'fingerHorizontalDirection integer? - "If set, put the middle fingerings to -the side of the note head. Use LEFT, RIGHT or unset.") +(translator-property-description + 'fingeringOrientations list? + "List of symbols, containing left, right, up and/or down. This list determines where fingerings are put wrt. to the chord being fingered.") (translator-property-description 'forceClef boolean? "Show clef symbol, even if it hasn't changed. Only active for the first clef after the property is set, not for the full staff.") diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 7e9c2d78fa..646f042ece 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -1449,9 +1449,18 @@ if 1: sys.stderr.write ("context-spec-music takes a symbol for the context now. Update by hand." raise FatalConversionError() + str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)', + "fingeringOrientations = #'(up down left)", str) + str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)', + "fingeringOrientations = #'(up down right)", str) + return str - conversions.append (((1,9,3), conv, """\acciaccatura misspelling""")) + conversions.append (((1,9,3), conv, + """\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations""")) + + + ################################ # END OF CONVERSIONS -- 2.39.5