- {
- extract_grob_set (c, "right-neighbors", rns_arr);
- extract_grob_set (c, "left-neighbors", lns_arr);
-
- SCM lns = lns_arr.size () ? lns_arr.back ()->self_scm () : SCM_BOOL_F;
- SCM rns = rns_arr.size () ? rns_arr.back ()->self_scm () : SCM_BOOL_F;
-
- /*
- Either object can be non existent, if the score ends
- prematurely.
- */
-
- extract_grob_set (unsmob_grob (rns), "right-items", right_items);
- c->set_object ("between-cols", scm_cons (lns,
- right_items[0]->self_scm ()));
-
- /*
- Set distance constraints for loose columns
- */
- Drul_array<Grob *> next_door;
- next_door[LEFT] = cols->at (i - 1);
- next_door[RIGHT] = cols->at (i + 1);
- Direction d = LEFT;
- Drul_array<Real> dists (0, 0);
-
- do
- {
- dists[d] = 0.0;
- Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
- Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
-
- extract_grob_set (lc, "spacing-wishes", wishes);
- for (vsize k = wishes.size (); k--;)
- {
- Grob *sp = wishes[k];
- if (Note_spacing::left_column (sp) != lc
- || Note_spacing::right_column (sp) != rc)
- continue;
-
- Real space, fixed;
- fixed = 0.0;
- bool dummy;
-
- if (Note_spacing::has_interface (sp))
- {
- /*
- The note spacing should be taken from the musical
- columns.
-
- */
- Real base = note_spacing (me, lc, rc, options, &dummy);
- Note_spacing::get_spacing (sp, rc, base, options->increment_, &space, &fixed);
-
- space -= options->increment_;
-
- dists[d] = max (dists[d], space);
- }
- else if (Staff_spacing::has_interface (sp))
- {
- Real space, fixed_space;
- Staff_spacing::get_spacing_params (sp,
- &space, &fixed_space);
-
- dists[d] = max (dists[d], fixed_space);
- }
- else
- programming_error ("Subversive spacing wish");
- }
- }
- while (flip (&d) != LEFT);
-
- Rod r;
- r.distance_ = dists[LEFT] + dists[RIGHT];
- r.item_drul_[LEFT] = dynamic_cast<Item *> (cols->at (i - 1));
- r.item_drul_[RIGHT] = dynamic_cast<Item *> (cols->at (i + 1));
-
- r.add_to_cols ();
- }
+ {
+ Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor"));
+ Grob *left_neighbor = unsmob_grob (c->get_object ("left-neighbor"));
+
+ /*
+ Either object can be non existent, if the score ends
+ prematurely.
+ */
+ if (!right_neighbor || !left_neighbor)
+ {
+ c->programming_error ("Cannot determine neighbors for floating column. ");
+ c->set_object ("between-cols", scm_cons (cols->at (i - 1)->self_scm (),
+ cols->at (i + 1)->self_scm ()));
+ }
+ else
+ {
+ c->set_object ("between-cols", scm_cons (left_neighbor->self_scm (),
+ right_neighbor->self_scm ()));
+
+ /*
+ Set distance constraints for loose columns
+ */
+ Drul_array<Item *> next_door (dynamic_cast<Item *> (left_neighbor),
+ dynamic_cast<Item *> (right_neighbor));
+
+ set_distances_for_loose_col (me, c, next_door, options);
+ }
+ }
+