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) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org> |
5 Han-Wen Nienhuys <hanwen@xs4all.nl> | 5 Han-Wen Nienhuys <hanwen@xs4all.nl> |
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. |
11 | 11 |
12 LilyPond is distributed in the hope that it will be useful, | 12 LilyPond is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
19 */ | 19 */ |
20 | 20 |
21 #include "hara-kiri-group-spanner.hh" | 21 #include "hara-kiri-group-spanner.hh" |
22 | 22 |
23 #include "paper-column.hh" | 23 #include "paper-column.hh" |
24 #include "pointer-group-interface.hh" | 24 #include "pointer-group-interface.hh" |
25 #include "axis-group-interface.hh" | 25 #include "axis-group-interface.hh" |
26 #include "spanner.hh" | 26 #include "spanner.hh" |
| 27 #include "system.hh" |
27 #include "warn.hh" | 28 #include "warn.hh" |
28 | 29 |
29 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, y_extent, 1); | 30 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, y_extent, 1); |
30 SCM | 31 SCM |
31 Hara_kiri_group_spanner::y_extent (SCM smob) | 32 Hara_kiri_group_spanner::y_extent (SCM smob) |
32 { | 33 { |
33 Grob *me = unsmob_grob (smob); | 34 Grob *me = unsmob_grob (smob); |
34 consider_suicide (me); | 35 consider_suicide (me); |
35 return Axis_group_interface::generic_group_extent (me, Y_AXIS); | 36 return Axis_group_interface::generic_group_extent (me, Y_AXIS); |
36 } | 37 } |
(...skipping 13 matching lines...) Expand all Loading... |
50 { | 51 { |
51 Grob *me = unsmob_grob (smob); | 52 Grob *me = unsmob_grob (smob); |
52 int start = robust_scm2int (start_scm, 0); | 53 int start = robust_scm2int (start_scm, 0); |
53 int end = robust_scm2int (end_scm, INT_MAX); | 54 int end = robust_scm2int (end_scm, INT_MAX); |
54 | 55 |
55 if (request_suicide (me, start, end)) | 56 if (request_suicide (me, start, end)) |
56 return ly_interval2scm (Interval ()); | 57 return ly_interval2scm (Interval ()); |
57 | 58 |
58 return ly_interval2scm (Axis_group_interface::pure_group_height (me, start, en
d)); | 59 return ly_interval2scm (Axis_group_interface::pure_group_height (me, start, en
d)); |
59 } | 60 } |
| 61 |
| 62 // Finds the furthest staff in the given direction whose x-extent |
| 63 // overlaps with the given interval. |
| 64 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, is_extremal, 3); |
| 65 SCM |
| 66 Hara_kiri_group_spanner::is_extremal (SCM smob, SCM start_scm, SCM end_scm) |
| 67 { |
| 68 Grob *me = unsmob_grob (smob); |
| 69 Grob *align = Grob::get_root_vertical_alignment (me); |
| 70 int start = robust_scm2int (start_scm, 0); |
| 71 int end = robust_scm2int (end_scm, INT_MAX); |
| 72 if (!align) |
| 73 return SCM_BOOL_F; |
| 74 |
| 75 int vag_index = Grob::get_vertical_axis_group_index (me); |
| 76 Interval_t<int> extremals; |
| 77 extremals.set_empty (); |
| 78 |
| 79 Direction d = DOWN; |
| 80 |
| 81 extract_grob_set (align, "elements", elts); |
| 82 do |
| 83 for (vsize i = d == DOWN ? 0 : elts.size (); |
| 84 d == DOWN ? i < elts.size () : i--; |
| 85 d == DOWN ? i++ : i = i) |
| 86 { |
| 87 if (Hara_kiri_group_spanner::request_suicide (elts[i], start, end) |
| 88 || to_boolean (elts[i]->get_property ("extremal-ignorable"))) |
| 89 continue; |
| 90 |
| 91 extremals[d] = i; |
| 92 break; |
| 93 } |
| 94 while (flip (&d) != DOWN); |
| 95 |
| 96 return scm_from_bool (!extremals.contains (vag_index)); |
| 97 } |
| 98 |
| 99 |
60 | 100 |
61 /* there is probably a way that doesn't involve re-implementing a binary | 101 /* there is probably a way that doesn't involve re-implementing a binary |
62 search (I would love some proper closures right now) */ | 102 search (I would love some proper closures right now) */ |
63 bool find_in_range (SCM vector, int low, int hi, int min, int max) | 103 bool find_in_range (SCM vector, int low, int hi, int min, int max) |
64 { | 104 { |
65 if (low >= hi) | 105 if (low >= hi) |
66 return false; | 106 return false; |
67 | 107 |
68 int mid = low + (hi - low) / 2; | 108 int mid = low + (hi - low) / 2; |
69 int val = scm_to_int (scm_c_vector_ref (vector, mid)); | 109 int val = scm_to_int (scm_c_vector_ref (vector, mid)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 { | 217 { |
178 Pointer_group_interface::add_unordered_grob (me, ly_symbol2scm ("items-worth-l
iving"), n); | 218 Pointer_group_interface::add_unordered_grob (me, ly_symbol2scm ("items-worth-l
iving"), n); |
179 } | 219 } |
180 | 220 |
181 ADD_INTERFACE (Hara_kiri_group_spanner, | 221 ADD_INTERFACE (Hara_kiri_group_spanner, |
182 "A group spanner that keeps track of interesting items. If it" | 222 "A group spanner that keeps track of interesting items. If it" |
183 " doesn't contain any after line breaking, it removes itself" | 223 " doesn't contain any after line breaking, it removes itself" |
184 " and all its children.", | 224 " and all its children.", |
185 | 225 |
186 /* properties */ | 226 /* properties */ |
| 227 "extremal-ignorable " |
187 "items-worth-living " | 228 "items-worth-living " |
188 "important-column-ranks " | 229 "important-column-ranks " |
189 "keep-alive-with " | 230 "keep-alive-with " |
190 "remove-empty " | 231 "remove-empty " |
191 "remove-first " | 232 "remove-first " |
192 ); | 233 ); |
193 | 234 |
LEFT | RIGHT |