void operator*= (Real);
bool operator> (Spring const&) const;
- Grob *other_;
};
DECLARE_UNSMOB (Spring, spring);
}
/*
- We look at the width of the note head, since smaller heads get less space
+ 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.
- eg. 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, right_col);
Real min_desired_space = max (left_head_end + (min_dist - left_head_end) / 2,
for (SCM s = me->get_object ("ideal-distances");
scm_is_pair (s); s = scm_cdr (s))
{
- Spring *sp = unsmob_spring (scm_car (s));
- if (!sp->other_->get_system ())
+ Spring *sp = unsmob_spring (scm_caar (s));
+ if (!unsmob_grob (scm_cdar (s))
+ || !unsmob_grob (scm_cdar (s))->get_system ())
continue;
j++;
Spaceable_grob::add_spring (Grob *me, Grob *other, Spring sp)
{
SCM ideal = me->get_object ("ideal-distances");
- sp.other_ = other;
- ideal = scm_cons (sp.smobbed_copy (), ideal);
+
+ ideal = scm_cons (scm_cons (sp.smobbed_copy (), other->self_scm ()), ideal);
me->set_object ("ideal-distances", ideal);
}
!spring && scm_is_pair (s);
s = scm_cdr (s))
{
- Spring *sp = unsmob_spring (scm_car (s));
-
- if (sp && sp->other_ == next_col)
- spring = sp;
+ if (scm_is_pair (scm_car (s))
+ && unsmob_grob (scm_cdar (s)) == next_col
+ && unsmob_spring (scm_caar (s)))
+ spring = unsmob_spring (scm_caar (s));
}
if (!spring)
#include <math.h>
#include <cstdio>
-using namespace std;
-
#include "spacing-options.hh"
#include "international.hh"
#include "main.hh"
#include "pointer-group-interface.hh"
#include "directional-element-interface.hh"
+/* A stem following a bar-line creates an optical illusion similar to the
+ one mentioned in note-spacing.cc. We correct for it here.
+
+ TODO: should we still correct if there are accidentals/arpeggios before
+ the stem?
+*/
+
Real
Staff_spacing::optical_correction (Grob *me, Grob *g, Interval bar_height)
{
return max_optical;
}
-/* This routine does not impose any minimum distances between columns; it only
- affects springs. As such, the FIXED variable does not refer to a minimum
- distance between columns, but instead to a minimum desired distance between
- columns -- this ends up affecting the stiffness of a spring. In fact, FIXED
- will be the distance between columns if there is a compression force of 1.0
- applied to the line. */
+/* We calculate three things here: the ideal distance, the minimum distance
+ (which is the distance at which collisions will occure) and the "fixed"
+ distance, which is the distance at which things start to look really bad.
+ We arrange things so that the fixed distance will be attained when the
+ line is compressed with a force of 1.0 */
Spring
Staff_spacing::get_spacing (Grob *me, Grob *right_col)
{
Real optical_correction = next_notes_correction (me, last_grob);
Real min_dist = Spacing_interface::minimum_distance (me, right_col);
+
+ /* ensure that the "fixed" distance will leave a gap of at least 0.3 ss. */
Real min_dist_correction = max (0.0, 0.3 + min_dist - fixed);
Real correction = max (optical_correction, min_dist_correction);