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) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2015 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 /* Return the translation between 2 adjoining beams. */ | 112 /* Return the translation between 2 adjoining beams. */ |
113 Real | 113 Real |
114 Beam::get_beam_translation (Grob *me) | 114 Beam::get_beam_translation (Grob *me) |
115 { | 115 { |
116 int beam_count = get_beam_count (me); | 116 int beam_count = get_beam_count (me); |
117 Real staff_space = Staff_symbol_referencer::staff_space (me); | 117 Real staff_space = Staff_symbol_referencer::staff_space (me); |
118 Real line = Staff_symbol_referencer::line_thickness (me); | 118 Real line = Staff_symbol_referencer::line_thickness (me); |
119 Real beam_thickness = get_beam_thickness (me); | 119 Real beam_thickness = get_beam_thickness (me); |
120 Real fract = robust_scm2double (me->get_property ("length-fraction"), 1.0); | 120 Real fract = robust_scm2double (me->get_property ("length-fraction"), 1.0); |
121 | 121 |
122 Real beam_translation = beam_count < 4 | 122 /* |
123 ? (2 * staff_space + line - beam_thickness/fract) / 2.
0 | 123 if fract != 1.0, as is the case for grace notes, we want the gap |
124 : (3 * staff_space + line - beam_thickness/fract) / 3.
0; | 124 to decrease too. To achieve this, we divide the thickness by |
125 | 125 fract */ |
126 return fract * beam_translation; | 126 return (beam_count < 4 |
| 127 ? (2 * staff_space * fract + line * fract - beam_thickness) / 2.0 |
| 128 : (3 * staff_space * fract + line * fract - beam_thickness) / 3.0); |
127 } | 129 } |
128 | 130 |
129 /* Maximum beam_count. */ | 131 /* Maximum beam_count. */ |
130 int | 132 int |
131 Beam::get_beam_count (Grob *me) | 133 Beam::get_beam_count (Grob *me) |
132 { | 134 { |
133 int m = 0; | 135 int m = 0; |
134 | 136 |
135 extract_grob_set (me, "stems", stems); | 137 extract_grob_set (me, "stems", stems); |
136 for (vsize i = 0; i < stems.size (); i++) | 138 for (vsize i = 0; i < stems.size (); i++) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (is_direction (stem->get_property_data ("direction"))) | 198 if (is_direction (stem->get_property_data ("direction"))) |
197 dir = to_dir (stem->get_property_data ("direction")); | 199 dir = to_dir (stem->get_property_data ("direction")); |
198 else | 200 else |
199 dir = to_dir (stem->get_property ("default-direction")); | 201 dir = to_dir (stem->get_property ("default-direction")); |
200 | 202 |
201 extract_grob_set (stem, "note-heads", heads); | 203 extract_grob_set (stem, "note-heads", heads); |
202 /* default position of Kievan heads with beams is down | 204 /* default position of Kievan heads with beams is down |
203 placing this here avoids warnings downstream */ | 205 placing this here avoids warnings downstream */ |
204 if (heads.size()) | 206 if (heads.size()) |
205 { | 207 { |
206 if (heads[0]->get_property ("style") == ly_symbol2scm ("kievan")) | 208 if (scm_is_eq (heads[0]->get_property ("style"), |
| 209 ly_symbol2scm ("kievan"))) |
207 { | 210 { |
208 if (dir == CENTER) | 211 if (dir == CENTER) |
209 dir = DOWN; | 212 dir = DOWN; |
210 } | 213 } |
211 } | 214 } |
212 } | 215 } |
213 } | 216 } |
214 | 217 |
215 if (count >= 1) | 218 if (count >= 1) |
216 { | 219 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 252 |
250 int best_count = 0; | 253 int best_count = 0; |
251 int best_start = 0; | 254 int best_start = 0; |
252 for (int i = lslice[-left_dir]; | 255 for (int i = lslice[-left_dir]; |
253 (i - lslice[left_dir]) * left_dir <= 0; i += left_dir) | 256 (i - lslice[left_dir]) * left_dir <= 0; i += left_dir) |
254 { | 257 { |
255 int count = 0; | 258 int count = 0; |
256 for (SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s)) | 259 for (SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s)) |
257 { | 260 { |
258 int k = -right_dir * scm_to_int (scm_car (s)) + i; | 261 int k = -right_dir * scm_to_int (scm_car (s)) + i; |
259 if (scm_c_memq (scm_from_int (k), left_beaming) != SCM_BOOL_F) | 262 if (scm_is_true (scm_c_memq (scm_from_int (k), left_beaming))) |
260 count++; | 263 count++; |
261 } | 264 } |
262 | 265 |
263 if (count >= best_count) | 266 if (count >= best_count) |
264 { | 267 { |
265 best_count = count; | 268 best_count = count; |
266 best_start = i; | 269 best_start = i; |
267 } | 270 } |
268 } | 271 } |
269 | 272 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 extract_grob_set (me, "normal-stems", stems); | 866 extract_grob_set (me, "normal-stems", stems); |
864 | 867 |
865 Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); | 868 Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); |
866 Real staff_space = Staff_symbol_referencer::staff_space (me); | 869 Real staff_space = Staff_symbol_referencer::staff_space (me); |
867 | 870 |
868 vector<Interval> head_extents_array; | 871 vector<Interval> head_extents_array; |
869 for (vsize i = 0; i < stems.size (); i++) | 872 for (vsize i = 0; i < stems.size (); i++) |
870 { | 873 { |
871 Grob *stem = stems[i]; | 874 Grob *stem = stems[i]; |
872 | 875 |
873 Interval head_extents = Stem::head_positions (stem); | 876 Interval head_extents; |
874 if (!head_extents.is_empty ()) | 877 if (Stem::head_count (stem)) |
875 { | 878 { |
876 head_extents[LEFT] += -1; | 879 head_extents = Stem::head_positions (stem); |
877 head_extents[RIGHT] += 1; | 880 head_extents.widen (1); |
878 head_extents *= staff_space * 0.5; | 881 head_extents *= staff_space * 0.5; |
879 | 882 |
880 /* | 883 /* |
881 We could subtract beam Y position, but this routine only | 884 We could subtract beam Y position, but this routine only |
882 sets stem directions, a constant shift does not have an | 885 sets stem directions, a constant shift does not have an |
883 influence. | 886 influence. |
884 */ | 887 */ |
885 head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX); | 888 head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX); |
886 | 889 |
887 if (to_dir (stem->get_property_data ("direction"))) | 890 if (to_dir (stem->get_property_data ("direction"))) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 */ | 957 */ |
955 if (is_knee (me)) | 958 if (is_knee (me)) |
956 return scm_from_int (0); | 959 return scm_from_int (0); |
957 | 960 |
958 Real forced_fraction = 1.0 * forced_stem_count (me) | 961 Real forced_fraction = 1.0 * forced_stem_count (me) |
959 / normal_stem_count (me); | 962 / normal_stem_count (me); |
960 | 963 |
961 int beam_count = get_beam_count (me); | 964 int beam_count = get_beam_count (me); |
962 | 965 |
963 SCM shorten_list = me->get_property ("beamed-stem-shorten"); | 966 SCM shorten_list = me->get_property ("beamed-stem-shorten"); |
964 if (shorten_list == SCM_EOL) | 967 if (scm_is_null (shorten_list)) |
965 return scm_from_int (0); | 968 return scm_from_int (0); |
966 | 969 |
967 Real staff_space = Staff_symbol_referencer::staff_space (me); | 970 Real staff_space = Staff_symbol_referencer::staff_space (me); |
968 | 971 |
969 SCM shorten_elt | 972 SCM shorten_elt |
970 = robust_list_ref (beam_count - 1, shorten_list); | 973 = robust_list_ref (beam_count - 1, shorten_list); |
971 Real shorten = scm_to_double (shorten_elt) * staff_space; | 974 Real shorten = scm_to_double (shorten_elt) * staff_space; |
972 | 975 |
973 shorten *= forced_fraction; | 976 shorten *= forced_fraction; |
974 | 977 |
(...skipping 21 matching lines...) Expand all Loading... |
996 Report slice containing the numbers that are both in (car BEAMING) | 999 Report slice containing the numbers that are both in (car BEAMING) |
997 and (cdr BEAMING) | 1000 and (cdr BEAMING) |
998 */ | 1001 */ |
999 Slice | 1002 Slice |
1000 where_are_the_whole_beams (SCM beaming) | 1003 where_are_the_whole_beams (SCM beaming) |
1001 { | 1004 { |
1002 Slice l; | 1005 Slice l; |
1003 | 1006 |
1004 for (SCM s = scm_car (beaming); scm_is_pair (s); s = scm_cdr (s)) | 1007 for (SCM s = scm_car (beaming); scm_is_pair (s); s = scm_cdr (s)) |
1005 { | 1008 { |
1006 if (scm_c_memq (scm_car (s), scm_cdr (beaming)) != SCM_BOOL_F) | 1009 if (scm_is_true (scm_c_memq (scm_car (s), scm_cdr (beaming)))) |
1007 | 1010 |
1008 l.add_point (scm_to_int (scm_car (s))); | 1011 l.add_point (scm_to_int (scm_car (s))); |
1009 } | 1012 } |
1010 | 1013 |
1011 return l; | 1014 return l; |
1012 } | 1015 } |
1013 | 1016 |
1014 /* Return the Y position of the stem-end, given the Y-left, Y-right | 1017 /* Return the Y position of the stem-end, given the Y-left, Y-right |
1015 in POS for stem S. This Y position is relative to S. */ | 1018 in POS for stem S. This Y position is relative to S. */ |
1016 Real | 1019 Real |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1135 |
1133 for (vsize i = 0; i < stems.size (); i++) | 1136 for (vsize i = 0; i < stems.size (); i++) |
1134 { | 1137 { |
1135 /* | 1138 /* |
1136 Don't overwrite user settings. | 1139 Don't overwrite user settings. |
1137 */ | 1140 */ |
1138 for (LEFT_and_RIGHT (d)) | 1141 for (LEFT_and_RIGHT (d)) |
1139 { | 1142 { |
1140 Grob *stem = stems[i]; | 1143 Grob *stem = stems[i]; |
1141 SCM beaming_prop = stem->get_property ("beaming"); | 1144 SCM beaming_prop = stem->get_property ("beaming"); |
1142 if (beaming_prop == SCM_EOL | 1145 if (scm_is_null (beaming_prop) |
1143 || index_get_cell (beaming_prop, d) == SCM_EOL) | 1146 || scm_is_null (index_get_cell (beaming_prop, d))) |
1144 { | 1147 { |
1145 int count = beaming->beamlet_count (i, d); | 1148 int count = beaming->beamlet_count (i, d); |
1146 if (i > 0 | 1149 if (i > 0 |
1147 && i + 1 < stems.size () | 1150 && i + 1 < stems.size () |
1148 && Stem::is_invisible (stem)) | 1151 && Stem::is_invisible (stem)) |
1149 count = min (count, beaming->beamlet_count (i, -d)); | 1152 count = min (count, beaming->beamlet_count (i, -d)); |
1150 | 1153 |
1151 if ( ((i == 0 && d == LEFT) | 1154 if ( ((i == 0 && d == LEFT) |
1152 || (i == stems.size () - 1 && d == RIGHT)) | 1155 || (i == stems.size () - 1 && d == RIGHT)) |
1153 && stems.size () > 1 | 1156 && stems.size () > 1 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 "least-squares-dy " | 1507 "least-squares-dy " |
1505 "neutral-direction " | 1508 "neutral-direction " |
1506 "normal-stems " | 1509 "normal-stems " |
1507 "positions " | 1510 "positions " |
1508 "quantized-positions " | 1511 "quantized-positions " |
1509 "shorten " | 1512 "shorten " |
1510 "skip-quanting " | 1513 "skip-quanting " |
1511 "stems " | 1514 "stems " |
1512 "X-positions " | 1515 "X-positions " |
1513 ); | 1516 ); |
LEFT | RIGHT |