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--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 15 matching lines...) Expand all Loading... |
26 #include "international.hh" | 26 #include "international.hh" |
27 #include "output-def.hh" | 27 #include "output-def.hh" |
28 #include "staff-symbol-referencer.hh" | 28 #include "staff-symbol-referencer.hh" |
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 (width, (SCM)); | 37 DECLARE_SCHEME_CALLBACK (width, (SCM)); |
37 DECLARE_SCHEME_CALLBACK (calc_y_offset, (SCM)); | 38 DECLARE_SCHEME_CALLBACK (calc_y_offset, (SCM)); |
38 DECLARE_SCHEME_CALLBACK (pure_calc_y_offset, (SCM, SCM, 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 (); |
41 | 42 |
42 static SCM internal_calc_y_offset (SCM smob, bool pure); | 43 static SCM internal_calc_y_offset (SCM smob, bool pure); |
43 }; | 44 }; |
44 | 45 |
45 MAKE_SCHEME_CALLBACK (Flag, width, 1); | 46 MAKE_SCHEME_CALLBACK (Flag, width, 1); |
46 SCM | 47 SCM |
47 Flag::width (SCM smob) | 48 Flag::width (SCM smob) |
48 { | 49 { |
49 Grob *me = unsmob_grob (smob); | 50 Grob *me = unsmob_grob (smob); |
50 Stencil *sten = unsmob_stencil (me->get_property ("stencil")); | 51 Stencil *sten = unsmob_stencil (me->get_property ("stencil")); |
51 if (!sten) | 52 if (!sten) |
52 return ly_interval2scm (Interval (0.0, 0.0)); | 53 return ly_interval2scm (Interval (0.0, 0.0)); |
53 | 54 |
54 Grob *stem = me->get_parent (X_AXIS); | 55 Grob *stem = me->get_parent (X_AXIS); |
55 | 56 |
56 /* | 57 /* |
57 TODO: | 58 TODO: |
58 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: |
59 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. |
60 */ | 61 */ |
61 | 62 |
62 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]); |
63 } | 64 } |
64 MAKE_SCHEME_CALLBACK (Flag, print, 1); | 65 |
65 SCM | 66 MAKE_SCHEME_CALLBACK (Flag, glyph_name, 1); |
66 Flag::print (SCM smob) | 67 SCM |
| 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); |
73 string flag_style; | 75 string flag_style; |
74 | 76 |
75 SCM flag_style_scm = me->get_property ("style"); | 77 SCM flag_style_scm = me->get_property ("style"); |
76 if (scm_is_symbol (flag_style_scm)) | 78 if (scm_is_symbol (flag_style_scm)) |
77 flag_style = ly_symbol2string (flag_style_scm); | 79 flag_style = ly_symbol2string (flag_style_scm); |
78 | |
79 if (flag_style == "no-flag") | |
80 return Stencil ().smobbed_copy (); | |
81 | 80 |
82 bool adjust = true; | 81 bool adjust = true; |
83 | 82 |
84 string staffline_offs; | 83 string staffline_offs; |
85 if (flag_style == "mensural") | 84 if (flag_style == "mensural") |
86 /* Mensural notation: For notes on staff lines, use different | 85 /* Mensural notation: For notes on staff lines, use different |
87 flags than for notes between staff lines. The idea is that | 86 flags than for notes between staff lines. The idea is that |
88 flags are always vertically aligned with the staff lines, | 87 flags are always vertically aligned with the staff lines, |
89 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 |
90 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 |
91 touches a staff line. | 90 touches a staff line. |
92 */ | 91 */ |
93 { | 92 { |
94 if (adjust) | 93 if (adjust) |
95 { | 94 { |
96 Real ss = Staff_symbol_referencer::staff_space (me); | 95 Real ss = Staff_symbol_referencer::staff_space (me); |
97 int p = (int) (rint (stem->extent (stem, Y_AXIS)[d] * 2 / ss)); | 96 int p = (int) (rint (stem->extent (stem, Y_AXIS)[d] * 2 / ss)); |
98 staffline_offs | 97 staffline_offs |
99 = Staff_symbol_referencer::on_line (stem, p) ? "0" : "1"; | 98 = Staff_symbol_referencer::on_line (stem, p) ? "0" : "1"; |
100 } | 99 } |
101 else | 100 else |
102 staffline_offs = "2"; | 101 staffline_offs = "2"; |
103 } | 102 } |
104 else | 103 else |
105 staffline_offs = ""; | 104 staffline_offs = ""; |
106 | 105 |
107 char dir = (d == UP) ? 'u' : 'd'; | 106 char dir = (d == UP) ? 'u' : 'd'; |
108 string font_char = flag_style | 107 string font_char = flag_style |
109 + to_string (dir) + staffline_offs + to_string (log); | 108 + to_string (dir) + staffline_offs + to_string (log); |
| 109 return ly_string2scm ("flags." + font_char); |
| 110 } |
| 111 |
| 112 MAKE_SCHEME_CALLBACK (Flag, print, 1); |
| 113 SCM |
| 114 Flag::print (SCM smob) |
| 115 { |
| 116 Grob *me = unsmob_grob (smob); |
| 117 Grob *stem = me->get_parent (X_AXIS); |
| 118 |
| 119 Direction d = get_grob_direction (stem); |
| 120 string flag_style; |
| 121 |
| 122 SCM flag_style_scm = me->get_property ("style"); |
| 123 if (scm_is_symbol (flag_style_scm)) |
| 124 flag_style = ly_symbol2string (flag_style_scm); |
| 125 |
| 126 if (flag_style == "no-flag") |
| 127 return Stencil ().smobbed_copy (); |
| 128 |
| 129 char dir = (d == UP) ? 'u' : 'd'; |
110 Font_metric *fm = Font_interface::get_default_font (me); | 130 Font_metric *fm = Font_interface::get_default_font (me); |
111 Stencil flag = fm->find_by_name ("flags." + font_char); | 131 string font_char = robust_scm2string (me->get_property ("glyph-name"), ""); |
| 132 Stencil flag = fm->find_by_name (font_char); |
112 if (flag.is_empty ()) | 133 if (flag.is_empty ()) |
113 me->warning (_f ("flag `%s' not found", font_char)); | 134 me->warning (_f ("flag `%s' not found", font_char)); |
114 | 135 |
115 /* | 136 /* |
116 TODO: maybe property stroke-style should take different values, | 137 TODO: maybe property stroke-style should take different values, |
117 e.g. "" (i.e. no stroke), "single" and "double" (currently, it's | 138 e.g. "" (i.e. no stroke), "single" and "double" (currently, it's |
118 '() or "grace"). */ | 139 '() or "grace"). */ |
119 SCM stroke_style_scm = me->get_property ("stroke-style"); | 140 SCM stroke_style_scm = me->get_property ("stroke-style"); |
120 if (scm_is_string (stroke_style_scm)) | 141 if (scm_is_string (stroke_style_scm)) |
121 { | 142 { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 204 |
184 ADD_INTERFACE (Flag, | 205 ADD_INTERFACE (Flag, |
185 "A flag that gets attached to a stem." | 206 "A flag that gets attached to a stem." |
186 "The style property is symbol determining" | 207 "The style property is symbol determining" |
187 " what style of flag glyph is typeset on a" | 208 " what style of flag glyph is typeset on a" |
188 " @code{Stem}. Valid options include @code{'()}" | 209 " @code{Stem}. Valid options include @code{'()}" |
189 " for standard flags, @code{'mensural} and" | 210 " for standard flags, @code{'mensural} and" |
190 " @code{'no-flag}, which switches off the flag.", | 211 " @code{'no-flag}, which switches off the flag.", |
191 | 212 |
192 /* properties */ | 213 /* properties */ |
| 214 "glyph-name " |
193 "style " | 215 "style " |
194 "stroke-style " | 216 "stroke-style " |
195 ); | 217 ); |
LEFT | RIGHT |