#include "tie-formatting-problem.hh"
+#include "axis-group-interface.hh"
#include "paper-column.hh"
#include "bezier.hh"
#include "directional-element-interface.hh"
Tie_formatting_problem::Tie_formatting_problem ()
{
x_refpoint_ = 0;
+ y_refpoint_ = 0;
+ use_horizontal_spacing_ = true;
}
Tie_formatting_problem::~Tie_formatting_problem ()
{
if (Stem::is_normal_stem (stem))
{
-
Interval x;
x.add_point (stem->relative_coordinate (x_refpoint_, X_AXIS));
x.widen (staff_space / 20); // ugh.
Interval y;
- y.add_point (Stem::stem_end_position (stem) * staff_space * .5);
+
+ Real stem_end_position = 0.0;
+ if (Stem::is_cross_staff (stem))
+ stem_end_position = get_grob_direction (stem) * infinity_f;
+ else
+ {
+ if (use_horizontal_spacing_ || !Stem::get_beam (stem))
+ stem_end_position = Stem::stem_end_position (stem) * staff_space * .5;
+ else
+ stem_end_position = Stem::note_head_positions (stem)[get_grob_direction (stem)]
+ * staff_space * .5;
+ }
+
+ y.add_point (stem_end_position);
Direction stemdir = get_grob_direction (stem);
y.add_point (Stem::head_positions (stem)[-stemdir]
Real x_center = head->extent (x_refpoint_, X_AXIS).center ();
Interval x_ext;
x_ext[-dir] = x_center;
+ x_ext[dir] = infinity_f * dir;
Interval y_ext;
for (vsize j = 0; j < head_boxes.size (); j++)
y_ext.unite (head_boxes[j][Y_AXIS]);
}
Grob *acc = unsmob_grob (heads[i]->get_object ("accidental-grob"));
+ if (acc)
+ acc->get_property ("stencil"); /* trigger tie-related suicide */
+
if (acc && acc->is_live () && dir == RIGHT)
{
boxes.push_back (Box (acc->extent (x_refpoint_, X_AXIS),
chord_outlines_[key] = Skyline (boxes, details_.skyline_padding_, Y_AXIS, -dir);
if (bounds[0]->break_status_dir ())
{
- Real x = robust_relative_extent (bounds[0], x_refpoint_, X_AXIS)[-dir];
-
- chord_outlines_[key].set_minimum_height (x);
+ Interval iv (Axis_group_interface::staff_extent (bounds[0], x_refpoint_, X_AXIS, y_refpoint_, Y_AXIS));
+ if (iv.is_empty ())
+ iv.add_point (bounds[0]->relative_coordinate (x_refpoint_, X_AXIS));
+
+ chord_outlines_[key].set_minimum_height (iv[-dir]);
}
else
{
return;
x_refpoint_ = ties[0];
+ y_refpoint_ = ties[0];
for (vsize i = 0; i < ties.size (); i++)
{
- x_refpoint_ = dynamic_cast<Spanner*> (ties[i])->get_bound (LEFT)->common_refpoint (x_refpoint_, X_AXIS);
- x_refpoint_ = dynamic_cast<Spanner*> (ties[i])->get_bound (RIGHT)->common_refpoint (x_refpoint_, X_AXIS);
+ Spanner *tie = dynamic_cast<Spanner*> (ties[i]);
+ Item *l = tie->get_bound (LEFT);
+ Item *r = tie->get_bound (RIGHT);
+
+ x_refpoint_ = l->common_refpoint (x_refpoint_, X_AXIS);
+ x_refpoint_ = r->common_refpoint (x_refpoint_, X_AXIS);
+
+ if (!l->break_status_dir ())
+ y_refpoint_ = l->common_refpoint (y_refpoint_, Y_AXIS);
+ if (!r->break_status_dir ())
+ y_refpoint_ = r->common_refpoint (y_refpoint_, Y_AXIS);
}
details_.from_grob (ties[0]);
{
Item *it = dynamic_cast<Spanner*> (ties[i])->get_bound (d);
if (it->break_status_dir ())
- {
- Item *sep
- = dynamic_cast<Item*> (unsmob_grob (ties[i]->get_object ("separation-item")));
- if (sep && sep->get_column () == it->get_column ())
- it = sep;
+ it = it->get_column ();
- bounds.push_back (it);
- }
- else
- {
- bounds.push_back (it);
- }
+ bounds.push_back (it);
}
set_chord_outline (bounds, d);
{
if (semi_ties.empty ())
return;
-
+
+ use_horizontal_spacing_ = false;
details_.from_grob (semi_ties[0]);
vector<Item*> heads;
specifications_.push_back (spec);
}
- x_refpoint_ = semi_ties [0];
+ x_refpoint_ = semi_ties[0];
+ y_refpoint_ = semi_ties[0];
+
for (vsize i = 0; i < semi_ties.size (); i++)
- x_refpoint_ = semi_ties[i]->common_refpoint (x_refpoint_, X_AXIS);
+ {
+ x_refpoint_ = semi_ties[i]->common_refpoint (x_refpoint_, X_AXIS);
+ y_refpoint_ = semi_ties[i]->common_refpoint (y_refpoint_, Y_AXIS);
+ }
for (vsize i = 0; i < heads.size (); i++)
- x_refpoint_ = heads[i]->common_refpoint (x_refpoint_, X_AXIS);
+ {
+ x_refpoint_ = heads[i]->common_refpoint (x_refpoint_, X_AXIS);
+ y_refpoint_ = heads[i]->common_refpoint (y_refpoint_, Y_AXIS) ;
+ }
set_chord_outline (heads, head_dir);