(staff_eligible): new function.
[lilypond.git] / lily / measure-grouping-spanner.cc
blobb29f91a1d9c92534614a54f8e15615f035e2bd25
1 /*
2 measure-grouping-spanner.cc -- implement Measure_grouping
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9 #include "paper-def.hh"
10 #include "spanner.hh"
11 #include "measure-grouping-spanner.hh"
12 #include "lookup.hh"
13 #include "item.hh"
15 MAKE_SCHEME_CALLBACK (Measure_grouping, brew_molecule, 1);
16 SCM
17 Measure_grouping::brew_molecule (SCM grob)
19 Spanner * me = dynamic_cast<Spanner*> (unsmob_grob (grob));
22 TODO: robustify.
24 SCM which = me->get_grob_property ("style");
25 SCM thick = me->get_grob_property ("thickness");
26 SCM height = me->get_grob_property ("height");
28 Real t = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")) * gh_scm2double (thick);
29 Grob *common = me->get_bound(LEFT)->common_refpoint (me->get_bound (RIGHT),
30 X_AXIS);
32 Interval rext = me->get_bound (RIGHT)->extent (common, X_AXIS);
35 Real w =(rext.empty_b()
36 ? me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS)
37 : rext[RIGHT])
38 - me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
40 Interval iv (0,w);
42 Molecule m;
43 if (which == ly_symbol2scm ("bracket"))
45 m = Lookup::bracket (X_AXIS, iv, t,-gh_scm2double (height));
47 else if (which == ly_symbol2scm ("triangle"))
49 m = Lookup::triangle (iv, t, gh_scm2double (height));
52 m.align_to (Y_AXIS, DOWN);
53 return m.smobbed_copy();
56 ADD_INTERFACE (Measure_grouping,"measure-grouping-interface",
57 "indicate groups of beats. Valid choices for 'type are 'bracket and 'triangle.",
58 "thickness style height");