Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / lily / figured-bass-continuation.cc
blob141bc5cc5decb8629f947140a7a3e1e012c14bce
1 /*
2 figured-bass-continuation.cc -- implement Figured_bass_continuation
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "line-interface.hh"
11 #include "spanner.hh"
12 #include "output-def.hh"
13 #include "item.hh"
14 #include "stencil.hh"
15 #include "pointer-group-interface.hh"
16 #include "axis-group-interface.hh"
19 #include "horizontal-bracket.hh"
21 struct Figured_bass_continuation
23 DECLARE_GROB_INTERFACE ();
25 public:
26 DECLARE_SCHEME_CALLBACK (print, (SCM));
27 DECLARE_SCHEME_CALLBACK (center_on_figures, (SCM));
30 MAKE_SCHEME_CALLBACK (Figured_bass_continuation, center_on_figures, 1);
31 SCM
32 Figured_bass_continuation::center_on_figures (SCM grob)
34 Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (grob));
35 extract_grob_set (me, "figures", figures);
36 if (figures.empty ())
37 return scm_from_double (0.0);
38 Grob *common = common_refpoint_of_array (figures, me, Y_AXIS);
40 Interval ext = Axis_group_interface::relative_group_extent (figures, common, Y_AXIS);
41 if (ext.is_empty ())
42 return scm_from_double (0.0);
43 return scm_from_double (ext.center () - me->relative_coordinate (common, Y_AXIS));
46 MAKE_SCHEME_CALLBACK (Figured_bass_continuation, print, 1);
47 SCM
48 Figured_bass_continuation::print (SCM grob)
50 Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (grob));
52 Real thick =
53 me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"))
54 * robust_scm2double (me->get_property ("thickness"), 1);
56 Interval spanned;
57 Direction d = LEFT;
58 Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
59 X_AXIS);
62 Item *bound = me->get_bound (d);
63 Direction extdir =
64 (d == LEFT && to_boolean (bound->get_property ("implicit")))
65 ? LEFT : RIGHT;
67 spanned[d]
68 = robust_relative_extent (bound, common, X_AXIS)[extdir]
69 - me->relative_coordinate (common, X_AXIS);
71 while (flip (&d) != LEFT);
72 spanned.widen (- robust_scm2double (me->get_property ("padding"), 0.2));
74 Stencil extender;
75 if (!spanned.is_empty ())
76 extender = Line_interface::make_line (thick,
77 Offset (spanned[LEFT], 0),
78 Offset (spanned[RIGHT], 0));
80 return extender.smobbed_copy ();
83 ADD_INTERFACE (Figured_bass_continuation,
84 "Simple extender line between bounds.",
86 /* properties */
87 "thickness "
88 "padding "
89 "figures "