]> git.donarmstrong.com Git - lilypond.git/blob - lily/horizontal-bracket.cc
*** empty log message ***
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8  */
9
10 #include "side-position-interface.hh"
11 #include "lookup.hh"
12 #include "group-interface.hh"
13 #include "directional-element-interface.hh"
14 #include "paper-def.hh"
15 #include "staff-symbol-referencer.hh"
16
17 struct Horizontal_bracket
18 {
19   DECLARE_SCHEME_CALLBACK (print, (SCM));
20   static bool has_interface (Grob*);
21 };
22
23
24 /*
25   TODO:
26
27   This doesn't look very elegant: should support winged edges.
28
29   Support texts on the brackets?
30 */
31 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
32
33 SCM
34 Horizontal_bracket::print (SCM smob)
35 {
36   Grob * me = unsmob_grob (smob);
37   Spanner *sp = dynamic_cast<Spanner*> (me);
38   Link_array<Grob> gs = Pointer_group_interface__extract_grobs (me,(Grob*)0, "columns");
39
40   if (!gs.size ())
41     {
42       me->suicide ();
43       return SCM_EOL;
44     }
45   Grob * cx = common_refpoint_of_array (gs, me, X_AXIS);
46   cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
47   cx = cx->common_refpoint (sp->get_bound (RIGHT),X_AXIS);
48
49   Interval ext = gs.top ()->extent (cx, X_AXIS);
50   ext.unite (gs[0]->extent (cx, X_AXIS));
51
52   Direction d = get_grob_direction (me);
53
54   Real thickness = Staff_symbol_referencer::line_thickness (me);
55   thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
56   
57   Stencil b = Lookup::bracket (X_AXIS, ext, thickness, - d* 1.0, thickness/2); 
58   
59   b.translate_axis ( - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
60
61   return b.smobbed_copy ();  
62 }
63
64 ADD_INTERFACE (Horizontal_bracket,"horizontal-bracket-interface",
65   "A horizontal bracket encompassing notes.",
66   "thickness columns direction");
67