From: Han-Wen Nienhuys Date: Wed, 14 Jul 2004 22:23:02 +0000 (+0000) Subject: (context_prop_spec): check grob name for X-Git-Tag: release/2.3.7~53 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=73eddbc277ed27aacfd6ed49f425ce02c39d87ef;p=lilypond.git (context_prop_spec): check grob name for alphanumericness.. --- diff --git a/ChangeLog b/ChangeLog index 576adb96f6..5c05f0d1d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ +2004-07-15 Han-Wen Nienhuys + + * lily/new-slur.cc (score_slopes): strong sloping score only when + stems point in same dir. + 2004-07-14 Han-Wen Nienhuys + * input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly (rondo): bugfix + for beam start. + * lily/parser.yy (context_prop_spec): check grob name for alphanumericness.. diff --git a/input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly b/input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly index 263cb0caeb..31503fd4d7 100644 --- a/input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly +++ b/input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly @@ -164,7 +164,7 @@ rondo = \relative c' \cresc g'2. bes,2. a4. b16[ c d e f g] a4. f4 d8 - [\endcresc c8\f g' e] c[ g e] + \endcresc c8[\f g' e] c[ g e] c[ e' c] g[ e c] g4 r8 g''8[ e c] diff --git a/input/test/new-slur.ly b/input/test/new-slur.ly index e61cc49983..8b674c76d0 100644 --- a/input/test/new-slur.ly +++ b/input/test/new-slur.ly @@ -8,8 +8,7 @@ \override Slur #'print-function = #New_slur::print \override Slur #'height = ##f - f'=''16( e) - d( c) + f'=''16( e) d( c) c'=''2(~c8 d16 c b8 a) f='4 4 ( f ) @@ -21,5 +20,6 @@ _( \stemDown g \stemBoth ) c,^( c'' c) c,,^( c'') - c,,^( c') + c,,^( c') + } diff --git a/lily/new-slur.cc b/lily/new-slur.cc index 100dd6d92e..4a6234339f 100644 --- a/lily/new-slur.cc +++ b/lily/new-slur.cc @@ -23,6 +23,7 @@ #include "slur.hh" #include "spanner.hh" #include "staff-symbol-referencer.hh" +#include "staff-symbol.hh" #include "stem.hh" #include "stencil.hh" #include "warn.hh" @@ -66,7 +67,9 @@ const Real HEAD_STRICT_FREE_SPACE = 0.2; struct Slur_score { Drul_array attachment_; - Real score_; + Real score_; + Bezier curve_; + #if DEBUG_SLUR_QUANTING String score_card_; #endif @@ -90,7 +93,7 @@ public: static bool has_interface (Grob*); static Array get_encompass_offsets (Grob *me); static Bezier get_curve (Grob *me); - static Bezier get_bezier (Grob *me, Drul_array); + static Bezier get_bezier (Grob *me, Drul_array,Real,Real); static Direction get_default_dir (Grob *me); DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); DECLARE_SCHEME_CALLBACK (height, (SCM,SCM)); @@ -111,7 +114,7 @@ New_slur::set_interface (Grob*me) { /* Copy to mutable list. */ me->set_property ("attachment", - ly_deep_copy (me->get_property ("attachment"))); + ly_deep_copy (me->get_property ("attachment"))); } void @@ -212,16 +215,10 @@ New_slur::after_line_breaking (SCM smob) } Bezier -New_slur::get_bezier (Grob *me, Drul_array extremes) +New_slur::get_bezier (Grob *me, Drul_array extremes, + Real r_0, + Real h_inf) { - // SCM details = me->get_property ("details"); - SCM h_inf_scm = me->get_property ("height-limit"); - SCM r_0_scm = me->get_property ("ratio"); - Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me); - - Real r_0 = robust_scm2double (r_0_scm, 1); - Real h_inf = staff_space * ly_scm2double (h_inf_scm); - Array encompasses; encompasses.push (extremes[LEFT]); encompasses.push (extremes[RIGHT]); @@ -275,17 +272,33 @@ New_slur::set_end_points (Grob *me) Grob *stem = Note_column::get_stem (extremes[d]); Grob * h = Stem::extremal_heads (stem)[dir]; - Real y = h->extent (common[Y_AXIS], Y_AXIS)[dir]; + Real y; + + if (stem + && get_grob_direction (stem) == dir + && Stem::get_beam (stem)) + { + y = stem->extent (common[Y_AXIS], Y_AXIS)[dir]; + } + else + { + y = h->extent (common[Y_AXIS], Y_AXIS)[dir]; + } y += dir * 0.5 * staff_space; - int p = Staff_symbol_referencer::get_position (h) + 2*dir; + + Grob * staff = Staff_symbol_referencer::get_staff_symbol (h); + Real pos = 2.0 * (y - staff->relative_coordinate (common[Y_AXIS], Y_AXIS)) / Staff_symbol::staff_space (staff); + + + /* + start off staffline. + */ + if (fabs (pos - round (pos)) < 0.2 + && Staff_symbol_referencer::on_staffline (h, (int) rint (pos))) + y += staff_space * dir / 10 ; - if (Staff_symbol_referencer::on_staffline (h, p)) - /* - start off staffline. - */ - y += staff_space * dir / 10 ; Grob * fh = Note_column::first_head (extremes[d]); Real x = fh->extent (common[X_AXIS], X_AXIS).linear_combination (CENTER); @@ -342,7 +355,16 @@ New_slur::set_end_points (Grob *me) os[LEFT][Y_AXIS] += incr; } - + { + Real r_0 = robust_scm2double (me->get_property ("ratio"), 1); + Real h_inf = staff_space * ly_scm2double (me->get_property ("height-limit")); + for (int i = scores.size(); i-- ;) + { + scores[i].curve_ = get_bezier (me, scores[i].attachment_, + r_0, h_inf); + } + } + score_encompass (me, common, base_attachment, &scores); score_slopes (me, common, base_attachment, &scores); @@ -357,7 +379,7 @@ New_slur::set_end_points (Grob *me) } } - Bezier b (get_bezier (me, scores.size () ? scores[opt_idx].attachment_ : base_attachment)); + Bezier const &b = scores[opt_idx].curve_; SCM controls = SCM_EOL; for (int i = 4; i--;) @@ -399,7 +421,7 @@ New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_a for (int i =0 ; i < scores->size (); i++) { - Bezier bez (get_bezier (me, scores->elem (i).attachment_)); + Bezier const &bez (scores->elem (i).curve_); Real demerit =0.; for (int j = 0; j < infos.size(); j++) { @@ -455,17 +477,17 @@ New_slur::score_slopes (Grob * me, Grob *common[], Drul_array base_atta Drul_array ys; Direction d = LEFT; + Drul_array stem_dirs; do { Grob *stem = Note_column::get_stem (extremes [d]); ys[d] = Stem::extremal_heads (stem)[Direction (dir)] ->relative_coordinate (common[Y_AXIS], Y_AXIS); + + stem_dirs[d] = get_grob_direction (stem); } while (flip (&d) != LEFT); Real dy = ys[RIGHT] - ys[LEFT]; - - - for (int i =0 ; i < scores->size (); i++) { Real slur_dy = (*scores)[i].attachment_[RIGHT][Y_AXIS] @@ -473,14 +495,21 @@ New_slur::score_slopes (Grob * me, Grob *common[], Drul_array base_atta Real demerit = 0.0; - demerit += STEEPER_SLOPE_FACTOR * (dir * (fabs (slur_dy) - fabs (dy)) >? 0); + + if (stem_dirs[LEFT] == stem_dirs[RIGHT]) + demerit += STEEPER_SLOPE_FACTOR * (dir * (fabs (slur_dy) - fabs (dy)) >? 0); if (sign (dy) == 0 && sign (slur_dy) != 0) demerit += NON_HORIZONTAL_PENALTY; + + + if (sign (dy) && sign (slur_dy) && sign (slur_dy) != sign (dy)) - demerit += SAME_SLOPE_PENALTY; + demerit += + (stem_dirs[LEFT] * stem_dirs[RIGHT] == -1) + ? SAME_SLOPE_PENALTY/10 : SAME_SLOPE_PENALTY; #if DEBUG_SLUR_QUANTING (*scores)[i].score_card_ += to_string ("S%.2f",d);