Allow for nested properties in list form when using \override.
[lilypond.git] / lily / staff-symbol-referencer-scheme.cc
blobd8f2e6386203f4851ac7332f978943cdb7abe9d7
1 /*
2 staff-symbol-referencer-scheme.cc -- implement Staff_symbol_referencer bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "grob.hh"
10 #include "staff-symbol-referencer.hh"
11 #include "staff-symbol.hh"
12 #include "libc-extension.hh"
14 LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position",
15 1, 0, 0, (SCM sg),
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));
24 else
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{pos} is on a line of the staff associated with the the grob @var{sg} (even on an extender line).")
32 LY_ASSERT_SMOB (Grob, sg, 1);
33 LY_ASSERT_TYPE (scm_is_number, spos, 2);
34 Grob *g = unsmob_grob (sg);
35 Grob *st = Staff_symbol_referencer::get_staff_symbol (g);
36 int pos = scm_to_int (spos);
37 bool on_line = st ? Staff_symbol::on_line (g, pos) : false;
38 return scm_from_bool (on_line);
41 LY_DEFINE (ly_staff_symbol_line_thickness, "ly:staff-symbol-line-thickness",
42 1, 0, 0, (SCM grob),
43 "Returns the line-thickness of the staff associated with @var{grob}.")
45 LY_ASSERT_SMOB (Grob, grob, 1);
46 Grob *g = unsmob_grob (grob);
47 Real thickness = Staff_symbol_referencer::line_thickness (g);
48 return scm_from_double (thickness);