]> git.donarmstrong.com Git - lilypond.git/blob - lily/measure-grouping-spanner.cc
* lily/lookup.cc (triangle): new function.
[lilypond.git] / lily / measure-grouping-spanner.cc
1 /*   
2 measure-grouping-spanner.cc --  implement Measure_grouping
3
4 source file of the GNU LilyPond music typesetter
5
6 (c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8  */
9 #include "paper-def.hh"
10 #include "spanner.hh"
11 #include "measure-grouping-spanner.hh"
12 #include "lookup.hh" 
13 #include "item.hh"
14
15 MAKE_SCHEME_CALLBACK (Measure_grouping, brew_molecule, 1);
16 SCM 
17 Measure_grouping::brew_molecule (SCM grob)
18 {
19   Spanner * me = dynamic_cast<Spanner*> (unsmob_grob (grob));
20
21   /*
22     TODO: robustify.
23    */
24   SCM which = me->get_grob_property ("type");
25   SCM thick = me->get_grob_property ("thickness");
26   SCM height = me->get_grob_property ("height");
27
28   Real t = me->get_paper ()->get_var ("linethickness") *   gh_scm2double (thick); 
29   Grob *common = me->get_bound(LEFT)->common_refpoint (me->get_bound (RIGHT),
30                                                        X_AXIS);
31   Real w = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
32     - me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS);
33
34   Interval iv (0,w);
35
36   Molecule m; 
37   if (which == ly_symbol2scm ("bracket"))
38     {
39       m = Lookup::bracket (X_AXIS, iv,t, gh_scm2double (height));
40     }
41   else if (which == ly_symbol2scm ("triangle"))
42     {
43       m = Lookup::triangle (iv, t, gh_scm2double (height));
44     }
45
46   return m.smobbed_copy();
47 }
48
49 ADD_INTERFACE (Measure_grouping,"measure-grouping-interface",
50                "indicate groups of beats. Valid choices for 'type are 'bracket and 'triangle.",
51                "thickness height");
52
53