]> git.donarmstrong.com Git - lilypond.git/blob - lily/horizontal-bracket.cc
* Documentation/user/instrument-notation.itely (Figured bass):
[lilypond.git] / lily / horizontal-bracket.cc
1 /*
2   horizontal-bracket.cc -- implement Horizontal_bracket
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "side-position-interface.hh"
10 #include "lookup.hh"
11 #include "pointer-group-interface.hh"
12 #include "directional-element-interface.hh"
13 #include "output-def.hh"
14 #include "staff-symbol-referencer.hh"
15 #include "tuplet-bracket.hh"
16 #include "horizontal-bracket.hh"        
17 #include "axis-group-interface.hh"
18
19 Stencil
20 Horizontal_bracket::make_bracket (Grob *me, Grob *refpoint,
21                                   Link_array<Grob> grobs,
22                                   Axis a, Direction dir)
23 {
24   Axis other = other_axis (a);
25   Grob *common = common_refpoint_of_array (grobs, refpoint, a);
26   Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a);
27
28   Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
29                                                       Interval (1.0, 1.0));
30   Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
31                                                 Interval (0, 0));
32   Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
33                                                   Interval (0, 0));
34
35   // Make sure that it points in the correct direction:
36   scale_drul (&edge_height, Real (-dir));
37
38   Interval empty;
39   Offset start;
40   start[a] = ext.length ();
41
42   /*
43     ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. 
44   */
45   Stencil b
46     = Tuplet_bracket::make_bracket (me, other, start, 
47                                     edge_height, empty, flare, shorten);
48
49   b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a)
50                     , a);
51
52   return b;
53 }
54
55
56 /*
57   TODO:
58
59   Support texts on the brackets?
60 */
61
62 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
63 SCM
64 Horizontal_bracket::print (SCM smob)
65 {
66   Grob *me = unsmob_grob (smob);
67   extract_grob_set (me, "columns", gs);
68   if (!gs.size ())
69     {
70       me->suicide ();
71       return SCM_EOL;
72     }
73
74   Stencil b = make_bracket (me, me, gs, X_AXIS, get_grob_direction (me));
75   return b.smobbed_copy ();
76 }
77
78 ADD_INTERFACE (Horizontal_bracket, "horizontal-bracket-interface",
79                "A horizontal bracket encompassing notes.",
80
81                /* props */                
82                "columns "
83                "bracket-flare "
84                "shorten-pair "
85                "edge-height");
86