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