\version "2.19.36" toggleMarkupLayout = { \omit Clef \omit TimeSignature \omit StaffSymbol \omit BarLine \omit SystemStartBar } toggleClefProblem = { \override Score.Clef.stencil = ##t \hide Score.Clef } controlBarLength = #(define-music-function (BarLength music1 music2)(number? ly:music? ly:music?) #{ << { #music2 } \new Voice { \override MultiMeasureRest.minimum-length = #BarLength \hide MultiMeasureRest #music1 } >> #}) toggleButton = #(define-music-function (svgId staffPadding xOff)(string? number? number?) #{ <> -\tweak id #svgId -\tweak outside-staff-priority ##f -\tweak staff-padding #staffPadding -\tweak X-offset #xOff ^\markup { \with-color #red \filled-box #'(0 . 2.5) #'(0 . 2.5) #0.2 } #}) toggleVariants = #(define-music-function (svgId color off music)(string? color? pair? ly:music?) #{ <> -\tweak Y-offset 0 -\tweak staff-padding 0 -\tweak outside-staff-priority ##f -\tweak color #color -\tweak id #svgId -\tweak self-alignment-X #LEFT -\tweak extra-offset #off ^\markup { \score { \layout { \context { \Score \toggleMarkupLayout } } #music } } #}) %%%%%%%%%%%%%%%%%%%%%% %%%%%--Variants--%%%%% %%%%%%%%%%%%%%%%%%%%%% toggleOneBarLength = #(define-music-function (music)(ly:music?) #{ \controlBarLength #25 R1 #music #}) toggleTwoBarLength = #(define-music-function (music)(ly:music?) #{ \controlBarLength #38 R1 #music #}) firstVersionOne = { << \new Staff \relative c'' { \toggleOneBarLength { g4 g g g } } \new Staff \relative c { \clef bass c4 c c c } >> } firstVersionTwo = { << \new Staff \relative c'' { \toggleOneBarLength { g4 \tuplet 3/2 { g8 -\tweak staff-padding 2 ^\markup { \with-color #red \italic \override #'(font-family . typewriter) \fontsize #-2 "Variante" } a g } g4\mordent g } } \new Staff \relative c { \clef bass c4( c8 d) e4^. c_! } >> } secondVersionOne = { << \toggleClefProblem \new Staff \relative c' { \toggleTwoBarLength { c4 d e f } } \new Staff \relative c' { \clef bass g4 f e d } >> } secondVersionTwo = { << \toggleClefProblem \new Staff \relative c' { \toggleTwoBarLength { \tuplet 3/2 4 { c8 b c d -\tweak staff-padding 2 ^\markup { \with-color #red \italic \override #'(font-family . typewriter) \fontsize #-2 "Variante" } c d e d e f e f } } } \new Staff \relative c' { \clef bass g4. g8~ 4 4 } >> } %%%%%%%%%%%%%%%%%%%% %%%%%--Score--%%%%%% %%%%%%%%%%%%%%%%%%%% \new Score { \new PianoStaff << \new Staff \relative c' { |%1 c4 d e f |%2 \toggleOneBarLength { \toggleButton "T1" #2 #-2 \toggleVariants "T1-1" #(x11-color 'blue3) #'(-4 . -9) \firstVersionOne \toggleVariants "T1-2" #(x11-color 'red3) #'(-4 . -9) \firstVersionTwo s1 } |%3 c4 d e f |% g2 g \break |%5 \toggleTwoBarLength { \toggleButton "T2" #2 #-2 \toggleVariants "T2-1" #(x11-color 'DarkCyan) #'(-5.6 . -9) \secondVersionOne \toggleVariants "T2-2" #(x11-color 'maroon) #'(-5.6 . -9) \secondVersionTwo s1 } |%6 g4 g g g |%7 g f e d |%8 c2 c2 } \new Staff \relative c' { \clef bass g4 f e d s1 g4 f e d c2 c s1 c4 c c c c d e f g2 g } >> }