From 2750f4bd4ed25ade9a849e08b1c087229c40b44e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 5 Jul 2003 00:41:12 +0000 Subject: [PATCH] (LY_DEFINE): add ly:grob-staff-position --- ChangeLog | 5 +++++ lily/staff-symbol-referencer.cc | 18 +++++++++++++++++- scm/new-markup.scm | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71ba91794e..768ce82393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-07-05 Han-Wen Nienhuys + + * lily/staff-symbol-referencer.cc (LY_DEFINE): add + ly:grob-staff-position + 2003-07-04 Han-Wen Nienhuys * scm/to-xml.scm: import srfi-1 diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index 080f9ab0a0..0ed60e616b 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -75,6 +75,22 @@ Staff_symbol_referencer::get_position (Grob*me) } +LY_DEFINE(ly_grob_staff_position, + "ly:grob-staff-position", + 1, 0,0, (SCM sg), + "Return the Y-position of this grob relative to the staff.") +{ + Grob * g = unsmob_grob (sg); + + SCM_ASSERT_TYPE (g, sg, SCM_ARG1, __FUNCTION__, "grob"); + Real pos = Staff_symbol_referencer::get_position (g); + + if (fabs (rint (pos) -pos) < 1e-6) // ugh. + return gh_int2scm (lrint (pos)); + else + return gh_double2scm (pos); +} + /* should use offset callback! @@ -92,7 +108,7 @@ Staff_symbol_referencer::callback (SCM element_smob, SCM) { Real space = Staff_symbol_referencer::staff_space (me); off = gh_scm2double (pos) * space/2.0; - me->set_grob_property ("staff-position", gh_double2scm (0.0)); + me->set_grob_property ("staff-position", gh_int2scm (0)); } return gh_double2scm (off); diff --git a/scm/new-markup.scm b/scm/new-markup.scm index 38d0079d2a..1cd7453db9 100644 --- a/scm/new-markup.scm +++ b/scm/new-markup.scm @@ -671,7 +671,7 @@ against SIGNATURE, reporting MAKE-NAME as the user-invoked function. (define-public empty-markup (make-simple-markup "")) -(define (interpret-markup grob props markup) +(define-public (interpret-markup grob props markup) (if (string? markup) (simple-markup grob props markup) (let* -- 2.39.2