LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 Jan Nieuwenhuizen <janneke@gnu.org> | 5 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 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 | 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 | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "stencil.hh" | 29 #include "stencil.hh" |
30 #include "warn.hh" | 30 #include "warn.hh" |
31 | 31 |
32 class Flag | 32 class Flag |
33 { | 33 { |
34 public: | 34 public: |
35 DECLARE_SCHEME_CALLBACK (print, (SCM)); | 35 DECLARE_SCHEME_CALLBACK (print, (SCM)); |
36 DECLARE_SCHEME_CALLBACK (glyph_name, (SCM)); | 36 DECLARE_SCHEME_CALLBACK (glyph_name, (SCM)); |
37 DECLARE_SCHEME_CALLBACK (width, (SCM)); | 37 DECLARE_SCHEME_CALLBACK (width, (SCM)); |
38 DECLARE_SCHEME_CALLBACK (calc_y_offset, (SCM)); | 38 DECLARE_SCHEME_CALLBACK (calc_y_offset, (SCM)); |
| 39 DECLARE_SCHEME_CALLBACK (pure_calc_y_offset, (SCM, SCM, SCM)); |
39 DECLARE_SCHEME_CALLBACK (calc_x_offset, (SCM)); | 40 DECLARE_SCHEME_CALLBACK (calc_x_offset, (SCM)); |
40 DECLARE_GROB_INTERFACE (); | 41 DECLARE_GROB_INTERFACE (); |
| 42 |
| 43 static SCM internal_calc_y_offset (SCM smob, bool pure); |
41 }; | 44 }; |
42 | 45 |
43 MAKE_SCHEME_CALLBACK (Flag, width, 1); | 46 MAKE_SCHEME_CALLBACK (Flag, width, 1); |
44 SCM | 47 SCM |
45 Flag::width (SCM smob) | 48 Flag::width (SCM smob) |
46 { | 49 { |
47 Grob *me = unsmob_grob (smob); | 50 Grob *me = unsmob_grob (smob); |
48 Stencil *sten = unsmob_stencil (me->get_property ("stencil")); | 51 Stencil *sten = unsmob_stencil (me->get_property ("stencil")); |
49 if (!sten) | 52 if (!sten) |
50 return ly_interval2scm (Interval (0.0, 0.0)); | 53 return ly_interval2scm (Interval (0.0, 0.0)); |
51 | 54 |
52 Grob *stem = me->get_parent (X_AXIS); | 55 Grob *stem = me->get_parent (X_AXIS); |
53 | 56 |
54 /* | 57 /* |
55 TODO: | 58 TODO: |
56 This reproduces a bad hard-coding that has been in the code for quite some t
ime: | 59 This reproduces a bad hard-coding that has been in the code for quite some t
ime: |
57 the bounding boxes for the flags are slightly off and need to be fixed. | 60 the bounding boxes for the flags are slightly off and need to be fixed. |
58 */ | 61 */ |
59 | 62 |
60 return ly_interval2scm (sten->extent (X_AXIS) - stem->extent (stem, X_AXIS)[RI
GHT]); | 63 return ly_interval2scm (sten->extent (X_AXIS) - stem->extent (stem, X_AXIS)[RI
GHT]); |
61 } | 64 } |
62 | |
63 | 65 |
64 MAKE_SCHEME_CALLBACK (Flag, glyph_name, 1); | 66 MAKE_SCHEME_CALLBACK (Flag, glyph_name, 1); |
65 SCM | 67 SCM |
66 Flag::glyph_name (SCM smob) | 68 Flag::glyph_name (SCM smob) |
67 { | 69 { |
68 Grob *me = unsmob_grob (smob); | 70 Grob *me = unsmob_grob (smob); |
69 Grob *stem = me->get_parent (X_AXIS); | 71 Grob *stem = me->get_parent (X_AXIS); |
70 | 72 |
71 Direction d = get_grob_direction (stem); | 73 Direction d = get_grob_direction (stem); |
72 int log = Stem::duration_log (stem); | 74 int log = Stem::duration_log (stem); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 font_char = to_string (dir) + stroke_style; | 150 font_char = to_string (dir) + stroke_style; |
149 stroke = fm->find_by_name ("flags." + font_char); | 151 stroke = fm->find_by_name ("flags." + font_char); |
150 } | 152 } |
151 if (stroke.is_empty ()) | 153 if (stroke.is_empty ()) |
152 me->warning (_f ("flag stroke `%s' not found", font_char)); | 154 me->warning (_f ("flag stroke `%s' not found", font_char)); |
153 else | 155 else |
154 flag.add_stencil (stroke); | 156 flag.add_stencil (stroke); |
155 } | 157 } |
156 } | 158 } |
157 | 159 |
158 me->set_property ("stencil", flag.smobbed_copy ()); | |
159 me->set_property ("vertical-skylines-cache-name", scm_call_1 (ly_lily_module_c
onstant ("grob::make-vertical-skylines-cache-name"), smob)); | |
160 return flag.smobbed_copy (); | 160 return flag.smobbed_copy (); |
161 } | 161 } |
162 | 162 |
| 163 MAKE_SCHEME_CALLBACK (Flag, pure_calc_y_offset, 3); |
| 164 SCM |
| 165 Flag::pure_calc_y_offset (SCM smob, |
| 166 SCM /* beg */, |
| 167 SCM /* end */) |
| 168 { |
| 169 return internal_calc_y_offset (smob, true); |
| 170 } |
| 171 |
163 MAKE_SCHEME_CALLBACK (Flag, calc_y_offset, 1); | 172 MAKE_SCHEME_CALLBACK (Flag, calc_y_offset, 1); |
164 SCM | 173 SCM |
165 Flag::calc_y_offset (SCM smob) | 174 Flag::calc_y_offset (SCM smob) |
| 175 { |
| 176 return internal_calc_y_offset (smob, false); |
| 177 } |
| 178 |
| 179 SCM |
| 180 Flag::internal_calc_y_offset (SCM smob, bool pure) |
166 { | 181 { |
167 Grob *me = unsmob_grob (smob); | 182 Grob *me = unsmob_grob (smob); |
168 Grob *stem = me->get_parent (X_AXIS); | 183 Grob *stem = me->get_parent (X_AXIS); |
169 Direction d = get_grob_direction (stem); | 184 Direction d = get_grob_direction (stem); |
170 | 185 |
171 Real blot | 186 Real blot |
172 = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); | 187 = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); |
173 | 188 |
174 Real y2 = stem->extent (stem, Y_AXIS)[d]; | 189 Real y2 = pure |
| 190 ? stem->pure_height (stem, 0, INT_MAX)[d] |
| 191 : stem->extent (stem, Y_AXIS)[d]; |
175 | 192 |
176 return scm_from_double (y2 - d * blot / 2); | 193 return scm_from_double (y2 - d * blot / 2); |
177 } | 194 } |
178 | 195 |
179 MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1); | 196 MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1); |
180 SCM | 197 SCM |
181 Flag::calc_x_offset (SCM smob) | 198 Flag::calc_x_offset (SCM smob) |
182 { | 199 { |
183 Grob *me = unsmob_grob (smob); | 200 Grob *me = unsmob_grob (smob); |
184 Grob *stem = me->get_parent (X_AXIS); | 201 Grob *stem = me->get_parent (X_AXIS); |
185 return scm_from_double (stem->extent (stem, X_AXIS)[RIGHT]); | 202 return scm_from_double (stem->extent (stem, X_AXIS)[RIGHT]); |
186 } | 203 } |
187 | 204 |
188 ADD_INTERFACE (Flag, | 205 ADD_INTERFACE (Flag, |
189 "A flag that gets attached to a stem." | 206 "A flag that gets attached to a stem." |
190 "The style property is symbol determining" | 207 "The style property is symbol determining" |
191 " what style of flag glyph is typeset on a" | 208 " what style of flag glyph is typeset on a" |
192 " @code{Stem}. Valid options include @code{'()}" | 209 " @code{Stem}. Valid options include @code{'()}" |
193 " for standard flags, @code{'mensural} and" | 210 " for standard flags, @code{'mensural} and" |
194 " @code{'no-flag}, which switches off the flag.", | 211 " @code{'no-flag}, which switches off the flag.", |
195 | 212 |
196 /* properties */ | 213 /* properties */ |
197 "glyph-name " | 214 "glyph-name " |
198 "style " | 215 "style " |
199 "stroke-style " | 216 "stroke-style " |
200 "vertical-skylines-cache-name " | |
201 ); | 217 ); |
LEFT | RIGHT |