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) 2019--2020 David Nalesnik <david.nalesnik@gmail.com> | 4 Copyright (C) 2019--2020 David Nalesnik <david.nalesnik@gmail.com> |
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 |
11 LilyPond is distributed in the hope that it will be useful, | 11 LilyPond is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
20 | |
21 #include "measure-spanner.hh" | 20 #include "measure-spanner.hh" |
22 | 21 |
23 #include "bracket.hh" | 22 #include "bracket.hh" |
24 #include "output-def.hh" | 23 #include "output-def.hh" |
25 #include "font-interface.hh" | 24 #include "font-interface.hh" |
26 #include "text-interface.hh" | 25 #include "text-interface.hh" |
27 #include "directional-element-interface.hh" | 26 #include "directional-element-interface.hh" |
28 #include "spanner.hh" | 27 #include "spanner.hh" |
29 #include "paper-column.hh" | 28 #include "paper-column.hh" |
30 | 29 |
31 | |
32 MAKE_SCHEME_CALLBACK (Measure_spanner, calc_connect_to_neighbors, 1); | 30 MAKE_SCHEME_CALLBACK (Measure_spanner, calc_connect_to_neighbors, 1); |
33 SCM | 31 SCM |
34 Measure_spanner::calc_connect_to_neighbors (SCM smob) | 32 Measure_spanner::calc_connect_to_neighbors (SCM smob) |
35 { | 33 { |
36 Spanner *me = unsmob<Spanner> (smob); | 34 Spanner *me = unsmob<Spanner> (smob); |
37 | 35 |
38 Spanner *orig_spanner = me->original (); | 36 Spanner *orig_spanner = me->original (); |
39 if (!orig_spanner) return SCM_EOL; | 37 if (!orig_spanner) return SCM_EOL; |
40 | 38 |
41 Drul_array<Item *> bounds (me->get_bound (LEFT), | 39 Drul_array<Item *> bounds (me->get_bound (LEFT), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 73 |
76 /* should store note columns in engraver? */ | 74 /* should store note columns in engraver? */ |
77 Grob *common_x = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); | 75 Grob *common_x = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); |
78 Drul_array<Real> x_points; | 76 Drul_array<Real> x_points; |
79 | 77 |
80 SCM sp = me->get_property ("spacing-pair"); | 78 SCM sp = me->get_property ("spacing-pair"); |
81 SCM align_syms; | 79 SCM align_syms; |
82 | 80 |
83 for (LEFT_and_RIGHT (d)) | 81 for (LEFT_and_RIGHT (d)) |
84 { | 82 { |
85 align_syms = (scm_is_pair (sp) ? | 83 align_syms = (scm_is_pair (sp) |
86 » index_get_cell (sp, d) | 84 ? index_get_cell (sp, d) |
87 : ly_symbol2scm ("staff-bar")); | 85 : ly_symbol2scm ("staff-bar")); |
88 » x_points[d] = Paper_column::break_align_width (bounds[d], | 86 x_points[d] = Paper_column::break_align_width (bounds[d], |
89 » align_syms)[-d]; | 87 align_syms)[-d]; |
90 } | 88 } |
91 | 89 |
92 Stencil bracket_text; | 90 Stencil bracket_text; |
93 Interval gap_iv; | 91 Interval gap_iv; |
94 | 92 |
95 if (Text_interface::is_markup (txt)) | 93 if (Text_interface::is_markup (txt)) |
96 { | 94 { |
97 Output_def *pap = me->layout (); | 95 Output_def *pap = me->layout (); |
98 SCM properties = Font_interface::text_font_alist_chain (me); | 96 SCM properties = Font_interface::text_font_alist_chain (me); |
99 SCM t = Text_interface::interpret_markup (pap->self_scm (), | 97 SCM t = Text_interface::interpret_markup (pap->self_scm (), |
100 properties, txt); | 98 properties, txt); |
101 bracket_text = *unsmob<Stencil> (t); | 99 bracket_text = *unsmob<Stencil> (t); |
102 bracket_text.align_to (X_AXIS, CENTER); | 100 bracket_text.align_to (X_AXIS, CENTER); |
103 Interval stil_Y_ext = bracket_text.extent (Y_AXIS); | 101 Interval stil_Y_ext = bracket_text.extent (Y_AXIS); |
104 bracket_text.translate_axis ( | 102 bracket_text.translate_axis ((x_points[RIGHT] - x_points[LEFT]) / 2.0, X_A
XIS); |
105 (x_points[RIGHT] - x_points[LEFT]) / 2.0, X_AXIS); | |
106 bracket_text.translate_axis (-stil_Y_ext[UP] / 2.0, Y_AXIS); | 103 bracket_text.translate_axis (-stil_Y_ext[UP] / 2.0, Y_AXIS); |
107 Real gap = bracket_text.extent (X_AXIS).length (); | 104 Real gap = bracket_text.extent (X_AXIS).length (); |
108 gap_iv = Interval (-0.5, 0.5) * gap; | 105 gap_iv = Interval (-0.5, 0.5) * gap; |
109 gap_iv.widen (0.6); | 106 gap_iv.widen (0.6); |
110 } | 107 } |
111 | 108 |
112 if (ly_scm2bool (visible)) | 109 if (ly_scm2bool (visible)) |
113 brack = Bracket::make_axis_constrained_bracket ( | 110 brack = Bracket::make_axis_constrained_bracket (me, x_points[RIGHT] - x_poin
ts[LEFT], X_AXIS, |
114 me, x_points[RIGHT] - x_points[LEFT], X_AXIS, | 111 get_grob_direction (me), gap
_iv); |
115 get_grob_direction (me), gap_iv); | |
116 | 112 |
117 if (!bracket_text.is_empty ()) | 113 if (!bracket_text.is_empty ()) |
118 brack.add_stencil (bracket_text); | 114 brack.add_stencil (bracket_text); |
119 | 115 |
120 mol.add_stencil (brack); | 116 mol.add_stencil (brack); |
121 | 117 |
122 Real me_coord = me->relative_coordinate (common_x, X_AXIS); | 118 Real me_coord = me->relative_coordinate (common_x, X_AXIS); |
123 | 119 |
124 mol.translate_axis (x_points[LEFT] - me_coord, X_AXIS); | 120 mol.translate_axis (x_points[LEFT] - me_coord, X_AXIS); |
125 | 121 |
126 return mol.smobbed_copy (); | 122 return mol.smobbed_copy (); |
127 } | 123 } |
128 | 124 |
129 ADD_INTERFACE (Measure_spanner, | 125 ADD_INTERFACE (Measure_spanner, |
130 "A bracket aligned to a measure or measures.", | 126 "A bracket aligned to a measure or measures.", |
131 | 127 |
132 /* properties */ | 128 /* properties */ |
133 "bracket-flare " | 129 "bracket-flare " |
134 "bracket-visibility " | 130 "bracket-visibility " |
135 "connect-to-neighbor " | 131 "connect-to-neighbor " |
136 "direction " | 132 "direction " |
137 "edge-height " | 133 "edge-height " |
138 "padding " | 134 "padding " |
139 "shorten-pair " | 135 "shorten-pair " |
140 "spacing-pair " | 136 "spacing-pair " |
141 "staff-padding " | 137 "staff-padding " |
142 "thickness " | 138 "thickness " |
143 ); | 139 ); |
OLD | NEW |