2 mensural-ligature.cc -- implement Mensural_ligature
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>,
7 Pal Benko <benkop@freestart.hu>
12 #include "mensural-ligature.hh"
14 #include "font-interface.hh"
16 #include "staff-symbol-referencer.hh"
17 #include "note-head.hh"
18 #include "output-def.hh"
22 * TODO: divide this function into mensural and neo-mensural style.
24 * TODO: move this function to class Lookup?
33 Real staff_space = Staff_symbol_referencer::staff_space (me);
34 Real height = 0.6 * staff_space;
37 Real slope = (interval / 2.0 * staff_space) / width;
39 // Compensate optical illusion regarding vertical position of left
40 // and right endings due to slope.
41 Real ypos_correction = -0.1 * staff_space * sign (slope);
42 Real slope_correction = 0.2 * staff_space * sign (slope);
43 Real corrected_slope = slope + slope_correction / width;
45 if (solid) // this will come handy for colorated flexae
48 = Lookup::beam (corrected_slope, width, height, 0.0);
49 stencil.add_stencil (solid_head);
54 = Lookup::beam (corrected_slope, thickness, height, 0.0);
55 stencil.add_stencil (left_edge);
58 = Lookup::beam (corrected_slope, thickness, height, 0.0);
59 right_edge.translate_axis (width - thickness, X_AXIS);
60 right_edge.translate_axis (corrected_slope * (width - thickness), Y_AXIS);
61 stencil.add_stencil (right_edge);
64 = Lookup::beam (corrected_slope, width, thickness, 0.0);
65 bottom_edge.translate_axis (-0.5 * height, Y_AXIS);
66 stencil.add_stencil (bottom_edge);
69 = Lookup::beam (corrected_slope, width, thickness, 0.0);
70 top_edge.translate_axis (+0.5 * height, Y_AXIS);
71 stencil.add_stencil (top_edge);
73 stencil.translate_axis (ypos_correction, Y_AXIS);
78 internal_brew_primitive (Grob *me)
80 SCM primitive_scm = me->get_property ("primitive");
81 if (primitive_scm == SCM_EOL)
83 programming_error ("Mensural_ligature: "
84 "undefined primitive -> ignoring grob");
87 int primitive = scm_to_int (primitive_scm);
93 Real staff_space = Staff_symbol_referencer::staff_space (me);
94 if (primitive & MLP_ANY)
96 thickness = robust_scm2double (me->get_property ("thickness"), .14);
99 if (primitive & MLP_FLEXA)
101 delta_pitch = robust_scm2int (me->get_property ("delta-pitch"),
104 = robust_scm2double (me->get_property ("flexa-width"), 2.0 * staff_space);
106 if (primitive & MLP_SINGLE_HEAD)
108 width = robust_scm2double (me->get_property ("head-width"), staff_space);
111 switch (primitive & MLP_ANY)
115 case MLP_LONGA: // mensural brevis head with right cauda
116 out = Font_interface::get_default_font (me)->find_by_name
117 ("noteheads.s-2mensural");
119 case MLP_BREVIS: // mensural brevis head
120 out = Font_interface::get_default_font (me)->find_by_name
121 ("noteheads.s-1mensural");
123 case MLP_MAXIMA: // should be mensural maxima head without stem
124 out = Font_interface::get_default_font (me)->find_by_name
125 ("noteheads.s-1neomensural");
128 out = brew_flexa (me, delta_pitch, false, width, thickness);
131 programming_error (_f ("Mensural_ligature: "
132 "unexpected case fall-through"));
137 = (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")));
139 if (primitive & MLP_STEM)
142 Real y_bottom = 0.0, y_top = 3.0 * staff_space;
144 if (primitive & MLP_DOWN)
150 Interval x_extent (0, thickness);
151 Interval y_extent (y_bottom, y_top);
152 Box join_box (x_extent, y_extent);
154 Stencil join = Lookup::round_filled_box (join_box, blotdiameter);
155 out.add_stencil (join);
158 SCM join_right_scm = me->get_property ("join-right-amount");
160 if (join_right_scm != SCM_EOL)
162 int join_right = scm_to_int (join_right_scm);
165 Real y_top = join_right * 0.5 * staff_space;
174 Interval x_extent (width - thickness, width);
175 Interval y_extent (y_bottom, y_top);
176 Box join_box (x_extent, y_extent);
177 Stencil join = Lookup::round_filled_box (join_box, blotdiameter);
179 out.add_stencil (join);
183 programming_error (_f ("Mensural_ligature: (join_right == 0)"));
187 #if 0 // what happend with the ledger lines?
188 int pos = Staff_symbol_referencer::get_rounded_position (me);
189 if (primitive & MLP_FLEXA)
192 add_ledger_lines (me, &out, pos, 0.5 * delta_pitch, ledger_take_space);
199 MAKE_SCHEME_CALLBACK (Mensural_ligature, brew_ligature_primitive, 1);
201 Mensural_ligature::brew_ligature_primitive (SCM smob)
203 Grob *me = unsmob_grob (smob);
204 return internal_brew_primitive (me).smobbed_copy ();
207 MAKE_SCHEME_CALLBACK (Mensural_ligature, print, 1);
209 Mensural_ligature::print (SCM)
214 ADD_INTERFACE (Mensural_ligature, "mensural-ligature-interface",
215 "A mensural ligature",
216 "delta-pitch flexa-width head-width join-right-amount " // "add-join "
217 "ligature-primitive-callback primitive thickness");