X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fstaff-symbol-referencer-scheme.cc;h=d58f5a50438967aea763bf80c13d8f7f3df1d4bf;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=da8491e8fa277b3ccb1dcb5d918823bc608566aa;hpb=7e33691750a97e1b66192cb484f479a173390132;p=lilypond.git diff --git a/lily/staff-symbol-referencer-scheme.cc b/lily/staff-symbol-referencer-scheme.cc index da8491e8fa..d58f5a5043 100644 --- a/lily/staff-symbol-referencer-scheme.cc +++ b/lily/staff-symbol-referencer-scheme.cc @@ -3,20 +3,20 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2006 Han-Wen Nienhuys + (c) 1999--2008 Han-Wen Nienhuys */ #include "grob.hh" #include "staff-symbol-referencer.hh" +#include "staff-symbol.hh" #include "libc-extension.hh" LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", 1, 0, 0, (SCM sg), "Return the Y-position of @var{sg} relative to the staff.") { + LY_ASSERT_SMOB (Grob, sg, 1); 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. @@ -24,3 +24,26 @@ LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", else return scm_from_double (pos); } + +LY_DEFINE (ly_position_on_line_p, "ly:position-on-line?", + 2, 0, 0, (SCM sg, SCM spos), + "Return whether @var{pos} is on a line of the staff associated with the the grob @var{sg} (even on an extender line).") +{ + LY_ASSERT_SMOB (Grob, sg, 1); + LY_ASSERT_TYPE (scm_is_number, spos, 2); + Grob *g = unsmob_grob (sg); + Grob *st = Staff_symbol_referencer::get_staff_symbol (g); + int pos = scm_to_int (spos); + 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); +}