From 3f141d50d558df9fdfe08cc97b1bc910c0833e86 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Fri, 22 Jun 2007 13:35:30 +1000 Subject: [PATCH] update outdated comments --- lily/include/spring.hh | 1 - lily/note-spacing.cc | 11 ++++++----- lily/paper-column.cc | 5 +++-- lily/spaceable-grob.cc | 12 ++++++------ lily/spacing-spanner.cc | 2 -- lily/staff-spacing.cc | 20 ++++++++++++++------ 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lily/include/spring.hh b/lily/include/spring.hh index 78bd68cb57..4022173201 100644 --- a/lily/include/spring.hh +++ b/lily/include/spring.hh @@ -46,7 +46,6 @@ public: void operator*= (Real); bool operator> (Spring const&) const; - Grob *other_; }; DECLARE_UNSMOB (Spring, spring); diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 1bf208c4bd..38a87e2d38 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -57,12 +57,13 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, } /* - 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, diff --git a/lily/paper-column.cc b/lily/paper-column.cc index d09518a590..56b9646997 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -200,8 +200,9 @@ Paper_column::print (SCM p) 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++; diff --git a/lily/spaceable-grob.cc b/lily/spaceable-grob.cc index 638a4fa83b..87d30397e3 100644 --- a/lily/spaceable-grob.cc +++ b/lily/spaceable-grob.cc @@ -59,8 +59,8 @@ void 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); } @@ -73,10 +73,10 @@ Spaceable_grob::get_spring (Grob *this_col, Grob *next_col) !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) diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 3e6ca27899..91b1b2e7f0 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -11,8 +11,6 @@ #include #include -using namespace std; - #include "spacing-options.hh" #include "international.hh" #include "main.hh" diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index a41f8f7f8c..83e7f6167d 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -24,6 +24,13 @@ using namespace std; #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) { @@ -100,12 +107,11 @@ Staff_spacing::next_notes_correction (Grob *me, 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) { @@ -193,6 +199,8 @@ 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); -- 2.39.5