Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / paper-system-scheme.cc
blob3b0c0c09c5d75be6d62fe29e137676fae6eff934
1 /*
2 paper-system-scheme.cc -- implement Paper_system bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2008--2009 Han-Wen Nienhuys <hanwen@lilypond.org>
8 */
10 #include "prob.hh"
12 #include "skyline-pair.hh"
14 LY_DEFINE (ly_paper_system_p, "ly:paper-system?",
15 1, 0, 0, (SCM obj),
16 "Is @var{obj} a C++ @code{Prob} object of type"
17 " @code{paper-system}?")
19 return ly_prob_type_p (obj, ly_symbol2scm ("paper-system"));
22 LY_DEFINE (ly_paper_system_minimum_distance, "ly:paper-system-minimum-distance",
23 2, 0, 0, (SCM sys1, SCM sys2),
24 "Measure the minimum distance between these two paper-systems,"
25 " using their stored skylines if possible and falling back to"
26 " their extents otherwise.")
28 Real ret = 0;
29 Prob *p1 = unsmob_prob (sys1);
30 Prob *p2 = unsmob_prob (sys2);
31 Skyline_pair *sky1 = Skyline_pair::unsmob (p1->get_property ("vertical-skylines"));
32 Skyline_pair *sky2 = Skyline_pair::unsmob (p2->get_property ("vertical-skylines"));
34 if (sky1 && sky2)
35 ret = (*sky1)[DOWN].distance ((*sky2)[UP]);
36 else
38 Stencil *s1 = unsmob_stencil (p1->get_property ("stencil"));
39 Stencil *s2 = unsmob_stencil (p2->get_property ("stencil"));
40 Interval iv1 = s1->extent (Y_AXIS);
41 Interval iv2 = s2->extent (Y_AXIS);
42 ret = iv2[UP] - iv1[DOWN];
44 return scm_from_double (ret);