X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fslur-scoring.cc;h=1973102650a063d3cefdc9cd9b7e14896abee52e;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=6b4b5699111b9abbecd1d8a4808cdcddf8ee8c42;hpb=c3153e5513e6b0ccdc226fbedd6e886d7df23a25;p=lilypond.git diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 6b4b569911..1973102650 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1996--2006 Han-Wen Nienhuys + (c) 1996--2008 Han-Wen Nienhuys Jan Nieuwenhuizen */ @@ -66,39 +66,6 @@ Slur_score_state::~Slur_score_state () junk_pointers (configurations_); } -Real -broken_trend_y (Slur_score_state const &state, Direction hdir) -{ - /* 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 ())) - { - vsize k = broken_spanner_index (state.slur_); - int j = int (k) + hdir; - if (j < 0 || vsize (j) >= mother->broken_intos_.size ()) - return by; - - Grob *neighbor = mother->broken_intos_[j]; - 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; - - if (common_j < 0 || vsize (common_j) >= common_mother->broken_intos_.size ()) - return by; - - 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; -} - /* copy slur dir forwards across line break. */ @@ -108,13 +75,8 @@ Slur_score_state::set_next_direction () if (extremes_[RIGHT].note_column_) return; - if (Spanner *mother = dynamic_cast (slur_->original ())) + if (Grob *neighbor = slur_->broken_neighbor (RIGHT)) { - vsize j = 1 + broken_spanner_index (slur_); - if (j >= mother->broken_intos_.size ()) - return; - - Grob *neighbor = mother->broken_intos_[j]; set_grob_direction (neighbor, dir_); } } @@ -230,13 +192,14 @@ Slur_score_state::fill (Grob *me) slur_ = dynamic_cast (me); columns_ = internal_extract_grob_array (me, ly_symbol2scm ("note-columns")); - + if (columns_.empty ()) { me->suicide (); return; } + Slur::replace_breakable_encompass_objects (me); staff_space_ = Staff_symbol_referencer::staff_space (me); Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt; @@ -310,7 +273,7 @@ Slur_score_state::fill (Grob *me) } -MAKE_SCHEME_CALLBACK(Slur, calc_control_points, 1) +MAKE_SCHEME_CALLBACK (Slur, calc_control_points, 1) SCM Slur::calc_control_points (SCM smob) { @@ -399,7 +362,7 @@ Slur_score_state::get_best_curve () } slur_->set_property ("quant-score", - scm_makfrom0str (total.c_str ())); + ly_string2scm (total)); } #endif @@ -412,6 +375,23 @@ Slur_score_state::get_best_curve () return configurations_[opt_idx]->curve_; } +Grob * +Slur_score_state::breakable_bound_item (Direction d) const +{ + Grob *col = slur_->get_bound (d)->get_column (); + + extract_grob_set (slur_, "encompass-objects", extra_encompasses); + + for (vsize i = 0; i < extra_encompasses.size (); i++) + { + Item *item = dynamic_cast (extra_encompasses[i]); + if (item && col == item->get_column ()) + return item; + } + + return 0; +} + int Slur_score_state::get_closest_index (SCM inspect_quants) const { @@ -430,7 +410,7 @@ Slur_score_state::get_closest_index (SCM inspect_quants) const } } if (mindist > 1e5) - programming_error ("can't not find quant"); + programming_error ("cannot find quant"); return opt_idx; } @@ -450,7 +430,7 @@ Slur_score_state::get_y_attachment_range () const { end_ys[d] = dir_ * max (max (dir_ * (base_attachments_[d][Y_AXIS] - + parameters_.region_size_ * dir_), + + parameters_.region_size_ * dir_), dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], Y_AXIS)[dir_])), dir_ * base_attachments_[-d][Y_AXIS]); } @@ -524,12 +504,18 @@ Slur_score_state::get_base_attachments () const { if (!extremes_[d].note_column_) { - Real x, y; - if (d == RIGHT) + Real x = 0; + Real y = 0; + + if (Grob *g = breakable_bound_item (d)) + { + x = robust_relative_extent (g, common_[X_AXIS], X_AXIS)[RIGHT]; + } + else if (d == RIGHT) x = robust_relative_extent (extremes_[d].bound_, common_[X_AXIS], X_AXIS)[d]; else x = slur_->get_broken_left_end_align (); - + Grob *col = (d == LEFT) ? columns_[0] : columns_.back (); if (extremes_[-d].bound_ != col) @@ -635,7 +621,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; @@ -797,34 +783,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_; } }