2 horizontal-bracket.cc -- implement Horizontal_bracket
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "side-position-interface.hh"
12 #include "group-interface.hh"
13 #include "directional-element-interface.hh"
14 #include "paper-def.hh"
15 #include "staff-symbol-referencer.hh"
17 struct Horizontal_bracket
19 DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
20 static bool has_interface (Grob*);
27 This doesn't look very elegant: should support winged edges.
29 Support texts on the brackets?
33 MAKE_SCHEME_CALLBACK(Horizontal_bracket, brew_molecule, 1);
36 Horizontal_bracket::brew_molecule (SCM smob)
38 Grob * me = unsmob_grob (smob);
39 Spanner *sp = dynamic_cast<Spanner*> (me);
40 Link_array<Grob> gs = Pointer_group_interface__extract_grobs (me,(Grob*)0, "columns");
47 Grob * cx = common_refpoint_of_array (gs, me, X_AXIS);
48 cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
49 cx = cx->common_refpoint (sp->get_bound (RIGHT),X_AXIS);
51 Interval ext = gs.top()->extent (cx, X_AXIS);
52 ext.unite (gs[0]->extent (cx, X_AXIS));
54 Direction d = get_grob_direction (me);
56 Real thickness = Staff_symbol_referencer::line_thickness (me);
57 thickness *= robust_scm2double (me->get_grob_property ("thickness"), 1.0);
59 Molecule b = Lookup::bracket (X_AXIS, ext, thickness, - d* 1.0, thickness/2);
61 b.translate_axis ( - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
63 return b.smobbed_copy();
66 ADD_INTERFACE (Horizontal_bracket,"horizontal-bracket-interface",
67 "A horizontal bracket encompassing notes.",
68 "thickness columns direction");