From 37319a0900a937282a04fa433bc0c62d234f7128 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Thu, 11 Sep 2008 22:20:59 +0200 Subject: [PATCH] Add ly:staff-symbol-line-thickness Scheme-callback, returning line thickness -) 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 | 8 ++++++-- lily/staff-symbol-referencer-scheme.cc | 10 ++++++++++ scm/safe-lily.scm | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/input/regression/flags-in-scheme.ly b/input/regression/flags-in-scheme.ly index 5d9238a1ce..637f210866 100644 --- a/input/regression/flags-in-scheme.ly +++ b/input/regression/flags-in-scheme.ly @@ -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 diff --git a/lily/staff-symbol-referencer-scheme.cc b/lily/staff-symbol-referencer-scheme.cc index efa0fcd73d..d8f2e63862 100644 --- a/lily/staff-symbol-referencer-scheme.cc +++ b/lily/staff-symbol-referencer-scheme.cc @@ -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); +} diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index ae3d56ccfb..5c79bba090 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -120,6 +120,7 @@ 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 -- 2.39.2