]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add ly:staff-symbol-line-thickness Scheme-callback, returning line thickness
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 11 Sep 2008 20:20:59 +0000 (22:20 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 21 Sep 2008 14:15:34 +0000 (16:15 +0200)
-) Add a callback ly:staff-symbol-line-thickness in staff-symbol-referencer-scheme,
   which simply gives you a Scheme interface to
       Staff_symbol_referencer::line_thickness (g)
-) Use this to shift inverted flags in the flags-in-scheme test case
   by the stem-width (the 'thickness grob property of the stem is given
   in units of the line-thickness!), so the flags really attach to the
   left edge of the stem

input/regression/flags-in-scheme.ly
lily/staff-symbol-referencer-scheme.cc
scm/safe-lily.scm

index 5d9238a1cedcf0282e56f39fa2fcddfdef917c91..637f210866a215c4d50c2ff1b08c4b3a3e0f3f64 100644 (file)
@@ -23,10 +23,14 @@ testnotes = { \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64 c''8 d''1
 #(define (inverted-flag stem-grob)
   (let* ((dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "d" "u"))
          (flag (retrieve-glyph-flag "" dir "" stem-grob))
+         (line-thickness (ly:staff-symbol-line-thickness stem-grob))
+         (stem-thickness (ly:grob-property stem-grob 'thickness))
+         (stem-width (* line-thickness stem-thickness))
          (stroke-style (ly:grob-property stem-grob 'stroke-style))
          (stencil (if (null? stroke-style) flag
-                         (add-stroke-glyph flag stem-grob dir stroke-style ""))))
-    (ly:stencil-rotate-absolute stencil 180 0 0)))
+                         (add-stroke-glyph flag stem-grob dir stroke-style "")))
+         (rotated-flag (ly:stencil-rotate-absolute stencil 180 0 0)))
+    (ly:stencil-translate rotated-flag (cons (- (/ stem-width 2))  0))))
 
 {
   \override Score.RehearsalMark #'self-alignment-X = #LEFT
index efa0fcd73d592b44e2887aaf9c1f19a9b418e74c..d8f2e6386203f4851ac7332f978943cdb7abe9d7 100644 (file)
@@ -37,3 +37,13 @@ LY_DEFINE (ly_position_on_line_p, "ly:position-on-line?",
   bool on_line = st ? Staff_symbol::on_line (g, pos) : false;
   return scm_from_bool (on_line);
 }
+
+LY_DEFINE (ly_staff_symbol_line_thickness, "ly:staff-symbol-line-thickness",
+           1, 0, 0, (SCM grob),
+           "Returns the line-thickness of the staff associated with @var{grob}.")
+{
+  LY_ASSERT_SMOB (Grob, grob, 1);
+  Grob *g = unsmob_grob (grob);
+  Real thickness = Staff_symbol_referencer::line_thickness (g);
+  return scm_from_double (thickness);
+}
index ae3d56ccfb9b452fdd2303a42dc0cd88b0f17207..5c79bba09093d27facfc162def12c2717369abdd 100644 (file)
    ly:spanner-broken-into
    ly:spanner-bound
    ly:spanner?
+   ly:staff-symbol-line-thickness
    ly:stencil-add
    ly:stencil-aligned-to
    ly:stencil-combine-at-edge