2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2012 Michael Krause
5 Extensions for ancient notation (c) 2003--2012 by Juergen Reuter
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "breathing-sign.hh"
23 #include "dimensions.hh"
24 #include "direction.hh"
25 #include "directional-element-interface.hh"
26 #include "font-interface.hh"
29 #include "output-def.hh"
30 #include "staff-symbol.hh"
31 #include "staff-symbol-referencer.hh"
32 #include "text-interface.hh"
35 UGH : this is full of C&P code. Consolidate! --hwn
39 Gregorian chant divisio minima. (Actually, this was the original
40 breathing sign by Michael. -- jr)
42 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1);
44 Breathing_sign::divisio_minima (SCM smob)
46 Grob *me = unsmob_grob (smob);
47 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);
52 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
55 * Draw a small vertical line through the uppermost (or, depending
56 * on direction, lowermost) staff line.
58 Interval xdim (0, thickness);
59 Interval ydim (-0.5 * staff_space, +0.5 * staff_space);
61 Stencil out = Lookup::round_filled_box (b, blotdiameter);
62 return out.smobbed_copy ();
66 Gregorian chant divisio maior.
68 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maior, 1);
70 Breathing_sign::divisio_maior (SCM smob)
72 Grob *me = unsmob_grob (smob);
73 Real thickness = Staff_symbol_referencer::line_thickness (me);
74 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
76 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
79 * Draw a vertical line that is vertically centered in the staff
80 * (just like a bar). The height of this line should be a little
81 * more than half the size of the staff, such that the endings of
82 * the line are in the middle of a staff space.
84 Interval ydim = Staff_symbol_referencer::staff_span (me);
85 ydim.widen (-0.25 * ydim.delta ());
88 int const int_dim = (int) ydim[i];
89 if (int_dim == ydim[i]
90 && Staff_symbol_referencer::on_staff_line (me, int_dim))
94 ydim *= 1.0 / Staff_symbol_referencer::staff_space (me);
96 Interval xdim (0, thickness);
98 Stencil out = Lookup::round_filled_box (b, blotdiameter);
99 return out.smobbed_copy ();
103 Gregorian chant divisio maxima.
105 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1);
107 Breathing_sign::divisio_maxima (SCM smob)
109 Grob *me = unsmob_grob (smob);
110 Real staff_space = Staff_symbol_referencer::staff_space (me);
111 Real thickness = Staff_symbol_referencer::line_thickness (me);
112 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
114 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
116 // like a "|" type bar
117 Interval xdim (0, thickness);
118 Interval ydim = Staff_symbol_referencer::staff_span (me);
119 ydim *= staff_space / 2;
121 Stencil out = Lookup::round_filled_box (b, blotdiameter);
122 return out.smobbed_copy ();
126 Gregorian chant finalis.
128 MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1);
130 Breathing_sign::finalis (SCM smob)
132 Grob *me = unsmob_grob (smob);
133 Real staff_space = Staff_symbol_referencer::staff_space (me);
134 Real thickness = Staff_symbol_referencer::line_thickness (me);
135 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
137 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
139 // like a "||" type bar
140 Interval xdim (0, thickness);
141 Interval ydim = Staff_symbol_referencer::staff_span (me);
142 ydim *= staff_space / 2;
144 Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
145 Stencil line2 (line1);
146 line2.translate_axis (0.5 * staff_space, X_AXIS);
147 line1.add_stencil (line2);
149 return line1.smobbed_copy ();
152 MAKE_SCHEME_CALLBACK (Breathing_sign, offset_callback, 1);
154 Breathing_sign::offset_callback (SCM smob)
156 Grob *me = unsmob_grob (smob);
158 Direction d = get_grob_direction (me);
162 set_grob_direction (me, d);
165 Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
168 Interval iv = Staff_symbol::line_span (staff);
169 Real inter = Staff_symbol::staff_space (staff) / 2;
170 return scm_from_double (inter * iv[d]);
173 return scm_from_double (0.0);
176 ADD_INTERFACE (Breathing_sign,