/*
- spacing-loose-columns.cc -- implement loose column spacing.
+ spacing-loose-columns.cc -- implement loose column spacing.
source file of the GNU LilyPond music typesetter
#include "system.hh"
#include "paper-column.hh"
#include "column-x-positions.hh"
+#include "pointer-group-interface.hh"
#include "staff-spacing.hh"
+#include "note-spacing.hh"
+#include "spacing-spanner.hh"
+
+#include "moment.hh"
/* Find the loose columns in POSNS, and drape them around the columns
specified in BETWEEN-COLS. */
set_loose_columns (System *which, Column_x_positions const *posns)
{
int loose_col_count = posns->loose_cols_.size ();
+ if (!loose_col_count)
+ return;
+
+ Real default_padding = 1.0;
for (int i = 0; i < loose_col_count; i++)
{
int divide_over = 1;
Item *loose = dynamic_cast<Item *> (posns->loose_cols_[i]);
Paper_column *col = dynamic_cast<Paper_column *> (loose);
- if (col->system_)
+ if (col->get_system ())
continue;
Item *left = 0;
Item *right = 0;
+
+ Link_array<Item> clique;
while (1)
{
- SCM between = loose->get_property ("between-cols");
+ SCM between = loose->get_object ("between-cols");
if (!scm_is_pair (between))
break;
left = le->get_column ();
if (!left->get_system ())
left = left->find_prebroken_piece (RIGHT);
+
+ clique.push (left);
}
+ clique.push (loose);
+
divide_over++;
loose = right = re->get_column ();
}
if (!right->get_system ())
right = right->find_prebroken_piece (LEFT);
+ clique.push (right);
+
Grob *common = right->common_refpoint (left, X_AXIS);
+ Item *finished_right_column = clique.top ();
- int count = 0;
- Real total_space = 0.0;
- Real total_fixed = 0.0;
- for (SCM wish = col->get_property ("spacing-wishes"); scm_is_pair (wish); wish = scm_cdr (wish))
+ for (int j = clique.size () - 2; j > 0; j--)
{
- Grob *spacing = unsmob_grob (scm_car (wish));
- if (Staff_spacing::has_interface (spacing))
+ int count = 0;
+ Real total_space = 0.0;
+ Real total_fixed = 0.0;
+
+ extract_grob_set (col, "spacing-wishes", wishes);
+ for (int i = 0; i < wishes.size (); i++)
{
+ Grob *spacing = wishes[i];
Real space = 0.0;
Real fixed = 0.0;
- Staff_spacing::get_spacing_params (spacing, &space, &fixed);
- total_fixed += fixed;
- total_space += space;
+ if (Staff_spacing::has_interface (spacing))
+ Staff_spacing::get_spacing_params (spacing, &space, &fixed);
+ else if (Note_spacing::has_interface (spacing))
+ {
+ Spacing_options options;
+ options.init ();
+
+ fixed = robust_relative_extent (col, col, X_AXIS)[RIGHT];
+
+ Moment dt = Paper_column::when_mom (right) - Paper_column::when_mom (col);
+ bool expand;
+ space = options.get_duration_space (dt, &expand);
+ Note_spacing::get_spacing (spacing, right, space, options.increment_,
+ &space, &fixed);
+ }
+ else
+ continue;
+
count++;
+
+ total_space += space;
+ total_fixed += fixed;
}
- }
- Real right_point = 0.0;
- Real distance_to_next = 0.0;
- if (count)
- {
- total_space /= count;
- total_fixed /= count;
+ Real distance_to_next = 0.0;
+ Real right_point = 0.0;
+ if (count)
+ {
+ total_space /= count;
+ total_fixed /= count;
- distance_to_next = total_space;
- right_point = right->relative_coordinate (common, X_AXIS);
- }
- else
- {
- Interval my_extent = col->extent (col, X_AXIS);
- distance_to_next = my_extent[RIGHT] + 1.0;
- right_point = right->extent (common, X_AXIS)[LEFT];
- }
-#if 0
- Real left_point = left->extent (common, X_AXIS)[RIGHT];
+ distance_to_next = total_space;
+ right_point
+ = finished_right_column->relative_coordinate (common, X_AXIS);
+ }
+ else
+ {
+ Interval my_extent = robust_relative_extent (col, col, X_AXIS);
+ distance_to_next = my_extent[RIGHT] + default_padding;
+ right_point = robust_relative_extent (finished_right_column, common, X_AXIS)[LEFT];
+ }
- Real space_left = ((right_point - left_point) >? 0.0)
- - (my_extent.is_empty () ? 0.0 : my_extent.length ());
+ Real my_offset = right_point - distance_to_next;
- Real padding = (space_left / 2) <? 1.0;
- /*
- Put it just left of the right column, with a bit of extra space
- */
-#endif
- Real my_offset = right_point - distance_to_next;
+ col->system_ = which;
+ col->translate_axis (my_offset - col->relative_coordinate (common, X_AXIS), X_AXIS);
- col->system_ = which;
- col->translate_axis (my_offset - col->relative_coordinate (common, X_AXIS), X_AXIS);
+ finished_right_column = col;
+ }
}
}