LEFT | RIGHT |
(no file at all) | |
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--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1996--2011 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 return ly_interval2scm (sten->extent (X_AXIS) - stem->extent (stem, X_AXIS)[RI
GHT]); | 61 return ly_interval2scm (sten->extent (X_AXIS) - stem->extent (stem, X_AXIS)[RI
GHT]); |
62 } | 62 } |
63 MAKE_SCHEME_CALLBACK (Flag, print, 1); | 63 MAKE_SCHEME_CALLBACK (Flag, print, 1); |
64 SCM | 64 SCM |
65 Flag::print (SCM smob) | 65 Flag::print (SCM smob) |
66 { | 66 { |
67 Grob *me = unsmob_grob (smob); | 67 Grob *me = unsmob_grob (smob); |
68 Grob *stem = me->get_parent (X_AXIS); | 68 Grob *stem = me->get_parent (X_AXIS); |
69 | 69 |
| 70 Direction d = get_grob_direction (stem); |
70 int log = Stem::duration_log (stem); | 71 int log = Stem::duration_log (stem); |
71 string flag_style; | 72 string flag_style; |
72 | 73 |
73 SCM flag_style_scm = me->get_property ("style"); | 74 SCM flag_style_scm = me->get_property ("style"); |
74 if (scm_is_symbol (flag_style_scm)) | 75 if (scm_is_symbol (flag_style_scm)) |
75 flag_style = ly_symbol2string (flag_style_scm); | 76 flag_style = ly_symbol2string (flag_style_scm); |
76 | 77 |
77 if (flag_style == "no-flag") | 78 if (flag_style == "no-flag") |
78 return Stencil ().smobbed_copy (); | 79 return Stencil ().smobbed_copy (); |
79 | 80 |
80 bool adjust = true; | 81 bool adjust = true; |
81 | 82 |
82 string staffline_offs; | 83 string staffline_offs; |
83 if (flag_style == "mensural") | 84 if (flag_style == "mensural") |
84 /* Mensural notation: For notes on staff lines, use different | 85 /* Mensural notation: For notes on staff lines, use different |
85 flags than for notes between staff lines. The idea is that | 86 flags than for notes between staff lines. The idea is that |
86 flags are always vertically aligned with the staff lines, | 87 flags are always vertically aligned with the staff lines, |
87 regardless if the note head is on a staff line or between two | 88 regardless if the note head is on a staff line or between two |
88 staff lines. In other words, the inner end of a flag always | 89 staff lines. In other words, the inner end of a flag always |
89 touches a staff line. | 90 touches a staff line. |
90 */ | 91 */ |
91 { | 92 { |
92 if (adjust) | 93 if (adjust) |
93 { | 94 { |
94 int p = (int) (rint (Stem::stem_end_position (stem))); | 95 Real ss = Staff_symbol_referencer::staff_space (me); |
| 96 int p = (int) (rint (stem->extent (stem, Y_AXIS)[d] * 2 / ss)); |
95 staffline_offs | 97 staffline_offs |
96 = Staff_symbol_referencer::on_line (stem, p) ? "0" : "1"; | 98 = Staff_symbol_referencer::on_line (stem, p) ? "0" : "1"; |
97 } | 99 } |
98 else | 100 else |
99 staffline_offs = "2"; | 101 staffline_offs = "2"; |
100 } | 102 } |
101 else | 103 else |
102 staffline_offs = ""; | 104 staffline_offs = ""; |
103 | 105 |
104 char dir = (get_grob_direction (stem) == UP) ? 'u' : 'd'; | 106 char dir = (d == UP) ? 'u' : 'd'; |
105 string font_char = flag_style | 107 string font_char = flag_style |
106 + to_string (dir) + staffline_offs + to_string (log); | 108 + to_string (dir) + staffline_offs + to_string (log); |
107 Font_metric *fm = Font_interface::get_default_font (me); | 109 Font_metric *fm = Font_interface::get_default_font (me); |
108 Stencil flag = fm->find_by_name ("flags." + font_char); | 110 Stencil flag = fm->find_by_name ("flags." + font_char); |
109 if (flag.is_empty ()) | 111 if (flag.is_empty ()) |
110 me->warning (_f ("flag `%s' not found", font_char)); | 112 me->warning (_f ("flag `%s' not found", font_char)); |
111 | 113 |
112 /* | 114 /* |
113 TODO: maybe property stroke-style should take different values, | 115 TODO: maybe property stroke-style should take different values, |
114 e.g. "" (i.e. no stroke), "single" and "double" (currently, it's | 116 e.g. "" (i.e. no stroke), "single" and "double" (currently, it's |
(...skipping 24 matching lines...) Expand all Loading... |
139 MAKE_SCHEME_CALLBACK (Flag, calc_y_offset, 1); | 141 MAKE_SCHEME_CALLBACK (Flag, calc_y_offset, 1); |
140 SCM | 142 SCM |
141 Flag::calc_y_offset (SCM smob) | 143 Flag::calc_y_offset (SCM smob) |
142 { | 144 { |
143 Grob *me = unsmob_grob (smob); | 145 Grob *me = unsmob_grob (smob); |
144 Grob *stem = me->get_parent (X_AXIS); | 146 Grob *stem = me->get_parent (X_AXIS); |
145 Direction d = get_grob_direction (stem); | 147 Direction d = get_grob_direction (stem); |
146 | 148 |
147 Real blot | 149 Real blot |
148 = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); | 150 = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); |
149 Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5; | |
150 Real y2 = robust_scm2double (stem->get_property ("stem-end-position"), 0.0); | |
151 | 151 |
152 return scm_from_double (y2 * half_space - d * blot / 2); | 152 Real y2 = stem->extent (stem, Y_AXIS)[d]; |
| 153 |
| 154 return scm_from_double (y2 - d * blot / 2); |
153 } | 155 } |
154 | 156 |
155 MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1); | 157 MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1); |
156 SCM | 158 SCM |
157 Flag::calc_x_offset (SCM smob) | 159 Flag::calc_x_offset (SCM smob) |
158 { | 160 { |
159 Grob *me = unsmob_grob (smob); | 161 Grob *me = unsmob_grob (smob); |
160 Grob *stem = me->get_parent (X_AXIS); | 162 Grob *stem = me->get_parent (X_AXIS); |
161 return scm_from_double (stem->extent (stem, X_AXIS)[RIGHT]); | 163 return scm_from_double (stem->extent (stem, X_AXIS)[RIGHT]); |
162 } | 164 } |
163 | 165 |
164 ADD_INTERFACE (Flag, | 166 ADD_INTERFACE (Flag, |
165 "A flag that gets attached to a stem." | 167 "A flag that gets attached to a stem." |
166 "The style property is symbol determining" | 168 "The style property is symbol determining" |
167 " what style of flag glyph is typeset on a" | 169 " what style of flag glyph is typeset on a" |
168 " @code{Stem}. Valid options include @code{'()}" | 170 " @code{Stem}. Valid options include @code{'()}" |
169 " for standard flags, @code{'mensural} and" | 171 " for standard flags, @code{'mensural} and" |
170 " @code{'no-flag}, which switches off the flag.", | 172 " @code{'no-flag}, which switches off the flag.", |
171 | 173 |
172 /* properties */ | 174 /* properties */ |
173 "style " | 175 "style " |
174 "stroke-style " | 176 "stroke-style " |
175 ); | 177 ); |
LEFT | RIGHT |