From 6981f610082ad44e8d876b2fb1cb737b927a6478 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 9 Feb 2006 13:20:49 +0000 Subject: [PATCH] * lily/relocate.cc (prefix_relocation): allow "current" iso. TOPLEVEL_VERSION for share/lilypond/ suffix. This makes changing VERSION in a lily tree less painful. * input/regression/parenthesize.ly: new file. * scm/output-lib.scm (parenthesize-element): new function. * scm/define-grobs.scm (all-grob-descriptions): add ParenthesesItem. * lily/accidental-engraver.cc (make_standard_accidental): reroute cause: accidentals are caused by note heads, not note events. --- ChangeLog | 17 ++++++++++++++++ Documentation/topdocs/NEWS.tely | 9 +++++++++ GNUmakefile.in | 8 ++++---- VERSION | 2 +- input/regression/parenthesize.ly | 23 ++++++++++++++++++++++ lily/accidental-engraver.cc | 13 +++++++------ lily/grob-scheme.cc | 23 ++++++++++++++++++---- lily/relocate.cc | 15 ++++++++++----- ly/music-functions-init.ly | 6 ++++++ scm/define-grob-interfaces.scm | 5 +++++ scm/define-grobs.scm | 9 +++++++++ scm/define-music-properties.scm | 1 + scm/lily-library.scm | 4 +++- scm/output-lib.scm | 33 ++++++++++++++++++++++++++++++-- 14 files changed, 145 insertions(+), 23 deletions(-) create mode 100644 input/regression/parenthesize.ly diff --git a/ChangeLog b/ChangeLog index 754226876d..1cd6a81386 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-02-09 Han-Wen Nienhuys + + * lily/relocate.cc (prefix_relocation): allow "current" + iso. TOPLEVEL_VERSION for share/lilypond/ suffix. This makes + changing VERSION in a lily tree less painful. + + * input/regression/parenthesize.ly: new file. + + * scm/output-lib.scm (parenthesize-element): new function. + + * scm/define-grobs.scm (all-grob-descriptions): add ParenthesesItem. + + * lily/parenthesis-engraver.cc (acknowledge_grob): new file. + + * lily/accidental-engraver.cc (make_standard_accidental): reroute + cause: accidentals are caused by note heads, not note events. + 2006-02-08 Graham Percival * darwin.patch: small patch from Erlend, thanks! diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index f0ef4da858..ac12b49d3e 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -63,8 +63,17 @@ which scares away people. * only show user-visible changes. @end ignore +@item Items directly connected with a music input element may be +parenthesized, for example, +@lilypond[verbatim,ragged-right,fragment] +c4 -\parenthesize -. + +@end lilypond + +This feature was sponsored by Ramana Kumar. + @item Multi-word variables in the @code{\paper} and @code{\layout} block are now separated with dashes, i.e. diff --git a/GNUmakefile.in b/GNUmakefile.in index 163297823f..00a3677909 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -83,16 +83,16 @@ local-WWW-post: tar -C $(outdir)/web-root/ -xf - cd $(outdir)/web-root/ && \ for a in `find . -name out-www`; do \ - mv $$a/* $$a/.. ; \ - rmdir $$a ; \ + rsync -a --link-dest $$a/ $$a/ $$a/.. ; \ + rm -rf $$a ; \ done tree-prefix = $(outdir) tree-bin = $(tree-prefix)/bin tree-lib = $(tree-prefix)/lib tree-share = $(tree-prefix)/share -tree-share-prefix = $(tree-share)/lilypond/$(TOPLEVEL_VERSION) -tree-lib-prefix = $(tree-lib)/lilypond/$(TOPLEVEL_VERSION) +tree-share-prefix = $(tree-share)/lilypond/current +tree-lib-prefix = $(tree-lib)/lilypond/current C_DIRS = flower lily c-clean: diff --git a/VERSION b/VERSION index 585440a180..b9d81808da 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=7 -PATCH_LEVEL=32 +PATCH_LEVEL=33 MY_PATCH_LEVEL= diff --git a/input/regression/parenthesize.ly b/input/regression/parenthesize.ly new file mode 100644 index 0000000000..e8b5050cc6 --- /dev/null +++ b/input/regression/parenthesize.ly @@ -0,0 +1,23 @@ + +\header { + + + texidoc = "The parenthesize function is a special tweak that + encloses objects in parentheses. The associated grob is + @code{Score.ParenthesesItem}. + +" +} + + +\paper { + ragged-right = ##t + } +\version "2.7.32" + +\relative { + c4 -\parenthesize -. + + + +} diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index bdd704da42..1c626529ca 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -387,7 +387,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, Grob * Accidental_engraver::make_standard_accidental (Music *note, - Grob *support, + Grob *note_head, Engraver *trans) { @@ -399,7 +399,7 @@ Accidental_engraver::make_standard_accidental (Music *note, Grob *a = make_grob_from_properties (trans, ly_symbol2scm ("Accidental"), - note->self_scm (), + note_head->self_scm (), "Accidental"); /* @@ -411,27 +411,28 @@ Accidental_engraver::make_standard_accidental (Music *note, for (vsize i = 0; i < right_objects_.size (); i++) Side_position_interface::add_support (a, right_objects_[i]); - a->set_parent (support, Y_AXIS); + a->set_parent (note_head, Y_AXIS); if (!accidental_placement_) accidental_placement_ = make_item ("AccidentalPlacement", a->self_scm ()); Accidental_placement::add_accidental (accidental_placement_, a); - support->set_object ("accidental-grob", a->self_scm ()); + note_head->set_object ("accidental-grob", a->self_scm ()); return a; } Grob * Accidental_engraver::make_suggested_accidental (Music *note, - Grob *note_head, Engraver *trans) + Grob *note_head, + Engraver *trans) { Grob *a = make_grob_from_properties (trans, ly_symbol2scm ("AccidentalSuggestion"), - note->self_scm (), + note_head->self_scm (), "AccidentalSuggestion"); Side_position_interface::add_support (a, note_head); diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 1cfe52094b..4e44d8937d 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -47,17 +47,23 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!", } LY_DEFINE (ly_grob_property, "ly:grob-property", - 2, 0, 0, (SCM grob, SCM sym), + 2, 1, 0, (SCM grob, SCM sym, SCM deflt), "Return the value of a value in grob @var{g} of property @var{sym}. " - "It will return @code{'()} (end-of-list) " + "It will return @code{'()} or @var{deflt} (if specified) " "if @var{sym} is undefined in @var{g}." "\n\n") { Grob *sc = unsmob_grob (grob); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + if (deflt == SCM_UNDEFINED) + deflt = SCM_EOL; - return sc->internal_get_property (sym); + SCM retval = sc->internal_get_property (sym); + if (retval == SCM_EOL) + retval = deflt; + + return retval; } @@ -134,11 +140,20 @@ LY_DEFINE (ly_get_extent, "ly:grob-extent", { Grob *sc = unsmob_grob (grob); Grob *ref = unsmob_grob (refp); + SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); - return ly_interval2scm (sc->extent (ref, Axis (scm_to_int (axis)))); + Axis a = Axis (scm_to_int (axis)); + + + if (ref->common_refpoint (sc, a) != ref) + { + // ugh. should use other error message + SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint"); + } + return ly_interval2scm (sc->extent (ref, a)); } LY_DEFINE (ly_grob_parent, "ly:grob-parent", diff --git a/lily/relocate.cc b/lily/relocate.cc index 4e5669c7aa..fb3c89951b 100644 --- a/lily/relocate.cc +++ b/lily/relocate.cc @@ -108,8 +108,10 @@ prefix_relocation (std::string prefix) std::string localedir = datadir + "/locale"; std::string lilypond_datadir = datadir + "/lilypond/" TOPLEVEL_VERSION; - if (is_dir (lilypond_datadir)) - prefix_directory = lilypond_datadir; + if (is_dir (lilypond_datadir + "/" + TOPLEVEL_VERSION)) + prefix_directory = lilypond_datadir + "/" + TOPLEVEL_VERSION; + else if (is_dir (lilypond_datadir + "/current")) + prefix_directory = lilypond_datadir + "/current"; #if HAVE_GETTEXT if (is_dir (localedir)) @@ -261,9 +263,12 @@ setup_paths (char const *argv0_ptr) */ struct stat statbuf; - std::string build_prefix = prefix_directory + "/share/lilypond/" TOPLEVEL_VERSION; - if (stat (build_prefix.c_str (), &statbuf) == 0) - prefix_directory = build_prefix; + std::string build_prefix_current = prefix_directory + "/share/lilypond/" "current"; + std::string build_prefix_version = prefix_directory + "/share/lilypond/" TOPLEVEL_VERSION; + if (stat (build_prefix_version.c_str (), &statbuf) == 0) + prefix_directory = build_prefix_version; + else if (stat (build_prefix_current.c_str (), &statbuf) == 0) + prefix_directory = build_prefix_current; /* Adding mf/out make lilypond unchanged source directory, when setting diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 42deb27cb5..50b87caf21 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -423,3 +423,9 @@ addquote = (make-music 'SequentialMusic 'void #t)) +parenthesize = +#(def-music-function (parser loc arg) (ly:music?) + "Tag @var{arg} to be parenthesized." + + (set! (ly:music-property arg 'parenthesize) #t) + arg) diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm index baa3b70d7a..db121eb7bd 100644 --- a/scm/define-grob-interfaces.scm +++ b/scm/define-grob-interfaces.scm @@ -93,6 +93,11 @@ "Kill this grob after the line breaking process." '()) +(ly:add-interface + 'parentheses-interface + "Parentheses for other objects" + '()) + (ly:add-interface 'piano-pedal-interface "A piano pedal sign" diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index ffe24ab280..54f1beb8c8 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1141,6 +1141,15 @@ axis-group-interface spaceable-grob-interface)))))) + (ParenthesesItem + . ( + (stencil . ,parentheses-item::print) + (font-size . -6) + (padding . 0.2) + (meta . ((class . Item) + (interfaces . (parentheses-interface font-interface)))) + + )) (PhrasingSlur . ((details . ,default-slur-details) diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index ebd8b9a0ff..32f6bbdac4 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -67,6 +67,7 @@ can only be defined as initializer in @file{define-music-types.scm}.") "This pitch was octavated by how many octaves? For chord inversions, this is negative.") (origin ,ly:input-location? "where was this piece of music defined?") + (parenthesize ,boolean? "Enclose resulting objects in parentheses?") (page-penalty ,number? "Penalty for page break hint.") (penalty ,number? "Penalty for line break hint.") (pitch ,ly:pitch? "the pitch of this note") diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 2c364187b3..3ad2d2764b 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -325,7 +325,9 @@ found." (define-public (interval-center x) "Center the number-pair X, when an interval" - (/ (+ (car x) (cdr x)) 2)) + (if (interval-empty? x) + 0.0 + (/ (+ (car x) (cdr x)) 2))) (define-public interval-start car) (define-public interval-end cdr) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index ee652b2533..ade314be23 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -268,22 +268,50 @@ centered, X==1 is at the right, X == -1 is at the left." (define-public darkyellow '(0.0 0.5 0.5)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Pitch Trill Heads +;; * Pitch Trill Heads +;; * Parentheses (define (parenthesize-elements grob) (let* ((elts (ly:grob-object grob 'elements)) (x-ext (ly:relative-group-extent elts grob X)) + (font (ly:grob-default-font grob)) (lp (ly:font-get-glyph font "accidentals.leftparen")) (rp (ly:font-get-glyph font "accidentals.rightparen")) - (padding 0.1)) + (padding (ly:grob-property grob 'padding 0.1)) (ly:stencil-add (ly:stencil-translate-axis lp (- (car x-ext) padding) X) (ly:stencil-translate-axis rp (+ (cdr x-ext) padding) X)) + ))) + + +(define (parenthesize-element me grob) + (let* + ((x-ext (ly:grob-extent grob grob X)) + (y-center + (interval-center (ly:grob-extent grob grob Y))) + (font (ly:grob-default-font me)) + (lp (ly:font-get-glyph font "accidentals.leftparen")) + (rp (ly:font-get-glyph font "accidentals.rightparen")) + (padding (ly:grob-property grob 'padding 0.1)) + ) + + (ly:stencil-add + (ly:stencil-translate lp + (cons + (- (car x-ext) padding) + y-center)) + (ly:stencil-translate rp + (cons + (+ (cdr x-ext) padding) + y-center))) )) +(define (parentheses-item::print me) + (parenthesize-element me (ly:grob-parent me Y))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -294,3 +322,4 @@ centered, X==1 is at the right, X == -1 is at the left." funcs) value) + -- 2.39.2