2 staff-symbol-referencer-scheme.cc -- implement Staff_symbol_referencer bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "libc-extension.hh"
11 #include "staff-symbol.hh"
12 #include "staff-symbol-referencer.hh"
14 LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position",
16 "Return the Y-position of @var{sg} relative to the staff.")
18 LY_ASSERT_SMOB (Grob, sg, 1);
19 Grob *g = unsmob_grob (sg);
20 Real pos = Staff_symbol_referencer::get_position (g);
22 if (fabs (rint (pos) -pos) < 1e-6) // ugh.
23 return scm_from_int ((int) my_round (pos));
25 return scm_from_double (pos);
28 LY_DEFINE (ly_position_on_line_p, "ly:position-on-line?",
29 2, 0, 0, (SCM sg, SCM spos),
30 "Return whether @var{spos} is on a line of the staff associated"
31 " with the the grob @var{sg} (even on an extender line).")
33 LY_ASSERT_SMOB (Grob, sg, 1);
34 LY_ASSERT_TYPE (scm_is_number, spos, 2);
35 Grob *g = unsmob_grob (sg);
36 Grob *st = Staff_symbol_referencer::get_staff_symbol (g);
37 int pos = scm_to_int (spos);
38 bool on_line = st ? Staff_symbol::on_line (g, pos) : false;
39 return scm_from_bool (on_line);
42 LY_DEFINE (ly_staff_symbol_line_thickness, "ly:staff-symbol-line-thickness",
44 "Returns the @code{line-thickness} of the staff associated"
47 LY_ASSERT_SMOB (Grob, grob, 1);
48 Grob *g = unsmob_grob (grob);
49 Real thickness = Staff_symbol_referencer::line_thickness (g);
50 return scm_from_double (thickness);
53 LY_DEFINE (ly_staff_symbol_staff_space, "ly:staff-symbol-staff-space",
55 "Returns the @code{staff-space} of the staff associated"
58 LY_ASSERT_SMOB (Grob, grob, 1);
59 Grob *g = unsmob_grob (grob);
60 Real staff_space = Staff_symbol_referencer::staff_space (g);
61 return scm_from_double (staff_space);