From: Han-Wen Nienhuys Date: Mon, 20 Mar 2006 11:47:13 +0000 (+0000) Subject: * input/regression/tie-single-manual.ly (Module): new file. X-Git-Tag: release/2.7.40~17 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=337f1aee4be0e4818f58cdfac1432327fd290ead;p=lilypond.git * input/regression/tie-single-manual.ly (Module): new file. * lily/tie-formatting-problem.cc (find_optimal_tie_configuration): look at has_manual_position_. (from_ties): set has_manual_position_ if tie has staff-position set. * lily/tuplet-bracket.cc (calc_positions): idem. * lily/tuplet-number.cc (print): don't print tupletnumber if it doesn't span time. --- diff --git a/ChangeLog b/ChangeLog index d5adfe918f..c28e7cf400 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-03-20 Han-Wen Nienhuys + + * input/regression/tie-single-manual.ly (Module): new file. + + * lily/tie-formatting-problem.cc (find_optimal_tie_configuration): + look at has_manual_position_. + (from_ties): set has_manual_position_ if tie has staff-position set. + + * lily/tuplet-bracket.cc (calc_positions): idem. + + * lily/tuplet-number.cc (print): don't print tupletnumber if it + doesn't span time. + 2006-03-19 Nicolas Sceaux * scm/define-markup-commands.scm (smallCaps): new markup command diff --git a/input/regression/tie-single-manual.ly b/input/regression/tie-single-manual.ly new file mode 100644 index 0000000000..ab917b0b6b --- /dev/null +++ b/input/regression/tie-single-manual.ly @@ -0,0 +1,21 @@ + +\header { + texidoc = "Individual ties may be formatted manually by +specifying their @code{direction} and/or @code{staff-position}." + +} + +\version "2.7.39" + +\paper { + ragged-right = ##t +} + +{ + \override Tie #'staff-position = #-5.5 + c'4 ~ c' + \override Tie #'staff-position = #-6.5 + c'4 ~ c' + \override Tie #'staff-position = #-7.5 + c'4 ~ c' +} diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 8d4cb2880f..3c1a517942 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -207,15 +207,18 @@ Dynamic_engraver::process_music () string start_type = ly_symbol2string (current_cresc_ev_->get_property ("name")); - - /* - ugh. Use push/pop? - */ + if (start_type == "DecrescendoEvent") start_type = "decrescendo"; else if (start_type == "CrescendoEvent") start_type = "crescendo"; + + + /* + UGH. TODO: should read from original event, so appearance + may be altered with \tweak. + */ SCM s = get_property ((start_type + "Spanner").c_str ()); if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin")) { diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index 1d6ea31c30..439e76cf50 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -242,7 +242,13 @@ Tie_formatting_problem::from_ties (vector const &ties) } spec.position_ = Tie::get_position (ties[i]); - + if (scm_is_number (ties[i]->get_property ("staff-position"))) + { + spec.manual_position_ = scm_to_double (ties[i]->get_property ("staff-position")); + spec.has_manual_position_ = true; + spec.position_ = int (my_round (spec.manual_position_)); + } + do { spec.note_head_drul_[d] = Tie::head (ties[i], d); @@ -566,6 +572,15 @@ Tie_formatting_problem::find_optimal_tie_configuration (Tie_specification const for (int i = 0; i < details_.single_tie_region_size_; i ++) { confs.push_back (generate_configuration (pos + i * dir, dir)); + + if (spec.has_manual_position_) + { + confs.back ()->delta_y_ + = (spec.manual_position_ - spec.position_) + * 0.5 * details_.staff_space_; + + break; + } } vector scores; diff --git a/lily/tie.cc b/lily/tie.cc index cd4591fd51..bdb7031fcf 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -71,7 +71,7 @@ Tie::get_position (Grob *me) { Grob *h = head (me, d); if (h) - return (int) Staff_symbol_referencer::get_position (h); + return (int) rint (Staff_symbol_referencer::get_position (h)); } while (flip (&d) != LEFT); @@ -206,7 +206,7 @@ Tie::calc_control_points (SCM smob) (void) yparent->get_property ("positioning-done"); } - if (!scm_is_pair (me->get_property ("control-points"))) + if (!scm_is_pair (me->get_property_data (ly_symbol2scm ("control-points")))) { set_default_control_points (me); } @@ -288,6 +288,7 @@ ADD_INTERFACE (Tie, "direction " "line-thickness " "quant-score " + "staff-position " "thickness " ); diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index a0f6ab8588..b812e622e3 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -44,6 +44,8 @@ #include "spanner.hh" #include "staff-symbol-referencer.hh" #include "lookup.hh" +#include "paper-column.hh" +#include "moment.hh" static Item * get_x_bound_item (Grob *me_grob, Direction hdir, Direction my_dir) @@ -64,7 +66,8 @@ flatten_number_pair_property (Grob *me, Direction xdir, SCM sym) { Drul_array zero (0, 0); - Drul_array pair = robust_scm2drul (me->internal_get_property (sym), zero); + Drul_array pair + = robust_scm2drul (me->internal_get_property (sym), zero); pair[xdir] = 0.0; me->internal_set_property (sym, ly_interval2scm (pair)); @@ -105,7 +108,8 @@ Tuplet_bracket::parallel_beam (Grob *me_grob, vector const &cols, bool *e return 0; } - *equally_long = (beam_stems[0] == stems[LEFT] && beam_stems.back () == stems[RIGHT]); + *equally_long = + (beam_stems[0] == stems[LEFT] && beam_stems.back () == stems[RIGHT]); return beams[LEFT]; } @@ -206,12 +210,16 @@ Tuplet_bracket::calc_control_points (SCM smob) x_span[d] = robust_relative_extent (bounds[d], commonx, X_AXIS)[RIGHT] - overshoot[LEFT]; } + else if (d == RIGHT && (columns.empty () || (bounds[d]->get_column () != dynamic_cast (columns.back ())->get_column ()))) { /* + We're connecting to a column, for the last bit of a broken + fullLength bracket. + TODO: make padding tunable? */ Real padding = 1.0; @@ -219,7 +227,9 @@ Tuplet_bracket::calc_control_points (SCM smob) if (bounds[d]->break_status_dir ()) padding = 0.0; - x_span[d] = robust_relative_extent (bounds[d], commonx, X_AXIS) [LEFT] - padding; + x_span[d] + = robust_relative_extent (bounds[d], commonx, X_AXIS) [LEFT] + - padding; } } while (flip (&d) != LEFT); @@ -556,19 +566,11 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) Real y = tuplet_y.linear_combination (d * sign (other_dy)); -#if 0 /* - Let's not take padding into account for nested tuplets. + We don't take padding into account for nested tuplets. the edges can come very close to the stems, likewise for nested tuplets? */ - Drul_array my_height - = robust_scm2drul (me->get_property ("edge-height"), - Interval (0, 0)); - if (dynamic_cast (tuplets[i])->get_bound (d) - == me->get_bound (d)) - y += dir * my_height[d]; -#endif points.push_back (Offset (tuplet_x[d] - x0, y)); } @@ -622,9 +624,21 @@ MAKE_SCHEME_CALLBACK (Tuplet_bracket, calc_positions, 1); SCM Tuplet_bracket::calc_positions (SCM smob) { - Grob *me = unsmob_grob (smob); + Spanner *me = unsmob_spanner (smob); extract_grob_set (me, "note-columns", columns); + + /* + Don't print if it doesn't span time. + */ + if (robust_scm2moment (me->get_bound (LEFT)->get_column ()->get_property ("when"), Moment (0)) + == robust_scm2moment (me->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0))) + { + me->suicide (); + return SCM_EOL; + } + + Direction dir = get_grob_direction (me); bool equally_long = false; Grob *par_beam = parallel_beam (me, columns, &equally_long); diff --git a/lily/tuplet-number.cc b/lily/tuplet-number.cc index d04e8f3aad..97c49129b3 100644 --- a/lily/tuplet-number.cc +++ b/lily/tuplet-number.cc @@ -8,6 +8,8 @@ */ #include "tuplet-bracket.hh" +#include "moment.hh" +#include "paper-column.hh" #include "text-interface.hh" #include "spanner.hh" #include "lookup.hh" @@ -23,13 +25,30 @@ MAKE_SCHEME_CALLBACK(Tuplet_number, print, 1); SCM Tuplet_number::print (SCM smob) { + Spanner *me = unsmob_spanner (smob); + Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); + + if (!tuplet || !tuplet->is_live ()) + { + me->suicide (); + return SCM_EOL; + } + + /* + Don't print if it doesn't span time. + */ + if (robust_scm2moment (tuplet->get_bound (LEFT)->get_column ()->get_property ("when"), Moment (0)) + == robust_scm2moment (tuplet->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0))) + { + me->suicide (); + return SCM_EOL; + } + Stencil *stc = unsmob_stencil (Text_interface::print (smob)); stc->align_to (X_AXIS, CENTER); stc->align_to (Y_AXIS, CENTER); - Spanner *me = unsmob_spanner (smob); - Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); SCM cpoints = tuplet->get_property ("control-points"); Drul_array points; points[LEFT] = ly_scm2offset (scm_car (cpoints));