2 breathing_sign.cc -- implement Breathing_sign
4 (c) 1999--2004 Michael Krause
6 written for the GNU LilyPond music typesetter
8 TODO: --> see breathing-sign-engraver.cc
10 Extensions for ancient notation (c) 2003 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).
32 UGH : this is full of C&P code. Consolidate! --hwn
36 Gregorian chant divisio minima. (Actually, this was the original
37 breathing sign by Michael. -- jr)
39 MAKE_SCHEME_CALLBACK (Breathing_sign,divisio_minima,1);
41 Breathing_sign::divisio_minima (SCM smob)
43 Grob *me = unsmob_grob (smob);
44 Real staff_space = Staff_symbol_referencer::staff_space (me);
47 Real thickness = Staff_symbol_referencer::line_thickness (me);
48 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
49 if (Staff_symbol_referencer::get_staff_symbol (me))
51 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
56 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
59 * Draw a small vertical line through the uppermost (or, depending
60 * on direction, lowermost) staff line.
62 Interval xdim (0, thickness);
63 Interval ydim (-0.5 * staff_space, +0.5 * staff_space);
65 Stencil out = Lookup::round_filled_box (b, blotdiameter);
66 return out.smobbed_copy ();
70 Gregorian chant divisio maior.
72 MAKE_SCHEME_CALLBACK (Breathing_sign,divisio_maior,1);
74 Breathing_sign::divisio_maior (SCM smob)
76 Grob *me = unsmob_grob (smob);
77 Real staff_space = Staff_symbol_referencer::staff_space (me);
79 Real thickness = Staff_symbol_referencer::line_thickness (me);
80 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
82 if (Staff_symbol_referencer::get_staff_symbol (me))
84 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
89 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
92 * Draw a vertical line that is vertically centered in the staff
93 * (just like a bar). The height of this line should be a little
94 * more than half the size of the staff, such that the endings of
95 * the line are in the middle of a staff space.
97 int lines = Staff_symbol_referencer::line_count (me);
98 int height = lines / 2; // little more than half of staff size
99 if ((lines & 1) != (height & 1))
100 height++; // ensure endings are centered in staff space
102 Interval xdim (0, thickness);
103 Interval ydim (-0.5 * height, +0.5 * height);
105 Stencil out = Lookup::round_filled_box (b, blotdiameter);
106 return out.smobbed_copy ();
110 Gregorian chant divisio maxima.
112 MAKE_SCHEME_CALLBACK (Breathing_sign,divisio_maxima,1);
114 Breathing_sign::divisio_maxima (SCM smob)
116 Grob *me = unsmob_grob (smob);
117 Real staff_space = Staff_symbol_referencer::staff_space (me);
119 Real thickness = Staff_symbol_referencer::line_thickness (me);
120 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
122 if (Staff_symbol_referencer::get_staff_symbol (me))
124 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
129 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
131 // like a "|" type bar
132 Interval xdim (0, thickness);
133 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
135 Stencil out = Lookup::round_filled_box (b, blotdiameter);
136 return out.smobbed_copy ();
140 Gregorian chant finalis.
142 MAKE_SCHEME_CALLBACK (Breathing_sign,finalis,1);
144 Breathing_sign::finalis (SCM smob)
146 Grob *me = unsmob_grob (smob);
147 Real staff_space = Staff_symbol_referencer::staff_space (me);
149 Real thickness = Staff_symbol_referencer::line_thickness (me);
150 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
152 if (Staff_symbol_referencer::get_staff_symbol (me))
154 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
159 Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
161 // like a "||" type bar
162 Interval xdim (0, thickness);
163 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
165 Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
166 Stencil line2 (line1);
167 line2.translate_axis (0.5 * staff_space, X_AXIS);
168 line1.add_stencil (line2);
170 return line1.smobbed_copy ();
173 MAKE_SCHEME_CALLBACK (Breathing_sign,offset_callback,2);
175 Breathing_sign::offset_callback (SCM element_smob, SCM)
177 Grob *me = unsmob_grob (element_smob);
179 Direction d = get_grob_direction (me);
183 set_grob_direction (me, d);
186 Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
187 int sz = Staff_symbol_referencer::line_count (me)-1;
188 return scm_make_real (inter_f * sz * d);
191 ADD_INTERFACE (Breathing_sign, "breathing-sign-interface",