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 "staff-symbol-referencer.hh"
14 #include "directional-element-interface.hh"
15 #include "breathing-sign.hh"
18 #include "output-def.hh"
21 #include "dimensions.hh"
22 #include "direction.hh"
23 #include "text-item.hh"
24 #include "font-interface.hh"
27 TODO: thickness should be a grob property (unit: linethickness)
28 rather than hardwired to (staff_space / 6).
34 UGH : this is full of C&P code. Consolidate! --hwn
38 Gregorian chant divisio minima. (Actually, this was the original
39 breathing sign by Michael. -- jr)
41 MAKE_SCHEME_CALLBACK (Breathing_sign
,divisio_minima
,1);
43 Breathing_sign::divisio_minima (SCM smob
)
45 Grob
*me
= unsmob_grob (smob
);
46 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
49 Real thickness
= Staff_symbol_referencer::line_thickness (me
);
50 thickness
*= robust_scm2double (me
->get_property ("thickness"), 1.0);
51 if (Staff_symbol_referencer::get_staff_symbol (me
))
53 staff_size
= (Staff_symbol_referencer::line_count (me
) - 1) * staff_space
;
58 Real blotdiameter
= me
->get_paper ()->get_dimension (ly_symbol2scm ("blotdiameter"));
61 * Draw a small vertical line through the uppermost (or, depending
62 * on direction, lowermost) staff line.
64 Interval
xdim (0, thickness
);
65 Interval
ydim (-0.5 * staff_space
, +0.5 * staff_space
);
67 Stencil out
= Lookup::round_filled_box (b
, blotdiameter
);
68 return out
.smobbed_copy ();
72 Gregorian chant divisio maior.
74 MAKE_SCHEME_CALLBACK (Breathing_sign
,divisio_maior
,1);
76 Breathing_sign::divisio_maior (SCM smob
)
78 Grob
*me
= unsmob_grob (smob
);
79 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
81 Real thickness
= Staff_symbol_referencer::line_thickness (me
);
82 thickness
*= robust_scm2double (me
->get_property ("thickness"), 1.0);
84 if (Staff_symbol_referencer::get_staff_symbol (me
))
86 staff_size
= (Staff_symbol_referencer::line_count (me
) - 1) * staff_space
;
91 Real blotdiameter
= me
->get_paper ()->get_dimension (ly_symbol2scm ("blotdiameter"));
94 * Draw a vertical line that is vertically centered in the staff
95 * (just like a bar). The height of this line should be a little
96 * more than half the size of the staff, such that the endings of
97 * the line are in the middle of a staff space.
99 int lines
= Staff_symbol_referencer::line_count (me
);
100 int height
= lines
/ 2; // little more than half of staff size
101 if ((lines
& 1) != (height
& 1))
102 height
++; // ensure endings are centered in staff space
104 Interval
xdim (0, thickness
);
105 Interval
ydim (-0.5 * height
, +0.5 * height
);
107 Stencil out
= Lookup::round_filled_box (b
, blotdiameter
);
108 return out
.smobbed_copy ();
112 Gregorian chant divisio maxima.
114 MAKE_SCHEME_CALLBACK (Breathing_sign
,divisio_maxima
,1);
116 Breathing_sign::divisio_maxima (SCM smob
)
118 Grob
*me
= unsmob_grob (smob
);
119 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
121 Real thickness
= Staff_symbol_referencer::line_thickness (me
);
122 thickness
*= robust_scm2double (me
->get_property ("thickness"), 1.0);
124 if (Staff_symbol_referencer::get_staff_symbol (me
))
126 staff_size
= (Staff_symbol_referencer::line_count (me
) - 1) * staff_space
;
131 Real blotdiameter
= me
->get_paper ()->get_dimension (ly_symbol2scm ("blotdiameter"));
133 // like a "|" type bar
134 Interval
xdim (0, thickness
);
135 Interval
ydim (-0.5 * staff_size
, +0.5 * staff_size
);
137 Stencil out
= Lookup::round_filled_box (b
, blotdiameter
);
138 return out
.smobbed_copy ();
142 Gregorian chant finalis.
144 MAKE_SCHEME_CALLBACK (Breathing_sign
,finalis
,1);
146 Breathing_sign::finalis (SCM smob
)
148 Grob
*me
= unsmob_grob (smob
);
149 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
151 Real thickness
= Staff_symbol_referencer::line_thickness (me
);
152 thickness
*= robust_scm2double (me
->get_property ("thickness"), 1.0);
154 if (Staff_symbol_referencer::get_staff_symbol (me
))
156 staff_size
= (Staff_symbol_referencer::line_count (me
) - 1) * staff_space
;
161 Real blotdiameter
= me
->get_paper ()->get_dimension (ly_symbol2scm ("blotdiameter"));
163 // like a "||" type bar
164 Interval
xdim (0, thickness
);
165 Interval
ydim (-0.5 * staff_size
, +0.5 * staff_size
);
167 Stencil line1
= Lookup::round_filled_box (b
, blotdiameter
);
168 Stencil
line2 (line1
);
169 line2
.translate_axis (0.5 * staff_space
, X_AXIS
);
170 line1
.add_stencil (line2
);
172 return line1
.smobbed_copy ();
175 MAKE_SCHEME_CALLBACK (Breathing_sign
,offset_callback
,2);
177 Breathing_sign::offset_callback (SCM element_smob
, SCM
)
179 Grob
*me
= unsmob_grob (element_smob
);
181 Direction d
= get_grob_direction (me
);
185 set_grob_direction (me
, d
);
188 Real inter_f
= Staff_symbol_referencer::staff_space (me
)/2;
189 int sz
= Staff_symbol_referencer::line_count (me
)-1;
190 return scm_make_real (inter_f
* sz
* d
);
193 ADD_INTERFACE (Breathing_sign
, "breathing-sign-interface",