Correct left text alignment of DynamicTextSpanner.
[lilypond.git] / lily / breathing-sign.cc
blob7c605c4b1950c0012c3026a025d22b27d386b0e2
1 /*
2 breathing_sign.cc -- implement Breathing_sign
4 (c) 1999--2007 Michael Krause
6 written for the GNU LilyPond music typesetter
8 TODO: --> see breathing-sign-engraver.cc
10 Extensions for ancient notation (c) 2003--2007 by Juergen Reuter
13 #include "breathing-sign.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "directional-element-interface.hh"
17 #include "output-def.hh"
18 #include "lookup.hh"
19 #include "dimensions.hh"
20 #include "direction.hh"
21 #include "text-interface.hh"
22 #include "font-interface.hh"
23 #include "grob.hh"
26 TODO: thickness should be a grob property (unit: linethickness)
27 rather than hardwired to (staff_space / 6).
31 UGH : this is full of C&P code. Consolidate! --hwn
35 Gregorian chant divisio minima. (Actually, this was the original
36 breathing sign by Michael. -- jr)
38 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1);
39 SCM
40 Breathing_sign::divisio_minima (SCM smob)
42 Grob *me = unsmob_grob (smob);
43 Real staff_space = Staff_symbol_referencer::staff_space (me);
45 Real thickness = Staff_symbol_referencer::line_thickness (me);
46 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
48 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
51 * Draw a small vertical line through the uppermost (or, depending
52 * on direction, lowermost) staff line.
54 Interval xdim (0, thickness);
55 Interval ydim (-0.5 * staff_space, +0.5 * staff_space);
56 Box b (xdim, ydim);
57 Stencil out = Lookup::round_filled_box (b, blotdiameter);
58 return out.smobbed_copy ();
62 Gregorian chant divisio maior.
64 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maior, 1);
65 SCM
66 Breathing_sign::divisio_maior (SCM smob)
68 Grob *me = unsmob_grob (smob);
69 Real staff_space = Staff_symbol_referencer::staff_space (me);
70 Real staff_size;
71 Real thickness = Staff_symbol_referencer::line_thickness (me);
72 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
74 if (Staff_symbol_referencer::get_staff_symbol (me))
75 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
76 else
77 staff_size = 0.0;
79 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
82 * Draw a vertical line that is vertically centered in the staff
83 * (just like a bar). The height of this line should be a little
84 * more than half the size of the staff, such that the endings of
85 * the line are in the middle of a staff space.
87 int lines = Staff_symbol_referencer::line_count (me);
88 int height = lines / 2; // little more than half of staff size
89 if ((lines & 1) != (height & 1))
90 height++; // ensure endings are centered in staff space
92 Interval xdim (0, thickness);
93 Interval ydim (-0.5 * height, +0.5 * height);
94 Box b (xdim, ydim);
95 Stencil out = Lookup::round_filled_box (b, blotdiameter);
96 return out.smobbed_copy ();
100 Gregorian chant divisio maxima.
102 MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1);
104 Breathing_sign::divisio_maxima (SCM smob)
106 Grob *me = unsmob_grob (smob);
107 Real staff_space = Staff_symbol_referencer::staff_space (me);
108 Real staff_size;
109 Real thickness = Staff_symbol_referencer::line_thickness (me);
110 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
112 if (Staff_symbol_referencer::get_staff_symbol (me))
113 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
114 else
115 staff_size = 0.0;
117 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
119 // like a "|" type bar
120 Interval xdim (0, thickness);
121 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
122 Box b (xdim, ydim);
123 Stencil out = Lookup::round_filled_box (b, blotdiameter);
124 return out.smobbed_copy ();
128 Gregorian chant finalis.
130 MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1);
132 Breathing_sign::finalis (SCM smob)
134 Grob *me = unsmob_grob (smob);
135 Real staff_space = Staff_symbol_referencer::staff_space (me);
136 Real staff_size;
137 Real thickness = Staff_symbol_referencer::line_thickness (me);
138 thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
140 if (Staff_symbol_referencer::get_staff_symbol (me))
141 staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
142 else
143 staff_size = 0.0;
145 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
147 // like a "||" type bar
148 Interval xdim (0, thickness);
149 Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
150 Box b (xdim, ydim);
151 Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
152 Stencil line2 (line1);
153 line2.translate_axis (0.5 * staff_space, X_AXIS);
154 line1.add_stencil (line2);
156 return line1.smobbed_copy ();
159 MAKE_SCHEME_CALLBACK (Breathing_sign, offset_callback, 1);
161 Breathing_sign::offset_callback (SCM smob)
163 Grob *me = unsmob_grob (smob);
165 Direction d = get_grob_direction (me);
166 if (!d)
168 d = UP;
169 set_grob_direction (me, d);
172 Real inter = Staff_symbol_referencer::staff_space (me) / 2;
173 int sz = Staff_symbol_referencer::line_count (me) - 1;
174 return scm_from_double (inter * sz * d);
177 ADD_INTERFACE (Breathing_sign,
178 "A breathing sign.",
180 /* properties */
181 "direction "