X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fline-spanner.cc;h=082db2f4b6b85b228b4a8055b9397d3900798ff9;hb=2005e201323314c8439d6aca062386c70c784294;hp=2e6eb1b8512d3cbae56320a1b563cf45d2da975f;hpb=db4c4e9f240b6c1becad366e1b62495e395cc10c;p=lilypond.git diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 2e6eb1b851..082db2f4b6 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -1,9 +1,20 @@ /* - line-spanner.cc -- implement Line_spanner + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2011 Jan Nieuwenhuizen - (c) 2000--2009 Jan Nieuwenhuizen + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "align-interface.hh" @@ -35,7 +46,7 @@ public: Spanner *parent_spanner (Grob *g) { if (Spanner::has_interface (g)) - return dynamic_cast (g); + return dynamic_cast (g); return parent_spanner (g->get_parent (Y_AXIS)); } @@ -64,7 +75,7 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) for (SCM s = scm_reverse (extra); scm_is_pair (s); s = scm_cdr (s)) details = scm_cons (scm_car (s), details); } - + if (details == SCM_BOOL_F) details = ly_assoc_get (ly_symbol2scm ("default"), bound_details, SCM_EOL); @@ -78,7 +89,7 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) properties, text), details); } - + if (!scm_is_number (ly_assoc_get (ly_symbol2scm ("X"), details, SCM_BOOL_F))) { Direction attach = (Direction) @@ -96,13 +107,13 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) bound_grob = (dir == LEFT) ? columns[0] : columns.back(); } - + details = scm_acons (ly_symbol2scm ("X"), scm_from_double (robust_relative_extent (bound_grob, commonx, X_AXIS) .linear_combination (attach)), details); } - + if (!scm_is_number (ly_assoc_get (ly_symbol2scm ("Y"), details, SCM_BOOL_F))) { @@ -128,11 +139,12 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) Spanner *next_bound_parent = parent_spanner (next_bound); Interval next_ext = next_bound->extent (next_bound_parent, Y_AXIS); - /* We want to know what would be the - y-position of the next bound (relative to my y-parent) if it belonged - to the same system as this bound. We rely on the fact that - the y-parent of the next bound is a spanner (probably the - VerticalAxisGroup of a staff) that extends over the break. + /* + We want to know what would be the y-position of the next + bound (relative to my y-parent) if it belonged to the + same system as this bound. We rely on the fact that the + y-parent of the next bound is a spanner (probably the + VerticalAxisGroup of a staff) that extends over the break. */ Spanner *next_bound_parent_on_this_line = next_bound_parent->broken_neighbor (other_dir (dir)); @@ -145,8 +157,10 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) } else { - /* We fall back to assuming that the distance between staves doesn't - change over line breaks. */ + /* + We fall back to assuming that the distance between + staves doesn't change over line breaks. + */ programming_error ("next-bound's parent doesn't extend to this line"); Grob *next_system = next_bound->get_system (); Grob *this_system = me->get_system (); @@ -200,7 +214,7 @@ Line_spanner::calc_left_bound_info_and_text (SCM smob) properties, text), alist); } - + return alist; } @@ -212,7 +226,7 @@ Line_spanner::print (SCM smob) Drul_array bounds (me->get_property ("left-bound-info"), me->get_property ("right-bound-info")); - + Grob *commonx = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); commonx = me->common_refpoint (commonx, X_AXIS); @@ -225,7 +239,7 @@ Line_spanner::print (SCM smob) bounds[d], SCM_BOOL_F), 0.0), robust_scm2double (ly_assoc_get (ly_symbol2scm ("Y"), bounds[d], SCM_BOOL_F), 0.0)); - + span_points[d] = z; } while (flip (&d) != LEFT); @@ -233,8 +247,13 @@ Line_spanner::print (SCM smob) Drul_array gaps (0, 0); Drul_array arrows (0, 0); Drul_array anchor_align (0, 0); - Drul_array stencils (0,0); - Drul_array common_y (0, 0); + Drul_array stencils (0,0); + Drul_array common_y (0, 0); + + // For scaling of 'padding and 'stencil-offset + Real magstep + = pow (2, robust_scm2double (me->get_property ("font-size"), 0.0) / 6); + do { gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), @@ -242,7 +261,7 @@ Line_spanner::print (SCM smob) arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"), bounds[d], SCM_BOOL_F)); anchor_align[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("anchor-alignment"), - bounds[d], SCM_BOOL_F), LEFT); + bounds[d], SCM_BOOL_F), LEFT); stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"), bounds[d], SCM_BOOL_F)); common_y[d] = unsmob_grob (ly_assoc_get (ly_symbol2scm ("common-Y"), @@ -267,7 +286,7 @@ Line_spanner::print (SCM smob) Stencil line; do { - span_points[d] += -d * gaps[d] * dz.direction (); + span_points[d] += -d * gaps[d] * magstep * dz.direction (); if (stencils[d]) { @@ -284,12 +303,9 @@ Line_spanner::print (SCM smob) 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)); - + s.translate (ly_scm2offset (off) * magstep); + line.add_stencil (s); } } @@ -320,7 +336,7 @@ Line_spanner::print (SCM smob) line.translate (Offset (-me->relative_coordinate (commonx, X_AXIS), -me->relative_coordinate (my_common_y, Y_AXIS))); - + return line.smobbed_copy (); } @@ -339,4 +355,3 @@ ADD_INTERFACE (Line_spanner, "thickness " "to-barline " ); -