2 spacing-loose-columns.cc -- implement loose column spacing.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "paper-column.hh"
11 #include "column-x-positions.hh"
12 #include "staff-spacing.hh"
14 /* Find the loose columns in POSNS, and drape them around the columns
15 specified in BETWEEN-COLS. */
17 set_loose_columns (System *which, Column_x_positions const *posns)
19 int loose_col_count = posns->loose_cols_.size ();
20 for (int i = 0; i < loose_col_count; i++)
23 Item *loose = dynamic_cast<Item *> (posns->loose_cols_[i]);
24 Paper_column *col = dynamic_cast<Paper_column *> (loose);
33 SCM between = loose->get_property ("between-cols");
34 if (!scm_is_pair (between))
37 Item *le = dynamic_cast<Item *> (unsmob_grob (scm_car (between)));
38 Item *re = dynamic_cast<Item *> (unsmob_grob (scm_cdr (between)));
45 left = le->get_column ();
46 if (!left->get_system ())
47 left = left->find_prebroken_piece (RIGHT);
51 loose = right = re->get_column ();
54 if (!right->get_system ())
55 right = right->find_prebroken_piece (LEFT);
57 Grob *common = right->common_refpoint (left, X_AXIS);
60 Real total_space = 0.0;
61 Real total_fixed = 0.0;
62 for (SCM wish = col->get_property ("spacing-wishes"); scm_is_pair (wish); wish = scm_cdr (wish))
64 Grob *spacing = unsmob_grob (scm_car (wish));
65 if (Staff_spacing::has_interface (spacing))
69 Staff_spacing::get_spacing_params (spacing, &space, &fixed);
77 Real right_point = 0.0;
78 Real distance_to_next = 0.0;
84 distance_to_next = total_space;
85 right_point = right->relative_coordinate (common, X_AXIS);
89 Interval my_extent = col->extent (col, X_AXIS);
90 distance_to_next = my_extent[RIGHT] + 1.0;
91 right_point = right->extent (common, X_AXIS)[LEFT];
94 Real left_point = left->extent (common, X_AXIS)[RIGHT];
96 Real space_left = ((right_point - left_point) >? 0.0)
97 - (my_extent.is_empty () ? 0.0 : my_extent.length ());
99 Real padding = (space_left / 2) <? 1.0;
101 Put it just left of the right column, with a bit of extra space
104 Real my_offset = right_point - distance_to_next;
106 col->system_ = which;
107 col->translate_axis (my_offset - col->relative_coordinate (common, X_AXIS), X_AXIS);