+ *fixed
+ = (left_head_wid.is_empty () ? increment
+ : /*
+ Size of the head:
+ */
+ (left_head_wid[RIGHT]+
+
+ /*
+ What's sticking out of the head, eg. a flag:
+ */
+ (extents[LEFT][RIGHT] - left_head_wid[RIGHT]) / 2))
+
+ /*
+ What is sticking out of the right note:
+ */
+ + (extents[RIGHT].is_empty () ? 0.0 : - extents[RIGHT][LEFT] / 2);
+
+ /*
+ We don't do complicated stuff: (base_space - increment) is the
+ normal amount of white, which also determines the amount of
+ stretch. Upon (extreme) stretching, notes with accidentals should
+ stretch as much as notes without accidentals.
+ */
+ *space = (base_space - increment) + *fixed;
+
+ if (!extents[RIGHT].is_empty ()
+ && (Item::is_breakable (right_col)
+ || right_col->original_))
+ {
+ /*
+ This is for the situation
+
+ rest | 3/4 (eol)
+
+ Since we only take half of the right-object space above, the
+ barline will bump into the notes preceding it, if the right
+ thing is big. We add the rest of the extents here:
+ */
+
+ *space += -extents[RIGHT][LEFT] / 2;
+ *fixed += -extents[RIGHT][LEFT] / 2;
+ }
+
+ stem_dir_correction (me, right_col, increment, space, fixed);
+}
+
+Item *
+Note_spacing::left_column (Grob *me)
+{
+ if (!me->is_live ())
+ return 0;
+
+ return dynamic_cast<Item *> (me)->get_column ();
+}
+
+/*
+ Compute the column of the right-items. This is a big function,
+ since RIGHT-ITEMS may span more columns (eg. if a clef if inserted,
+ this will add a new columns to RIGHT-ITEMS. Here we look at the
+ columns, and return the left-most. If there are multiple columns, we
+ prune RIGHT-ITEMS.
+*/
+Item *
+Note_spacing::right_column (Grob *me)
+{
+ if (!me->is_live ())
+ return 0;
+
+ SCM right = me->get_property ("right-items");
+ Item *mincol = 0;
+ int min_rank = INT_MAX;
+ bool prune = false;
+ for (SCM s = right; scm_is_pair (s); s = scm_cdr (s))
+ {
+ Item *ri = unsmob_item (scm_car (s));
+
+ Item *col = ri->get_column ();
+ int rank = Paper_column::get_rank (col);
+
+ if (rank < min_rank)
+ {
+ min_rank = rank;
+ if (mincol)
+ prune = true;
+
+ mincol = col;
+ }
+ }
+
+ if (prune)
+ {
+ // I'm a lazy bum. We could do this in-place.
+ SCM newright = SCM_EOL;
+ for (SCM s = right; scm_is_pair (s); s = scm_cdr (s))
+ {
+ if (unsmob_item (scm_car (s))->get_column () == mincol)
+ newright = scm_cons (scm_car (s), newright);
+ }
+
+ me->set_property ("right-items", newright);
+ }
+
+ if (!mincol)
+ {
+ /*
+ int r = Paper_column::get_rank (dynamic_cast<Item*>(me)->get_column ());
+ programming_error (_f ("Spacing wish column %d has no right item.", r));
+ */
+
+ return 0;
+ }
+
+ return mincol;