]> git.donarmstrong.com Git - lilypond.git/blob - lily/page-layout-problem.cc
Make loose lines use header/footer padding.
[lilypond.git] / lily / page-layout-problem.cc
1 /*
2   page-layout-problem.cc -- space systems nicely on a page. If systems can
3   be stretched, do that too.
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2009 Joe Neeman <joeneeman@gmail.com>
8 */
9
10 #include "page-layout-problem.hh"
11
12 #include "align-interface.hh"
13 #include "axis-group-interface.hh"
14 #include "hara-kiri-group-spanner.hh"
15 #include "international.hh"
16 #include "item.hh"
17 #include "output-def.hh"
18 #include "paper-book.hh"
19 #include "pointer-group-interface.hh"
20 #include "prob.hh"
21 #include "skyline-pair.hh"
22 #include "system.hh"
23
24 Page_layout_problem::Page_layout_problem (Paper_book *pb, SCM page_scm, SCM systems)
25   : bottom_skyline_ (DOWN)
26 {
27   Prob *page = unsmob_prob (page_scm);
28   header_height_ = 0;
29   footer_height_ = 0;
30   header_padding_ = 0;
31   footer_padding_ = 0;
32   page_height_ = 100;
33
34   if (page)
35     {
36       Stencil *head = unsmob_stencil (page->get_property ("head-stencil"));
37       Stencil *foot = unsmob_stencil (page->get_property ("foot-stencil"));
38
39       header_height_ = head ? head->extent (Y_AXIS).length () : 0;
40       footer_height_ = foot ? foot->extent (Y_AXIS).length () : 0;
41       page_height_ = robust_scm2double (page->get_property ("paper-height"), 100);
42     }
43
44   // Initially, bottom_skyline_ represents the top of the page. Make
45   // it solid, so that the top of the first system will be forced
46   // below the top of the printable area.
47   bottom_skyline_.set_minimum_height (-header_height_);
48
49   SCM between_system_spacing = SCM_EOL;
50   SCM after_title_spacing = SCM_EOL;
51   SCM before_title_spacing = SCM_EOL;
52   SCM between_title_spacing = SCM_EOL;
53
54   // first_system_spacing controls the spring from the top of the printable
55   // area to the first staff. It allows the user to control the offset of
56   // the first staff (as opposed to the top of the first system) from the
57   // top of the page. Similarly for last_system_spacing.
58   SCM first_system_spacing = SCM_EOL;
59   SCM last_system_spacing = SCM_EOL;
60   if (pb && pb->paper_)
61     {
62       Output_def *paper = pb->paper_;
63       between_system_spacing = paper->c_variable ("between-system-spacing");
64       after_title_spacing = paper->c_variable ("after-title-spacing");
65       before_title_spacing = paper->c_variable ("before-title-spacing");
66       between_title_spacing = paper->c_variable ("between-title-spacing");
67       last_system_spacing = paper->c_variable ("last-system-spacing");
68       first_system_spacing = paper->c_variable ("first-system-spacing");
69       if (scm_is_pair (systems) && unsmob_prob (scm_car (systems)))
70         first_system_spacing = paper->c_variable ("first-system-title-spacing");
71
72       // Note: the page height here does _not_ reserve space for headers and
73       // footers. This is because we want to anchor the first-system-spacing
74       // spring at the _top_ of the header.
75       page_height_ -= robust_scm2double (paper->c_variable ("top-margin"), 0)
76         + robust_scm2double (paper->c_variable ("bottom-margin"), 0);
77
78       read_spacing_spec (first_system_spacing, &header_padding_, ly_symbol2scm ("padding"));
79       read_spacing_spec (last_system_spacing, &footer_padding_, ly_symbol2scm ("padding"));
80     }
81   bool last_system_was_title = false;
82
83
84   for (SCM s = systems; scm_is_pair (s); s = scm_cdr (s))
85     {
86       bool first = (s == systems);
87
88       if (Grob *g = unsmob_grob (scm_car (s)))
89         {
90           System *sys = dynamic_cast<System*> (g);
91           if (!sys)
92             {
93               programming_error ("got a grob for vertical spacing that wasn't a System");
94               continue;
95             }
96
97           SCM spec = first ? first_system_spacing
98             : (last_system_was_title ? after_title_spacing : between_system_spacing);
99           Spring spring (first ? 0 : 1, 0.0);
100           Real padding = 0.0;
101           alter_spring_from_spacing_spec (spec, &spring);
102           read_spacing_spec (spec, &padding, ly_symbol2scm ("padding"));
103
104           append_system (sys, spring, padding);
105           last_system_was_title = false;
106         }
107       else if (Prob *p = unsmob_prob (scm_car (s)))
108         {
109           SCM spec = first ? first_system_spacing
110             : (last_system_was_title ? between_title_spacing : before_title_spacing);
111           Spring spring (first ? 0 : 1, 0.0);
112           Real padding = 0.0;
113           alter_spring_from_spacing_spec (spec, &spring);
114           read_spacing_spec (spec, &padding, ly_symbol2scm ("padding"));
115
116           append_prob (p, spring, padding);
117           last_system_was_title = true;
118         }
119       else
120         programming_error ("got a system that was neither a Grob nor a Prob");
121     }
122
123   Spring last_spring (0, 0);
124   Real last_padding = 0;
125   alter_spring_from_spacing_spec (last_system_spacing, &last_spring);
126   read_spacing_spec (last_system_spacing, &last_padding, ly_symbol2scm ("padding"));
127   last_spring.ensure_min_distance (last_padding - bottom_skyline_.max_height () + footer_height_);
128   springs_.push_back (last_spring);
129
130   if (elements_.size ())
131     {
132       Real bottom_padding;
133
134       // TODO: junk bottom-space now that we have last-system-spacing?
135       // bottom-space has the flexibility that one can do it per-system.
136       // NOTE: bottom-space is misnamed since it is not stretchable space.
137       if (Prob *p = elements_.back ().prob)
138         bottom_padding = robust_scm2double (p->get_property ("bottom-space"), 0);
139       else if (elements_.back ().staves.size ())
140         {
141           SCM details = get_details (elements_.back ());
142           bottom_padding = robust_scm2double (ly_assoc_get (ly_symbol2scm ("bottom-space"),
143                                                             details,
144                                                             SCM_BOOL_F),
145                                               0.0);
146         }
147       page_height_ -= bottom_padding;
148     }
149 }
150
151 void
152 Page_layout_problem::set_header_height (Real height)
153 {
154   header_height_ = height;
155 }
156
157 void
158 Page_layout_problem::set_footer_height (Real height)
159 {
160   footer_height_ = height;
161 }
162
163 Grob*
164 Page_layout_problem::find_vertical_alignment (System *sys)
165 {
166   extract_grob_set (sys, "elements", elts);
167   for (vsize i = 0; i < elts.size (); ++i)
168     if (Align_interface::has_interface (elts[i]))
169       return elts[i];
170
171   return 0;
172 }
173
174 void
175 Page_layout_problem::append_system (System *sys, Spring const& spring, Real padding)
176 {
177   Grob *align = find_vertical_alignment (sys);
178   if (!align)
179     {
180       sys->programming_error ("no VerticalAlignment in system: can't do vertical spacing");
181       return;
182     }
183
184   align->set_property ("positioning-done", SCM_BOOL_T);
185
186   extract_grob_set (align, "elements", all_elts);
187   vector<Grob*> elts = filter_dead_elements (all_elts);
188   vector<Real> minimum_offsets = Align_interface::get_minimum_translations (align, elts, Y_AXIS,
189                                                                             false, 0, 0);
190
191   Skyline up_skyline (UP);
192   Skyline down_skyline (DOWN);
193   build_system_skyline (elts, minimum_offsets, &up_skyline, &down_skyline);
194
195   Real minimum_distance = up_skyline.distance (bottom_skyline_) + padding;
196
197   Spring spring_copy = spring;
198   spring_copy.ensure_min_distance (minimum_distance);
199   springs_.push_back (spring_copy);
200
201   bottom_skyline_ = down_skyline;
202   elements_.push_back (Element (elts, minimum_offsets));
203
204   // Add the springs for the VerticalAxisGroups in this system.
205
206   // If the user has specified the offsets of the individual staves, fix the
207   // springs at the given distances. Otherwise, use stretchable springs.
208   SCM details = get_details (elements_.back ());
209   SCM manual_dists = ly_assoc_get (ly_symbol2scm ("alignment-distances"), details, SCM_EOL);
210   vsize last_spaceable_staff = 0;
211   bool found_spaceable_staff = false;
212   for (vsize i = 0; i < elts.size (); ++i)
213     {
214       if (is_spaceable (elts[i]))
215         {
216           // We don't add a spring for the first staff, since
217           // we are only adding springs _between_ staves here.
218           if (!found_spaceable_staff)
219             {
220               found_spaceable_staff = true;
221               last_spaceable_staff = i;
222               continue;
223             }
224
225           Spring spring (0.5, 0.0);
226           SCM spec = elts[last_spaceable_staff]->get_property ("next-staff-spacing");
227           alter_spring_from_spacing_spec (spec, &spring);
228
229           springs_.push_back (spring);
230           Real min_distance = (found_spaceable_staff ? minimum_offsets[last_spaceable_staff] : 0) - minimum_offsets[i];
231           springs_.back ().ensure_min_distance (min_distance);
232
233           if (scm_is_pair (manual_dists))
234             {
235               if (scm_is_number (scm_car (manual_dists)))
236                 {
237                   Real dy = scm_to_double (scm_car (manual_dists));
238
239                   springs_.back ().set_distance (dy);
240                   springs_.back ().set_min_distance (dy);
241                   springs_.back ().set_inverse_stretch_strength (0);
242                 }
243               manual_dists = scm_cdr (manual_dists);
244             }
245           last_spaceable_staff = i;
246         }
247     }
248
249   // Corner case: there was only one staff, and it wasn't spaceable.
250   // Mark it spaceable, because we do not allow non-spaceable staves
251   // to be at the top or bottom of a system.
252   if (!found_spaceable_staff && elts.size ())
253     mark_as_spaceable (elts[0]);
254 }
255
256 void
257 Page_layout_problem::append_prob (Prob *prob, Spring const& spring, Real padding)
258 {
259   Skyline_pair *sky = Skyline_pair::unsmob (prob->get_property ("vertical-skylines"));
260   Real minimum_distance = 0;
261   if (sky)
262     {
263       minimum_distance = (*sky)[UP].distance (bottom_skyline_);
264       bottom_skyline_ = (*sky)[DOWN];
265     }
266   else if (Stencil *sten = unsmob_stencil (prob->get_property ("stencil")))
267     {
268       Interval iv = sten->extent (Y_AXIS);
269       minimum_distance = iv[UP] - bottom_skyline_.max_height ();
270
271       bottom_skyline_.clear ();
272       bottom_skyline_.set_minimum_height (iv[DOWN]);
273     }
274   minimum_distance += padding;
275
276   Spring spring_copy = spring;
277   spring_copy.ensure_min_distance (minimum_distance);
278   springs_.push_back (spring_copy);
279   elements_.push_back (Element (prob));
280 }
281
282 void
283 Page_layout_problem::solve_rod_spring_problem (bool ragged)
284 {
285   Simple_spacer spacer;
286
287   for (vsize i = 0; i < springs_.size (); ++i)
288     spacer.add_spring (springs_[i]);
289
290   spacer.solve (page_height_, ragged);
291   solution_ = spacer.spring_positions ();
292 }
293
294 // The solution_ vector stores the position of every live VerticalAxisGroup
295 // and every title. From that information,
296 // 1) within each system, stretch the staves so they land at the right position
297 // 2) find the offset of each system (relative to the printable area of the page).
298 // TODO: this function is getting too long, maybe split it up?
299 SCM
300 Page_layout_problem::find_system_offsets ()
301 {
302   SCM system_offsets = SCM_EOL;
303   SCM *tail = &system_offsets;
304
305   // spring_idx 0 is the top of the page. Interesting values start from 1.
306   vsize spring_idx = 1;
307   vector<Grob*> loose_lines;
308   vector<Real> loose_line_min_distances;
309   Grob *last_spaceable_line = 0;
310   Real last_spaceable_line_translation = 0;
311   for (vsize i = 0; i < elements_.size (); ++i)
312     {
313       if (elements_[i].prob)
314         {
315           *tail = scm_cons (scm_from_double (solution_[spring_idx]), SCM_EOL);
316           tail = SCM_CDRLOC (*tail);
317
318           // Lay out any non-spaceable lines between this line and
319           // the last one.
320           if (loose_lines.size ())
321             {
322               Interval loose_extent = loose_lines.back ()->extent (loose_lines.back (), Y_AXIS);
323               Interval prob_extent = unsmob_stencil (elements_[i].prob->get_property ("stencil"))->extent (Y_AXIS);
324               Real min_distance = -loose_extent[DOWN] + prob_extent[UP]; // TODO: include padding/minimum-distance
325
326               loose_line_min_distances.push_back (min_distance);
327               loose_lines.push_back (0);
328
329               distribute_loose_lines (loose_lines, loose_line_min_distances,
330                                       last_spaceable_line_translation, -solution_[spring_idx]);
331               loose_lines.clear ();
332               loose_line_min_distances.clear ();
333             }
334
335           last_spaceable_line = 0;
336           last_spaceable_line_translation = -solution_[spring_idx];
337           spring_idx++;
338         }
339       else
340         {
341           // Getting this signs right here is a little tricky. The configuration
342           // we return has zero at the top of the page and positive numbers further
343           // down, as does the solution_ vector.  Within a staff, however, positive
344           // numbers are up.
345           // TODO: perhaps change the way the page 'configuration variable works so
346           // that it is consistent with the usual up/down sign conventions in
347           // Lilypond. Then this would be less confusing.
348
349           // These two positions are relative to the page (with positive numbers being
350           // down).
351           Real first_staff_position = solution_[spring_idx];
352           Real first_staff_min_translation = elements_[i].min_offsets.size () ? elements_[i].min_offsets[0] : 0;
353           Real system_position = first_staff_position + first_staff_min_translation;
354
355           // Position the staves within this system.
356           Real translation = 0;
357           vector<Real> const& min_offsets = elements_[i].min_offsets;
358           bool found_spaceable_staff = false;
359           for (vsize staff_idx = 0; staff_idx < elements_[i].staves.size (); ++staff_idx)
360             {
361               Grob *staff = elements_[i].staves[staff_idx];
362               staff->set_property ("system-Y-offset", scm_from_double (-system_position));
363
364               if (is_spaceable (staff))
365                 {
366                   // this is relative to the system: negative numbers are down.
367                   translation = system_position - solution_[spring_idx];
368                   spring_idx++;
369
370                   // Lay out any non-spaceable lines between this line and
371                   // the last one.
372                   if (loose_lines.size ())
373                     {
374                       loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
375                       loose_lines.push_back (staff);
376
377                       distribute_loose_lines (loose_lines, loose_line_min_distances,
378                                               last_spaceable_line_translation, translation - system_position);
379                       loose_lines.clear ();
380                       loose_line_min_distances.clear ();
381                     }
382                   last_spaceable_line = staff;
383                   // Negative is down but the translation is relative to the whole page.
384                   last_spaceable_line_translation = -system_position + translation;
385
386                   staff->translate_axis (translation, Y_AXIS);
387                   found_spaceable_staff = true;
388                 }
389               else
390                 {
391                   if (loose_lines.empty ())
392                     loose_lines.push_back (last_spaceable_line);
393
394                   loose_lines.push_back (staff);
395                   if (staff_idx)
396                     loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
397                   else
398                     {
399                       Real min_dist = 0;
400                       if (last_spaceable_line)
401                         min_dist = Axis_group_interface::minimum_distance (last_spaceable_line,
402                                                                            staff,
403                                                                            Y_AXIS);
404                       else // distance to the top margin
405                         min_dist = header_padding_ + header_height_ + staff->extent (staff, Y_AXIS)[UP];
406
407                       loose_line_min_distances.push_back (min_dist);
408                     }
409                 }
410             }
411
412           // Corner case: even if a system has no live staves, it still takes up
413           // one spring (a system with one live staff also takes up one spring),
414           // which we need to increment past.
415           if (!found_spaceable_staff)
416             spring_idx++;
417
418           *tail = scm_cons (scm_from_double (system_position), SCM_EOL);
419           tail = SCM_CDRLOC (*tail);
420         }
421     }
422
423   if (loose_lines.size ())
424     {
425       Grob *last = loose_lines.back ();
426       Interval last_ext = last->extent (last, Y_AXIS);
427       loose_line_min_distances.push_back (-last_ext[DOWN] + footer_height_ + footer_padding_);
428       loose_lines.push_back (0);
429
430       distribute_loose_lines (loose_lines, loose_line_min_distances,
431                               last_spaceable_line_translation, -page_height_);
432
433     }
434
435   assert (spring_idx == solution_.size () - 1);
436   return system_offsets;
437 }
438
439 // Given two lines that are already spaced (the first and last
440 // elements of loose_lines), distribute some unspaced lines between
441 // them.
442 void
443 Page_layout_problem::distribute_loose_lines (vector<Grob*> const &loose_lines,
444                                              vector<Real> const &min_distances,
445                                              Real first_translation, Real last_translation)
446 {
447   Simple_spacer spacer;
448   for (vsize i = 0; i + 1 < loose_lines.size (); ++i)
449     {
450       SCM spec = get_spacing_spec (loose_lines[i], loose_lines[i+1]);
451       Spring spring (1.0, 0.0);
452       alter_spring_from_spacing_spec (spec, &spring);
453       spring.ensure_min_distance (min_distances[i]);
454
455       if ((spec == SCM_BOOL_F && loose_lines[0] && loose_lines.back ())
456           || !loose_lines[i]
457           || !loose_lines[i+1])
458         {
459           // Insert a very flexible spring, so it doesn't have much effect.
460           // TODO: set a default distance and a compress strength so that a
461           // lyrics line, for example, will stay closer to the top staff
462           // even in a compressed configuration.
463           spring.set_inverse_stretch_strength (100000);
464           spring.set_inverse_compress_strength (100000);
465         }
466
467       spacer.add_spring (spring);
468     }
469
470   // Remember: offsets are decreasing, since we're going from UP to DOWN!
471   spacer.solve (first_translation - last_translation, false);
472
473   vector<Real> solution = spacer.spring_positions ();
474   for (vsize i = 1; i + 1 < solution.size (); ++i)
475     {
476       Real system_offset = scm_to_double (loose_lines[i]->get_property ("system-Y-offset"));
477       loose_lines[i]->translate_axis (first_translation - solution[i] - system_offset, Y_AXIS);
478     }
479 }
480
481 SCM
482 Page_layout_problem::solution (bool ragged)
483 {
484   solve_rod_spring_problem (ragged);
485   return find_system_offsets ();
486 }
487
488 // Build upper and lower skylines for a system. We don't yet know the positions
489 // of the staves within the system, so we make the skyline as conservative as
490 // possible. That is, for the upper skyline, we pretend that all of the staves
491 // in the system are packed together close to the top system; for the lower
492 // skyline, we pretend that all of the staves are packed together close to
493 // the bottom system.
494 //
495 // The upper skyline is relative to the top staff; the lower skyline is relative to
496 // the bottom staff.
497 void
498 Page_layout_problem::build_system_skyline (vector<Grob*> const& staves,
499                                            vector<Real> const& minimum_translations,
500                                            Skyline *up,
501                                            Skyline *down)
502 {
503   if (minimum_translations.empty ())
504     return;
505
506   assert (staves.size () == minimum_translations.size ());
507   Real first_translation = minimum_translations[0];
508   Real last_spaceable_dy = 0;
509   Real first_spaceable_dy = 0;
510   bool found_spaceable_staff;
511
512   for (vsize i = 0; i < staves.size (); ++i)
513     {
514       Real dy = minimum_translations[i] - first_translation;
515       Grob *g = staves[i];
516       Skyline_pair *sky = Skyline_pair::unsmob (g->get_property ("vertical-skylines"));
517       if (sky)
518         {
519           up->raise (-dy);
520           up->merge ((*sky)[UP]);
521           up->raise (dy);
522
523           down->raise (-dy);
524           down->merge ((*sky)[DOWN]);
525           down->raise (dy);
526         }
527       if (is_spaceable (staves[i]))
528         {
529           if (!found_spaceable_staff)
530             {
531               found_spaceable_staff = true;
532               first_spaceable_dy = dy;
533             }
534           last_spaceable_dy = dy;
535         }
536     }
537
538   // Leave the up skyline at a position relative
539   // to the top spaceable staff.
540   up->raise (-first_spaceable_dy);
541
542   // Leave the down skyline at a position
543   // relative to the bottom spaceable staff.
544   down->raise (-last_spaceable_dy);
545 }
546
547 Interval
548 Page_layout_problem::prob_extent (Prob *p)
549 {
550   Stencil *sten = unsmob_stencil (p->get_property ("stencil"));
551   return sten ? sten->extent (Y_AXIS) : Interval (0, 0);
552 }
553
554 Interval
555 Page_layout_problem::first_staff_extent (Element const& e)
556 {
557   if (e.prob)
558     return prob_extent (e.prob);
559   else if (e.staves.size ())
560     return e.staves[0]->extent (e.staves[0], Y_AXIS);
561
562   return Interval (0, 0);
563 }
564
565 Interval
566 Page_layout_problem::last_staff_extent (Element const& e)
567 {
568   if (e.prob)
569     return prob_extent (e.prob);
570   else if (e.staves.size ())
571     return e.staves.back ()->extent (e.staves.back (), Y_AXIS);
572
573   return Interval (0, 0);
574 }
575
576 SCM
577 Page_layout_problem::get_details (Element const& elt)
578 {
579   if (elt.staves.empty ())
580     return SCM_EOL;
581
582   return get_details (elt.staves.back ()->get_system ());
583 }
584
585 SCM
586 Page_layout_problem::get_details (Grob *g)
587 {
588   Grob *left_bound = dynamic_cast<Spanner*> (g)->get_bound (LEFT);
589   return left_bound->get_property ("line-break-system-details");
590 }
591
592 bool
593 Page_layout_problem::is_spaceable (Grob *g)
594 {
595   return !scm_is_number (g->get_property ("staff-affinity"));
596 }
597
598 void
599 Page_layout_problem::mark_as_spaceable (Grob *g)
600 {
601   g->set_property ("staff-affinity", SCM_BOOL_F);
602 }
603
604 bool
605 Page_layout_problem::read_spacing_spec (SCM spec, Real* dest, SCM sym)
606 {
607   SCM pair = scm_sloppy_assq (sym, spec);
608   if (scm_is_pair (pair) && scm_is_number (scm_cdr (pair)))
609     {
610       *dest = scm_to_double (scm_cdr (pair));
611       return true;
612     }
613   return false;
614 }
615
616 // Returns the spacing spec connecting BEFORE to AFTER.  A return
617 // value of SCM_BOOL_F means that there should be no spring (in
618 // practice, this means that we use a very flexible spring).
619 SCM
620 Page_layout_problem::get_spacing_spec (Grob *before, Grob *after)
621 {
622   if (!before || !after)
623     return SCM_BOOL_F;
624
625   if (is_spaceable (before))
626     {
627       if (is_spaceable (after))
628         return before->get_property ("next-staff-spacing");
629       else
630         {
631           Direction affinity = to_dir (after->get_property ("staff-affinity"));
632           return (affinity == DOWN) ? SCM_BOOL_F : after->get_property ("inter-staff-spacing");
633         }
634     }
635   else
636     {
637       if (is_spaceable (after))
638         {
639           Direction affinity = to_dir (before->get_property ("staff-affinity"));
640           return (affinity == UP) ? SCM_BOOL_F : before->get_property ("inter-staff-spacing");
641         }
642       else
643         {
644           Direction before_affinity = to_dir (before->get_property ("staff-affinity"));
645           Direction after_affinity = to_dir (after->get_property ("staff-affinity"));
646           if (after_affinity > before_affinity)
647             {
648               warning (_ ("staff-affinities should only decrease"));
649               after_affinity = before_affinity;
650             }
651           if (before_affinity != UP)
652             return before->get_property ("inter-loose-line-spacing");
653           else if (after_affinity != DOWN)
654             return before->get_property ("inter-loose-line-spacing");
655         }
656     }
657   return SCM_BOOL_F;
658 }
659
660 void
661 Page_layout_problem::alter_spring_from_spacing_spec (SCM spec, Spring* spring)
662 {
663   Real space;
664   Real stretch;
665   Real min_dist;
666   if (read_spacing_spec (spec, &space, ly_symbol2scm ("space")))
667     spring->set_distance (space);
668   if (read_spacing_spec (spec, &min_dist, ly_symbol2scm ("minimum-distance")))
669     spring->set_min_distance (min_dist);
670   spring->set_default_strength ();
671
672   if (read_spacing_spec (spec, &stretch, ly_symbol2scm ("stretchability")))
673     {
674       spring->set_inverse_stretch_strength (stretch);
675       spring->set_inverse_compress_strength (stretch);
676     }
677 }
678
679 vector<Grob*>
680 Page_layout_problem::filter_dead_elements (vector<Grob*> const& input)
681 {
682   vector<Grob*> output;
683   for (vsize i = 0; i < input.size (); ++i)
684     {
685       if (Hara_kiri_group_spanner::has_interface (input[i]))
686         Hara_kiri_group_spanner::consider_suicide (input[i]);
687
688       if (input[i]->is_live ())
689         output.push_back (input[i]);
690     }
691
692   return output;
693 }