Another option would be to accept height and width in the same argument
using a custom type predicate:
Thanks again. Here's the _complete_ version.
I find it *very* useful. In this way you can easily add a *precise* space between grobs, position grobs vertically in a chosen order and avoid collisions without
troubling with unexpected behaviors of the avoid-collision properties.
I still ask to Lilypond people a feedback for this and if is there an easier alternative.
HTH
P
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.19.45"
#(define OSSPW 3)
#(define OSSPacerColor white)
#(define (number-or-number-pair? x) (or (number? x) (number-pair? x)))
OSSpacer = #(define-music-function (pos arg) (number? number-or-number-pair?)
(let ((width (if (pair? arg) (cdr arg) OSSPW))
(height (if (pair? arg) (car arg) arg)))
#{ \tweak TextScript.color #OSSPacerColor \tweak TextScript.outside-staff-priority #(* 100 pos) -\markup{ \filled-box #(cons 0 width) #(cons 0 height) #0 } #}))
setOSPosition = #(define-music-function (obj pos mus) (string? number? ly:music?)
(if (string=? obj "TextScript")
#{ \tweak TextScript.outside-staff-priority #(* 105 pos) #mus #}
#{ \once \override #obj .outside-staff-priority = #(* 105 pos) #}))
{
\time 2/4
\set Staff.pedalSustainStyle = #'mixed
\once \override TupletBracket.direction = #UP
#(set! OSSPacerColor grey)
% Assign a position to each object.
% A lower position is nearer to the staff.
% Different markups can have different positions
% and their positions is set "inline" (see below)
% Objects above staff
\setOSPosition "Script" 1 {}
\setOSPosition "TupletBracket" 2 {}
\setOSPosition "Slur" 3 {}
\setOSPosition "Staff.OttavaBracket" 4 {}
% Objects below staff
\setOSPosition "DynamicLineSpanner" 1 {}
\setOSPosition "Staff.SustainPedalLineSpanner" 2 {}
\setOSPosition "Staff.SostenutoPedalLineSpanner" 3 {}
\tuplet 3/2 { \ottava #1 c''''
% Place objects above/below the staff according to
% the previous positions list and create barriers between them.
% Each barrier has a default width = $OSSPW (3)
^\OSSpacer 5 4 -\setOSPosition "TextScript" 5 ^\markup { "Espressivo" }
^\OSSpacer 4 2
^\OSSpacer 3 3 ^(
^\OSSpacer 2 2
^\OSSpacer 1 0.7 ^>
%------------------------------------------
%------------------------------------------
%------------------STAFF-------------------
%------------------------------------------
%------------------------------------------
_\OSSpacer 1 #'(5 . 8) \mf
_\OSSpacer 2 3 \sustainOn
_\OSSpacer 3 4 \sostenutoOn
_\OSSpacer 4 3 -\setOSPosition "TextScript" 4 _\markup { "Use pedal with care!"}
c'''' c'''')\sustainOff\sostenutoOff \ottava #0 }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%