#include <math.h>
+#include "line-interface.hh"
#include "beam.hh"
#include "box.hh"
#include "warn.hh"
after_line_breaking (smob);
}
- Real ly = gh_scm2double (me->get_grob_property ("left-position"));
- Real ry = gh_scm2double (me->get_grob_property ("right-position"));
+ Real ly = robust_scm2double (me->get_grob_property ("left-position"), 0);
+ Real ry = robust_scm2double (me->get_grob_property ("right-position"), 0);
bool equally_long = false;
Grob * par_beam = parallel_beam (me, columns, &equally_long);
if (bracket_visibility)
{
- Real lt = pap->get_realvar (ly_symbol2scm ("linethickness"));
-
- SCM thick = me->get_grob_property ("thickness");
- if (gh_number_p (thick))
- lt *= gh_scm2double (thick);
-
SCM gap = me->get_grob_property ("gap");
SCM fl = me->get_grob_property ("bracket-flare");
}
while (flip (&d) != LEFT);
- Molecule brack = make_bracket (Y_AXIS,
- w, ry - ly, lt,
+ Molecule brack = make_bracket (me, Y_AXIS,
+ Offset (w, ry - ly),
height,
gh_scm2double (gap),
flare,
brackets.
*/
Molecule
-Tuplet_bracket::make_bracket (Axis protusion_axis,
- Real dx, Real dy, Real thick, Drul_array<Real> height,
+Tuplet_bracket::make_bracket (Grob *me, // for line properties.
+ Axis protusion_axis,
+ Offset dz,
+ Drul_array<Real> height,
Real gap,
Drul_array<Real> flare,
Drul_array<Real> shorten)
{
- Offset dz = Offset (dx,dy);
Drul_array<Offset> corners (Offset(0,0), dz);
Real length = dz.length ();
Molecule m;
do {
-
- m.add_molecule (Lookup::line (thick, straight_corners[d],
- gap_corners[d]));
+ m.add_molecule (Line_interface::line (me, straight_corners[d],
+ gap_corners[d]));
- m.add_molecule (Lookup::line (thick, straight_corners[d],
- flare_corners[d]));
+ m.add_molecule (Line_interface::line (me, straight_corners[d],
+ flare_corners[d]));
} while (flip (&d) != LEFT);
return m;
SCM cols = me->get_grob_property ("note-columns");
Grob * commony = common_refpoint_of_list (cols, me, Y_AXIS);
Grob * commonx = common_refpoint_of_list (cols, me, X_AXIS);
+
+ Interval staff;
+
+ if (Grob * st = Staff_symbol_referencer::get_staff_symbol (me))
+ staff = st->extent (commony, Y_AXIS);
Direction dir = get_grob_direction (me);
if (l < r)
{
- *dy = columns[r]->extent (commony, Y_AXIS) [dir]
- - columns[l]->extent (commony, Y_AXIS) [dir] ;
+ Interval rv =columns[r]->extent (commony, Y_AXIS);
+ Interval lv =columns[l]->extent (commony, Y_AXIS);
+ rv.unite (staff);
+ lv.unite (staff);
+ Real graphical_dy = rv[dir] - lv[dir];
+
+ Slice ls = Note_column::head_positions_interval (columns[l]);
+ Slice rs = Note_column::head_positions_interval (columns[r]);
+
+ 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 x1 = rgr->extent (commonx,X_AXIS)[RIGHT];
- /*
- Slope.
- */
+ /*
+ Slope.
+ */
Real factor = columns.size () > 1 ? 1/ (x1 - x0) : 1.0;
for (int i = 0; i < columns.size (); i++)
{
- Real notey = columns[i]->extent (commony, Y_AXIS)[dir]
- - me->relative_coordinate (commony, Y_AXIS);
+ Interval note_ext =columns[i]->extent (commony, Y_AXIS);
+ note_ext.unite (staff);
+ Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS);
Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0;
Real tuplety = *dy * x * factor;
}
-/*
- use first -> last note for slope,
-*/
-void
-Tuplet_bracket::calc_dy (Grob*me,Real * dy)
-{
- Link_array<Grob> columns=
- Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
-
- /*
- ugh. refps.
- */
- Direction d = get_grob_direction (me);
- *dy = columns.top ()->extent (columns.top (), Y_AXIS) [d]
- - columns[0]->extent (columns[0], Y_AXIS) [d];
-}
/*
}
if (dynamic_cast<Spanner*> (me)->broken_b ())
{
- me->warning ("Tuplet_bracket was across linebreak. Farewell cruel world.");
+ me->warning (_("Killing tuplet bracket across linebreak."));
me->suicide();
return SCM_UNSPECIFIED;
}