• Willkommen im Forum „Archiviertes Lilypond Forum (2017)“.
 

Dies ist das Archiv des alten Forums (bis März 2017). Das aktuelle Forum ist unter lilypondforum.de zu finden.
This is the archive of the old forum (until March 2017). You can find the current forum at lilypondforum.de.

Hauptmenü

Textscript mittig zu Notenkopfmitte ausrichten?

Begonnen von Arnold, Montag, 7. Mai 2012, 09:00

Vorheriges Thema - Nächstes Thema

Arnold

Hallo,

ich wollte Text-Markups zu Noten mittig auf die Mitte des Notenkopfs ausrichten statt auf den linken Rand des Notenkopfs.
Mein erster Versuch, einfach (wie bei den Artikulations) X-offset auf #ly:script-interface::calc-x-offset
zu setzen, scheiterte einfach daran, daß anstelle des Notenkopfs ein PaperColumn gefunden wird.
Ist es etwa doch nicht so einfach, diesen X-offset in Abhängigkeit von Notenkopfgröße und Notenkopfform zu bestimmen
- oder weiß jemand eine Abhilfe, wie es ohne Kollisionsprobleme (also vor der Zeilenumbruchberechnung) doch noch geht?

Zwar kann ich eine Artikulation mit tweaks dazu mißbrauchen, aber da kommt nur eine einzige pro Ton durch - oder ich gebe jeder einen eigenständigen Namen, und bekomme massenhaft Warnungsmeldungen, daß dieser Artikulationstyp eigentlich undefiniert ist.


\version "2.15.38"
% copied of ly:script-interface::calc-x-offset
% and added some inquiries and text console output
#(define-public (my-calc-x-offset grob)
  (ly:grob-property grob 'positioning-done)
  (let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
(note-head-location
  (ly:self-alignment-interface::centered-on-x-parent grob))
(note-head-grob (ly:grob-parent grob X))
         (xprob (ly:grob-properties note-head-grob))
         (x-x-parent (ly:grob-parent note-head-grob X))
         (x-y-parent (ly:grob-parent note-head-grob Y))
(y-parent (ly:grob-parent grob Y))
         (yprob (ly:grob-properties y-parent))
         (y-x-parent (ly:grob-parent y-parent X))
         (y-y-parent (ly:grob-parent y-parent Y))
(stem-grob (ly:grob-object note-head-grob 'stem))
         (gprob (ly:grob-properties grob))
         (event (event-cause grob))
        )

    (display "\nmy-calc-x-offset: ")
    (display "\n  note-head-location: ") (display note-head-location) (display " ")
    (display "\n  stem-grob exists: ") (display (ly:grob? stem-grob)) (display " ")
    (display "\n  note-head-grob: ") (display note-head-grob) (display " ")
    (display "\n  -properties: ") (display xprob) (display " ")
    (display "\n  -basics: ") (display (ly:grob-basic-properties note-head-grob)) (display " ")
    (display "\n  y-parent: ") (display y-parent) (display " ")
    (display "\n  -properties: ") (display yprob) (display " ")
    (display "\n  x-x-parent: ") (display x-x-parent) (display " ")
    (display "\n  x-y-parent: ") (display x-y-parent) (display " ")
    (display "\n  y-x-parent: ") (display y-x-parent) (display " ")
    (display "\n  y-y-parent: ") (display y-y-parent) (display " ")
    (display "\n  grob: ") (display grob) (display " ")
    (display "\n  -properties: ") (display gprob) (display " ")
    (display "\n  event: ") (display event) (display " ")
    (display "\n")
    (+ note-head-location
       ;; If the property 'toward-stem-shift is defined and the script
       ;; has the same direction as the stem, move the script accordingly.
       ;; Since scripts can also be over skips, we need to check whether
       ;; the grob has a stem at all.
       (if (ly:grob? stem-grob)
   (let ((dir1 (ly:grob-property grob 'direction))
(dir2 (ly:grob-property stem-grob 'direction)))
     (if (equal? dir1 dir2)
(let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
(stem-location
(ly:grob-relative-coordinate stem-grob common-refp X)))
   (* shift (- stem-location note-head-location)))
0.0))
   0.0))))

{
  e''4^\markup { \center-align "V" }
  \override TextScript #'X-offset = #my-calc-x-offset
  <e''>4 ^\markup { \center-align "V" } % -\tweak #'X-offset #my-calc-x-offset
  \override Script #'X-offset = #my-calc-x-offset
  <e''>4\prall
}


Arnold


Arnold

Danke,

werd's in den nächsten Tagen ausprobieren.

Arnold.