spacing?
*/
-void
+Spring
Note_spacing::get_spacing (Grob *me, Item *right_col,
- Real base_space, Real increment, Real *space, Real *fixed)
+ Real base_space, Real increment)
{
vector<Item*> note_columns = Spacing_interface::left_note_columns (me);
Real left_head_end = 0;
}
/*
- We look at the width of the note head, since smaller heads get less space
-
- eg. a quarter rest gets almost 0.5 ss less horizontal space than a note.
+ The main factor that determines the amount of space is the width of the
+ note head (or the rest). For example, a quarter rest gets almost 0.5 ss
+ less horizontal space than a note.
- What is sticking out of the note head (eg. a flag), doesn't get
- the full amount of space.
+ The other parts of a note column (eg. flags, accidentals, etc.) don't get
+ the full amount of space. We give them half the amount of space, but then
+ adjust things so there are no collisions.
*/
- Real min_dist = Spacing_interface::minimum_distance (me);
+ Drul_array<Skyline> skys = Spacing_interface::skylines (me, right_col);
+ Real min_dist = max (0.0, skys[LEFT].distance (skys[RIGHT]));
+ Real min_desired_space = left_head_end + (min_dist - left_head_end) / 2;
- *fixed = max (min_dist, left_head_end + min_dist/2);
+ /* if the right object sticks out a lot, include a bit of extra space.
+ But only for non-musical-columns; this shouldn't apply to accidentals */
+ if (!Paper_column::is_musical (right_col))
+ min_desired_space = max (min_desired_space,
+ left_head_end + LEFT * skys[RIGHT].max_height ());
- /*
- 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;
+ Real ideal = base_space - increment + min_desired_space;
+
+ stem_dir_correction (me, right_col, increment, &ideal, &min_desired_space);
- stem_dir_correction (me, right_col, increment, space, fixed);
+ Spring ret (ideal, min_dist);
+ ret.set_inverse_compress_strength (max (0.0, ideal - max (min_dist, min_desired_space)));
+ ret.set_inverse_stretch_strength (max (0.1, base_space - increment));
+ return ret;
}
up-stem + down-stem should get extra space, the combination
down-stem + up-stem less.
- TODO: have to check wether the stems are in the same staff.
+ TODO: have to check whether the stems are in the same staff.
*/
void
Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,