- {
- // Getting this signs right here is a little tricky. The configuration
- // we return has zero at the top of the page and positive numbers further
- // down, as does the solution_ vector. Within a staff, however, positive
- // numbers are up.
- // TODO: perhaps change the way the page 'configuration variable works so
- // that it is consistent with the usual up/down sign conventions in
- // Lilypond. Then this would be less confusing.
-
- // These two positions are relative to the page (with positive numbers being
- // down).
- Real first_staff_position = solution_[spring_idx];
- Real first_staff_min_translation = elements_[i].min_offsets.size () ? elements_[i].min_offsets[0] : 0;
- Real system_position = first_staff_position + first_staff_min_translation;
-
- // Position the staves within this system.
- vector<Real> const& min_offsets = elements_[i].min_offsets;
- bool found_spaceable_staff = false;
- for (vsize staff_idx = 0; staff_idx < elements_[i].staves.size (); ++staff_idx)
- {
- Grob *staff = elements_[i].staves[staff_idx];
- staff->set_property ("system-Y-offset", scm_from_double (-system_position));
-
- if (is_spaceable (staff))
- {
- // this is relative to the system: negative numbers are down.
- staff->translate_axis (system_position - solution_[spring_idx], Y_AXIS);
-
- // Lay out any non-spaceable lines between this line and
- // the last one.
- if (loose_lines.size ())
- {
- if (staff_idx)
- loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
- else
- loose_line_min_distances.push_back (elements_[i].padding - min_offsets[staff_idx]);
- loose_lines.push_back (staff);
-
- distribute_loose_lines (loose_lines, loose_line_min_distances,
- last_spaceable_line_translation, -solution_[spring_idx]);
- loose_lines.clear ();
- loose_line_min_distances.clear ();
- }
- last_spaceable_line = staff;
- last_spaceable_line_translation = -solution_[spring_idx];
- found_spaceable_staff = true;
- spring_idx++;
- }
- else
- {
- if (loose_lines.empty ())
- loose_lines.push_back (last_spaceable_line);
-
- if (staff_idx)
- // NOTE: the way we do distances between loose lines (and other lines too, actually)
- // is not the most accurate way possible: we only insert rods between adjacent
- // lines. To be more accurate, we could insert rods between non-adjacent lines
- // using a scheme similar to the one in set_column_rods.
- loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
- else
- { // this is the first line in a system
- Real min_dist = 0;
- if (loose_lines.back ())
- // distance to the final line in the preceding system,
- // including 'system-system-spacing 'padding
- min_dist = (Axis_group_interface::minimum_distance (loose_lines.back (),
- staff,
- Y_AXIS)
- + elements_[i].padding);
- else if (!last_title_extent.is_empty ())
- // distance to the preceding title,
- // including 'markup-system-spacing 'padding
- min_dist = (staff->extent (staff, Y_AXIS)[UP] - last_title_extent[DOWN]
- + elements_[i].padding);
- else // distance to the top margin
- min_dist = header_padding_ + header_height_ + staff->extent (staff, Y_AXIS)[UP];
-
- loose_line_min_distances.push_back (min_dist);
- }
- loose_lines.push_back (staff);
- }
- }
-
- // Corner case: even if a system has no live staves, it still takes up
- // one spring (a system with one live staff also takes up one spring),
- // which we need to increment past.
- if (!found_spaceable_staff)
- spring_idx++;
-
- *tail = scm_cons (scm_from_double (system_position), SCM_EOL);
- tail = SCM_CDRLOC (*tail);
- }
+ {
+ // Getting this signs right here is a little tricky. The configuration
+ // we return has zero at the top of the page and positive numbers further
+ // down, as does the solution_ vector. Within a staff, however, positive
+ // numbers are up.
+ // TODO: perhaps change the way the page 'configuration variable works so
+ // that it is consistent with the usual up/down sign conventions in
+ // Lilypond. Then this would be less confusing.
+
+ // These two positions are relative to the page (with positive numbers being
+ // down).
+ Real first_staff_position = solution_[spring_idx];
+ Real first_staff_min_translation = elements_[i].min_offsets.size () ? elements_[i].min_offsets[0] : 0;
+ Real system_position = first_staff_position + first_staff_min_translation;
+
+ // Position the staves within this system.
+ vector<Real> const &min_offsets = elements_[i].min_offsets;
+ bool found_spaceable_staff = false;
+ for (vsize staff_idx = 0; staff_idx < elements_[i].staves.size (); ++staff_idx)
+ {
+ Grob *staff = elements_[i].staves[staff_idx];
+ staff->set_property ("system-Y-offset", scm_from_double (-system_position));
+
+ if (is_spaceable (staff))
+ {
+ // this is relative to the system: negative numbers are down.
+ staff->translate_axis (system_position - solution_[spring_idx], Y_AXIS);
+
+ // Lay out any non-spaceable lines between this line and
+ // the last one.
+ if (loose_lines.size ())
+ {
+ if (staff_idx)
+ loose_line_min_distances.push_back (min_offsets[staff_idx - 1] - min_offsets[staff_idx]);
+ else
+ {
+ // A null line to break any staff-affinity from the previous system
+ loose_line_min_distances.push_back (0.0);
+ loose_lines.push_back (0);
+ loose_line_min_distances.push_back (elements_[i].padding - min_offsets[0]);
+ }
+ loose_lines.push_back (staff);
+
+ distribute_loose_lines (loose_lines, loose_line_min_distances,
+ last_spaceable_line_translation, -solution_[spring_idx]);
+ loose_lines.clear ();
+ loose_line_min_distances.clear ();
+ }
+ last_spaceable_line = staff;
+ last_spaceable_line_translation = -solution_[spring_idx];
+ found_spaceable_staff = true;
+ spring_idx++;
+ }
+ else // ! is_spaceable
+ {
+ if (staff->extent (staff, Y_AXIS).is_empty ())
+ continue;
+
+ if (loose_lines.empty ())
+ loose_lines.push_back (last_spaceable_line);
+
+ if (staff_idx)
+ // NOTE: the way we do distances between loose lines (and other lines too, actually)
+ // is not the most accurate way possible: we only insert rods between adjacent
+ // lines. To be more accurate, we could insert rods between non-adjacent lines
+ // using a scheme similar to the one in set_column_rods.
+ loose_line_min_distances.push_back (min_offsets[staff_idx - 1] - min_offsets[staff_idx]);
+ else
+ {
+ // this is the first line in a system
+ Real min_dist = 0;
+ if (loose_lines.back ())
+ {
+ // distance to the final line in the preceding system,
+ // including 'system-system-spacing 'padding
+ min_dist = elements_[i].min_distance + elements_[i].padding;
+ // A null line to break any staff-affinity for the previous system
+ loose_line_min_distances.push_back (0.0);
+ loose_lines.push_back (0);
+ }
+ else if (!last_title_extent.is_empty ())
+ // distance to the preceding title,
+ // including 'markup-system-wg 'padding
+ min_dist = (staff->extent (staff, Y_AXIS)[UP] - last_title_extent[DOWN]
+ + elements_[i].padding);
+ else // distance to the top margin
+ min_dist = header_padding_ + header_height_ + staff->extent (staff, Y_AXIS)[UP];
+
+ loose_line_min_distances.push_back (min_dist);
+ }
+ loose_lines.push_back (staff);
+ }
+ }
+
+ // Corner case: even if a system has no live staves, it still takes up
+ // one spring (a system with one live staff also takes up one spring),
+ // which we need to increment past.
+ if (!found_spaceable_staff)
+ spring_idx++;
+
+ *tail = scm_cons (scm_from_double (system_position), SCM_EOL);
+ tail = SCM_CDRLOC (*tail);
+ }