From: Han-Wen Nienhuys Date: Fri, 1 Oct 2004 23:28:39 +0000 (+0000) Subject: (outside_slur_callback): try three sample points X-Git-Tag: release/2.3.20~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5dfec3f8bf3a865ac9f9feaf3abbce6235349804;p=lilypond.git (outside_slur_callback): try three sample points for determining collisions. This fixes: slur-script.ly. --- diff --git a/ChangeLog b/ChangeLog index b37b94049d..092d579c69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-10-02 Han-Wen Nienhuys + + * lily/slur.cc (outside_slur_callback): try three sample points + for determining collisions. This fixes: slur-script.ly. + 2004-09-30 Jan Nieuwenhuizen * scripts/lilypond-book.py (ext2format): Add latex as Latex. diff --git a/lily/script-interface.cc b/lily/script-interface.cc index c13ddf8764..59672c7e2f 100644 --- a/lily/script-interface.cc +++ b/lily/script-interface.cc @@ -100,5 +100,5 @@ ADD_INTERFACE (Text_script,"text-script-interface", */ ADD_INTERFACE (Script_interface, "script-interface", "An object that is put above or below a note", - "add-stem-support slur script-priority script-stencil inside-slur"); + "add-stem-support slur-padding slur script-priority script-stencil inside-slur"); diff --git a/lily/slur.cc b/lily/slur.cc index 2f83d045a3..a115f5303c 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -151,38 +151,47 @@ Slur::outside_slur_callback (SCM grob, SCM axis) Interval xext = robust_relative_extent (script, cx, X_AXIS); - Real slur_padding = robust_scm2double (script->get_property ("padding"), - 0.2); // todo: slur property, script property? + Real slur_padding = robust_scm2double (script->get_property ("slur-padding"), + 0.0); // todo: slur property, script property? yext.widen (slur_padding); Interval bezext (curve.control_[0][X_AXIS], curve.control_[3][X_AXIS]); - Real x = xext.center (); - if (bezext.contains (x)) - ; - else if (!bezext.contains (xext[RIGHT])) - x = xext[LEFT]; - else if (!bezext.contains (xext[LEFT])) - x = xext[RIGHT]; + bool consider[] = { false, false, false }; + Real ys[] = {0, 0, 0}; + int k = 0; + bool do_shift = false; - - if (!bezext.contains (x)) - return scm_make_real (0); - Real dist = fabs (x - bezext[LEFT]) 1e-3) - ? curve.get_other_coordinate (X_AXIS, x) - : ((x < bezext.center()) - ? curve.control_[0][Y_AXIS] - : curve.control_[3][Y_AXIS]); - - if (yext.contains (y)) + for (Direction d = LEFT ; d <= RIGHT; d = Direction (d + 1)) { - Direction dir = get_grob_direction (script); - return scm_make_real (y - yext[-dir] + dir * slur_padding); + Real x = xext.linear_combination (d); + consider[k] = bezext.contains (x); + + if (consider[k]) + { + ys[k] = curve.get_other_coordinate (X_AXIS, x); + consider[k] = true; + + if (yext.contains (ys[k])) + do_shift = true; + } } - return scm_make_real (0.0); + Real offset = 0.0; + if (do_shift) + { + k = 0; + Direction dir = get_grob_direction (script); + for (Direction d = LEFT ; d <= RIGHT; d = Direction (d + 1)) + { + offset = + dir * (dir * offset >? dir * (ys[k] + - yext[-dir] + dir * slur_padding)); + k++; + } + } + + return scm_make_real (offset); } diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index d40a9b50fc..168944dec2 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -391,6 +391,7 @@ note that starts here.") object.") (size ,number? "Size of object, relative to standard size.") (slope ,number? "The slope of this object.") + (slur-padding ,number? "Extra distance between slur and script.") (slur-details ,list? "An alist of scoring parameters for slur formatting") (space-alist ,list? "A table that specifies distances between diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index c400bbc883..b7ec9a9093 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -191,7 +191,7 @@ (header bookpaper (length pages) #f) (define-fonts bookpaper) (header-end))) - (ly:outputter-dump-string outputter "\\nopagebreak") + (ly:outputter-dump-string outputter "\\lilypondnopagebreak") (for-each (lambda (page) (dump-page outputter page (eq? last-page page) with-extents)) pages) diff --git a/tex/lilyponddefs.tex b/tex/lilyponddefs.tex index 9d7f7196c0..ff2fa55dec 100644 --- a/tex/lilyponddefs.tex +++ b/tex/lilyponddefs.tex @@ -188,6 +188,12 @@ {\gdef\lilypondpagebreak{\newpage}}} {} +%% Allow overriding of pagebreak +\lilypondifundefined{lilypondnopagebreak} +{\lilypondifundefined{@nodocument} + {\gdef\lilypondnopagebreak{}} + {\gdef\lilypondnopagebreak{\nopagebreak}}} +{} %% Include \special only once. \gdef\lilypondspecial{ \special{header=music-drawing-routines.ps}