2 ligature-bracket.cc -- implement Ligature_bracket
4 source file of the GNU LilyPond music typesetter
6 (c) 2002 Juergen Reuter <reuter@ipd.uka.de>
9 #include "ligature-bracket.hh"
11 #include "paper-def.hh"
13 #include "staff-symbol-referencer.hh"
18 brew_edge (Direction dir
, Real thickness
, Real width
, Real height
,
21 Molecule hline
= Lookup::roundfilledbox (Box (Interval (0, width
),
22 Interval (0, thickness
)),
24 hline
.translate_axis (height
- thickness
, Y_AXIS
);
26 Molecule vline
= Lookup::roundfilledbox (Box (Interval (0, thickness
),
27 Interval (0, height
)),
31 vline
.translate_axis (width
- thickness
, X_AXIS
);
34 Molecule edge
= Molecule ();
35 edge
.add_molecule (hline
);
36 edge
.add_molecule (vline
);
40 MAKE_SCHEME_CALLBACK (Ligature_bracket
, brew_molecule
, 1);
42 Ligature_bracket::brew_molecule (SCM smob
)
44 Grob
*me
= unsmob_grob (smob
);
45 Spanner
*spanner
= dynamic_cast<Spanner
*> (me
);
46 Real blotdiameter
= me
->get_paper ()->get_var ("blotdiameter");
47 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
49 Real thickness
= me
->get_paper ()->get_var ("linethickness");
50 SCM grob_thickness
= me
->get_grob_property ("thickness");
51 if (gh_number_p (grob_thickness
))
52 thickness
*= gh_scm2double (grob_thickness
);
54 SCM edge_width_scm
= me
->get_grob_property ("width");
56 if (gh_number_p (edge_width_scm
))
58 edge_width
= gh_scm2double (edge_width_scm
);
64 edge_width
*= staff_space
;
66 SCM edge_height_scm
= me
->get_grob_property ("height");
68 if (gh_number_p (edge_height_scm
))
70 edge_height
= gh_scm2double (edge_height_scm
);
76 edge_height
*= staff_space
;
78 Item
* left_bound
= spanner
->get_bound (LEFT
);
79 Item
* right_bound
= spanner
->get_bound (RIGHT
);
81 Molecule bracket
= Molecule ();
84 0.5 * Staff_symbol_referencer::line_count (me
) * staff_space
;
85 Real y_left_offs
= y_min_offs
;
86 Real y_right_offs
= y_min_offs
;
88 Real left_bound_left_extent
= 0;
93 brew_edge (LEFT
, thickness
, edge_width
, edge_height
, blotdiameter
);
94 Grob
*left_common_x
= me
->common_refpoint (left_bound
, X_AXIS
);
95 left_bound_left_extent
=
96 left_bound
->extent (left_common_x
, X_AXIS
)[LEFT
];
97 left_edge
.translate_axis (left_bound_left_extent
, X_AXIS
);
98 bracket
.add_molecule (left_edge
);
99 Grob
*left_common_y
= me
->common_refpoint (left_bound
, Y_AXIS
);
101 max(y_left_offs
, left_bound
->extent (left_common_y
, Y_AXIS
)[UP
]);
105 me
->warning (_ ("no left bound"));
110 Molecule right_edge
=
111 brew_edge (RIGHT
, thickness
, edge_width
, edge_height
, blotdiameter
);
112 Grob
*staff_symbol
= Staff_symbol_referencer::get_staff_symbol (me
);
113 Grob
*right_common_bound_x
=
114 right_bound
->common_refpoint (staff_symbol
, X_AXIS
);
119 Grob
*left_common_bound_x
=
120 left_bound
->common_refpoint (staff_symbol
, X_AXIS
);
121 left_offs
= left_bound
->extent (left_common_bound_x
, X_AXIS
)[LEFT
];
125 right_bound
->extent (right_common_bound_x
, X_AXIS
)[RIGHT
];
127 right_edge
.translate_axis (+ right_offs
129 + left_bound_left_extent
132 bracket
.add_molecule (right_edge
);
133 Grob
*right_common_y
= me
->common_refpoint (right_bound
, Y_AXIS
);
135 max(y_right_offs
, right_bound
->extent (right_common_y
, Y_AXIS
)[UP
]);
139 me
->warning (_ ("no left bound"));
142 bracket
.translate_axis (max (y_left_offs
, y_right_offs
), Y_AXIS
);
144 return bracket
.smobbed_copy ();
147 ADD_INTERFACE (Ligature_bracket
, "ligature-bracket-interface",
148 "A bracket indicating a ligature in the original edition",
149 "width thickness height ligature-primitive-callback");