X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fstaff-symbol-referencer-scheme.cc;h=e954dd37feffdd8164a1b8b3eba9a468e69e995c;hb=84bdcba4e72ed9161fa6091441a41a02d81069aa;hp=ec12f1639be0d06ea20145d1320b2d7b7f0ad68b;hpb=474c8729dc274a30558102a015a01fa5882673db;p=lilypond.git diff --git a/lily/staff-symbol-referencer-scheme.cc b/lily/staff-symbol-referencer-scheme.cc index ec12f1639b..e954dd37fe 100644 --- a/lily/staff-symbol-referencer-scheme.cc +++ b/lily/staff-symbol-referencer-scheme.cc @@ -1,22 +1,33 @@ /* - staff-symbol-referencer-scheme.cc -- implement Staff_symbol_referencer bindings + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1999--2011 Han-Wen Nienhuys - (c) 1999--2007 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "grob.hh" -#include "staff-symbol-referencer.hh" #include "libc-extension.hh" +#include "staff-symbol.hh" +#include "staff-symbol-referencer.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.") + 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 +35,39 @@ 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{spos} is on a line of the staff associated" + " with 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 @code{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); +} + +LY_DEFINE (ly_staff_symbol_staff_space, "ly:staff-symbol-staff-space", + 1, 0, 0, (SCM grob), + "Returns the @code{staff-space} of the staff associated" + " with @var{grob}.") +{ + LY_ASSERT_SMOB (Grob, grob, 1); + Grob *g = unsmob_grob (grob); + Real staff_space = Staff_symbol_referencer::staff_space (g); + return scm_from_double (staff_space); +}