From ae4d8be58f3ec00614f21ede696967e54cecaac8 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 24 Jan 2007 15:32:41 +0100 Subject: [PATCH] use new-line-spanner for voice follower too. --- lily/new-line-spanner.cc | 55 ++++++++++++++++++++++++++++++++-------- scm/define-grobs.scm | 21 ++++++++++++--- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/lily/new-line-spanner.cc b/lily/new-line-spanner.cc index 122ba66b80..b22607bfab 100644 --- a/lily/new-line-spanner.cc +++ b/lily/new-line-spanner.cc @@ -32,9 +32,24 @@ public: DECLARE_SCHEME_CALLBACK (calc_right_bound_info, (SCM)); DECLARE_SCHEME_CALLBACK (calc_bound_info, (SCM, Direction)); DECLARE_GROB_INTERFACE(); + + static Grob *common_y (Grob*); }; +Grob* +New_line_spanner::common_y (Grob*me_grob) +{ + Spanner *me = dynamic_cast (me_grob); + + Grob *commony = me; + Direction d = LEFT; + do + if (me->get_bound (d)->break_status_dir () == CENTER) + commony = me->get_bound (d)->common_refpoint (commony, Y_AXIS); + while (flip (&d) != LEFT); + return commony; +} static Grob * line_spanner_common_parent (Grob *me) @@ -134,8 +149,7 @@ New_line_spanner::calc_bound_info (SCM smob, Direction dir) } else { - Grob *commony = me->get_bound (LEFT); - commony = me->common_refpoint (commony, Y_AXIS); + Grob *commony = common_y (me); y = me->get_bound (dir)->extent (commony, Y_AXIS).center(); } @@ -237,12 +251,13 @@ New_line_spanner::print (SCM smob) Drul_array stencils (0,0); do { - gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), - bounds[d], SCM_BOOL_F), 0.0); - arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"), - bounds[d], SCM_BOOL_F)); - stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"), - bounds[d], SCM_BOOL_F)); + gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), + bounds[d], SCM_BOOL_F), 0.0); + arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"), + bounds[d], SCM_BOOL_F)); + stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"), + bounds[d], SCM_BOOL_F)); + } while (flip (&d) != LEFT); @@ -255,7 +270,24 @@ New_line_spanner::print (SCM smob) do { if (stencils[d]) - line.add_stencil (stencils[d]->translated (span_points[d])); + { + Stencil s = stencils[d]->translated (span_points[d]); + SCM align = ly_assoc_get (ly_symbol2scm ("stencil-align-dir-y"), + bounds[d], SCM_BOOL_F); + SCM off = ly_assoc_get (ly_symbol2scm ("stencil-offset"), + bounds[d], SCM_BOOL_F); + + if (scm_is_number (align)) + s.align_to (Y_AXIS, scm_to_double (align)); + + /* + todo: should use font-size. + */ + if (is_number_pair (off)) + s.translate (ly_scm2offset (off)); + + line.add_stencil (s); + } } while (flip (&d) != LEFT); @@ -279,8 +311,11 @@ New_line_spanner::print (SCM smob) span_points[RIGHT], arrows[LEFT], arrows[RIGHT])); + Grob *commony = common_y (me); - line.translate_axis (-me->relative_coordinate (commonx, X_AXIS), X_AXIS); + line.translate (Offset (-me->relative_coordinate (commonx, X_AXIS), + -me->relative_coordinate (commony, Y_AXIS))); + return line.smobbed_copy (); } diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 909f33fb9b..50e984034e 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -641,9 +641,14 @@ (Y . 0) (padding . 0.75) )) + (right-broken . ((attach-dir . ,RIGHT) + (Y . 0) + (padding . 0.0) + )) (left . ((attach-dir . ,LEFT) (Y . 0) - (padding . 1.5) + (stencil-offset . (0 . -0.5)) + (padding . 0.5) )) (left-broken . ((attach-dir . ,RIGHT) (padding . 0.5) @@ -651,7 +656,7 @@ ;; make sure the - - - stays at reasonable ;; distance from staff. - (text . " ") + (text . " ") )) )) (stencil . ,ly:new-line-spanner::print) @@ -2087,8 +2092,16 @@ (non-musical . #t) (X-extent . #f) (Y-extent . #f) - (stencil . ,ly:line-spanner::print) - (after-line-breaking . ,ly:line-spanner::after-line-breaking) + (bound-details . ((right . ((attach-dir . ,CENTER) + (padding . 1.5) + )) + (left . ((attach-dir . ,CENTER) + (padding . 1.5) + )) + )) + (stencil . ,ly:new-line-spanner::print) + (left-bound-info . ,ly:new-line-spanner::calc-left-bound-info) + (right-bound-info . ,ly:new-line-spanner::calc-right-bound-info) (meta . ((class . Spanner) (interfaces . (line-spanner-interface line-interface)))) -- 2.39.5