Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / breathing-sign.cc
blob09fd1d7c516e7b35cd1ce85f1e944d7b9869ebd1
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2011 Michael Krause
5 Extensions for ancient notation (c) 2003--2011 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 "staff-symbol-referencer.hh"
24 #include "directional-element-interface.hh"
25 #include "output-def.hh"
26 #include "lookup.hh"
27 #include "dimensions.hh"
28 #include "direction.hh"
29 #include "text-interface.hh"
30 #include "font-interface.hh"
31 #include "grob.hh"
34 TODO: thickness should be a grob property (unit: linethickness)
35 rather than hardwired to (staff_space / 6).
39 UGH : this is full of C&P code. Consolidate! --hwn
43 Gregorian chant divisio minima. (Actually, this was the original
44 breathing sign by Michael. -- jr)
46 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1);
47 SCM
48 Breathing_sign::divisio_minima (SCM smob)
50 Grob *me = unsmob_grob (smob);
51 Real staff_space = Staff_symbol_referencer::staff_space (me);
53 Real thickness = Staff_symbol_referencer::line_thickness (me);
54 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
56 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
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);
64 Box b (xdim, ydim);
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);
73 SCM
74 Breathing_sign::divisio_maior (SCM smob)
76 Grob *me = unsmob_grob (smob);
77 Real staff_space = Staff_symbol_referencer::staff_space (me);
78 Real staff_size;
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))
83 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
84 else
85 staff_size = 0.0;
87 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
90 * Draw a vertical line that is vertically centered in the staff
91 * (just like a bar). The height of this line should be a little
92 * more than half the size of the staff, such that the endings of
93 * the line are in the middle of a staff space.
95 int lines = Staff_symbol_referencer::line_count (me);
96 int height = lines / 2; // little more than half of staff size
97 if ((lines & 1) != (height & 1))
98 height++; // ensure endings are centered in staff space
100 Interval xdim (0, thickness);
101 Interval ydim (-0.5 * height, +0.5 * height);
102 Box b (xdim, ydim);
103 Stencil out = Lookup::round_filled_box (b, blotdiameter);
104 return out.smobbed_copy ();
108 Gregorian chant divisio maxima.
110 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1);
112 Breathing_sign::divisio_maxima (SCM smob)
114 Grob *me = unsmob_grob (smob);
115 Real staff_space = Staff_symbol_referencer::staff_space (me);
116 Real staff_size;
117 Real thickness = Staff_symbol_referencer::line_thickness (me);
118 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
120 if (Staff_symbol_referencer::get_staff_symbol (me))
121 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
122 else
123 staff_size = 0.0;
125 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
127 // like a "|" type bar
128 Interval xdim (0, thickness);
129 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
130 Box b (xdim, ydim);
131 Stencil out = Lookup::round_filled_box (b, blotdiameter);
132 return out.smobbed_copy ();
136 Gregorian chant finalis.
138 MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1);
140 Breathing_sign::finalis (SCM smob)
142 Grob *me = unsmob_grob (smob);
143 Real staff_space = Staff_symbol_referencer::staff_space (me);
144 Real staff_size;
145 Real thickness = Staff_symbol_referencer::line_thickness (me);
146 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
148 if (Staff_symbol_referencer::get_staff_symbol (me))
149 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
150 else
151 staff_size = 0.0;
153 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
155 // like a "||" type bar
156 Interval xdim (0, thickness);
157 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
158 Box b (xdim, ydim);
159 Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
160 Stencil line2 (line1);
161 line2.translate_axis (0.5 * staff_space, X_AXIS);
162 line1.add_stencil (line2);
164 return line1.smobbed_copy ();
167 MAKE_SCHEME_CALLBACK (Breathing_sign, offset_callback, 1);
169 Breathing_sign::offset_callback (SCM smob)
171 Grob *me = unsmob_grob (smob);
173 Direction d = get_grob_direction (me);
174 if (!d)
176 d = UP;
177 set_grob_direction (me, d);
180 Real inter = Staff_symbol_referencer::staff_space (me) / 2;
181 int sz = Staff_symbol_referencer::line_count (me) - 1;
182 return scm_from_double (inter * sz * d);
185 ADD_INTERFACE (Breathing_sign,
186 "A breathing sign.",
188 /* properties */
189 "direction "