source file of the GNU LilyPond music typesetter
- (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
Direction d = LEFT;
do
straight_corners[d] += -d * shorten[d] / length * dz;
- while (flip (&d) != LEFT)
- ;
+ while (flip (&d) != LEFT);
- if (gap.is_empty ())
- gap = Interval (0, 0);
- do
- gap_corners[d] = (dz * 0.5) + gap[d] / length * dz;
- while (flip (&d) != LEFT)
- ;
+ if (!gap.is_empty ())
+ {
+ do
+ gap_corners[d] = (dz * 0.5) + gap[d] / length * dz;
+ while (flip (&d) != LEFT);
+ }
Drul_array<Offset> flare_corners = straight_corners;
do
Stencil m;
do
{
- m.add_stencil (Line_interface::line (me, straight_corners[d],
- gap_corners[d]));
+ if (!gap.is_empty ())
+ m.add_stencil (Line_interface::line (me, straight_corners[d],
+ gap_corners[d]));
m.add_stencil (Line_interface::line (me, straight_corners[d],
flare_corners[d]));
}
+
while (flip (&d) != LEFT);
+ if (gap.is_empty ())
+ m.add_stencil (Line_interface::line (me, straight_corners[LEFT],
+ straight_corners[RIGHT]));
+
return m;
}
Direction dir = get_grob_direction (me);
- /*
- Use outer non-rest columns to determine slope
- */
- Grob *left_col = 0;
- Grob *right_col = 0;
- get_bounds (me, &left_col, &right_col);
- if (left_col && right_col)
- {
- Interval rv = right_col->extent (commony, Y_AXIS);
- Interval lv = left_col->extent (commony, Y_AXIS);
- rv.unite (staff);
- lv.unite (staff);
- Real graphical_dy = rv[dir] - lv[dir];
-
- Slice ls = Note_column::head_positions_interval (left_col);
- Slice rs = Note_column::head_positions_interval (right_col);
-
- Interval musical_dy;
- musical_dy[UP] = rs[UP] - ls[UP];
- musical_dy[DOWN] = rs[DOWN] - ls[DOWN];
- if (sign (musical_dy[UP]) != sign (musical_dy[DOWN]))
- *dy = 0.0;
- else if (sign (graphical_dy) != sign (musical_dy[DOWN]))
- *dy = 0.0;
- else
- *dy = graphical_dy;
- }
- else
- *dy = 0;
+ bool equally_long = false;
+ Grob *par_beam = parallel_beam (me, columns, &equally_long);
+
- *offset = -dir * infinity_f;
Item *lgr = get_x_bound_item (me, LEFT, dir);
Item *rgr = get_x_bound_item (me, RIGHT, dir);
Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT];
vector<Offset> points;
- points.push_back (Offset (x0 - x0, staff[dir]));
- points.push_back (Offset (x1 - x0, staff[dir]));
- for (vsize i = 0; i < columns.size (); i++)
+ if (columns.size ()
+ && par_beam
+ && get_grob_direction (par_beam) == dir
+ && Note_column::get_stem (columns[0])
+ && Note_column::get_stem (columns.back ()))
+ {
+ /*
+ trigger set_stem_ends
+ */
+ (void) par_beam->get_property ("quantized-positions");
+
+
+ Drul_array<Grob *> stems (Note_column::get_stem (columns[0]),
+ Note_column::get_stem (columns.back ()));
+
+
+
+
+ Real ss = 0.5 * Staff_symbol_referencer::staff_space (me);
+ Real lp = ss * robust_scm2double (stems[LEFT]->get_property ("stem-end-position"), 0.0);
+ Real rp = ss * robust_scm2double (stems[RIGHT]->get_property ("stem-end-position"), 0.0);
+
+ *dy = rp - lp;
+ points.push_back (Offset (stems[LEFT]->relative_coordinate (commonx, X_AXIS) - x0, lp));
+ points.push_back (Offset (stems[RIGHT]->relative_coordinate (commonx, X_AXIS) - x0, rp));
+ }
+ else
{
- Interval note_ext = columns[i]->extent (commony, Y_AXIS);
- Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS);
+ /*
+ Use outer non-rest columns to determine slope
+ */
+ Grob *left_col = 0;
+ Grob *right_col = 0;
+ get_bounds (me, &left_col, &right_col);
+ if (left_col && right_col)
+ {
+ Interval rv = right_col->extent (commony, Y_AXIS);
+ Interval lv = left_col->extent (commony, Y_AXIS);
+ rv.unite (staff);
+ lv.unite (staff);
+ Real graphical_dy = rv[dir] - lv[dir];
+
+ Slice ls = Note_column::head_positions_interval (left_col);
+ Slice rs = Note_column::head_positions_interval (right_col);
+
+ Interval musical_dy;
+ musical_dy[UP] = rs[UP] - ls[UP];
+ musical_dy[DOWN] = rs[DOWN] - ls[DOWN];
+ if (sign (musical_dy[UP]) != sign (musical_dy[DOWN]))
+ *dy = 0.0;
+ else if (sign (graphical_dy) != sign (musical_dy[DOWN]))
+ *dy = 0.0;
+ else
+ *dy = graphical_dy;
+ }
+ else
+ *dy = 0;
- Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0;
- points.push_back (Offset (x, notey));
+ *offset = -dir * infinity_f;
+ for (vsize i = 0; i < columns.size (); i++)
+ {
+ Interval note_ext = columns[i]->extent (commony, Y_AXIS);
+ Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS);
+
+ Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0;
+ points.push_back (Offset (x, notey));
+ }
}
+ if (!(par_beam && get_grob_direction (par_beam) == dir))
+ {
+ points.push_back (Offset (x0 - x0, staff[dir]));
+ points.push_back (Offset (x1 - x0, staff[dir]));
+ }
+
/*
This is a slight hack. We compute two encompass points from the
bbox of the smaller tuplets.
Interval tuplet_x (tuplets[i]->extent (commonx, X_AXIS));
Interval tuplet_y (tuplets[i]->extent (commony, Y_AXIS));
+ if (!tuplets[i]->is_live ())
+ continue;
+
Direction d = LEFT;
- Drul_array<Real> positions = ly_scm2realdrul (tuplets[i]->get_property ("positions"));
+ Drul_array<Real> positions = robust_scm2interval (tuplets[i]->get_property ("positions"),
+ Interval (0,0));
Real other_dy = positions[RIGHT] - positions[LEFT];
Tuplet_bracket::calc_positions (SCM smob)
{
Spanner *me = unsmob_spanner (smob);
- extract_grob_set (me, "note-columns", columns);
/*
Don't print if it doesn't span time.
return SCM_EOL;
}
-
- Direction dir = get_grob_direction (me);
- bool equally_long = false;
- Grob *par_beam = parallel_beam (me, columns, &equally_long);
-
- /*
- We follow the beam only if there is one, and we are next to it.
- */
Real dy = 0.0;
Real offset = 0.0;
- if (!par_beam
- || get_grob_direction (par_beam) != dir)
- calc_position_and_height (me, &offset, &dy);
- else if (columns.size ()
- && Note_column::get_stem (columns[0])
- && Note_column::get_stem (columns.back ()))
- {
- /*
- trigger set_stem_ends
- */
- (void) par_beam->get_property ("quantized-positions");
-
-
- Drul_array<Grob *> stems (Note_column::get_stem (columns[0]),
- Note_column::get_stem (columns.back ()));
-
-
-
-
- Real ss = 0.5 * Staff_symbol_referencer::staff_space (me);
- Real lp = ss * robust_scm2double (stems[LEFT]->get_property ("stem-end-position"), 0.0);
- Real rp = ss * robust_scm2double (stems[RIGHT]->get_property ("stem-end-position"), 0.0);
-
-
- offset = lp + dir * (0.5 + scm_to_double (me->get_property ("padding")));
- dy = (rp - lp);
- }
-
+ calc_position_and_height (me, &offset, &dy);
SCM x = scm_cons (scm_from_double (offset),
scm_from_double (offset + dy));
}
ADD_INTERFACE (Tuplet_bracket,
- "tuplet-bracket-interface",
"A bracket with a number in the middle, used for tuplets. "
"When the bracket spans a line break, the value of "
"@code{break-overshoot} determines how far it extends "