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>
11 #include "paper-column.hh"
12 #include "column-x-positions.hh"
13 #include "staff-spacing.hh"
14 #include "pointer-group-interface.hh"
16 /* Find the loose columns in POSNS, and drape them around the columns
17 specified in BETWEEN-COLS. */
19 set_loose_columns (System *which, Column_x_positions const *posns)
21 int loose_col_count = posns->loose_cols_.size ();
22 for (int i = 0; i < loose_col_count; i++)
25 Item *loose = dynamic_cast<Item *> (posns->loose_cols_[i]);
26 Paper_column *col = dynamic_cast<Paper_column *> (loose);
28 if (col->get_system ())
35 SCM between = loose->get_object ("between-cols");
36 if (!scm_is_pair (between))
39 Item *le = dynamic_cast<Item *> (unsmob_grob (scm_car (between)));
40 Item *re = dynamic_cast<Item *> (unsmob_grob (scm_cdr (between)));
47 left = le->get_column ();
48 if (!left->get_system ())
49 left = left->find_prebroken_piece (RIGHT);
53 loose = right = re->get_column ();
56 if (!right->get_system ())
57 right = right->find_prebroken_piece (LEFT);
59 Grob *common = right->common_refpoint (left, X_AXIS);
62 Real total_space = 0.0;
63 Real total_fixed = 0.0;
65 extract_grob_set (col, "spacing-wishes", wishes);
66 for (int i = 0; i < wishes.size (); i++)
68 Grob *spacing = wishes[i];
69 if (Staff_spacing::has_interface (spacing))
73 Staff_spacing::get_spacing_params (spacing, &space, &fixed);
81 Real right_point = 0.0;
82 Real distance_to_next = 0.0;
88 distance_to_next = total_space;
89 right_point = right->relative_coordinate (common, X_AXIS);
93 Interval my_extent = col->extent (col, X_AXIS);
94 distance_to_next = my_extent[RIGHT] + 1.0;
95 right_point = right->extent (common, X_AXIS)[LEFT];
98 Real my_offset = right_point - distance_to_next;
100 col->system_ = which;
101 col->translate_axis (my_offset - col->relative_coordinate (common, X_AXIS), X_AXIS);