[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Allow \shape to tweak music, swap its arguments (issue 6585052)
From: |
dak |
Subject: |
Re: Allow \shape to tweak music, swap its arguments (issue 6585052) |
Date: |
Wed, 03 Oct 2012 13:46:14 +0000 |
Reviewers: david.nalesnik, janek,
Message:
On 2012/10/03 05:04:11, janek wrote:
i've skimmed over the discussion in
http://code.google.com/p/lilypond/issues/detail?id=2858 and i'm
confused.
Do we want to change
\shape GrobName #'offsets
into
\shape #'offsets GrobName
or
\shape #'offsets
(used as a tweak, with GrobName being guessed)?
Yes. It is quite valuable to be able to use this function as a tweak
(for example, if you want to meddle with tied chords which LilyPond is
not spectacularly good at), and multiple tweaks to the same music stack
reasonably well syntactically only if the tweaked music is at the end.
So the somewhat more natural argument order when used as an override is
sacrificed in order to make \shape more versatile.
When used as a tweak, the grob name is not "guessed" but only grobs
created directly from the tweaked music event are affected, whether or
not they share the same grob name. That is the usual behavior of
\tweak.
Description:
Allow \shape to tweak music, swap its arguments
Also does
Run scripts/auxiliar/update-with-convert-ly.sh
Add string-or-music? predicate
Please review this at http://codereview.appspot.com/6585052/
Affected files:
M input/regression/shape-other-curves.ly
M input/regression/shape-slurs.ly
M ly/music-functions-init.ly
M python/convertrules.py
M scm/c++.scm
M scm/lily.scm
Index: input/regression/shape-other-curves.ly
diff --git a/input/regression/shape-other-curves.ly
b/input/regression/shape-other-curves.ly
index
6e8bda777443df88ea62d2e680ecb4b49dc77c0a..d3cce657fa0101338ab6b61e450759915b164290
100644
--- a/input/regression/shape-other-curves.ly
+++ b/input/regression/shape-other-curves.ly
@@ -1,4 +1,4 @@
-\version "2.16.0"
+\version "2.17.4"
\header {
texidoc = "In addition to @code{Slur}, the music function @code{\\shape}
works
@@ -16,7 +16,7 @@ function."
% PhrasingSlur
d4\( d' b g g,8 f' e d c2\)
\override PhrasingSlur #'color = #blue
- \shape PhrasingSlur #'((0 . -2) (-1 . 3.5) (0.5 . 0.5) (0 . -2.5))
+ \shape #'((0 . -2) (-1 . 3.5) (0.5 . 0.5) (0 . -2.5)) PhrasingSlur
d4\( d' b g g,8 f' e d c2\)
\break
@@ -25,7 +25,7 @@ function."
\break
cis
\override Tie #'color = #blue
- \shape Tie #'(() ((0 . -0.9) (0 . -0.5) (0 . -0.5) (0 . -0.9)))
+ \shape #'(() ((0 . -0.9) (0 . -0.5) (0 . -0.5) (0 . -0.9))) Tie
cis~
\break
cis
@@ -34,13 +34,13 @@ function."
% LaissezVibrerTie
c\laissezVibrer
\override LaissezVibrerTie #'color = #blue
- \shape LaissezVibrerTie #'((0 . 0) (0.5 . 0.2) (1.5 . 0.2) (2 . 0))
+ \shape #'((0 . 0) (0.5 . 0.2) (1.5 . 0.2) (2 . 0)) LaissezVibrerTie
c\laissezVibrer
\break
% RepeatTie
c\repeatTie
\override RepeatTie #'color = #blue
- \shape RepeatTie #'((-1 . 0) (-0.7 . 0) (-0.3 . 0) (0 . 0))
+ \shape #'((-1 . 0) (-0.7 . 0) (-0.3 . 0) (0 . 0)) RepeatTie
c\repeatTie
}
Index: input/regression/shape-slurs.ly
diff --git a/input/regression/shape-slurs.ly
b/input/regression/shape-slurs.ly
index
8b4ad53a6d683008c0dc0769a3c644a12fde3aaf..729ddad2aedf4e5b3f7b27e7e5721fa0e98f55bb
100644
--- a/input/regression/shape-slurs.ly
+++ b/input/regression/shape-slurs.ly
@@ -1,4 +1,4 @@
-\version "2.16.0"
+\version "2.17.4"
\header {
texidoc = "The control points of a broken or unbroken slur may be offset
by
@@ -22,12 +22,12 @@
% modified
\relative c'' {
\override Slur #'color = #blue
- \shape Slur #'((0 . -2) (-1 . 3.5) (0.5 . 0.5) (0 . -2.5))
+ \shape #'((0 . -2) (-1 . 3.5) (0.5 . 0.5) (0 . -2.5)) Slur
d4( d' b g g,8 f' e d c2)
- \shape Slur #'(
+ \shape #'(
((0 . -2.5) (0 . 1.5) (0 . 1) (0 . -0.5))
((1 . 2.5) (0 . 1.5) (0 . 1) (0 . 0))
- )
+ ) Slur
d4( d' b g
\break
g,8 f' e d c2)
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index
26db17c5ede8ce07e9b72f78fa7d05c0f82a7cbf..ab24bdf4f24d5b3d7a891eecb192ec98cd228ea3
100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -1095,12 +1095,16 @@ a context modification duplicating their effect.")
mods))
shape =
-#(define-music-function (parser location grob offsets)
- (string? list?)
- (_i "Offset control-points of @var{grob} by @var{offsets}. The argument
-is a list of number pairs or list of such lists. Each element of a pair
-represents an offset to one of the coordinates of a control-point.")
- (define ((shape-curve offsets) grob)
+#(define-music-function (parser location offsets item)
+ (list? string-or-music?)
+ (_i "Offset control-points of @var{item} by @var{offsets}. The
+argument is a list of number pairs or list of such lists. Each
+element of a pair represents an offset to one of the coordinates of a
+control-point. If @var{item} is a string, the result is
address@hidden for the specified grob type. If @var{item} is
+a music expression, the result is the same music expression with an
+appropriate tweak applied.")
+ (define (shape-curve grob)
(let* ((orig (ly:grob-original grob))
(siblings (if (ly:spanner? grob)
(ly:spanner-broken-into orig) '()))
@@ -1131,10 +1135,13 @@ represents an offset to one of the coordinates of a
control-point.")
(if (>= total-found 2)
(helper siblings offsets)
(offset-control-points (car offsets)))))
-
- #{
- \once \override $grob #'control-points = #(shape-curve offsets)
- #})
+ (if (ly:music? item)
+ #{
+ \tweak #'control-points #shape-curve $item
+ #}
+ #{
+ \once \override $item #'control-points = #shape-curve
+ #}))
shiftDurations =
#(define-music-function (parser location dur dots arg)
Index: python/convertrules.py
diff --git a/python/convertrules.py b/python/convertrules.py
index
fa63726069269c30b9581fe1bff94e87adc75bfa..b8921a02be3709ed546cac50dab9d137af8475b2
100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -3392,6 +3392,12 @@ def conv (str):
str = re.sub
('blank-after-score-page-force', 'blank-after-score-page-penalty', str)
return str
address@hidden ((2, 17, 4), r"\shape Grob #offsets -> \shape #offsets Grob")
+def conv (str):
+ str = re.sub (r"\\shape(\s+(?:[a-zA-Z]+|" + matchstring + "))(" +
+ matcharg + ")", r"\\shape\2\1", str)
+ return str
+
# Guidelines to write rules (please keep this at the end of this file)
#
# - keep at most one rule per version; if several conversions should be
done,
Index: scm/c++.scm
diff --git a/scm/c++.scm b/scm/c++.scm
index
ded5e9b1209bc0c0be4627db018962d7196eb0f1..444a3e9ba6534b9201c26937785bcbb4fc9e6a5d
100644
--- a/scm/c++.scm
+++ b/scm/c++.scm
@@ -57,6 +57,9 @@
(define-public (string-or-pair? x)
(or (string? x) (pair? x)))
+(define-public (string-or-music? x)
+ (or (string? x) (ly:music? x)))
+
(define-public (number-or-pair? x)
(or (number? x) (pair? x)))
Index: scm/lily.scm
diff --git a/scm/lily.scm b/scm/lily.scm
index
9bc04dbddf085f646046893197dd0f11e17dd918..3ee924a1b1c44c429e635156416d8789af7a74de
100644
--- a/scm/lily.scm
+++ b/scm/lily.scm
@@ -505,6 +505,7 @@ messages into errors.")
(,rhythmic-location? . "rhythmic location")
(,scheme? . "any type")
(,string-or-pair? . "string or pair")
+ (,string-or-music? . "string or music")
(,string-or-symbol? . "string or symbol")
(,void? . "void")
))
- Allow \shape to tweak music, swap its arguments (issue 6585052), david . nalesnik, 2012/10/02
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052), janek . lilypond, 2012/10/03
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052),
dak <=
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052), dak, 2012/10/03
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052), david . nalesnik, 2012/10/03
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052), dak, 2012/10/03
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052), david . nalesnik, 2012/10/03
- Re: Allow \shape to tweak music, swap its arguments (issue 6585052), dak, 2012/10/03