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) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 SCM | 49 SCM |
50 Ottava_bracket::print (SCM smob) | 50 Ottava_bracket::print (SCM smob) |
51 { | 51 { |
52 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob)); | 52 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob)); |
53 Interval span_points; | 53 Interval span_points; |
54 | 54 |
55 Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X
_AXIS); | 55 Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X
_AXIS); |
56 Output_def *layout = me->layout (); | 56 Output_def *layout = me->layout (); |
57 | 57 |
58 Drul_array<bool> broken; | 58 Drul_array<bool> broken; |
59 Direction d = LEFT; | 59 for (LEFT_and_RIGHT (d)) |
60 do | |
61 { | 60 { |
62 Item *b = me->get_bound (d); | 61 Item *b = me->get_bound (d); |
63 broken[d] = (b->break_status_dir () != CENTER); | 62 broken[d] = (b->break_status_dir () != CENTER); |
64 | 63 |
65 if (Note_column::has_interface (b)) | 64 if (Note_column::has_interface (b)) |
66 { | 65 { |
67 extract_grob_set (b, "note-heads", heads); | 66 extract_grob_set (b, "note-heads", heads); |
68 common = common_refpoint_of_array (heads, common, X_AXIS); | 67 common = common_refpoint_of_array (heads, common, X_AXIS); |
69 for (vsize i = 0; i < heads.size (); i++) | 68 for (vsize i = 0; i < heads.size (); i++) |
70 { | 69 { |
71 Grob *h = heads[i]; | 70 Grob *h = heads[i]; |
72 Grob *dots = Rhythmic_head::get_dots (h); | 71 Grob *dots = Rhythmic_head::get_dots (h); |
73 if (dots) | 72 if (dots) |
74 common = dots->common_refpoint (common, X_AXIS); | 73 common = dots->common_refpoint (common, X_AXIS); |
75 } | 74 } |
76 } | 75 } |
77 } | 76 } |
78 while (flip (&d) != LEFT); | |
79 | 77 |
80 SCM properties = Font_interface::text_font_alist_chain (me); | 78 SCM properties = Font_interface::text_font_alist_chain (me); |
81 SCM markup = me->get_property ("text"); | 79 SCM markup = me->get_property ("text"); |
82 Stencil text; | 80 Stencil text; |
83 if (Text_interface::is_markup (markup)) | 81 if (Text_interface::is_markup (markup)) |
84 text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (
), | 82 text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (
), |
85 properties, markup
)); | 83 properties, markup
)); |
86 | 84 |
87 Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pai
r"), | 85 Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pai
r"), |
88 Interval (0, 0)); | 86 Interval (0, 0)); |
89 | 87 |
90 /* | 88 /* |
91 TODO: we should check if there are ledgers, and modify length of | 89 TODO: we should check if there are ledgers, and modify length of |
92 the spanner to that. | 90 the spanner to that. |
93 */ | 91 */ |
94 do | 92 for (LEFT_and_RIGHT (d)) |
95 { | 93 { |
96 Item *b = me->get_bound (d); | 94 Item *b = me->get_bound (d); |
97 | 95 |
98 Interval ext; | 96 Interval ext; |
99 if (Note_column::has_interface (b)) | 97 if (Note_column::has_interface (b)) |
100 { | 98 { |
101 extract_grob_set (b, "note-heads", heads); | 99 extract_grob_set (b, "note-heads", heads); |
102 for (vsize i = 0; i < heads.size (); i++) | 100 for (vsize i = 0; i < heads.size (); i++) |
103 { | 101 { |
104 Grob *h = heads[i]; | 102 Grob *h = heads[i]; |
(...skipping 10 matching lines...) Expand all Loading... |
115 | 113 |
116 if (broken[d]) | 114 if (broken[d]) |
117 { | 115 { |
118 span_points[d] = Axis_group_interface::generic_bound_extent (b, common
, X_AXIS)[RIGHT]; | 116 span_points[d] = Axis_group_interface::generic_bound_extent (b, common
, X_AXIS)[RIGHT]; |
119 shorten[d] = 0.; | 117 shorten[d] = 0.; |
120 } | 118 } |
121 | 119 |
122 else | 120 else |
123 span_points[d] = ext[d]; | 121 span_points[d] = ext[d]; |
124 } | 122 } |
125 while (flip (&d) != LEFT); | |
126 | 123 |
127 /* | 124 /* |
128 0.3 is ~ italic correction. | 125 0.3 is ~ italic correction. |
129 */ | 126 */ |
130 Real text_size = text.extent (X_AXIS).is_empty () | 127 Real text_size = text.extent (X_AXIS).is_empty () |
131 ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; | 128 ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; |
132 | 129 |
133 span_points[LEFT] | 130 span_points[LEFT] |
134 = min (span_points[LEFT], | 131 = min (span_points[LEFT], |
135 (span_points[RIGHT] - text_size | 132 (span_points[RIGHT] - text_size |
136 - robust_scm2double (me->get_property ("minimum-length"), -1.0))); | 133 - robust_scm2double (me->get_property ("minimum-length"), -1.0))); |
137 | 134 |
138 Interval bracket_span_points = span_points; | 135 Interval bracket_span_points = span_points; |
139 bracket_span_points[LEFT] += text_size; | 136 bracket_span_points[LEFT] += text_size; |
140 | 137 |
141 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-he
ight"), | 138 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-he
ight"), |
142 Interval (1.0, 1.0)); | 139 Interval (1.0, 1.0)); |
143 | 140 |
144 Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare
"), | 141 Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare
"), |
145 Interval (0, 0)); | 142 Interval (0, 0)); |
146 | 143 |
147 do | 144 for (LEFT_and_RIGHT (d)) |
148 { | 145 { |
149 edge_height[d] *= -get_grob_direction (me); | 146 edge_height[d] *= -get_grob_direction (me); |
150 if (broken[d]) | 147 if (broken[d]) |
151 edge_height[d] = 0.0; | 148 edge_height[d] = 0.0; |
152 } | 149 } |
153 while (flip (&d) != LEFT); | |
154 | 150 |
155 Stencil b; | 151 Stencil b; |
156 Interval empty; | 152 Interval empty; |
157 if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001) | 153 if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001) |
158 b = Tuplet_bracket::make_bracket (me, | 154 b = Tuplet_bracket::make_bracket (me, |
159 Y_AXIS, Offset (bracket_span_points.length
(), 0), | 155 Y_AXIS, Offset (bracket_span_points.length
(), 0), |
160 edge_height, | 156 edge_height, |
161 empty, | 157 empty, |
162 flare, shorten); | 158 flare, shorten); |
163 | 159 |
(...skipping 29 matching lines...) Expand all Loading... |
193 ADD_INTERFACE (Ottava_bracket, | 189 ADD_INTERFACE (Ottava_bracket, |
194 "An ottava bracket.", | 190 "An ottava bracket.", |
195 | 191 |
196 /* properties */ | 192 /* properties */ |
197 "edge-height " | 193 "edge-height " |
198 "bracket-flare " | 194 "bracket-flare " |
199 "shorten-pair " | 195 "shorten-pair " |
200 "minimum-length " | 196 "minimum-length " |
201 ); | 197 ); |
202 | 198 |
OLD | NEW |