2 figured-bass-continuation.cc -- implement Figured_bass_continuation
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "line-interface.hh"
11 #include "lily-guile.hh"
13 #include "output-def.hh"
16 #include "pointer-group-interface.hh"
17 #include "axis-group-interface.hh"
20 #include "horizontal-bracket.hh"
22 struct Figured_bass_bracket
24 static bool has_interface (Grob*);
27 DECLARE_SCHEME_CALLBACK(print, (SCM));
31 ADD_INTERFACE(Figured_bass_bracket,
32 "figured-bass-bracket-interface",
33 "Brackets alongside bass figures.",
37 /* ugh: should make bracket interface. */
46 MAKE_SCHEME_CALLBACK (Figured_bass_bracket, print, 1);
48 Figured_bass_bracket::print (SCM grob)
50 Grob *me = unsmob_grob (grob);
51 extract_grob_set (me, "elements", elements);
52 if (elements.is_empty ())
58 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
59 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
61 Stencil left_br = Horizontal_bracket::make_bracket (me, me, elements,
63 Stencil right_br = Horizontal_bracket::make_bracket (me, me, elements,
66 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
67 left_br.translate_axis (xext[LEFT], X_AXIS);
68 right_br.translate_axis (xext[RIGHT], X_AXIS);
70 left_br.add_stencil (right_br);
71 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
72 return left_br.smobbed_copy ();
76 struct Figured_bass_continuation
78 static bool has_interface (Grob*);
81 DECLARE_SCHEME_CALLBACK(print, (SCM));
82 DECLARE_SCHEME_CALLBACK(center_on_figures, (SCM, SCM));
85 MAKE_SCHEME_CALLBACK (Figured_bass_continuation, center_on_figures, 2);
87 Figured_bass_continuation::center_on_figures (SCM grob, SCM axis)
89 Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (grob));
92 extract_grob_set (me, "figures", figures);
93 Grob *common = common_refpoint_of_array (figures, me, Y_AXIS);
95 Interval ext = Axis_group_interface::relative_group_extent (figures, common, Y_AXIS);
97 return scm_from_double (ext.center () - me->relative_coordinate (common, Y_AXIS));
100 MAKE_SCHEME_CALLBACK (Figured_bass_continuation, print, 1);
102 Figured_bass_continuation::print (SCM grob)
104 Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (grob));
107 me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"))
108 * robust_scm2double (me->get_property ("thickness"), 1);
112 Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
117 = robust_relative_extent (me->get_bound (d), common, X_AXIS)[RIGHT]
118 - me->relative_coordinate (common, X_AXIS);
120 while (flip (&d) != LEFT);
123 = Line_interface::make_line (thick,
124 Offset (spanned[LEFT], 0),
125 Offset (spanned[RIGHT], 0));
127 return extender.smobbed_copy ();
130 ADD_INTERFACE(Figured_bass_continuation,
131 "figured-bass-continuation-interface",
132 "Simple extender line between bounds.",