]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-symbol-referencer-scheme.cc
Merge branch 'master' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / staff-symbol-referencer-scheme.cc
1 /*
2   staff-symbol-referencer-scheme.cc -- implement Staff_symbol_referencer bindings
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "grob.hh"
10 #include "staff-symbol-referencer.hh"
11 #include "libc-extension.hh"
12
13 LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position",
14            1, 0, 0, (SCM sg),
15            "Return the Y-position of @var{sg} relative to the staff.")
16 {
17   Grob *g = unsmob_grob (sg);
18
19   SCM_ASSERT_TYPE (g, sg, SCM_ARG1, __FUNCTION__, "grob");
20   Real pos = Staff_symbol_referencer::get_position (g);
21
22   if (fabs (rint (pos) -pos) < 1e-6) // ugh.
23     return scm_from_int ((int) my_round (pos));
24   else
25     return scm_from_double (pos);
26 }