X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fslur-scoring.cc;h=0e8c60cbcb61fbaa73e8b6b5ac85005761547782;hb=292ac10aee40154613568fc4805e02124793e91d;hp=4e6167a650a88628543feffeb846bc778186a4f4;hpb=3e08e326e7c38c81d3355a3f2e7ef8eb48bd121e;p=lilypond.git diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 4e6167a650..0e8c60cbcb 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -1,10 +1,21 @@ /* - slur-scoring.cc -- Score based slur formatting + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter - - (c) 1996--2006 Han-Wen Nienhuys + Copyright (C) 1996--2010 Han-Wen Nienhuys 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 . */ @@ -66,51 +77,25 @@ Slur_score_state::~Slur_score_state () junk_pointers (configurations_); } -Real -broken_trend_y (Slur_score_state const &state, Direction hdir) +/* + If a slur is broken across a line break, the direction + of the post-break slur must be the same as the pre-break + slur. +*/ +Direction +Slur_score_state::slur_direction () const { - /* A broken slur should maintain the same vertical trend - the unbroken slur would have had. */ - Real by = 0.0; - if (Spanner *mother = dynamic_cast (state.slur_->original ())) - { - Grob *neighbor = mother->broken_neighbor (hdir); - if (!neighbor) - return by; - - - Spanner *common_mother - = dynamic_cast (state.common_[Y_AXIS]->original ()); - int common_k - = broken_spanner_index (dynamic_cast (state.common_[Y_AXIS])); - int common_j = common_k + hdir; + Grob *left_neighbor = slur_->broken_neighbor (LEFT); - if (common_j < 0 || vsize (common_j) >= common_mother->broken_intos_.size ()) - return by; + if (left_neighbor && left_neighbor->is_live ()) + return get_grob_direction (left_neighbor); - Grob *common_next_system = common_mother->broken_intos_[common_j]; - - SCM last_point = scm_car (scm_last_pair (neighbor->get_property ("control-points"))); - - return scm_to_double (scm_cdr (last_point)) - + neighbor->relative_coordinate (common_next_system, Y_AXIS); - } - return by; -} + Direction dir = get_grob_direction (slur_); -/* - copy slur dir forwards across line break. -*/ -void -Slur_score_state::set_next_direction () -{ - if (extremes_[RIGHT].note_column_) - return; + if (Grob *right_neighbor = slur_->broken_neighbor (RIGHT)) + set_grob_direction (right_neighbor, dir); - if (Grob *neighbor = slur_->broken_neighbor (RIGHT)) - { - set_grob_direction (neighbor, dir_); - } + return dir; } Encompass_info @@ -148,7 +133,7 @@ Slur_score_state::get_encompass_info (Grob *col) const { ei.stem_ = stem->extent (common_[Y_AXIS], Y_AXIS)[dir_]; if (Grob *b = Stem::get_beam (stem)) - ei.stem_ += stem_dir * 0.5 * Beam::get_thickness (b); + ei.stem_ += stem_dir * 0.5 * Beam::get_beam_thickness (b); Interval x = stem->extent (common_[X_AXIS], X_AXIS); ei.x_ = x.is_empty () @@ -236,7 +221,7 @@ Slur_score_state::fill (Grob *me) Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt; - dir_ = get_grob_direction (me); + dir_ = slur_direction (); parameters_.fill (me); extract_grob_set (me, "note-columns", columns); @@ -298,14 +283,12 @@ Slur_score_state::fill (Grob *me) = (extremes_[LEFT].stem_ && Stem::get_beam (extremes_[LEFT].stem_)) || (extremes_[RIGHT].stem_ && Stem::get_beam (extremes_[RIGHT].stem_)); - set_next_direction (); - if (is_broken_) musical_dy_ = 0.0; } -MAKE_SCHEME_CALLBACK(Slur, calc_control_points, 1) +MAKE_SCHEME_CALLBACK (Slur, calc_control_points, 1) SCM Slur::calc_control_points (SCM smob) { @@ -394,7 +377,7 @@ Slur_score_state::get_best_curve () } slur_->set_property ("quant-score", - scm_makfrom0str (total.c_str ())); + ly_string2scm (total)); } #endif @@ -653,7 +636,7 @@ Slur_score_state::generate_avoid_offsets () const if (!xe.is_empty () && !ye.is_empty ()) - avoid.push_back (Offset (xe.center(), ye[dir_])); + avoid.push_back (Offset (xe.center (), ye[dir_])); } } return avoid; @@ -815,34 +798,21 @@ Slur_score_state::get_extra_encompass_infos () const if (Accidental_interface::has_interface (g)) { penalty = parameters_.accidental_collision_; - /* Begin copy accidental.cc */ - bool parens = false; - if (to_boolean (g->get_property ("cautionary"))) - { - SCM cstyle = g->get_property ("cautionary-style"); - parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses")); - } - SCM accs = g->get_property ("accidentals"); + Rational alt = ly_scm2rational (g->get_property ("alteration")); SCM scm_style = g->get_property ("style"); if (!scm_is_symbol (scm_style) - && !parens - && scm_ilength (accs) == 1) + && !to_boolean (g->get_property ("parenthesized")) + && !to_boolean (g->get_property ("restore-first"))) { /* End copy accidental.cc */ - switch (scm_to_int (scm_car (accs))) - { - case FLAT: - case DOUBLE_FLAT: - xp = LEFT; - break; - case SHARP: - xp = 0.5 * dir_; - break; - case NATURAL: - xp = -dir_; - break; - } + if (alt == FLAT_ALTERATION + || alt == DOUBLE_FLAT_ALTERATION) + xp = LEFT; + else if (alt == SHARP_ALTERATION) + xp = 0.5 * dir_; + else if (alt == NATURAL_ALTERATION) + xp = -dir_; } }