lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

possible tuplet bug?


From: David Nalesnik
Subject: possible tuplet bug?
Date: Wed, 25 Dec 2013 12:41:45 -0600

Hi,

I just noticed something fishy about the interaction of Tuplet.connect-to-neighbor and Tuplet.break-overshoot.  The property 'break-overshoot is meant to apply to broken spanners, but here it is having an effect on unbroken "connected" tuplet brackets. (Break-overshoot is described as "How much does a broken spanner stick out of its bounds?")

The following snippet demonstrates the problem (see attached image):

%%%%%%%%%%

\version "2.17.97"


\layout {

  ragged-right = ##t

}


\relative c' {

  \times 2/3 { c4 d e }

  \times 2/3 { d4 e c }

  \times 2/3 { c'4 d e }

  \times 2/3 { d4 e c }

  \bar "||"

  %This "fixes" the problem:

  %\override TupletBracket.break-overshoot = #'(0 . 0)

  \override TupletBracket.connect-to-neighbor = #'(#t . #t)

  \times 2/3 { c,4 d e }

  \times 2/3 { d4 e c }

  \times 2/3 { c'4 d e }

  \times 2/3 { d4 e c }

}


%%%%%%%%%%%%


A default value of '(-0.5 . 0.0) is being applied to the tuplet brackets affected by the override of 'break-overshoot.  Thus, the left side is shifted to the right.  (The tuplet number is also moved from its position in the ordinary tuplets.)


In the "patch" below, I've suggested a modification of the relevant function in tuplet-bracket.cc which appears to fix the problem.  (The replacement is above the commented-out section of the original.) You can see the results in the second image. 


I hesitate to submit a formal patch because I haven't worked with C++ in LilyPond before, and I'd like to get some feedback from someone who understands this aspect of the codebase to make sure I'm not missing something big!  (It does compile--the image uses the patch.)


Thanks,

David


________________________________________________

from tuplet-bracket.cc:


MAKE_SCHEME_CALLBACK (Tuplet_bracket, calc_x_positions, 1)
SCM
Tuplet_bracket::calc_x_positions (SCM smob)
{
  Spanner *me = unsmob_spanner (smob);
  extract_grob_set (me, "note-columns", columns);

  Grob *commonx = get_common_x (me);
  Direction dir = get_grob_direction (me);

  Drul_array<Item *> bounds;
  bounds[LEFT] = get_x_bound_item (me, LEFT, dir);
  bounds[RIGHT] = get_x_bound_item (me, RIGHT, dir);

  Drul_array<bool> connect_to_other
    = robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
                           Drul_array<bool> (false, false));

  Interval x_span;
  for (LEFT_and_RIGHT (d))
    {
      x_span[d] = Axis_group_interface::generic_bound_extent (bounds[d], commonx, X_AXIS)[d];
      
      if (connect_to_other[d] && bounds[d]->break_status_dir())
      {
          Interval overshoot (robust_scm2drul (me->get_property ("break-overshoot"),
                                               Interval (-0.5, 0.0)));
          if (d == RIGHT)
            x_span[d] += d * overshoot[d];
          else
            x_span[d] = Axis_group_interface::generic_bound_extent (bounds[d], commonx, X_AXIS)[-d]
                        - overshoot[LEFT];
      }


/*
      if (connect_to_other[d])
        {
          Interval overshoot (robust_scm2drul (me->get_property ("break-overshoot"),
                                               Interval (-0.5, 0.0)));

          if (d == RIGHT)
            x_span[d] += d * overshoot[d];
          else
            x_span[d] = (bounds[d]->break_status_dir ()
                         ? Axis_group_interface::generic_bound_extent (bounds[d], commonx, X_AXIS)[-d]
                         : robust_relative_extent (bounds[d], commonx, X_AXIS)[-d])
                        - overshoot[LEFT];
        }
*/


      else if (d == RIGHT
               && (columns.empty ()
                   || (bounds[d]->get_column ()
                       != dynamic_cast<Item *> (columns.back ())->get_column ())))
        {
          /*
            We're connecting to a column, for the last bit of a broken
            fullLength bracket.
          */
          Real padding
            = robust_scm2double (me->get_property ("full-length-padding"), 1.0);

          if (bounds[d]->break_status_dir ())
            padding = 0.0;

          Real coord = bounds[d]->relative_coordinate (commonx, X_AXIS);
          if (to_boolean (me->get_property ("full-length-to-extent")))
            coord = robust_relative_extent (bounds[d], commonx, X_AXIS)[LEFT];

          coord = max (coord, x_span[LEFT]);

          x_span[d] = coord - padding;
        }
    }

  return ly_interval2scm (x_span - me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS));
}

Attachment: with-patch.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]