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:
28 * stafflinethickness) rather than hardwired to (staff_space / 6).
32 WTF: what does Breathing_sign have to do with text?!
36 MAKE_SCHEME_CALLBACK (Breathing_sign,brew_molecule,1);
38 Breathing_sign::brew_molecule (SCM smob)
40 Grob *me = unsmob_grob (smob);
41 SCM text = me->get_grob_property ("text");
43 return divisio_minima (smob);
44 SCM properties = Font_interface::font_alist_chain (me);
45 Molecule out = Text_item::interpret_new_markup (smob, properties, text);
46 SCM space_scm = me->get_grob_property ("word-space");
47 if (gh_number_p (space_scm))
50 mol.set_empty (false);
51 out.add_at_edge (X_AXIS, RIGHT, mol, gh_scm2double (space_scm) *
52 Staff_symbol_referencer::staff_space (me), 0);
54 return out.smobbed_copy ();
60 MAKE_SCHEME_CALLBACK (Breathing_sign,railtracks,1);
62 Breathing_sign::railtracks (SCM smob)
64 Grob * me = unsmob_grob (smob);
65 Real space = Staff_symbol_referencer::staff_space (me);
66 Real th = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
67 SCM lt = me->get_grob_property ("thickness");
69 th *= gh_scm2double (lt);
71 Offset x1 (0, -space);
72 Offset x2 (space / 3, space);
73 Molecule l1 (Lookup::line (th, x1, x2));
75 l2.translate_axis (space *0.6 , X_AXIS);
77 return l1.smobbed_copy();
81 Gregorian chant divisio minima. (Actually, this was the original
82 breathing sign by Michael. -- jr)
84 MAKE_SCHEME_CALLBACK (Breathing_sign,divisio_minima,1);
86 Breathing_sign::divisio_minima (SCM smob)
88 Grob *me = unsmob_grob (smob);
89 Real staff_space = Staff_symbol_referencer::staff_space (me);
91 Real thickness = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
92 SCM lt = me->get_grob_property ("thickness");
94 thickness *= gh_scm2double (lt);
95 if (Staff_symbol_referencer::get_staff_symbol (me))
97 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
102 Real blotdiameter = me->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"));
105 * Draw a small vertical line through the uppermost (or, depending
106 * on direction, lowermost) staff line.
108 Interval xdim (0, thickness);
109 Interval ydim (-0.5 * staff_space, +0.5 * staff_space);
111 Molecule out = Lookup::roundfilledbox (b, blotdiameter);
112 return out.smobbed_copy ();
116 Gregorian chant divisio maior.
118 MAKE_SCHEME_CALLBACK (Breathing_sign,divisio_maior,1);
120 Breathing_sign::divisio_maior (SCM smob)
122 Grob *me = unsmob_grob (smob);
123 Real staff_space = Staff_symbol_referencer::staff_space (me);
125 Real thickness = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
126 SCM lt = me->get_grob_property ("thickness");
127 if (gh_number_p (lt))
128 thickness *= gh_scm2double (lt);
129 if (Staff_symbol_referencer::get_staff_symbol (me))
131 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
136 Real blotdiameter = me->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"));
139 * Draw a vertical line that is vertically centered in the staff
140 * (just like a bar). The height of this line should be a little
141 * more than half the size of the staff, such that the endings of
142 * the line are in the middle of a staff space.
144 int lines = Staff_symbol_referencer::line_count (me);
145 int height = lines / 2; // little more than half of staff size
146 if ((lines & 1) != (height & 1))
147 height++; // ensure endings are centered in staff space
149 Interval xdim (0, thickness);
150 Interval ydim (-0.5 * height, +0.5 * height);
152 Molecule out = Lookup::roundfilledbox (b, blotdiameter);
153 return out.smobbed_copy ();
157 Gregorian chant divisio maxima.
159 MAKE_SCHEME_CALLBACK (Breathing_sign,divisio_maxima,1);
161 Breathing_sign::divisio_maxima (SCM smob)
163 Grob *me = unsmob_grob (smob);
164 Real staff_space = Staff_symbol_referencer::staff_space (me);
166 Real thickness = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
167 SCM lt = me->get_grob_property ("thickness");
168 if (gh_number_p (lt))
169 thickness *= gh_scm2double (lt);
170 if (Staff_symbol_referencer::get_staff_symbol (me))
172 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
177 Real blotdiameter = me->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"));
179 // like a "|" type bar
180 Interval xdim (0, thickness);
181 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
183 Molecule out = Lookup::roundfilledbox (b, blotdiameter);
184 return out.smobbed_copy ();
188 Gregorian chant finalis.
190 MAKE_SCHEME_CALLBACK (Breathing_sign,finalis,1);
192 Breathing_sign::finalis (SCM smob)
194 Grob *me = unsmob_grob (smob);
195 Real staff_space = Staff_symbol_referencer::staff_space (me);
197 Real thickness = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
198 SCM lt = me->get_grob_property ("thickness");
199 if (gh_number_p (lt))
200 thickness *= gh_scm2double (lt);
201 if (Staff_symbol_referencer::get_staff_symbol (me))
203 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
208 Real blotdiameter = me->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"));
210 // like a "||" type bar
211 Interval xdim (0, thickness);
212 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
214 Molecule line1 = Lookup::roundfilledbox (b, blotdiameter);
215 Molecule line2 (line1);
216 line2.translate_axis (0.5 * staff_space, X_AXIS);
217 line1.add_molecule (line2);
219 return line1.smobbed_copy ();
222 MAKE_SCHEME_CALLBACK (Breathing_sign,offset_callback,2);
224 Breathing_sign::offset_callback (SCM element_smob, SCM)
226 Grob *me = unsmob_grob (element_smob);
228 Direction d = Directional_element_interface::get (me);
232 Directional_element_interface::set (me, d);
235 Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
236 int sz = Staff_symbol_referencer::line_count (me)-1;
237 return gh_double2scm (inter_f * sz * d);
240 ADD_INTERFACE(Breathing_sign, "breathing-sign-interface",