2 breathing_sign.cc -- implement Breathing_sign
4 (c) 1999--2006 Michael Krause
6 written for the GNU LilyPond music typesetter
8 TODO: --> see breathing-sign-engraver.cc
10 Extensions for ancient notation (c) 2003--2006 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-interface.hh"
22 #include "font-interface.hh"
26 TODO: thickness should be a grob property (unit: linethickness)
27 rather than hardwired to (staff_space / 6).
31 UGH : this is full of C&P code. Consolidate! --hwn
35 Gregorian chant divisio minima. (Actually, this was the original
36 breathing sign by Michael. -- jr)
38 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1);
40 Breathing_sign::divisio_minima (SCM smob)
42 Grob *me = unsmob_grob (smob);
43 Real staff_space = Staff_symbol_referencer::staff_space (me);
46 Real thickness = Staff_symbol_referencer::line_thickness (me);
47 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
48 if (Staff_symbol_referencer::get_staff_symbol (me))
49 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
53 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
56 * Draw a small vertical line through the uppermost (or, depending
57 * on direction, lowermost) staff line.
59 Interval xdim (0, thickness);
60 Interval ydim (-0.5 * staff_space, +0.5 * staff_space);
62 Stencil out = Lookup::round_filled_box (b, blotdiameter);
63 return out.smobbed_copy ();
67 Gregorian chant divisio maior.
69 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maior, 1);
71 Breathing_sign::divisio_maior (SCM smob)
73 Grob *me = unsmob_grob (smob);
74 Real staff_space = Staff_symbol_referencer::staff_space (me);
76 Real thickness = Staff_symbol_referencer::line_thickness (me);
77 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
79 if (Staff_symbol_referencer::get_staff_symbol (me))
80 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
84 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
87 * Draw a vertical line that is vertically centered in the staff
88 * (just like a bar). The height of this line should be a little
89 * more than half the size of the staff, such that the endings of
90 * the line are in the middle of a staff space.
92 int lines = Staff_symbol_referencer::line_count (me);
93 int height = lines / 2; // little more than half of staff size
94 if ((lines & 1) != (height & 1))
95 height++; // ensure endings are centered in staff space
97 Interval xdim (0, thickness);
98 Interval ydim (-0.5 * height, +0.5 * height);
100 Stencil out = Lookup::round_filled_box (b, blotdiameter);
101 return out.smobbed_copy ();
105 Gregorian chant divisio maxima.
107 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1);
109 Breathing_sign::divisio_maxima (SCM smob)
111 Grob *me = unsmob_grob (smob);
112 Real staff_space = Staff_symbol_referencer::staff_space (me);
114 Real thickness = Staff_symbol_referencer::line_thickness (me);
115 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
117 if (Staff_symbol_referencer::get_staff_symbol (me))
118 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
122 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
124 // like a "|" type bar
125 Interval xdim (0, thickness);
126 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
128 Stencil out = Lookup::round_filled_box (b, blotdiameter);
129 return out.smobbed_copy ();
133 Gregorian chant finalis.
135 MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1);
137 Breathing_sign::finalis (SCM smob)
139 Grob *me = unsmob_grob (smob);
140 Real staff_space = Staff_symbol_referencer::staff_space (me);
142 Real thickness = Staff_symbol_referencer::line_thickness (me);
143 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
145 if (Staff_symbol_referencer::get_staff_symbol (me))
146 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
150 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
152 // like a "||" type bar
153 Interval xdim (0, thickness);
154 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
156 Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
157 Stencil line2 (line1);
158 line2.translate_axis (0.5 * staff_space, X_AXIS);
159 line1.add_stencil (line2);
161 return line1.smobbed_copy ();
164 MAKE_SCHEME_CALLBACK (Breathing_sign, offset_callback, 1);
166 Breathing_sign::offset_callback (SCM smob)
168 Grob *me = unsmob_grob (smob);
170 Direction d = get_grob_direction (me);
174 set_grob_direction (me, d);
177 Real inter = Staff_symbol_referencer::staff_space (me) / 2;
178 int sz = Staff_symbol_referencer::line_count (me) - 1;
179 return scm_from_double (inter * sz * d);
182 ADD_INTERFACE (Breathing_sign,