/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 1997--2011 Jan Nieuwenhuizen <janneke@gnu.org>
+ Copyright (C) 1997--2012 Jan Nieuwenhuizen <janneke@gnu.org>
Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
*/
#include "tuplet-bracket.hh"
+#include "axis-group-interface.hh"
#include "line-interface.hh"
#include "beam.hh"
#include "warn.hh"
#include "note-column.hh"
#include "pointer-group-interface.hh"
#include "directional-element-interface.hh"
+#include "skyline.hh"
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
#include "lookup.hh"
return commonx;
}
-MAKE_SCHEME_CALLBACK (Tuplet_bracket, calc_control_points, 1)
+MAKE_SCHEME_CALLBACK (Tuplet_bracket, calc_x_positions, 1)
SCM
-Tuplet_bracket::calc_control_points (SCM smob)
+Tuplet_bracket::calc_x_positions (SCM smob)
{
Spanner *me = unsmob_spanner (smob);
-
extract_grob_set (me, "note-columns", columns);
- SCM scm_positions = me->get_property ("positions");
- if (!me->is_live ())
- return SCM_EOL;
-
- if (!scm_is_pair (scm_positions))
- programming_error ("Positions should be number pair");
-
- Drul_array<Real> positions
- = robust_scm2drul (scm_positions, Drul_array<Real> (0, 0));
-
Grob *commonx = get_common_x (me);
Direction dir = get_grob_direction (me);
Direction d = LEFT;
do
{
- x_span[d] = robust_relative_extent (bounds[d], commonx, X_AXIS)[d];
-
+ 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];
if (connect_to_other[d])
{
Interval overshoot (robust_scm2drul (me->get_property ("break-overshoot"),
if (d == RIGHT)
x_span[d] += d * overshoot[d];
else
- x_span[d] = robust_relative_extent (bounds[d],
- commonx, X_AXIS)[RIGHT]
+ 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];
}
}
while (flip (&d) != LEFT);
- x_span -= me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS);
- return scm_list_2 (ly_offset2scm (Offset (x_span[LEFT], positions[LEFT])),
- ly_offset2scm (Offset (x_span[RIGHT], positions[RIGHT])));
+ return ly_interval2scm (x_span - me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS));
}
/*
/*
Don't print a tuplet bracket and number if
- no control-points were calculated
+ no X or Y positions were calculated.
*/
- SCM cpoints = me->get_property ("control-points");
- if (scm_ilength (cpoints) < 2)
+ SCM scm_x_span = me->get_property ("X-positions");
+ SCM scm_positions = me->get_property ("positions");
+ if (!scm_is_pair (scm_x_span) || !scm_is_pair (scm_positions))
{
me->suicide ();
return SCM_EOL;
== robust_scm2moment (me->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0))))
bracket_visibility = false;
- Drul_array<Offset> points;
- points[LEFT] = ly_scm2offset (scm_car (cpoints));
- points[RIGHT] = ly_scm2offset (scm_cadr (cpoints));
+ Interval x_span = robust_scm2interval (scm_x_span, Interval (0.0, 0.0));
+ Interval positions = robust_scm2interval (scm_positions, Interval (0.0, 0.0));
- Interval x_span (points[LEFT][X_AXIS], points[RIGHT][X_AXIS]);
- Drul_array<Real> positions (points[LEFT][Y_AXIS], points[RIGHT][Y_AXIS]);
+ Drul_array<Offset> points;
+ Direction d = LEFT;
+ do
+ points[d] = Offset (x_span[d], positions[d]);
+ while (flip (&d) != LEFT);
Output_def *pap = me->layout ();
&& 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)
- + stems[LEFT]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS);
- Real rp = ss * robust_scm2double (stems[RIGHT]->get_property ("stem-end-position"), 0.0)
- + stems[RIGHT]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS);
+ Interval poss;
+ Direction side = LEFT;
+ do
+ {
+ // Trigger setting of stem lengths if necessary.
+ if (Grob *beam = Stem::get_beam (stems[side]))
+ (void) beam->get_property ("quantized-positions");
+ poss[side] = stems[side]->extent (stems[side], Y_AXIS)[get_grob_direction (stems[side])]
+ + stems[side]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS);
+ }
+ while (flip (&side) != LEFT);
- *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));
+ *dy = poss[RIGHT] - poss[LEFT];
+ points.push_back (Offset (stems[LEFT]->relative_coordinate (commonx, X_AXIS) - x0, poss[LEFT]));
+ points.push_back (Offset (stems[RIGHT]->relative_coordinate (commonx, X_AXIS) - x0, poss[RIGHT]));
}
else
{
points.push_back (Offset (tuplet_x[d] - x0, y));
}
while (flip (&d) != LEFT);
+ // Check for number-on-bracket collisions
+ Grob *number = unsmob_grob (tuplets[i]->get_object ("tuplet-number"));
+ if (number)
+ points.push_back (Offset (number->extent (commonx, X_AXIS).center () - x0,
+ number->extent (commony, Y_AXIS)[dir]));
+ }
+
+ if (to_boolean (me->get_property ("avoid-scripts"))
+ && !scm_is_number (me->get_property ("outside-staff-priority")))
+ {
+ extract_grob_set (me, "scripts", scripts);
+ for (vsize i = 0; i < scripts.size (); i++)
+ {
+ if (!scripts[i]->is_live ())
+ continue;
+ if (scm_is_number (scripts[i]->get_property ("outside-staff-priority")))
+ continue;
+
+ Interval script_x (scripts[i]->extent (commonx, X_AXIS));
+ Interval script_y (scripts[i]->extent (commony, Y_AXIS));
+
+ points.push_back (Offset (script_x.center () - x0,
+ script_y[dir]));
+ }
}
*offset = -dir * infinity_f;
add_bound_item (dynamic_cast<Spanner *> (me), n);
}
+void
+Tuplet_bracket::add_script (Grob *me, Item *s)
+{
+ Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"), s);
+}
+
void
Tuplet_bracket::add_tuplet_bracket (Grob *me, Grob *bracket)
{
" @code{edge-text} are printed at the edges.",
/* properties */
+ "avoid-scripts "
"bracket-flare "
"bracket-visibility "
"break-overshoot "
"connect-to-neighbor "
- "control-points "
"direction "
"edge-height "
"edge-text "
"staff-padding "
"thickness "
"tuplets "
+ "X-positions "
);