- // ugh, rather calc from Stem_tremolo_req
- int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT);
- mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS),
- stem->stem_end_position () * ss / 2 -
- directional_element (beam).get () * beams_i * interbeam_f));
+ beamthickness = gh_scm2double (sbt) * ss;
+ }
+
+ Real end_y
+ = Stem::stem_end_position (stem) *ss/2
+ - stemdir * (beam_count * beamthickness
+ + ((beam_count -1) >? 0) * beam_translation);
+
+ /*
+ the 0.33 ss is to compensate for the size of the note head
+ */
+ Real chord_start_y = Stem::chord_start_y (stem) +
+ 0.33 * ss * stemdir;
+
+ Real padding = beam_translation;
+
+ /*
+ if there is a flag, just above/below the notehead.
+ if there is not enough space, center on remaining space,
+ else one beamspace away from stem end.
+ */
+ if (!beam && Stem::duration_log (stem) >= 3)
+ {
+ mol.align_to (Y_AXIS, -stemdir);
+ mol.translate_axis (chord_start_y + .5 * stemdir, Y_AXIS);
+ }
+ else if (stemdir * (end_y - chord_start_y) - 2*padding - mol_ext.length () < 0.0)
+ {
+ mol.translate_axis (0.5 * (end_y + chord_start_y) - mol_ext.center (),Y_AXIS);