2 breathing_sign.cc -- implement Breathing_sign
4 (c) 1999--2005 Michael Krause
6 written for the GNU LilyPond music typesetter
8 TODO: --> see breathing-sign-engraver.cc
10 Extensions for ancient notation (c) 2003--2005 by Juergen Reuter
13 #include "breathing-sign.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "directional-element-interface.hh"
17 #include "output-def.hh"
19 #include "dimensions.hh"
20 #include "direction.hh"
21 #include "text-item.hh"
22 #include "font-interface.hh"
25 TODO: thickness should be a grob property (unit: linethickness)
26 rather than hardwired to (staff_space / 6).
30 UGH : this is full of C&P code. Consolidate! --hwn
34 Gregorian chant divisio minima. (Actually, this was the original
35 breathing sign by Michael. -- jr)
37 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1);
39 Breathing_sign::divisio_minima (SCM smob)
41 Grob *me = unsmob_grob (smob);
42 Real staff_space = Staff_symbol_referencer::staff_space (me);
45 Real thickness = Staff_symbol_referencer::line_thickness (me);
46 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
47 if (Staff_symbol_referencer::get_staff_symbol (me))
49 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
54 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
57 * Draw a small vertical line through the uppermost (or, depending
58 * on direction, lowermost) staff line.
60 Interval xdim (0, thickness);
61 Interval ydim (-0.5 * staff_space, +0.5 * staff_space);
63 Stencil out = Lookup::round_filled_box (b, blotdiameter);
64 return out.smobbed_copy ();
68 Gregorian chant divisio maior.
70 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maior, 1);
72 Breathing_sign::divisio_maior (SCM smob)
74 Grob *me = unsmob_grob (smob);
75 Real staff_space = Staff_symbol_referencer::staff_space (me);
77 Real thickness = Staff_symbol_referencer::line_thickness (me);
78 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
80 if (Staff_symbol_referencer::get_staff_symbol (me))
82 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
87 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
90 * Draw a vertical line that is vertically centered in the staff
91 * (just like a bar). The height of this line should be a little
92 * more than half the size of the staff, such that the endings of
93 * the line are in the middle of a staff space.
95 int lines = Staff_symbol_referencer::line_count (me);
96 int height = lines / 2; // little more than half of staff size
97 if ((lines & 1) != (height & 1))
98 height++; // ensure endings are centered in staff space
100 Interval xdim (0, thickness);
101 Interval ydim (-0.5 * height, +0.5 * height);
103 Stencil out = Lookup::round_filled_box (b, blotdiameter);
104 return out.smobbed_copy ();
108 Gregorian chant divisio maxima.
110 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1);
112 Breathing_sign::divisio_maxima (SCM smob)
114 Grob *me = unsmob_grob (smob);
115 Real staff_space = Staff_symbol_referencer::staff_space (me);
117 Real thickness = Staff_symbol_referencer::line_thickness (me);
118 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
120 if (Staff_symbol_referencer::get_staff_symbol (me))
122 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
127 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
129 // like a "|" type bar
130 Interval xdim (0, thickness);
131 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
133 Stencil out = Lookup::round_filled_box (b, blotdiameter);
134 return out.smobbed_copy ();
138 Gregorian chant finalis.
140 MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1);
142 Breathing_sign::finalis (SCM smob)
144 Grob *me = unsmob_grob (smob);
145 Real staff_space = Staff_symbol_referencer::staff_space (me);
147 Real thickness = Staff_symbol_referencer::line_thickness (me);
148 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
150 if (Staff_symbol_referencer::get_staff_symbol (me))
152 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
157 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
159 // like a "||" type bar
160 Interval xdim (0, thickness);
161 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
163 Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
164 Stencil line2 (line1);
165 line2.translate_axis (0.5 * staff_space, X_AXIS);
166 line1.add_stencil (line2);
168 return line1.smobbed_copy ();
171 MAKE_SCHEME_CALLBACK (Breathing_sign, offset_callback, 2);
173 Breathing_sign::offset_callback (SCM element_smob, SCM)
175 Grob *me = unsmob_grob (element_smob);
177 Direction d = get_grob_direction (me);
181 set_grob_direction (me, d);
184 Real inter_f = Staff_symbol_referencer::staff_space (me) / 2;
185 int sz = Staff_symbol_referencer::line_count (me) - 1;
186 return scm_make_real (inter_f * sz * d);
189 ADD_INTERFACE (Breathing_sign, "breathing-sign-interface",