2 breathing_sign.cc -- implement Breathing_sign
4 (c) 1999--2003 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"
17 #include "molecule.hh"
18 #include "paper-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: stafflinethickness)
28 rather than hardwired to (staff_space / 6).
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
);
44 Real thickness
= me
->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
45 SCM lt
= me
->get_grob_property ("thickness");
47 thickness
*= gh_scm2double (lt
);
48 if (Staff_symbol_referencer::get_staff_symbol (me
))
50 staff_size
= (Staff_symbol_referencer::line_count (me
) - 1) * staff_space
;
55 Real blotdiameter
= me
->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"));
58 * Draw a small vertical line through the uppermost (or, depending
59 * on direction, lowermost) staff line.
61 Interval
xdim (0, thickness
);
62 Interval
ydim (-0.5 * staff_space
, +0.5 * staff_space
);
64 Molecule out
= Lookup::round_filled_box (b
, blotdiameter
);
65 return out
.smobbed_copy ();
69 Gregorian chant divisio maior.
71 MAKE_SCHEME_CALLBACK (Breathing_sign
,divisio_maior
,1);
73 Breathing_sign::divisio_maior (SCM smob
)
75 Grob
*me
= unsmob_grob (smob
);
76 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
78 Real thickness
= me
->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
79 SCM lt
= me
->get_grob_property ("thickness");
81 thickness
*= gh_scm2double (lt
);
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_paper ()->get_realvar (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 Molecule 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
= me
->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
120 SCM lt
= me
->get_grob_property ("thickness");
121 if (gh_number_p (lt
))
122 thickness
*= gh_scm2double (lt
);
123 if (Staff_symbol_referencer::get_staff_symbol (me
))
125 staff_size
= (Staff_symbol_referencer::line_count (me
) - 1) * staff_space
;
130 Real blotdiameter
= me
->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"));
132 // like a "|" type bar
133 Interval
xdim (0, thickness
);
134 Interval
ydim (-0.5 * staff_size
, +0.5 * staff_size
);
136 Molecule out
= Lookup::round_filled_box (b
, blotdiameter
);
137 return out
.smobbed_copy ();
141 Gregorian chant finalis.
143 MAKE_SCHEME_CALLBACK (Breathing_sign
,finalis
,1);
145 Breathing_sign::finalis (SCM smob
)
147 Grob
*me
= unsmob_grob (smob
);
148 Real staff_space
= Staff_symbol_referencer::staff_space (me
);
150 Real thickness
= me
->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
151 SCM lt
= me
->get_grob_property ("thickness");
152 if (gh_number_p (lt
))
153 thickness
*= gh_scm2double (lt
);
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_realvar (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 Molecule line1
= Lookup::round_filled_box (b
, blotdiameter
);
168 Molecule
line2 (line1
);
169 line2
.translate_axis (0.5 * staff_space
, X_AXIS
);
170 line1
.add_molecule (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
= Directional_element_interface::get (me
);
185 Directional_element_interface::set (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 gh_double2scm (inter_f
* sz
* d
);
193 ADD_INTERFACE(Breathing_sign
, "breathing-sign-interface",