From bb1e4714509957e87d42f6ad8e8c3054b48a5680 Mon Sep 17 00:00:00 2001 From: hanwen Date: Sat, 13 Apr 2002 11:57:25 +0000 Subject: [PATCH] '' --- ChangeLog | 7 ++++ input/regression/rest-collision-default.ly | 15 ++++++++ lily/beam.cc | 7 ++-- lily/include/stem.hh | 2 +- lily/rest-collision.cc | 6 +++- lily/stem.cc | 41 +++++++++++++--------- 6 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 input/regression/rest-collision-default.ly diff --git a/ChangeLog b/ChangeLog index 7788a963b3..564cb2d51a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,13 @@ 2002-04-13 Han-Wen + * lily/stem.cc (get_default_dir): set direction to CENTER if + invisible. Various other fixes to deal with invisible stems and + stem-direction == CENTER. + + * lily/rest-collision.cc (do_shift): take direction from note if + not set. + * input/regression/tie-grace.ly: new file. * lily/tie-engraver.cc (create_grobs): fix tied graces. diff --git a/input/regression/rest-collision-default.ly b/input/regression/rest-collision-default.ly new file mode 100644 index 0000000000..0dd3ba2683 --- /dev/null +++ b/input/regression/rest-collision-default.ly @@ -0,0 +1,15 @@ + +\header +{ +texidoc = "Rests in collisions sit opposite of the note if no direction is + specified for the voice containing the rest." +} + + +\score{\notes\relative c'' + \context Staff < +\time 2/4 +\context Voice=upper { + r4 } +\context Voice=lower {\voiceTwo +b8 }>} diff --git a/lily/beam.cc b/lily/beam.cc index 706b503eca..898c9e0ce3 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -179,8 +179,9 @@ Beam::get_default_dir (Grob *me) do { Grob *s = stems[i]; Direction sd = Directional_element_interface::get (s); - int current = sd ? (1 + d * sd)/2 - : Stem::get_center_distance (s, (Direction)-d); + + int center_distance = int(- d * Stem::head_positions (s) [-d]) >? 0; + int current = sd ? (1 + d * sd)/2 : center_distance; if (current) { @@ -558,7 +559,7 @@ Beam::score_stem_lengths (Link_arraystems, demerit_score += 5 * shrink_extra_weight (d * current_y - info.ideal_y); } - demerit_score *= 2.0 /stems.size (); + demerit_score *= 2.0 / stems.size (); return demerit_score; } diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 70051bed6b..caa430cb42 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -32,7 +32,7 @@ public: static int type_i (Grob *) ; static void set_stemend (Grob *,Real); static Direction get_default_dir (Grob *) ; - static int get_center_distance (Grob *,Direction) ; + static int heads_i (Grob *) ; static bool invisible_b (Grob *) ; static Interval head_positions (Grob *) ; diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 2569c7ab2b..2bbb79d07a 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -196,7 +196,11 @@ Rest_collision::do_shift (Grob *me, SCM elts) } Grob * rcol = rests[0]; Direction dir = Note_column::dir (rests[0]); - + + if (!dir) + { + dir = - Note_column::dir (notes[0]); + } Grob * r = unsmob_grob (rcol->get_grob_property ("rest")); Interval restdim = r->extent (r, Y_AXIS); // ?? diff --git a/lily/stem.cc b/lily/stem.cc index 7286daeee0..0f6591987a 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -238,22 +238,21 @@ Stem::invisible_b (Grob*me) return ! (heads_i (me) && Rhythmic_head::balltype_i (support_head (me)) >= 1); } -int -Stem::get_center_distance (Grob*me, Direction d) -{ - int staff_center = 0; - int distance = (int) (d* (head_positions (me)[d] - staff_center)); - return distance >? 0; -} - Direction Stem::get_default_dir (Grob*me) { - int du = get_center_distance (me,UP); - int dd = get_center_distance (me,DOWN); - - if (sign (dd - du)) - return Direction (sign (dd -du)); + int staff_center = 0; + Interval hp = head_positions (me); + if (hp.empty_b()) + { + return CENTER; + } + + int udistance = (int) (UP * hp[UP] - staff_center); + int ddistance = (int) (DOWN* hp[DOWN] - staff_center); + + if (sign (ddistance - udistance)) + return Direction (sign (ddistance -udistance)); return to_dir (me->get_grob_property ("neutral-direction")); } @@ -431,13 +430,15 @@ SCM Stem::before_line_breaking (SCM smob) { Grob*me = unsmob_grob (smob); - stem_end_position (me); // ugh. Trigger direction calc. - position_noteheads (me); - if (invisible_b (me)) + if (!invisible_b (me)) + { + stem_end_position (me); // ugh. Trigger direction calc. + position_noteheads (me); + } + else { me->remove_grob_property ("molecule-callback"); - // suicide (); } return SCM_UNSPECIFIED; @@ -628,6 +629,12 @@ Stem::off_callback (SCM element_smob, SCM) Grob *me = unsmob_grob (element_smob); Real r=0; + + if (invisible_b (me)) + { + return gh_double2scm (0.0); + } + if (Grob * f = first_head (me)) { Interval head_wid = Note_head::head_extent(f, X_AXIS); -- 2.39.5