X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftie-formatting-problem.cc;h=d4755f1b9a019344f1019819e9264b036cb8f9d9;hb=512b082a1c470d0315ae8c5f48da3b374a2de716;hp=d93df73abf2ef3db0d49169833cba4b7a2b7dd76;hpb=caac677710724849651381d11577f61dd9618bcf;p=lilypond.git diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index d93df73abf..d4755f1b9a 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2012 Han-Wen Nienhuys + Copyright (C) 2005--2014 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify @@ -102,7 +102,7 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, continue; if (!stem) - stem = unsmob_grob (head->get_object ("stem")); + stem = Grob::unsmob (head->get_object ("stem")); Real p = Staff_symbol_referencer::get_position (head); Interval y ((p - 1) * 0.5 * staff_space, @@ -211,7 +211,7 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, boxes.push_back (Box (x, y)); } - Grob *acc = unsmob_grob (heads[i]->get_object ("accidental-grob")); + Grob *acc = Grob::unsmob (heads[i]->get_object ("accidental-grob")); if (acc) acc->get_property ("stencil"); /* trigger tie-related suicide */ @@ -243,8 +243,7 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, boxes.push_back (Box (x, y)); } - /* todo: the horizon_padding is somewhat arbitrary */ - chord_outlines_[key] = Skyline (boxes, details_.skyline_padding_, Y_AXIS, -dir); + chord_outlines_[key] = Skyline (boxes, Y_AXIS, -dir).padded (details_.skyline_padding_); if (bounds[0]->break_status_dir ()) { Interval iv (Axis_group_interface::staff_extent (bounds[0], x_refpoint_, X_AXIS, y_refpoint_, Y_AXIS)); @@ -381,7 +380,7 @@ Tie_formatting_problem::from_semi_ties (vector const &semi_ties, Directi for (vsize i = 0; i < semi_ties.size (); i++) { Tie_specification spec; - Item *head = unsmob_item (semi_ties[i]->get_object ("note-head")); + Item *head = Item::unsmob (semi_ties[i]->get_object ("note-head")); if (!head) programming_error ("LV tie without head?!"); @@ -497,22 +496,25 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir, size. */ + Interval staff_span + = Staff_symbol_referencer::staff_span (details_.staff_symbol_referencer_); + staff_span.widen (-1); + bool const within_staff = staff_span.contains (pos); if (head_positions_slice (columns[LEFT]).contains (pos) || head_positions_slice (columns[RIGHT]).contains (pos) - || abs (pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) + || within_staff) { if (h < details_.intra_space_threshold_ * 0.5 * details_.staff_space_) { - if (!Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos) - && abs (pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) - { - conf->center_tie_vertically (details_); - } - else if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos)) + if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos)) { conf->delta_y_ += dir * details_.tip_staff_line_clearance_ * 0.5 * details_.staff_space_; } + else if (within_staff) + { + conf->center_tie_vertically (details_); + } } else { @@ -653,7 +655,7 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf, if (!spec.note_head_drul_[d]) continue; - Grob *stem = unsmob_grob (spec.note_head_drul_[d]->get_object ("stem")); + Grob *stem = Grob::unsmob (spec.note_head_drul_[d]->get_object ("stem")); if (stem && Stem::is_normal_stem (stem)) stems[d] = stem; @@ -718,9 +720,11 @@ Tie_formatting_problem::score_configuration (Tie_configuration *conf) const Real top_y = tip_y + conf->dir_ * height; Real top_pos = 2 * top_y / details_.staff_space_; Real round_top_pos = rint (top_pos); + Interval staff_span + = Staff_symbol_referencer::staff_span (details_.staff_symbol_referencer_); if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, int (round_top_pos)) - && Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_) > top_y) + && staff_span[UP] * 0.5 > top_y) { conf->add_score (details_.staff_line_collision_penalty_ * peak_around (0.1 * details_.center_staff_line_clearance_, @@ -730,10 +734,11 @@ Tie_formatting_problem::score_configuration (Tie_configuration *conf) const } int rounded_tip_pos = int (rint (tip_pos)); + staff_span.widen (-1); if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, rounded_tip_pos) && (head_positions_slice (conf->column_ranks_[LEFT]).contains (rounded_tip_pos) || head_positions_slice (conf->column_ranks_[RIGHT]).contains (rounded_tip_pos) - || abs (rounded_tip_pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) + || staff_span.contains (rounded_tip_pos)) ) { conf->add_score (details_.staff_line_collision_penalty_