Re: Aligning 'to Coda' rehearsal marks

2013-03-14 Thread Thomas Morley
2013/3/14 Jim Long :
> On Thu, Mar 14, 2013 at 02:09:37AM +0100, Thomas Morley wrote:
>>
>> Hi Jim,
>>
>> below some code, which should do what you want.
>
> Wow, Harm, this is truly outstanding, more than I could have
> hoped for.

Glad I could help

> I'll play with this some more, but at first glance,
> it performs well in three different staff sizes that I tried.

If the calculation is correct, it will work with _all_ staff-sizes.

> I'll try to work this into something that could become part of
> the snippet repository.

Actually, the function is an abstract of a larger one, trying to achieve
a) combination and alignment of various markups and/or \mark\default
without disturbing a markFormatter.
b) the possibility to stack the markups vertical or horizontal.
c) different marks at line-end and line-begin with individual alignment.

It was the attempt to get an alternative to Neil's multi-mark-engraver
http://old.nabble.com/Nice-workaround-for-simultaneous-rehearsal-marks-%E2%80%93-thanks-Neil!-td32212763.html
without the necessity to rearrange engravers.

Well, in the end I puzzled myself by trying to deal with too many variables.

Until now I couldn't motivate myself to clean up/improve the code to
get a really working function.
Perhaps I should return to it. ;)

... after finishing some other work I promised to do ...

Regards,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Aligning 'to Coda' rehearsal marks

2013-03-14 Thread Eluze
+100!

Eluze



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Aligning-to-Coda-rehearsal-marks-tp142601p142726.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Aligning 'to Coda' rehearsal marks

2013-03-14 Thread Jim Long
On Thu, Mar 14, 2013 at 02:09:37AM +0100, Thomas Morley wrote:
> 
> Hi Jim,
> 
> below some code, which should do what you want.

Wow, Harm, this is truly outstanding, more than I could have
hoped for.  I'll play with this some more, but at first glance,
it performs well in three different staff sizes that I tried.

I'll try to work this into something that could become part of
the snippet repository.

Thank you very much!

Jim


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Aligning 'to Coda' rehearsal marks

2013-03-13 Thread Thomas Morley
2013/3/13 Jim Long :
> I'm not content with my skills in engraving coda jumps.  I suspect
> Lilypond could do better if I knew how to code it.
>
> My current method is to use a rehearsal mark to concatenate some
> text and a Coda glyph, and then apply a trial-end-error X-offset
> until it lines up the way I want it to, and then when the layout
> changes, I usually have to adjust it again.
>
> In my example code, the first score uses \toCoda to create coda
> glyph centered very nicely over the barline.  I modify the
> visibility properties of the rehearsal mark so that if the barline
> is broken, the coda mark will not be visibile at the beginning of
> a line.  I also set the outside-staff-priority so that the coda
> glyph will be engraved in between the staff and the volta
> brackets.  And yes, many of the coda marks are placed oddly in
> the code, to demonstrate that the break-visibility property is
> doing what I want it to do.
>
> This code also scales well to the smaller size shown in the second
> example, although I don't understand why a magnification factor of
> 1.0 results in a smaller size.
>
> The third variable 'txtCoda' contains a more detailed representation
> of what I like to use, but it requires manual manipulation to get it
> to align, and one size does not fit all.
>
> How can I create a coda mark which:
>
> 1) aligns the X-center line of the coda glyph with the X-center of
> the barline;
>
> 2) places the arbitrary "to Coda" alongside the glyph, while leaving
> the glyph itself centered over the barline; and
>
> 3) can be scaled easily (text and glyph) to different sizes, without
> disturbing the alignment of the coda glyph to the barline?
>
> An elegant solution to this would be very welcome.  Thank you for
> your time.
>
> Jim
>
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>

Hi Jim,

below some code, which should do what you want.

Usage:
a)
Predefine two markups:
mrkpI = \markup \fontsize #-1 "to Coda"
mrkpII = \markup \fontsize #-1 { \musicglyph #"scripts.coda" }

b)
Combine and align them with `alignCombinedRehearsalMarks´. Use an alist:

myMarkI =
\alignCombinedRehearsalMarks \mrkpI \mrkpII
  #`(;(center-on-first . #t)
 (center-on-second . #t)
 ;(general-align . ,LEFT)
 (outside-staff-priority . 5)
 (break-visibility . ,begin-of-line-invisible)
  )
This alist offers the possibilities to have the RehearsalMark centered
at the first markup or the second markup or align it as you want as a
whole. Please make one choice.
In addition you may want to set outside-staff-priority and
break-visibility within this alist.
Comment what you don't need, choose the values you want. Even an empty
list will combine the two markups, defaulting all other properties.
Some more comments in the code.

The Code:


\version "2.16.2"

alignCombinedRehearsalMarks =
#(define-music-function (parser location mrkp-1 mrkp-2 align)
   (markup? markup? list?)
#{
  %% Combines and aligns two markups
  \once \override Score.RehearsalMark #'before-line-breaking =
 #(lambda (grob)
(let* (;; mrkp-stils
   (mrkp-1-stil (grob-interpret-markup grob mrkp-1))
   (mrkp-2-stil (grob-interpret-markup grob mrkp-2))
   ;; x-extent of mrkp-stils
   (mrkp-1-x-length
 (interval-length (ly:stencil-extent mrkp-1-stil X)))
   (mrkp-2-x-length
 (interval-length (ly:stencil-extent mrkp-2-stil X)))
   ;; get alist-values
   (general-align (assoc-ref align 'general-align))
   (center-on-first (assoc-ref align 'center-on-first))
   (center-on-second (assoc-ref align 'center-on-second))

   (padding 0.6)
   ;; combine mrkp-1-stil and mrkp-2-stil
   (combined-stil
 (ly:stencil-combine-at-edge
   (ly:stencil-aligned-to
  mrkp-1-stil
  Y
  CENTER)
   X
   RIGHT
   (ly:stencil-aligned-to
  mrkp-2-stil
  Y
  CENTER)
   padding))
   (combined-stil-length
 (interval-length (ly:stencil-extent combined-stil X)))
   (set-stencil!
 (ly:grob-set-property! grob 'stencil combined-stil))
    align the stencil,
    defined for:
   ;; center the new stencil on the first markup
   ;; for all not #f values.
   ;; (center-on-first . #t)
   ;; center the new stencil on the second markup
   ;; for all 

Re: Aligning 'to Coda' rehearsal marks

2013-03-13 Thread Eluze
Jim Long wrote
> On Wed, Mar 13, 2013 at 03:43:04AM -0700, Eluze wrote:
> 
>>   \once \override Score.RehearsalMark #'self-alignment-X = #center %
>> default
>>   \mark \markup {
>> "to coda"
>> \hspace #1
>> \raise #1 \musicglyph #"scripts.coda"
>> \hspace #-.5
>> \with-color #white
>> "to coda"
>>   }
> 
> Hmm, an interesting approach.  Might this create artificial
> "invisible" collisions between the white text and other markup
> that might closely follow the glyph? 

most certainly

>  I'll fiddle with it a bit, just the same.  Early tests indicate that the
> amount of negative
> hspace required in the second position is surprisingly large.
> #-16.25 seems to be the best approximation so far. 

the \hspace before and after the glyph are only to compensate for the
(missing in the 1st case) gap between the glyph and the preceding/following
text - they should only be adapted if you're changing the \fontsize and
\magnify the glyph (this is also the way to solve your 3rd question)

Eluze




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Aligning-to-Coda-rehearsal-marks-tp142601p142664.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Aligning 'to Coda' rehearsal marks

2013-03-13 Thread Eluze
Jim Long wrote
> How can I create a coda mark which:
> 
> 1) aligns the X-center line of the coda glyph with the X-center of
> the barline;
> 
> 2) places the arbitrary "to Coda" alongside the glyph, while leaving
> the glyph itself centered over the barline; and
> 
> An elegant solution to this would be very welcome.  Thank you for
> your time.

maybe it's a hack but it will do for many cases: 

- add the text after the glyph as well, but hide it, 
- correct the horizontal space before and after the glyph
- make sure the horizontal self alignment of the rehearsal mark is center

it should be possible to write a small scheme function to avoid having to
type the same text twice or to calculate the length of the text in another
way.

  \once \override Score.RehearsalMark #'self-alignment-X = #center % default
  \mark \markup {
"to coda"
\hspace #1
\raise #1 \musicglyph #"scripts.coda"
\hspace #-.5
\with-color #white
"to coda"
  }

Eluze



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Aligning-to-Coda-rehearsal-marks-tp142601p142626.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user