OLD | NEW |
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) 1998--2015 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1998--2015 Jan Nieuwenhuizen <janneke@gnu.org> |
5 Han-Wen Nienhuys | 5 Han-Wen Nienhuys |
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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 Grob *common = left_edge; | 39 Grob *common = left_edge; |
40 | 40 |
41 if (right_text) | 41 if (right_text) |
42 common = common->common_refpoint (right_text, X_AXIS); | 42 common = common->common_refpoint (right_text, X_AXIS); |
43 | 43 |
44 common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS); | 44 common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS); |
45 common = common->common_refpoint (me->get_system (), X_AXIS); | 45 common = common->common_refpoint (me->get_system (), X_AXIS); |
46 | 46 |
47 Real sl = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); | 47 Real sl = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); |
| 48 bool start_of_part_b = |
| 49 !left_edge->internal_has_interface ( |
| 50 ly_symbol2scm ("lyric-syllable-interface")); |
| 51 bool end_of_part_a = me->get_bound (RIGHT)->break_status_dir (); |
| 52 bool force_extender = to_boolean (me->get_property ("force-extender")); |
| 53 bool no_extender = to_boolean (me->get_property ("no-extender")); |
| 54 |
| 55 if (!force_extender && no_extender) |
| 56 return SCM_EOL; |
48 | 57 |
49 extract_grob_set (me, "heads", heads); | 58 extract_grob_set (me, "heads", heads); |
50 | 59 |
51 if (!heads.size ()) | 60 int hs = heads.size (); |
| 61 |
| 62 while (hs && robust_scm2double (heads[hs-1]->get_property |
| 63 ("font-size"), 0) < 0) { |
| 64 hs = hs - 1; |
| 65 } |
| 66 |
| 67 if (!hs || (!force_extender |
| 68 && !start_of_part_b && !end_of_part_a && hs < 2)) |
52 return SCM_EOL; | 69 return SCM_EOL; |
53 | 70 |
54 common = common_refpoint_of_array (heads, common, X_AXIS); | 71 common = common_refpoint_of_array (heads, common, X_AXIS); |
55 | 72 |
56 Real left_point = 0.0; | 73 Real left_point = 0.0; |
57 if (left_edge->internal_has_interface (ly_symbol2scm ("lyric-syllable-interfac
e"))) | 74 if (!start_of_part_b) |
58 left_point = left_edge->extent (common, X_AXIS)[RIGHT]; | 75 left_point = left_edge->extent (common, X_AXIS)[RIGHT]; |
59 else if (heads.size ()) | 76 else |
60 left_point = heads[0]->extent (common, X_AXIS)[LEFT]; | 77 left_point = heads[0]->extent (common, X_AXIS)[LEFT]; |
61 else | |
62 left_point = left_edge->extent (common, X_AXIS)[RIGHT]; | |
63 | 78 |
64 if (isinf (left_point)) | 79 if (isinf (left_point)) |
65 return SCM_EOL; | 80 return SCM_EOL; |
66 | 81 |
67 /* It seems that short extenders are even lengthened to go past the | 82 Real h = sl * robust_scm2double (me->get_property ("thickness"), 0); |
68 note head, but haven't found a pattern in it yet. --hwn 1/1/04 */ | 83 Drul_array<Real> paddings ( |
69 SCM minlen = me->get_property ("minimum-length"); | 84 robust_scm2double (me->get_property ("left-padding"), h), |
70 Real right_point | 85 robust_scm2double (me->get_property ("right-padding"), h)); |
71 = left_point + (robust_scm2double (minlen, 0)); | 86 Real force_len = robust_scm2double (me->get_property ("force-length"), 0); |
| 87 Real collapse_len = robust_scm2double (me->get_property ("collapse-length"), |
| 88 0); |
72 | 89 |
73 right_point = min (right_point, me->get_system ()->get_bound (RIGHT)->relative
_coordinate (common, X_AXIS)); | 90 Real right_point = heads[hs-1]->extent (common, X_AXIS)[RIGHT]; |
74 | 91 |
75 if (heads.size ()) | 92 if (force_extender) |
76 right_point = max (right_point, heads.back ()->extent (common, X_AXIS)[RIGHT
]); | 93 right_point = max (heads[hs-1]->extent (common, X_AXIS)[RIGHT], |
77 | 94 left_point + force_len); |
78 Real h = sl * robust_scm2double (me->get_property ("thickness"), 0); | |
79 Drul_array<Real> paddings (robust_scm2double (me->get_property ("left-padding"
), h), | |
80 robust_scm2double (me->get_property ("right-padding
"), h)); | |
81 | 95 |
82 if (right_text) | 96 if (right_text) |
83 right_point = min (right_point, (robust_relative_extent (right_text, common,
X_AXIS)[LEFT] - paddings[RIGHT])); | 97 right_point = min (right_point, |
| 98 (robust_relative_extent (right_text, common, |
| 99 X_AXIS)[LEFT])); |
84 | 100 |
85 /* run to end of line. */ | 101 if (end_of_part_a) |
86 if (me->get_bound (RIGHT)->break_status_dir ()) | 102 right_point = robust_relative_extent (me->get_bound (RIGHT), |
87 right_point = max (right_point, (robust_relative_extent (me->get_bound (RIGH
T), common, X_AXIS)[LEFT] - paddings[RIGHT])); | 103 common, X_AXIS)[LEFT]; |
88 | 104 |
89 left_point += paddings[LEFT]; | 105 right_point -= paddings[RIGHT]; |
| 106 |
| 107 if (!start_of_part_b) |
| 108 left_point += paddings[LEFT]; |
| 109 |
90 Real w = right_point - left_point; | 110 Real w = right_point - left_point; |
91 | 111 |
92 if (w < 1.5 * h) | 112 if ((w <= 0) || (w < collapse_len && !force_extender &&· |
| 113 !end_of_part_a && !start_of_part_b)) |
93 return SCM_EOL; | 114 return SCM_EOL; |
94 | 115 |
95 Stencil mol (Lookup::round_filled_box (Box (Interval (0, w), | 116 Stencil mol (Lookup::round_filled_box (Box (Interval (0, w), |
96 Interval (0, h)), | 117 Interval (0, h)), |
97 0.8 * h)); | 118 0.8 * h)); |
98 mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS), | 119 mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS), |
99 X_AXIS); | 120 X_AXIS); |
100 return mol.smobbed_copy (); | 121 return mol.smobbed_copy (); |
101 } | 122 } |
102 | 123 |
103 ADD_INTERFACE (Lyric_extender, | 124 ADD_INTERFACE (Lyric_extender, |
104 "The extender is a simple line at the baseline of the lyric" | 125 "The extender is a simple line at the baseline of the lyric" |
105 " that helps show the length of a melisma (a tied or slurred" | 126 " that helps show the length of a melisma (a tied or slurred" |
106 " note).", | 127 " note).", |
107 | 128 |
108 /* properties */ | 129 /* properties */ |
| 130 "collapse-length " |
| 131 "force-extender " |
| 132 "force-length " |
109 "heads " | 133 "heads " |
110 "left-padding " | 134 "left-padding " |
111 "next " | 135 "next " |
| 136 "no-extender " |
112 "right-padding " | 137 "right-padding " |
113 "thickness " | 138 "thickness " |
114 ); | 139 ); |
OLD | NEW |