lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Provide \hide and \omit functions for transparent and void glyphs (i


From: dak
Subject: Re: Provide \hide and \omit functions for transparent and void glyphs (issue 6575048)
Date: Fri, 28 Sep 2012 05:33:10 +0000

Reviewers: janek,

Message:
On 2012/09/28 05:18:42, janek wrote:
sorry to join the discussion so late...

what about using \no for turning stencil off? e.g.
\new Voice \with { \no StringNumber }

As for the code, it LGTM.

It is grammatically cuter in connection with \with, but that's actually
more a problem of \with than of \omit: every other command working on
properties is a verb: \set, \override, \revert, \hide*.

So while \no definitely has its charme, I think it makes sense to stay
consistent here.  If you want to have more than a one-on-one discussion
on it, it might make sense bringing your proposal up on the developer
list to give it more exposure.  It is not that I am wildly opposed, it
is just that I think "\omit" fits better into our naming schemes and is
less likely than "\no" to make users think of something different.

Description:
Provide \hide and \omit functions for transparent and void glyphs

Both functions take either a grob name to override, or a music
expression to tweak (that is, the type of the argument decides whether
this results in an override or a tweak).

\hide sets #'transparent for the affected grob to ##t,
\omit sets #'stencil for the affected grob to ##f.

Example uses are
\new Voice \with { \omit StringNumber } { c'\4 }
{ <c' \hide g'~> g' }

Add string-or-music? predicate

Please review this at http://codereview.appspot.com/6575048/

Affected files:
  M ly/music-functions-init.ly
  M scm/c++.scm
  M scm/lily.scm


Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index e1dcd992e00bf66c60fa7e09e012632732fc7db6..cbdd007c5289bc9b9d7e2ee1f49a484dd0953343 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -475,6 +475,18 @@ given through @var{ratio}.")
     \revert NoteHead #'stencil
   #})

+hide =
+#(define-music-function (parser location item) (string-or-music?)
+   (_i "Set @var{item}'s @samp{transparent} property to @code{#t},
+making it invisible while still retaining its dimensions.
+
+If @var{item} is a string, the result is an override for the grob name
+specified by it.  If @var{item} is a music expression, the result is
+the same music expression with an appropriate tweak applied to it.")
+   (if (string? item)
+       #{ \override $item #'transparent = ##t #}
+       #{ \tweak #'transparent ##t $item #}))
+
 inStaffSegno =
 #(define-music-function (parser location) ()
    (_i "Put the segno variant 'varsegno' at this position into the staff,
@@ -664,6 +676,18 @@ octaveCheck =
    (make-music 'RelativeOctaveCheck
                'pitch pitch))

+omit =
+#(define-music-function (parser location item) (string-or-music?)
+   (_i "Set @var{item}'s @samp{stencil} property to @code{#f},
+effectively omitting it without taking up space.
+
+If @var{item} is a string, the result is an override for the grob name
+specified by it.  If @var{item} is a music expression, the result is
+the same music expression with an appropriate tweak applied to it.")
+   (if (string? item)
+       #{ \override $item #'stencil = ##f #}
+       #{ \tweak #'stencil ##f $item #}))
+
 once =
 #(define-music-function (parser location music) (ly:music?)
(_i "Set @code{once} to @code{#t} on all layout instruction events in @var{music}.")
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")
     ))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]